/* ============================================
   CUBE DROP — 3D Tetris 
   Design System & Styles
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Colors */
    --bg-primary: #000000;
    --bg-secondary: #0a0a0f;
    --bg-tertiary: #111118;
    --bg-glass: rgba(10, 10, 20, 0.85);
    --bg-glass-light: rgba(20, 20, 40, 0.6);

    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555570;

    --accent-primary: #00ffcc;
    --accent-secondary: #7b61ff;
    --accent-tertiary: #ff3d71;
    --accent-warning: #ffaa00;

    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(0, 255, 204, 0.3);

    /* Typography */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Borders */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 20px rgba(0, 255, 204, 0.15);
    --shadow-glow-strong: 0 0 40px rgba(0, 255, 204, 0.3);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
}

.hidden {
    display: none !important;
}

/* --- Loading Screen --- */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

/* 3D Cube Loader Animation */
.cube-loader {
    width: 60px;
    height: 60px;
    position: relative;
    transform-style: preserve-3d;
    animation: cubeRotate 3s infinite ease-in-out;
}

.cube-face {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 2px solid var(--accent-primary);
    background: rgba(0, 255, 204, 0.05);
    box-shadow: inset 0 0 20px rgba(0, 255, 204, 0.1);
}

.cube-face.front {
    transform: translateZ(30px);
}

.cube-face.back {
    transform: rotateY(180deg) translateZ(30px);
}

.cube-face.right {
    transform: rotateY(90deg) translateZ(30px);
}

.cube-face.left {
    transform: rotateY(-90deg) translateZ(30px);
}

.cube-face.top {
    transform: rotateX(90deg) translateZ(30px);
}

.cube-face.bottom {
    transform: rotateX(-90deg) translateZ(30px);
}

@keyframes cubeRotate {
    0% {
        transform: rotateX(0deg) rotateY(0deg);
    }

    25% {
        transform: rotateX(90deg) rotateY(90deg);
    }

    50% {
        transform: rotateX(180deg) rotateY(180deg);
    }

    75% {
        transform: rotateX(270deg) rotateY(270deg);
    }

    100% {
        transform: rotateX(360deg) rotateY(360deg);
    }
}

.loader-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    color: var(--accent-primary);
    text-shadow: 0 0 30px rgba(0, 255, 204, 0.5);
}

.loader-subtitle {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.loader-bar {
    width: 200px;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.loader-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* --- Main Menu --- */
#main-menu {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0, 10, 20, 0.9) 0%, rgba(0, 0, 0, 0.98) 100%);
}

.menu-container {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--space-2xl);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: menuFadeIn 0.6s ease-out;
}

/* Custom scrollbar for menu */
.menu-container::-webkit-scrollbar {
    width: 4px;
}

.menu-container::-webkit-scrollbar-track {
    background: transparent;
}

.menu-container::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 2px;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.menu-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.game-title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    color: var(--text-primary);
    line-height: 1.1;
}

.title-accent {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-subtitle {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.3em;
    margin-top: var(--space-sm);
}

/* Menu Sections */
.menu-sections {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.menu-section {
    padding: var(--space-lg);
    background: var(--bg-glass-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-normal);
}

.menu-section:hover {
    border-color: var(--border-glow);
}

.section-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--accent-primary);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-icon {
    font-size: 1rem;
}

/* Config Rows */
.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    gap: var(--space-md);
}

.config-row label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

/* Sliders */
.slider-group {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 1;
    max-width: 200px;
}

.config-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.config-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.4);
    transition: transform var(--transition-fast);
}

.config-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.config-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.4);
}

.slider-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 28px;
    text-align: right;
}

/* Color Picker */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.color-picker {
    -webkit-appearance: none;
    appearance: none;
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-sm);
}

.color-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Texture Selector */
.texture-selector {
    display: flex;
    gap: var(--space-sm);
}

.texture-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: var(--font-body);
}

.texture-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: rgba(0, 255, 204, 0.05);
}

.texture-btn.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(0, 255, 204, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.15);
}

.texture-icon {
    font-size: 1.4rem;
}

