* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            user-select: none;
        }

        :root {
            --bg-dark: #07070c;
            --bg-mid: #0e0e18;
            --bg-panel: #12121c;
            --bg-panel-2: #161622;
            --bg-control: #1a1a28;
            --accent: #f97316;
            --accent-dim: #ea580c;
            --accent-glow: rgba(249, 115, 22, 0.4);
            --accent-glow-soft: rgba(249, 115, 22, 0.14);
            --accent-secondary: #8b5cf6;
            --accent-secondary-glow: rgba(139, 92, 246, 0.45);
            --text: #eef0f8;
            --text-dim: #7a7a94;
            --border: #2c2c42;
            --border-glow: rgba(249, 115, 22, 0.32);
            --danger: #ff4757;
            --danger-glow: rgba(255, 71, 87, 0.4);
            --warning: #ffa502;
            --safe-top: env(safe-area-inset-top, 0px);
            --safe-right: env(safe-area-inset-right, 0px);
            --safe-bottom: env(safe-area-inset-bottom, 0px);
            --safe-left: env(safe-area-inset-left, 0px);
            --controls-h: 0px;
        }

        @keyframes title-pulse {
            0%, 100% { text-shadow: 0 0 8px var(--accent-glow-soft), 0 0 18px transparent; }
            50% { text-shadow: 0 0 14px var(--accent-glow), 0 0 28px var(--accent-glow-soft); }
        }

        @keyframes board-aura {
            0%, 100% {
                box-shadow:
                    0 0 0 1px var(--border-glow),
                    0 0 28px rgba(249, 115, 22, 0.12),
                    0 0 56px rgba(0, 0, 0, 0.55),
                    inset 0 0 24px rgba(0, 0, 0, 0.35);
            }
            50% {
                box-shadow:
                    0 0 0 1px rgba(249, 115, 22, 0.42),
                    0 0 36px rgba(249, 115, 22, 0.2),
                    0 0 64px rgba(0, 0, 0, 0.5),
                    inset 0 0 24px rgba(0, 0, 0, 0.3);
            }
        }

        @keyframes btn-shine {
            0%, 100% { box-shadow: 0 0 16px var(--accent-glow), 0 4px 0 #c2410c; }
            50% { box-shadow: 0 0 24px var(--accent-glow), 0 4px 0 #c2410c; }
        }

        html, body {
            height: 100%;
            height: 100dvh;
            overscroll-behavior: none;
            touch-action: manipulation;
        }

        body {
            font-family: 'Segoe UI', ui-sans-serif, system-ui, -apple-system, sans-serif;
            background:
                radial-gradient(ellipse 90% 70% at 50% 0%, rgba(249, 115, 22, 0.07), transparent 55%),
                radial-gradient(ellipse 60% 50% at 100% 100%, rgba(139, 92, 246, 0.06), transparent 50%),
                radial-gradient(ellipse 50% 40% at 0% 80%, rgba(0, 180, 220, 0.04), transparent 45%),
                linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-dark) 100%);
            color: var(--text);
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: stretch;
            padding: 0;
            padding-top: var(--safe-top);
            padding-right: var(--safe-right);
            padding-bottom: var(--safe-bottom);
            padding-left: var(--safe-left);
            position: relative;
        }

        body::before {
            content: "";
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 0;
            background-image:
                linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
            background-size: 28px 28px;
            mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, #000 20%, transparent 75%);
            opacity: 0.9;
        }

        body::after {
            content: "";
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 0;
            background: radial-gradient(ellipse 80% 75% at 50% 40%, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
        }

        .game-container {
            position: relative;
            z-index: 1;
        }

        .game-container {
            display: grid;
            grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) minmax(280px, 340px);
            grid-template-areas: "chrome board rail";
            align-items: stretch;
            justify-content: center;
            column-gap: clamp(10px, 2vw, 24px);
            width: 100%;
            height: 100%;
            max-width: none;
            padding: 10px clamp(8px, 1.5vw, 20px);
            margin: 0;
            box-sizing: border-box;
        }

        .chrome-left {
            grid-area: chrome;
            display: flex;
            flex-direction: column;
            gap: 10px;
            min-width: 0;
            height: 100%;
            max-height: 100%;
            align-self: stretch;
        }

        .side-panel {
            display: flex;
            flex-direction: column;
            gap: 10px;
            align-items: stretch;
            justify-content: flex-start;
            padding: 14px;
            min-width: 0;
            flex: 0 0 auto;
            background:
                linear-gradient(160deg, rgba(249, 115, 22, 0.06), transparent 42%),
                linear-gradient(180deg, var(--bg-panel-2), var(--bg-panel));
            border: 1px solid var(--border);
            border-radius: 12px;
            box-shadow:
                0 0 0 1px rgba(255, 255, 255, 0.03) inset,
                0 8px 24px rgba(0, 0, 0, 0.35);
        }

        .chrome-head {
            display: flex;
            align-items: center;
            gap: 8px;
            min-width: 0;
        }

        .chrome-actions {
            display: flex;
            flex-direction: column;
            gap: 10px;
            align-items: stretch;
        }

        .stats-panel {
            display: flex;
            flex-direction: column;
            gap: 8px;
            justify-content: flex-start;
            flex: 1 1 auto;
            min-height: 0;
            overflow: auto;
        }

        .board-panel {
            grid-area: board;
            display: flex;
            flex-direction: column;
            gap: 12px;
            align-items: center;
            justify-content: center;
            min-width: 0;
            min-height: 0;
            height: 100%;
            max-height: 100%;
            overflow: hidden;
        }

        /* Right thumb zone — keeps Next/stats off the controls */
        .control-rail {
            grid-area: rail;
            position: relative;
            min-width: 0;
            height: 100%;
            align-self: stretch;
            pointer-events: none;
        }

        .game-board {
            position: relative;
            background:
                radial-gradient(ellipse 80% 60% at 50% 30%, rgba(249, 115, 22, 0.04), transparent 60%),
                var(--bg-panel);
            border: 2px solid rgba(249, 115, 22, 0.35);
            border-radius: 12px;
            overflow: hidden;
            box-shadow:
                0 0 0 1px var(--border-glow),
                0 0 28px rgba(249, 115, 22, 0.12),
                0 0 56px rgba(0, 0, 0, 0.55),
                inset 0 0 24px rgba(0, 0, 0, 0.35);
            animation: board-aura 5.5s ease-in-out infinite;
            touch-action: none;
            flex: 0 1 auto;
            max-width: 100%;
            max-height: 100%;
        }

        @media (prefers-reduced-motion: reduce) {
            .game-board,
            .side-panel .title,
            .btn-primary {
                animation: none !important;
            }
        }

        #gameCanvas {
            display: block;
            max-width: 100%;
            max-height: 100%;
            width: auto;
            height: auto;
            object-fit: contain;
        }

        .overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background:
                radial-gradient(ellipse 70% 50% at 50% 40%, rgba(249, 115, 22, 0.08), transparent 65%),
                rgba(7, 7, 12, 0.94);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 16px;
            z-index: 10;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            padding: 16px;
            text-align: center;
        }

        .overlay.hidden {
            display: none;
        }

        .overlay h2 {
            font-size: clamp(22px, 5vw, 28px);
            font-weight: 800;
            color: var(--accent);
            text-shadow: 0 0 20px var(--accent-glow), 0 0 40px var(--accent-glow-soft);
            letter-spacing: 3px;
            text-transform: uppercase;
            animation: title-pulse 3.2s ease-in-out infinite;
        }

        .overlay p {
            color: var(--text-dim);
            font-size: 14px;
            line-height: 1.45;
            max-width: 240px;
        }

        .overlay #finalScore {
            color: var(--text);
            font-weight: 700;
            font-variant-numeric: tabular-nums;
        }

        .btn {
            padding: 14px 28px;
            min-height: 48px;
            border: none;
            border-radius: 10px;
            font-size: 16px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, filter 0.15s ease;
            text-transform: uppercase;
            letter-spacing: 1.2px;
            touch-action: manipulation;
        }

        .btn:active {
            transform: translateY(2px) scale(0.98);
        }

        .btn-primary {
            background: linear-gradient(180deg, #fb923c 0%, var(--accent) 45%, var(--accent-dim) 100%);
            color: var(--bg-dark);
            box-shadow: 0 0 16px var(--accent-glow), 0 4px 0 #c2410c;
            animation: btn-shine 2.8s ease-in-out infinite;
        }

        .btn-primary:hover {
            filter: brightness(1.06);
            box-shadow: 0 0 26px var(--accent-glow), 0 4px 0 #c2410c;
        }

        .btn-primary:active {
            box-shadow: 0 0 12px var(--accent-glow), 0 1px 0 #c2410c;
        }

        .btn-secondary {
            background: linear-gradient(180deg, #222234, var(--bg-control));
            color: var(--text);
            border: 1px solid var(--border);
            box-shadow: 0 3px 0 #0e0e16;
        }

        .btn-secondary:hover {
            border-color: var(--accent-dim);
            background: linear-gradient(180deg, #2a2a40, var(--bg-control));
        }

        .btn-secondary:active {
            box-shadow: 0 1px 0 #0e0e16;
        }

        .info-box {
            background:
                linear-gradient(165deg, rgba(249, 115, 22, 0.05), transparent 50%),
                linear-gradient(180deg, var(--bg-panel-2), var(--bg-panel));
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 12px;
            text-align: center;
            flex: 0 0 auto;
            box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset, 0 4px 14px rgba(0, 0, 0, 0.25);
        }

        .info-label {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: var(--text-dim);
            margin-bottom: 4px;
            font-weight: 600;
        }

        .info-value {
            font-size: 22px;
            font-weight: 800;
            color: var(--accent);
            font-variant-numeric: tabular-nums;
            text-shadow: 0 0 12px var(--accent-glow-soft);
            letter-spacing: 0.5px;
        }

        #nextCanvas {
            display: block;
            margin: 0 auto;
            background:
                radial-gradient(circle at 50% 40%, rgba(249, 115, 22, 0.06), transparent 65%),
                var(--bg-control);
            border-radius: 8px;
            width: 72px;
            height: 72px;
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 2px 8px rgba(0, 0, 0, 0.35);
        }

        .controls {
            /* Always right-handed: cluster at bottom-right for right thumb */
            position: fixed;
            right: max(12px, var(--safe-right));
            bottom: max(48px, calc(var(--safe-bottom) + 40px));
            left: auto;
            display: none;
            flex-direction: column;
            align-items: center;
            gap: 72px;
            z-index: 20;
            padding: 6px;
            pointer-events: none;
        }

        .controls > * {
            pointer-events: auto;
        }

        .controls-main {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
        }

        .rotate-btn {
            width: 120px;
            height: 76px;
            background: linear-gradient(180deg, #a78bfa 0%, var(--accent-secondary) 55%, #6d28d9 100%);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 20px;
            color: white;
            font-size: 34px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow:
                0 0 18px var(--accent-secondary-glow),
                0 5px 0 #4c1d95,
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
            transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
            touch-action: manipulation;
        }

        .rotate-btn:active {
            transform: translateY(3px) scale(0.96);
            box-shadow:
                0 0 12px var(--accent-secondary-glow),
                0 2px 0 #4c1d95,
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
        }

        .dpad {
            display: flex;
            gap: 14px;
        }

        .dpad-btn {
            width: 88px;
            height: 88px;
            background: linear-gradient(180deg, #252538 0%, var(--bg-control) 100%);
            border: 2px solid var(--border);
            border-radius: 22px;
            color: var(--text);
            font-size: 30px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow:
                0 4px 0 #0c0c14,
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
            transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease, color 0.1s ease;
            touch-action: manipulation;
        }

        .dpad-btn:active {
            background: linear-gradient(180deg, #fb923c 0%, var(--accent) 100%);
            color: var(--bg-dark);
            border-color: var(--accent);
            transform: translateY(2px) scale(0.96);
            box-shadow:
                0 0 14px var(--accent-glow),
                0 2px 0 #c2410c,
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
        }

        .dpad-btn.hard-drop {
            width: 100%;
            max-width: 200px;
            height: 56px;
            background: linear-gradient(180deg, #ff6b7a 0%, var(--danger) 55%, #e03545 100%);
            border-color: rgba(255, 255, 255, 0.15);
            color: white;
            font-size: 26px;
            border-radius: 16px;
            box-shadow:
                0 0 16px var(--danger-glow),
                0 4px 0 #b01e2c,
                inset 0 1px 0 rgba(255, 255, 255, 0.22);
        }

        .dpad-btn.hard-drop:active {
            background: linear-gradient(180deg, #ff8a96 0%, #ff6b7a 100%);
            transform: translateY(2px) scale(0.97);
            box-shadow:
                0 0 12px var(--danger-glow),
                0 2px 0 #b01e2c,
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
        }

        .side-panel .title {
            font-size: 18px;
            font-weight: 800;
            color: var(--accent);
            letter-spacing: 3px;
            text-transform: uppercase;
            text-align: center;
            flex: 1 1 auto;
            min-width: 0;
            animation: title-pulse 3.2s ease-in-out infinite;
        }

        .side-panel .sound-toggle {
            width: 100%;
            justify-content: center;
            white-space: nowrap;
        }

        .side-panel .icon-btn {
            width: 100%;
            min-height: 44px;
            height: 44px;
            font-size: 18px;
        }

        .icon-btn {
            width: 38px;
            height: 38px;
            background: linear-gradient(180deg, #222234, var(--bg-control));
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            font-size: 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 0 #0c0c14, inset 0 1px 0 rgba(255, 255, 255, 0.06);
            transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.1s ease;
            touch-action: manipulation;
        }

        .icon-btn:hover {
            border-color: rgba(249, 115, 22, 0.35);
            background: linear-gradient(180deg, #2a2a40, var(--bg-control));
        }

        .icon-btn:active {
            transform: translateY(1px);
            box-shadow: 0 1px 0 #0c0c14;
        }

        .icon-btn.active {
            background: linear-gradient(180deg, #fb923c, var(--accent));
            color: var(--bg-dark);
            border-color: var(--accent);
            box-shadow: 0 0 10px var(--accent-glow), 0 2px 0 #c2410c;
        }

        .sound-toggle {
            padding: 10px 12px;
            min-height: 44px;
            background: linear-gradient(180deg, #222234, var(--bg-control));
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
            box-shadow: 0 2px 0 #0c0c14, inset 0 1px 0 rgba(255, 255, 255, 0.06);
            transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
            touch-action: manipulation;
        }

        .sound-toggle:hover {
            border-color: rgba(249, 115, 22, 0.35);
            background: linear-gradient(180deg, #2a2a40, var(--bg-control));
        }

        .sound-toggle:active {
            transform: translateY(1px);
        }

        .sound-toggle.muted {
            opacity: 0.45;
            border-color: var(--danger);
            color: var(--danger);
            background: rgba(255, 71, 87, 0.08);
            box-shadow: none;
        }

        #installBtn {
            display: none;
        }

        #installBtn.show {
            display: flex;
        }

        a.sound-toggle {
            text-decoration: none;
            color: inherit;
            box-sizing: border-box;
        }

        a.sound-toggle:visited {
            color: inherit;
        }

        .about-sheet {
            position: fixed;
            inset: 0;
            z-index: 40;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: max(16px, var(--safe-top)) max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
            background: rgba(7, 7, 12, 0.72);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }

        .about-sheet.hidden {
            display: none;
        }

        .about-pill-card {
            width: min(420px, 100%);
            max-height: min(86dvh, 640px);
            overflow: auto;
            padding: 28px 26px 24px;
            border-radius: 999px / 72px;
            background:
                radial-gradient(ellipse 80% 50% at 50% 0%, rgba(249, 115, 22, 0.16), transparent 55%),
                linear-gradient(165deg, #1a1a28 0%, #12121c 55%, #0e0e16 100%);
            border: 2px solid rgba(249, 115, 22, 0.4);
            box-shadow:
                0 0 0 1px rgba(249, 115, 22, 0.12),
                0 0 40px rgba(249, 115, 22, 0.18),
                0 24px 48px rgba(0, 0, 0, 0.55);
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
            animation: about-pop 0.28s ease-out;
        }

        @keyframes about-pop {
            from { opacity: 0; transform: scale(0.92) translateY(10px); }
            to { opacity: 1; transform: scale(1) translateY(0); }
        }

        @media (prefers-reduced-motion: reduce) {
            .about-pill-card {
                animation: none;
            }
        }

        .about-pill-card h2 {
            font-size: clamp(22px, 5vw, 28px);
            font-weight: 800;
            color: var(--accent);
            letter-spacing: 3px;
            text-transform: uppercase;
            text-shadow: 0 0 18px var(--accent-glow);
            margin: 0;
        }

        .about-lead {
            color: var(--text);
            font-size: 14px;
            line-height: 1.45;
            max-width: 300px;
            margin: 0;
        }

        .about-list {
            list-style: none;
            margin: 4px 0;
            padding: 0;
            width: 100%;
            max-width: 300px;
            text-align: left;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .about-list li {
            color: var(--text-dim);
            font-size: 13px;
            line-height: 1.35;
            padding-left: 1.1em;
            position: relative;
        }

        .about-list li::before {
            content: "●";
            color: var(--accent);
            position: absolute;
            left: 0;
            font-size: 8px;
            top: 0.45em;
        }

        .about-note {
            color: var(--text-dim);
            font-size: 12px;
            line-height: 1.4;
            max-width: 300px;
            margin: 0;
            font-style: italic;
        }

        .about-link {
            color: var(--accent);
            font-size: 13px;
            font-weight: 600;
            text-decoration: none;
            border-bottom: 1px solid rgba(249, 115, 22, 0.45);
            padding-bottom: 1px;
        }

        .about-link:hover {
            color: #fb923c;
        }

        .about-credit {
            color: var(--text-dim);
            font-size: 12px;
            margin: 2px 0 6px;
        }

        .about-pill-card .btn {
            min-width: 140px;
            border-radius: 999px;
        }

        @media (max-width: 420px) {
            .about-pill-card {
                border-radius: 40px;
                padding: 22px 18px 18px;
            }
        }

        .privacy-badge {
            position: fixed;
            bottom: max(10px, var(--safe-bottom));
            left: max(10px, var(--safe-left));
            font-size: 10px;
            color: var(--text-dim);
            display: flex;
            align-items: center;
            gap: 5px;
            z-index: 2;
            pointer-events: none;
        }

        .privacy-badge::before {
            content: "🔒";
        }

        .swipe-hint {
            display: none;
            font-size: 11px;
            color: var(--text-dim);
            text-align: center;
            margin-top: 4px;
        }

        /* Touch: on-screen controls always bottom-right (right thumb) */
        @media (hover: none), (pointer: coarse) {
            .controls {
                display: flex;
            }
        }

        /* Mouse/trackpad desktop: no need for a fat empty rail */
        @media (hover: hover) and (pointer: fine) {
            .game-container {
                grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) 0fr;
                column-gap: clamp(10px, 2vw, 24px);
            }
            .control-rail {
                display: none;
            }
        }

        /* Landscape tablet / wide short viewports — fill height, chrome left */
        @media (orientation: landscape) and (min-width: 600px) {
            .game-container {
                padding: 8px clamp(8px, 1.2vw, 16px);
                column-gap: clamp(8px, 1.5vw, 18px);
            }

            .side-panel {
                padding: 10px;
                gap: 8px;
            }

            .side-panel .title {
                font-size: 15px;
                letter-spacing: 2px;
            }

            .info-box {
                padding: 10px 8px;
            }

            .info-value {
                font-size: 20px;
            }

            #nextCanvas {
                width: 64px;
                height: 64px;
            }

            .privacy-badge {
                display: none;
            }
        }

        /* Phone landscape — compact left chrome */
        @media (orientation: landscape) and (max-height: 480px),
               (orientation: landscape) and (max-width: 920px) {
            .game-container {
                grid-template-columns: minmax(132px, 168px) minmax(0, 1fr) minmax(220px, 300px);
                padding: 6px 8px;
                column-gap: 8px;
            }

            .chrome-left {
                gap: 6px;
            }

            .side-panel {
                padding: 6px 8px;
                gap: 6px;
                border-radius: 10px;
            }

            .chrome-head {
                gap: 6px;
            }

            .side-panel .title {
                font-size: 11px;
                letter-spacing: 1px;
                text-align: left;
            }

            .chrome-actions {
                flex-direction: row;
                flex-wrap: nowrap;
                gap: 4px;
                align-items: stretch;
            }

            .side-panel .sound-toggle {
                flex: 1 1 0;
                width: auto;
                min-width: 0;
                min-height: 32px;
                padding: 4px 4px;
                font-size: 10px;
                gap: 2px;
                border-radius: 6px;
            }

            .side-panel .icon-btn {
                flex: 0 0 32px;
                width: 32px;
                height: 32px;
                min-height: 32px;
                font-size: 13px;
                border-radius: 6px;
            }

            .stats-panel {
                display: grid;
                grid-template-columns: 1fr 1fr;
                gap: 4px;
                overflow: hidden;
                align-content: start;
            }

            .info-box {
                padding: 4px 4px;
                border-radius: 8px;
            }

            .info-box.next-box {
                grid-column: auto;
                padding: 4px;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
            }

            .info-label {
                font-size: 9px;
                letter-spacing: 1px;
                margin-bottom: 1px;
            }

            .info-value {
                font-size: 15px;
            }

            #nextCanvas {
                width: 44px;
                height: 44px;
            }

            .privacy-badge {
                display: none;
            }
        }

        /* Landscape + touch: dedicate right column to right-thumb controls */
        @media (orientation: landscape) and (min-width: 600px) and ((hover: none), (pointer: coarse)) {
            .game-container {
                grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) minmax(280px, 340px);
            }

            .controls {
                display: flex;
                position: fixed;
                right: max(10px, var(--safe-right));
                bottom: max(40px, calc(var(--safe-bottom) + 32px));
                left: auto;
                top: auto;
                width: auto;
                height: auto;
                padding: 8px;
                flex-direction: column;
                justify-content: flex-end;
                align-items: center;
                gap: 48px;
                background: none;
                pointer-events: none;
                z-index: 20;
            }

            .controls > * {
                pointer-events: auto;
            }

            .controls-main {
                gap: 14px;
            }

            .dpad {
                flex-direction: row;
                gap: 14px;
            }

            .rotate-btn {
                width: 132px;
                height: 84px;
                border-radius: 22px;
                font-size: 38px;
            }

            .dpad-btn {
                width: 92px;
                height: 92px;
                border-radius: 24px;
                font-size: 34px;
                border-width: 2px;
            }

            .dpad-btn.hard-drop {
                width: 100%;
                max-width: 220px;
                height: 58px;
                font-size: 28px;
            }
        }

        /* Touch phone landscape: slightly smaller control rail */
        @media (orientation: landscape) and (max-width: 920px) and ((hover: none), (pointer: coarse)) {
            .game-container {
                grid-template-columns: minmax(132px, 168px) minmax(0, 1fr) minmax(200px, 260px);
            }

            .controls {
                right: max(6px, var(--safe-right));
                bottom: max(36px, calc(var(--safe-bottom) + 28px));
                padding: 4px;
                gap: 40px;
            }

            .controls-main {
                gap: 8px;
            }

            .rotate-btn {
                width: 96px;
                height: 56px;
                border-radius: 16px;
                font-size: 28px;
            }

            .dpad {
                gap: 8px;
            }

            .dpad-btn {
                width: 64px;
                height: 64px;
                border-radius: 16px;
                font-size: 22px;
            }

            .dpad-btn.hard-drop {
                max-width: 160px;
                height: 46px;
                font-size: 22px;
                border-radius: 12px;
            }
        }

        /* Portrait phones — compact chrome; board-first; pad bottom-right */
        @media (max-width: 720px) and (orientation: portrait) {
            body {
                align-items: stretch;
            }

            .game-container {
                display: flex;
                flex-direction: column;
                align-items: stretch;
                gap: 6px;
                padding: 6px 8px;
                padding-bottom: calc(var(--controls-h, 280px) + 8px);
                height: 100%;
                overflow: hidden;
            }

            .chrome-left {
                flex: 0 0 auto;
                height: auto;
                max-height: none;
                gap: 6px;
            }

            .side-panel {
                flex-direction: row;
                flex-wrap: nowrap;
                align-items: center;
                justify-content: space-between;
                gap: 8px;
                width: 100%;
                height: auto;
                padding: 6px 8px;
                border-radius: 10px;
            }

            .chrome-head {
                width: auto;
                flex: 0 0 auto;
            }

            .side-panel .title {
                text-align: left;
                font-size: 13px;
                letter-spacing: 1.5px;
                margin-right: 0;
            }

            .chrome-actions {
                flex-direction: row;
                flex-wrap: nowrap;
                align-items: center;
                justify-content: flex-end;
                gap: 6px;
                flex: 1 1 auto;
                min-width: 0;
            }

            .side-panel .sound-toggle {
                flex: 0 0 34px;
                width: 34px;
                min-width: 34px;
                height: 34px;
                min-height: 34px;
                padding: 0;
                justify-content: center;
                gap: 0;
                border-radius: 6px;
                font-size: 15px;
            }

            .side-panel .sound-toggle .btn-label {
                display: none;
            }

            .side-panel .icon-btn {
                flex: 0 0 34px;
                width: 34px;
                height: 34px;
                min-height: 34px;
                font-size: 14px;
            }

            .stats-panel {
                flex-direction: row;
                flex-wrap: nowrap;
                justify-content: space-between;
                align-items: stretch;
                gap: 4px;
                width: 100%;
                flex: 0 0 auto;
                overflow: visible;
            }

            .board-panel {
                width: 100%;
                flex: 1 1 auto;
                min-height: 0;
                height: auto;
                max-height: 100%;
                justify-content: center;
                overflow: hidden;
            }

            .control-rail {
                display: none;
            }

            .game-board {
                margin: 0 auto;
                max-width: 100%;
            }

            .info-box {
                flex: 1 1 0;
                min-width: 0;
                padding: 6px 4px;
                border-radius: 8px;
            }

            .info-box.next-box {
                flex: 0 0 auto;
                padding: 4px 6px;
            }

            .info-label {
                font-size: 8px;
                margin-bottom: 1px;
            }

            .info-value {
                font-size: 14px;
            }

            #nextCanvas {
                width: 44px;
                height: 44px;
            }

            .controls {
                display: flex;
                left: auto;
                right: max(6px, var(--safe-right));
                top: auto;
                bottom: max(48px, calc(var(--safe-bottom) + 40px));
                padding: 4px;
                flex-direction: column;
                justify-content: flex-end;
                align-items: center;
                gap: 72px;
                background: none;
                pointer-events: none;
                transform: none;
            }

            .controls > * {
                pointer-events: auto;
            }

            .controls-main {
                gap: 10px;
            }

            .rotate-btn {
                width: 96px;
                height: 56px;
                border-radius: 16px;
                font-size: 28px;
            }

            .dpad {
                flex-direction: row;
                gap: 10px;
            }

            .dpad-btn {
                width: 68px;
                height: 68px;
                border-radius: 18px;
                font-size: 26px;
            }

            .dpad-btn.hard-drop {
                max-width: 148px;
                height: 44px;
                font-size: 20px;
                border-radius: 14px;
            }

            .privacy-badge {
                display: none;
            }

            .swipe-hint {
                display: block;
            }

            .overlay h2 {
                font-size: 24px;
            }

            .btn {
                width: min(240px, 80vw);
            }
        }

        @media (max-width: 380px) and (orientation: portrait) {
            .dpad-btn {
                width: 60px;
                height: 60px;
                font-size: 22px;
            }
            .dpad-btn.hard-drop {
                max-width: 132px;
                height: 40px;
                font-size: 18px;
            }
            .rotate-btn {
                width: 84px;
                height: 48px;
                font-size: 24px;
            }
            .controls {
                gap: 64px;
            }
            .side-panel .title {
                font-size: 11px;
            }
        }

        @media (display-mode: standalone), (display-mode: minimal-ui) {
            .privacy-badge {
                display: none;
            }
        }
