:root {
    --bg-color: #121212;
    --text-color: #ffffff;
    --neon-blue: #00ffff;
    --neon-pink: #ff00ff;
    --neon-green: #00ff00;
    --neon-yellow: #ffff00;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --font-main: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
    background: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #000000 100%);
}

.game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: min(980px, calc(100vw - 28px));
    padding-top: 26px;
    z-index: 10;
}

.game-header {
    text-align: center;
    margin-bottom: 14px;
}

.game-title {
    font-size: 3rem;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: transparent;
    -webkit-text-stroke: 2px var(--neon-blue);
    text-shadow: 0 0 10px var(--neon-blue), 0 0 20px var(--neon-blue);
}

.back-link {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    color: rgba(232, 245, 255, 0.8);
    text-decoration: none;
    font-size: 0.62rem;
    letter-spacing: 0.02em;
    z-index: 20;
    transition: color 0.3s, opacity 0.3s;
}

.back-link:hover {
    color: var(--neon-blue);
    opacity: 1;
    text-shadow: 0 0 5px var(--neon-blue);
}

.game-meta {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-size: 0.54rem;
    color: rgba(198, 223, 255, 0.72);
    letter-spacing: 0.4px;
    line-height: 1.3;
    text-align: right;
    z-index: 20;
}

.game-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.game-board-container {
    position: relative;
    padding: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.1);
}

canvas#tetris {
    background: rgba(0, 0, 0, 0.8);
    display: block;
    border: 1px solid #333;
    touch-action: none;
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 150px;
}

.info-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.info-panel h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: var(--neon-pink);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-panel div {
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.best-date {
    margin: 8px 0 0;
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.68);
    line-height: 1.35;
}

#next-piece {
    background: rgba(0, 0, 0, 0.5);
    margin: 0 auto;
    display: block;
    border-radius: 4px;
    max-width: 100%;
    height: auto;
}

.controls-info {
    margin-top: 20px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.controls-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.controls-list li {
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.controls-list span {
    color: var(--neon-green);
    font-weight: bold;
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #222;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid var(--neon-pink);
    box-shadow: 0 0 30px var(--neon-pink);
}

.modal-content h2 {
    color: var(--neon-pink);
    font-size: 2rem;
    margin-top: 0;
    text-shadow: 0 0 10px var(--neon-pink);
}

.btn {
    background: transparent;
    color: #fff;
    border: 2px solid var(--neon-blue);
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    font-family: var(--font-main);
    text-transform: uppercase;
    transition: all 0.3s;
    margin-top: 15px;
}

.btn:hover {
    background: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 20px var(--neon-blue);
}

/* Mobile Responsive Styles */
@media (max-width: 600px) {
    .game-content {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .game-sidebar {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .info-panel {
        min-width: 0;
        padding: 10px;
    }

    .next-panel {
        grid-column: 1 / -1;
    }

    .next-panel #next-piece {
        width: 120px;
    }

    .info-panel h3 {
        font-size: 0.8rem;
    }

    .info-panel div {
        font-size: 1.2rem;
    }

    .best-date {
        font-size: 0.56rem;
    }

    .controls-info {
        width: 100%;
        grid-column: 1 / -1;
        text-align: center;
        margin-top: 10px;
    }
    
    .controls-list {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    .controls-list li {
        margin-bottom: 0;
    }

    .game-board-container {
        padding: 5px;
    }

    canvas#tetris {
        /* Ensure canvas doesn't overflow very small screens */
        max-width: 100%;
        height: auto;
    }
    
    .game-header {
        margin-bottom: 10px;
    }
    
    .game-title {
        font-size: 2rem;
        letter-spacing: 2px;
    }

    .game-meta {
        font-size: 0.5rem;
    }
}

@media (max-width: 768px) {
    body {
        align-items: stretch;
        justify-content: flex-start;
        min-height: 100dvh;
        overflow: hidden;
    }

    .game-container {
        width: 100vw;
        min-height: 100dvh;
        padding: calc(28px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
        gap: 12px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .game-header {
        margin-bottom: 6px;
    }

    .game-meta {
        top: calc(8px + env(safe-area-inset-top));
        right: 8px;
        font-size: 0.46rem;
    }

    .back-link {
        top: calc(8px + env(safe-area-inset-top));
        left: 8px;
        font-size: 0.52rem;
    }

    .game-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .game-board-container {
        width: min(calc(100vw - 20px), calc(100dvh * 0.6));
        max-width: none;
        margin: 0 auto;
    }

    canvas#tetris {
        width: 100%;
        height: auto;
        aspect-ratio: 3 / 5;
        max-height: none;
    }
}