.texture-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all var(--transition-normal);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all var(--transition-normal);
}

.toggle-switch input:checked+.toggle-slider {
    background: rgba(0, 255, 204, 0.2);
    border-color: var(--accent-primary);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
    background: var(--accent-primary);
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

.gpu-status {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.gpu-status.detected {
    color: var(--accent-primary);
}

.gpu-status.not-detected {
    color: var(--accent-tertiary);
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Menu Actions */
.menu-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.btn-primary {
    position: relative;
    padding: var(--space-md) var(--space-2xl);
    background: linear-gradient(135deg, rgba(0, 255, 204, 0.15), rgba(123, 97, 255, 0.15));
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-lg);
    color: var(--accent-primary);
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.btn-primary:hover {
    background: linear-gradient(135deg, rgba(0, 255, 204, 0.25), rgba(123, 97, 255, 0.25));
    box-shadow: var(--shadow-glow-strong);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 255, 204, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-primary:hover .btn-glow {
    width: 300px;
    height: 300px;
}

.btn-text {
    position: relative;
    z-index: 1;
}

.btn-secondary {
    padding: var(--space-sm) var(--space-xl);
    background: var(--bg-glass-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: rgba(0, 255, 204, 0.05);
}

.high-score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.hs-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.2em;
}

.hs-value {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-warning);
    text-shadow: 0 0 15px rgba(255, 170, 0, 0.3);
}

/* --- Game Container --- */
#game-container {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- HUD --- */
#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

#hud>* {
    pointer-events: auto;
}

.hud-top-left {
    position: absolute;
    top: var(--space-lg);
    left: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.hud-score,
.hud-level,
.hud-lines {
    display: flex;
    flex-direction: column;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.hud-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.hud-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.hud-score .hud-value {
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.3);
}

.hud-level .hud-value {
    color: var(--accent-secondary);
    text-shadow: 0 0 10px rgba(123, 97, 255, 0.3);
}

.hud-lines .hud-value {
    color: var(--accent-warning);
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.3);
}

.hud-top-right {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-md);
}

.hud-next {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.hud-next .hud-label {
    text-align: center;
}

#next-piece-canvas {
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.3);
}

.hud-fps {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.fps-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.fps-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
}

.hud-top-center {
    position: absolute;
    top: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-sm);
}

.hud-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--transition-fast);
}

/* Custom Button Colors */
#btn-help-ingame,
#btn-reset-camera {
    color: #33ccff;
    /* Sky Blue (Subtle) */
    border-color: rgba(51, 204, 255, 0.3);
    text-shadow: 0 0 8px rgba(51, 204, 255, 0.4);
}

#btn-help-ingame:hover,
#btn-reset-camera:hover {
    color: #80e5ff;
    /* Brighter on hover */
    border-color: #33ccff;
    box-shadow: 0 0 20px rgba(51, 204, 255, 0.4);
    background: rgba(51, 204, 255, 0.1);
}

/* Freeze Button - Only blue when active (frozen) */
#btn-pause.frozen-active {
    color: #80e5ff;
    /* Very bright/light Sky Blue */
    border-color: #80e5ff;
    background: rgba(128, 229, 255, 0.15);
    box-shadow: 0 0 25px rgba(128, 229, 255, 0.5);
    text-shadow: 0 0 10px rgba(128, 229, 255, 0.8);
}

#btn-pause.frozen-active:hover {
    color: #ffffff;
    background: rgba(128, 229, 255, 0.25);
    box-shadow: 0 0 35px rgba(128, 229, 255, 0.7);
}

.hud-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

/* Undo Button - Light Green */
#btn-undo {
    color: #40ff40;
    /* Light Green */
    border-color: rgba(64, 255, 64, 0.3);
    text-shadow: 0 0 8px rgba(64, 255, 64, 0.4);
}

#btn-undo:hover {
    color: #ccffcc;
    border-color: #40ff40;
    box-shadow: 0 0 25px rgba(64, 255, 64, 0.5);
    background: rgba(64, 255, 64, 0.15);
}

