:root {
    --bg-color: #0a0a0a;
    --text-color: #e0e0e0;
    --accent-color: #ff3b3b;
    --glass-bg: rgba(20, 20, 20, 0.85);
    --glass-border: rgba(255, 59, 59, 0.3);
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    background-color: #000;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
}

/* Lighting Effects */
#lighting-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: background 2s ease;
    z-index: 10;
}

.level-dark #lighting-overlay {
    background: radial-gradient(circle at center, transparent 10%, rgba(20, 0, 0, 0.6) 60%, rgba(0, 0, 0, 0.95) 100%);
    box-shadow: inset 0 0 100px rgba(255, 0, 0, 0.1);
}

.level-exit #lighting-overlay {
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 100%);
    background-color: rgba(255, 255, 255, 0.8);
}

#version-footer {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    z-index: 100;
    pointer-events: none;
}

/* Back Zone */
.back-zone {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 50;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.back-zone:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 3D Doors Container */
#doors-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 12;
}

.doorframe {
    position: absolute;
    display: flex;
    perspective: 1200px;
    transform-style: preserve-3d;
    cursor: pointer;
    pointer-events: all;
}

.door {
    flex-grow: 1;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: all 0.5s;
    backface-visibility: hidden;
    position: relative;
    background: linear-gradient(to right, #5d4037 0%, #4e342e 50%, #3e2723 100%);
    border: 3px solid #2c1810;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.door:before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    right: 10%;
    bottom: 10%;
    border: 2px solid #3e2723;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.door-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    transition: opacity 0.3s;
}

.doorframe:hover .door-label {
    opacity: 0;
}

.door-knob {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: #ffd700;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.doorframe:hover .door,
.doorframe.open .door {
    transform: rotate3d(0, 1, 0, -90deg);
}

.doorframe.solved .door {
    background: linear-gradient(to right, #2e7d32 0%, #1b5e20 50%, #0d3d14 100%);
    border-color: #0a2f0f;
}

/* UI Screens - Mobile First */
.ui-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    z-index: 20;
    transition: opacity 0.5s ease;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem 1rem;
}

.ui-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.ui-screen.active {
    opacity: 1;
    pointer-events: all;
}

h1 {
    font-size: 2rem;
    letter-spacing: 0.2rem;
    color: var(--accent-color);
    text-shadow: 0 0 20px var(--accent-color);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
    text-align: center;
    width: 100%;
    padding: 0 1rem;
}

.subtitle {
    font-size: 1rem;
    color: #888;
    margin-bottom: 2rem;
    letter-spacing: 0.1rem;
    text-align: center;
    width: 100%;
    padding: 0 1rem;
}

.input-group {
    margin-bottom: 1.5rem;
    width: 100%;
    display: flex;
    justify-content: center;
}

input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    color: white;
    border-radius: 50px;
    text-align: center;
    font-family: var(--font-main);
    outline: none;
    transition: border-color 0.3s;
    width: 90%;
    max-width: 300px;
}

input:focus {
    border-color: var(--accent-color);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 600;
    letter-spacing: 0.05rem;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 59, 59, 0.5);
}

.btn-primary:active {
    transform: scale(0.95);
}

/* Game Cards Grid - Mobile First */
.game-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    width: 100%;
    max-width: 500px;
    padding: 0 1rem;
    margin-bottom: 2rem;
}

.game-card {
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.9) 0%, rgba(20, 20, 20, 0.95) 100%);
    border: 2px solid rgba(255, 59, 59, 0.3);
    border-radius: 15px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.game-card:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 59, 59, 0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-card.active-game:active {
    border-color: var(--accent-color);
    transform: scale(0.98);
}

.game-card.active-game:active:before {
    opacity: 1;
}

.game-card.coming-soon {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: rgba(100, 100, 100, 0.3);
}

.card-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.card-badge {
    background: var(--accent-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05rem;
}

.card-badge.soon {
    background: #666;
}

.card-content h2 {
    color: white;
    font-size: 1.3rem;
    margin-bottom: 0.8rem;
    font-weight: 600;
}

.card-content p {
    color: #aaa;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    min-height: 40px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-btn {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.05rem;
    transition: all 0.2s;
}

.coming-soon-text {
    color: #666;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.05rem;
}

/* Story Content */
.story-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 700px;
    width: 100%;
    padding: 1rem;
}

.story-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Modal */
.ui-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 30;
    backdrop-filter: blur(5px);
    padding: 1rem;
}

.ui-modal.hidden {
    display: none;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 2rem 1.5rem;
    border-radius: 20px;
    text-align: center;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    color: var(--accent-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.modal-content p {
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
}

#feedback-msg {
    height: 1.5rem;
    margin: 1rem 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.feedback-error {
    color: #ff3b3b;
}

.feedback-success {
    color: #4caf50;
}

/* HUD */
#hud {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 15;
    flex-wrap: wrap;
}

.hud-item {
    background: rgba(0, 0, 0, 0.5);
    padding: 0.4rem 0.8rem;
    border-radius: 10px;
    border: 1px solid #333;
    font-weight: 600;
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

/* End Screen Specifics */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin: 2rem 0;
    width: 100%;
    max-width: 400px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
}

.stat-item .label {
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
}

.stat-item .value {
    font-size: 1.8rem;
    font-weight: 600;
    color: white;
}

.screenshot-hint {
    font-size: 0.75rem;
    color: #555;
    margin-bottom: 1.5rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid white;
    color: white;
    padding: 0.7rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.3s;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: white;
    color: black;
}

/* Desktop Adjustments */
@media (min-width: 768px) {
    h1 {
        font-size: 3.5rem;
        letter-spacing: 0.4rem;
    }

    .subtitle {
        font-size: 1.3rem;
        margin-bottom: 2.5rem;
    }

    input {
        padding: 1rem 2rem;
        font-size: 1.2rem;
    }

    .btn-primary {
        padding: 1rem 2.5rem;
        font-size: 1.1rem;
    }

    .game-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
        max-width: 1000px;
    }

    .game-card.active-game:hover {
        border-color: var(--accent-color);
        transform: translateY(-5px);
        box-shadow: 0 10px 30px rgba(255, 59, 59, 0.3);
    }

    .game-card.active-game:hover:before {
        opacity: 1;
    }

    .game-card.active-game:hover .play-btn {
        transform: scale(1.1);
        text-shadow: 0 0 10px rgba(255, 59, 59, 0.5);
    }

    .modal-content {
        padding: 3rem;
    }

    .modal-content h2 {
        font-size: 2rem;
    }

    .modal-content p {
        font-size: 1.2rem;
        margin-bottom: 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
        margin: 3rem 0;
    }

    .stat-item .value {
        font-size: 2rem;
    }

    .hud-item {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }

    .ui-screen {
        justify-content: center;
        padding: 3rem 2rem;
    }
}