#btn-undo:active {
    background: rgba(64, 255, 64, 0.3);
    transform: scale(0.95);
}

.hud-help-btn {
    width: 42px;
    height: 42px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 800;
    align-self: flex-end;
}

/* --- Touch Controls (iPad Mode) --- */
#touch-controls {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    display: flex;
    gap: var(--space-lg);
    z-index: 200;
    pointer-events: auto;
}

.touch-dpad {
    display: grid;
    grid-template-areas:
        ". up ."
        "left center right"
        ". down .";
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 56px);
    gap: 4px;
}

.touch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--transition-fast);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
    background: rgba(0, 255, 204, 0.2);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: scale(0.95);
}

.touch-up {
    grid-area: up;
}

.touch-down {
    grid-area: down;
}

.touch-left {
    grid-area: left;
}

.touch-right {
    grid-area: right;
}

.touch-center {
    grid-area: center;
    background: rgba(0, 255, 204, 0.1);
    border-color: var(--accent-primary);
}

.touch-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}

.touch-actions .touch-btn {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.75rem;
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* --- Pause Overlay --- */
#pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.pause-content,
.gameover-content {
    text-align: center;
    padding: var(--space-2xl);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    animation: menuFadeIn 0.3s ease-out;
}

.pause-title,
.gameover-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 0.2em;
    color: var(--accent-primary);
    text-shadow: 0 0 30px rgba(0, 255, 204, 0.4);
    margin-bottom: var(--space-xl);
}

.gameover-title {
    color: var(--accent-tertiary);
    text-shadow: 0 0 30px rgba(255, 61, 113, 0.4);
}

.pause-actions,
.gameover-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    align-items: center;
}

/* --- Game Over --- */
#gameover-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

.gameover-stats {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-xl);
}

.stat-row.highlight {
    background: rgba(255, 170, 0, 0.05);
    border: 1px solid rgba(255, 170, 0, 0.2);
    border-radius: var(--radius-md);
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-row.highlight .stat-value {
    color: var(--accent-warning);
    text-shadow: 0 0 15px rgba(255, 170, 0, 0.3);
}

/* --- Controls Help --- */
#controls-help {
    position: fixed;
    inset: 0;
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.controls-content {
    padding: var(--space-2xl);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    max-width: 400px;
    width: 90%;
}

.controls-content h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: 0.15em;
    text-align: center;
    margin-bottom: var(--space-lg);
}

.control-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.control-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.control-item kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* --- Layer Clear Animation --- */
@keyframes layerClear {
    0% {
        opacity: 1;
        transform: scaleY(1);
    }

    50% {
        opacity: 0.5;
        transform: scaleY(1.1);
        filter: brightness(3);
    }

    100% {
        opacity: 0;
        transform: scaleY(0);
    }
}

.layer-clearing {
    animation: layerClear 0.5s ease-out forwards;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .menu-container {
        padding: var(--space-lg);
        max-height: 95vh;
    }

    .game-title {
        font-size: 2rem;
    }

    .config-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .slider-group {
        max-width: 100%;
        width: 100%;
    }

    .texture-selector {
        flex-wrap: wrap;
    }

    .hud-top-left {
        top: var(--space-md);
        left: var(--space-md);
    }

    .hud-top-right {
        top: var(--space-md);
        right: var(--space-md);
    }

    #touch-controls {
        bottom: var(--space-md);
        right: var(--space-md);
    }

    .touch-dpad {
        grid-template-columns: repeat(3, 48px);
        grid-template-rows: repeat(3, 48px);
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }

    .hud-value {
        font-size: 1.2rem;
    }

    .touch-dpad {
        grid-template-columns: repeat(3, 42px);
        grid-template-rows: repeat(3, 42px);
    }
}

/* --- Score Pop Animation --- */
@keyframes scorePop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
        color: #fff;
    }

    100% {
        transform: scale(1);
    }
}

.score-pop {
    animation: scorePop 0.3s ease-out;
}

/* --- Ghost piece indicator --- */
.ghost-piece {
    opacity: 0.2;
}