        @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;500;600;700&display=swap');

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Rajdhani', sans-serif;
            background: #0a0a0f;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            flex-direction: column;
            padding: 10px;
            overflow-x: hidden;
        }

        #particles-canvas {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
        }

        .ambient-glow {
            position: fixed;
            width: 600px;
            height: 600px;
            border-radius: 50%;
            filter: blur(150px);
            opacity: 0.15;
            z-index: -1;
            animation: float 8s ease-in-out infinite;
        }

        .ambient-glow-1 {
            top: -200px;
            left: -200px;
            background: #4a90e2;
        }

        .ambient-glow-2 {
            bottom: -200px;
            right: -200px;
            background: #ff6b6b;
            animation-delay: -4s;
        }

        @keyframes float {
            0%, 100% { transform: translate(0, 0); }
            50% { transform: translate(30px, 30px); }
        }

        h1 {
            margin-bottom: 20px;
            font-size: 36px;
            font-family: 'Orbitron', sans-serif;
            font-weight: 900;
            letter-spacing: 4px;
            text-transform: uppercase;
            background: linear-gradient(135deg, #00f2ff 0%, #4a90e2 50%, #ff6b6b 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-shadow: none;
            filter: drop-shadow(0 0 20px rgba(74, 144, 226, 0.5));
            animation: titleGlow 3s ease-in-out infinite;
        }

        @keyframes titleGlow {
            0%, 100% { filter: drop-shadow(0 0 20px rgba(74, 144, 226, 0.5)); }
            50% { filter: drop-shadow(0 0 30px rgba(74, 144, 226, 0.8)); }
        }

        .game-container {
            display: flex;
            gap: 30px;
            padding: 25px;
            align-items: flex-start;
            background: rgba(255, 255, 255, 0.02);
            border-radius: 20px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            backdrop-filter: blur(10px);
        }

        .player-section {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .player-title {
            text-align: center;
            font-size: 20px;
            font-weight: 700;
            padding: 12px 20px;
            border-radius: 10px;
            font-family: 'Orbitron', sans-serif;
            letter-spacing: 2px;
            text-transform: uppercase;
            position: relative;
            overflow: hidden;
        }

        .player-title::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
            animation: shimmer 3s infinite;
        }

        @keyframes shimmer {
            0% { left: -100%; }
            100% { left: 100%; }
        }

        .player-1 .player-title {
            background: linear-gradient(135deg, rgba(0, 242, 255, 0.2), rgba(74, 144, 226, 0.3));
            border: 2px solid #00f2ff;
            box-shadow: 0 0 20px rgba(0, 242, 255, 0.3), inset 0 0 20px rgba(0, 242, 255, 0.1);
            color: #00f2ff;
        }

        .player-2 .player-title {
            background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(255, 82, 82, 0.3));
            border: 2px solid #ff6b6b;
            box-shadow: 0 0 20px rgba(255, 107, 107, 0.3), inset 0 0 20px rgba(255, 107, 107, 0.1);
            color: #ff6b6b;
        }

        .game-board-wrapper {
            display: flex;
            gap: 15px;
        }

        .game-board {
            position: relative;
            flex-shrink: 0;
        }

        .game-canvas {
            border-radius: 12px;
            background: linear-gradient(180deg, rgba(10, 10, 26, 0.95) 0%, rgba(20, 20, 40, 0.95) 100%);
            position: relative;
            overflow: hidden;
        }

        .game-canvas::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            border-radius: 12px;
            padding: 2px;
            background: linear-gradient(135deg, #00f2ff, #4a90e2);
            -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
            mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
            -webkit-mask-composite: xor;
            mask-composite: exclude;
            pointer-events: none;
        }

        .player-2 .game-canvas::before {
            background: linear-gradient(135deg, #ff6b6b, #ff5252);
        }

        .game-canvas::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            border-radius: 12px;
            box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5), 0 0 30px rgba(74, 144, 226, 0.3);
            pointer-events: none;
        }

        .player-2 .game-canvas::after {
            box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 107, 107, 0.3);
        }

        .side-panel {
            display: flex;
            flex-direction: column;
            gap: 12px;
            min-width: 170px;
            justify-content: flex-start;
            flex-grow: 1;
        }

        .panel-section {
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
            padding: 15px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(5px);
            transition: all 0.3s ease;
            flex: 1;
        }

        .panel-section:hover {
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
            border-color: rgba(255, 255, 255, 0.2);
            transform: translateY(-2px);
        }

        .panel-section h3 {
            margin-bottom: 10px;
            font-family: 'Orbitron', sans-serif;
            font-size: 14px;
            text-transform: uppercase;
            letter-spacing: 2px;
            background: linear-gradient(90deg, #00f2ff, #4a90e2);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .score-display {
            font-size: 36px;
            font-weight: 700;
            font-family: 'Orbitron', sans-serif;
            color: #ffd700;
            text-align: center;
            text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
        }

        .level-display {
            font-size: 36px;
            font-weight: 700;
            font-family: 'Orbitron', sans-serif;
            color: #00ff88;
            text-align: center;
            text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
        }

        .lines-display {
            font-size: 36px;
            font-weight: 700;
            font-family: 'Orbitron', sans-serif;
            color: #ff6b6b;
            text-align: center;
            text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
        }

        .next-canvas {
            display: block;
            margin: 0 auto;
            background: linear-gradient(180deg, rgba(10, 10, 26, 0.9) 0%, rgba(20, 20, 40, 0.9) 100%);
            border-radius: 8px;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .controls-info {
            font-size: 11px;
            line-height: 1.8;
        }

        .controls-info p {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 4px 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        }

        .controls-info p:last-child {
            border-bottom: none;
        }

        .controls-info span {
            background: linear-gradient(135deg, rgba(74, 144, 226, 0.4), rgba(74, 144, 226, 0.2));
            padding: 3px 8px;
            border-radius: 4px;
            font-family: 'Orbitron', sans-serif;
            font-size: 10px;
            font-weight: 600;
            border: 1px solid rgba(74, 144, 226, 0.3);
        }

        .center-panel {
            display: flex;
            flex-direction: column;
            gap: 20px;
            justify-content: center;
            min-width: 160px;
        }

        .battle-status {
            background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 165, 0, 0.05));
            padding: 20px;
            border-radius: 15px;
            border: 2px solid rgba(255, 215, 0, 0.3);
            text-align: center;
            position: relative;
            overflow: hidden;
        }

        .battle-status::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: conic-gradient(from 0deg, transparent, rgba(255, 215, 0, 0.1), transparent);
            animation: rotate 4s linear infinite;
        }

        @keyframes rotate {
            100% { transform: rotate(360deg); }
        }

        .battle-status h3 {
            color: #ffd700;
            margin-bottom: 15px;
            font-size: 14px;
            font-family: 'Orbitron', sans-serif;
            letter-spacing: 3px;
            position: relative;
            z-index: 1;
        }

        .vs-text {
            font-size: 40px;
            font-weight: 900;
            font-family: 'Orbitron', sans-serif;
            background: linear-gradient(135deg, #ffd700, #ff6b6b);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-shadow: none;
            filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6));
            position: relative;
            z-index: 1;
            animation: vsPulse 2s ease-in-out infinite;
        }

        @keyframes vsPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.1); }
        }

        .buttons {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        button {
            width: 100%;
            padding: 14px 20px;
            font-size: 14px;
            font-weight: 700;
            border: none;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            font-family: 'Orbitron', sans-serif;
            letter-spacing: 2px;
            position: relative;
            overflow: hidden;
        }

        button::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
            transition: left 0.5s;
        }

        button:hover::before {
            left: 100%;
        }

        .btn-primary {
            background: linear-gradient(135deg, #00f2ff, #4a90e2, #667eea);
            color: #0a0a1a;
            box-shadow: 0 4px 15px rgba(0, 242, 255, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-3px) scale(1.02);
            box-shadow: 0 8px 25px rgba(0, 242, 255, 0.5);
        }

        .btn-secondary {
            background: linear-gradient(135deg, #667eea, #764ba2, #ff6b6b);
            color: white;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
        }

        .btn-secondary:hover {
            transform: translateY(-3px) scale(1.02);
            box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
        }

        #soundBtn {
            background: linear-gradient(135deg, #00ff88, #00cc6a);
            color: #0a0a1a;
            box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3);
        }

        #soundBtn:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(0, 255, 136, 0.5);
        }

        .sound-off {
            background: linear-gradient(135deg, #ff6b6b, #ff5252) !important;
            box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3) !important;
        }

        .btn-pause {
            background: linear-gradient(135deg, #ffd700, #ff9500);
            color: #0a0a1a;
            box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
        }

        .btn-pause:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(255, 215, 0, 0.5);
        }

        .btn-pause.paused {
            background: linear-gradient(135deg, #00ff88, #00cc6a);
        }

        .game-over-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.95);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            backdrop-filter: blur(10px);
        }

        .game-over-content {
            text-align: center;
            padding: 50px 60px;
            background: linear-gradient(135deg, rgba(20, 20, 40, 0.95), rgba(10, 10, 26, 0.98));
            border-radius: 25px;
            border: 3px solid;
            border-image: linear-gradient(135deg, #ffd700, #ff6b6b, #00f2ff) 1;
            box-shadow: 0 0 50px rgba(255, 215, 0, 0.3), 0 0 100px rgba(0, 242, 255, 0.1);
            animation: gameOverPulse 2s ease-in-out infinite;
        }

        @keyframes gameOverPulse {
            0%, 100% { box-shadow: 0 0 50px rgba(255, 215, 0, 0.3), 0 0 100px rgba(0, 242, 255, 0.1); }
            50% { box-shadow: 0 0 70px rgba(255, 215, 0, 0.5), 0 0 150px rgba(0, 242, 255, 0.2); }
        }

        .game-over-content h2 {
            font-size: 42px;
            margin-bottom: 25px;
            font-family: 'Orbitron', sans-serif;
            font-weight: 900;
            background: linear-gradient(135deg, #ffd700, #ff6b6b);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            animation: celebratePulse 0.5s ease-in-out infinite;
        }

        @keyframes celebratePulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }

        .winner-text {
            font-size: 32px;
            font-weight: 700;
            font-family: 'Orbitron', sans-serif;
            background: linear-gradient(90deg, #00ff88, #00f2ff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            margin-bottom: 30px;
            text-shadow: none;
        }

        .game-over-content button {
            background: linear-gradient(135deg, #00f2ff, #4a90e2);
            color: #0a0a1a;
            margin-top: 15px;
            padding: 16px 40px;
            font-size: 16px;
        }

        .game-over-content button:hover {
            transform: scale(1.05);
            box-shadow: 0 10px 30px rgba(0, 242, 255, 0.5);
        }

        .attack-indicator {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 28px;
            font-weight: 900;
            font-family: 'Orbitron', sans-serif;
            color: #ff6b6b;
            text-shadow: 0 0 20px rgba(255, 107, 107, 0.8), 0 0 40px rgba(255, 107, 107, 0.5);
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.3s;
            z-index: 10;
        }

        .attack-indicator.show {
            opacity: 1;
            animation: attackPulse 0.5s ease-out;
        }

        @keyframes attackPulse {
            0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
            50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
            100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
        }

        .mode-select-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 2000;
            backdrop-filter: blur(5px);
        }

        .mode-select-content {
            text-align: center;
            padding: 60px 80px;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
            border-radius: 30px;
            border: 2px solid rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(20px);
            position: relative;
            overflow: hidden;
        }

        .mode-select-content::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: conic-gradient(from 0deg, transparent, rgba(0, 242, 255, 0.1), transparent, rgba(255, 107, 107, 0.1), transparent);
            animation: bgRotate 10s linear infinite;
        }

        @keyframes bgRotate {
            100% { transform: rotate(360deg); }
        }

        .mode-select-content h1 {
            font-size: 52px;
            margin-bottom: 15px;
            position: relative;
            z-index: 1;
        }

        .mode-select-content .subtitle {
            font-size: 20px;
            color: rgba(255, 255, 255, 0.5);
            margin-bottom: 50px;
            font-family: 'Rajdhani', sans-serif;
            font-weight: 300;
            letter-spacing: 4px;
            position: relative;
            z-index: 1;
        }

        .mode-buttons {
            display: flex;
            gap: 30px;
            flex-wrap: wrap;
            justify-content: center;
            position: relative;
            z-index: 1;
        }

        .difficulty-setting {
            margin-top: 28px;
            display: flex;
            gap: 12px;
            align-items: center;
            justify-content: center;
            font-family: 'Orbitron', sans-serif;
            letter-spacing: 1px;
            position: relative;
            z-index: 1;
        }

        .difficulty-setting label {
            color: rgba(255, 255, 255, 0.85);
            font-size: 13px;
        }

        .difficulty-setting select {
            background: rgba(10, 10, 26, 0.8);
            color: #00f2ff;
            border: 1px solid rgba(0, 242, 255, 0.35);
            border-radius: 8px;
            padding: 8px 12px;
            font-size: 13px;
            font-family: 'Orbitron', sans-serif;
            letter-spacing: 1px;
            outline: none;
        }

        .ai-difficulty-panel {
            margin-top: 0;
            padding: 10px 12px;
            border-radius: 10px;
            background: linear-gradient(135deg, rgba(0, 242, 255, 0.08), rgba(74, 144, 226, 0.06));
            border: 1px solid rgba(0, 242, 255, 0.2);
        }

        .mode-btn {
            padding: 30px 50px;
            font-size: 20px;
            min-width: 220px;
            border-radius: 16px;
            cursor: pointer;
            transition: all 0.4s ease;
            position: relative;
            overflow: hidden;
        }

        .mode-btn-local {
            background: linear-gradient(135deg, #00f2ff, #4a90e2);
            color: #0a0a1a;
            box-shadow: 0 8px 30px rgba(0, 242, 255, 0.3);
        }

        .mode-btn-local:hover {
            transform: translateY(-8px) scale(1.05);
            box-shadow: 0 15px 50px rgba(0, 242, 255, 0.5);
        }

        .mode-btn-online {
            background: linear-gradient(135deg, #667eea, #764ba2, #ff6b6b);
            color: white;
            box-shadow: 0 8px 30px rgba(102, 126, 234, 0.3);
        }

        .mode-btn-online:hover {
            transform: translateY(-8px) scale(1.05);
            box-shadow: 0 15px 50px rgba(102, 126, 234, 0.5);
        }

        .mode-btn .icon {
            font-size: 48px;
            display: block;
            margin-bottom: 15px;
        }

        .waiting-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.95);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 2000;
            backdrop-filter: blur(10px);
        }

        .waiting-content {
            text-align: center;
        }

        .waiting-content h2 {
            font-size: 36px;
            margin-bottom: 25px;
            font-family: 'Orbitron', sans-serif;
            font-weight: 700;
            background: linear-gradient(90deg, #ffd700, #ff6b6b);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .spinner {
            width: 70px;
            height: 70px;
            border: 4px solid rgba(255, 255, 255, 0.1);
            border-top-color: #00f2ff;
            border-right-color: #4a90e2;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 30px auto;
            box-shadow: 0 0 30px rgba(0, 242, 255, 0.3);
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        .cancel-btn {
            margin-top: 35px;
            background: linear-gradient(135deg, #ff6b6b, #ff5252);
            color: white;
            padding: 14px 35px;
            border: none;
            border-radius: 10px;
            font-family: 'Orbitron', sans-serif;
            font-weight: 600;
            letter-spacing: 2px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .cancel-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 30px rgba(255, 107, 107, 0.5);
        }

        .opponent-preview {
            background: rgba(255, 255, 255, 0.05);
            padding: 10px;
            border-radius: 8px;
            border: 1px dashed rgba(255, 255, 255, 0.2);
        }

        .opponent-preview canvas {
            opacity: 0.7;
        }

        .status-message {
            position: fixed;
            top: 25px;
            left: 50%;
            transform: translateX(-50%);
            background: linear-gradient(135deg, rgba(20, 20, 40, 0.95), rgba(10, 10, 26, 0.98));
            padding: 18px 40px;
            border-radius: 12px;
            border: 2px solid #00f2ff;
            z-index: 3000;
            display: none;
            font-family: 'Orbitron', sans-serif;
            font-size: 14px;
            letter-spacing: 2px;
            box-shadow: 0 0 30px rgba(0, 242, 255, 0.3);
            animation: statusSlide 0.3s ease-out;
        }

        @keyframes statusSlide {
            from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
            to { transform: translateX(-50%) translateY(0); opacity: 1; }
        }

        @media (max-width: 1000px) {
            .game-container {
                flex-direction: column;
                gap: 20px;
            }

            .game-board-wrapper {
                flex-direction: column;
            }

            .mode-select-content {
                padding: 40px;
            }

            .mode-select-content h1 {
                font-size: 36px;
            }

            .mode-btn {
                padding: 20px 30px;
                font-size: 16px;
                min-width: 180px;
            }
        }
/* ===== Mobile gameplay optimization ===== */
.mobile-controls {
    display: none;
}

@media (max-width: 900px) {
    body {
        align-items: flex-start;
        padding: 8px;
    }

    #gameUI > h1 {
        font-size: 20px;
        margin-bottom: 10px;
        letter-spacing: 1px;
    }

    .game-container {
        width: 100%;
        padding: 10px;
        gap: 10px;
        flex-direction: column;
    }

    .player-section.player-2 {
        display: none; /* 手机上聚焦自己，避免太拥挤 */
    }

    .center-panel {
        order: 3;
        width: 100%;
        min-width: 0;
    }

    .buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .buttons button,
    .buttons select {
        font-size: 14px;
        padding: 10px 12px;
        min-height: 42px;
    }

    .player-section.player-1 {
        order: 1;
    }

    .player-section.player-1 .player-title {
        font-size: 16px;
        padding: 8px 10px;
        letter-spacing: 1px;
    }

    .player-section.player-1 .game-board-wrapper {
        flex-direction: row;
        align-items: flex-start;
        gap: 8px;
    }

    #player2Board .game-canvas {
        width: min(58vw, 240px);
        height: auto;
        touch-action: none;
    }

    .player-section.player-1 .side-panel {
        min-width: 0;
        width: calc(100vw - min(58vw, 240px) - 48px);
        gap: 8px;
    }

    .player-section.player-1 .panel-section {
        padding: 8px;
    }

    .player-section.player-1 .panel-section h3 {
        font-size: 11px;
        margin-bottom: 6px;
        letter-spacing: 1px;
    }

    .player-section.player-1 .score-display,
    .player-section.player-1 .level-display,
    .player-section.player-1 .lines-display {
        font-size: 24px;
    }

    .player-section.player-1 .next-canvas {
        width: 80px;
        height: 80px;
    }

    .mobile-controls {
        display: block;
        width: 100%;
        margin-top: 10px;
        order: 2;
        background: rgba(255,255,255,0.03);
        border: 1px solid rgba(255,255,255,0.08);
        border-radius: 12px;
        padding: 10px;
        backdrop-filter: blur(8px);
        touch-action: manipulation;
    }

    .mobile-controls-row {
        display: grid;
        gap: 8px;
    }

    .mobile-controls-row.top {
        grid-template-columns: 1fr 1fr;
        margin-bottom: 8px;
    }

    .mobile-controls-row.middle {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .mc-btn {
        border: 1px solid rgba(255,255,255,0.2);
        background: linear-gradient(135deg, rgba(74,144,226,0.35), rgba(74,144,226,0.18));
        color: #fff;
        border-radius: 10px;
        padding: 12px 8px;
        font-size: 14px;
        font-weight: 700;
        min-height: 46px;
        -webkit-tap-highlight-color: transparent;
    }

    .mc-btn:active {
        transform: scale(0.97);
        filter: brightness(1.15);
    }

    .mc-btn.drop {
        background: linear-gradient(135deg, rgba(255,107,107,0.45), rgba(255,82,82,0.2));
    }

    .mobile-hint {
        font-size: 11px;
        color: rgba(255,255,255,0.7);
        margin-top: 8px;
        text-align: center;
    }
}


/* ===== Mobile UI v2 (reference-style) ===== */
@media (max-width: 900px) {
  body { padding: 6px; overflow-x: hidden; }

  #gameUI > h1 { font-size: 16px; margin: 4px 0 8px; letter-spacing: .5px; }

  .game-container {
    width: 100%;
    padding: 8px;
    border-radius: 14px;
    gap: 8px;
    background: rgba(7, 18, 42, 0.55);
  }

  .player-section.player-2,
  .battle-status,
  #aiDifficultyPanel,
  #backBtn { display: none !important; }

  .player-section.player-1 .player-title {
    font-size: 14px;
    padding: 6px 8px;
    border-width: 1px;
    margin-bottom: 2px;
  }

  .player-section.player-1 .game-board-wrapper {
    display: grid;
    grid-template-columns: repeat(3, 1fr) 88px;
    grid-template-rows: auto auto;
    gap: 6px;
    align-items: start;
  }

  /* board */
  #player2Board { grid-column: 1 / 4; grid-row: 2; }
  #player2Board .game-canvas {
    width: min(66vw, 280px);
    height: auto;
    border-radius: 10px;
    touch-action: none;
  }

  /* convert side-panel sections to HUD tiles + next box */
  .player-section.player-1 .side-panel {
    display: contents;
  }

  .player-section.player-1 .side-panel .panel-section {
    padding: 6px 8px;
    border-radius: 10px;
    min-height: 50px;
    background: linear-gradient(135deg, rgba(45,140,220,0.42), rgba(32,82,170,0.28));
    border: 1px solid rgba(140,200,255,0.35);
  }

  .player-section.player-1 .side-panel .panel-section h3 {
    font-size: 10px;
    margin-bottom: 3px;
    letter-spacing: .5px;
    color: rgba(220,240,255,.95);
    -webkit-text-fill-color: unset;
    background: none;
  }

  .player-section.player-1 .side-panel .panel-section:nth-child(1) { grid-column: 1; grid-row: 1; }
  .player-section.player-1 .side-panel .panel-section:nth-child(2) { grid-column: 2; grid-row: 1; }
  .player-section.player-1 .side-panel .panel-section:nth-child(3) { grid-column: 3; grid-row: 1; }
  .player-section.player-1 .side-panel .panel-section:nth-child(4) {
    grid-column: 4;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: calc(min(66vw, 280px) + 56px);
    background: linear-gradient(180deg, rgba(14,34,80,.85), rgba(13,25,64,.95));
  }

  .player-section.player-1 .score-display,
  .player-section.player-1 .level-display,
  .player-section.player-1 .lines-display {
    font-size: 22px;
    line-height: 1;
    text-shadow: none;
  }

  .player-section.player-1 .next-canvas { width: 72px; height: 72px; }

  .center-panel {
    width: 100%;
    min-width: 0;
    order: 3;
    gap: 8px;
  }

  .buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  #startBtn { grid-column: span 1; }
  #pauseBtn { grid-column: span 1; }
  #soundBtn { grid-column: span 1; }

  .buttons button {
    min-height: 40px;
    padding: 8px;
    font-size: 13px;
    border-radius: 10px;
  }

  .mobile-controls {
    display: block;
    width: 100%;
    margin-top: 8px;
    border-radius: 14px;
    padding: 10px;
    background: rgba(9, 35, 76, 0.55);
    border: 1px solid rgba(120, 200, 255, 0.35);
  }

  .mobile-controls-row.top,
  .mobile-controls-row.middle {
    display: grid;
    gap: 10px;
  }

  .mobile-controls-row.top { grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
  .mobile-controls-row.middle { grid-template-columns: 1fr 1fr 1fr; }

  .mc-btn {
    min-height: 50px;
    border-radius: 999px;
    border: 1px solid rgba(180,230,255,.55);
    background: radial-gradient(circle at 30% 25%, #5ec7ff, #2b86d7 70%);
    color: #fff;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .5px;
    box-shadow: inset 0 2px 0 rgba(255,255,255,.35), 0 3px 12px rgba(0,90,180,.35);
  }

  .mc-btn.drop { background: radial-gradient(circle at 30% 25%, #6fd5ff, #2b9fd7 70%); }
  .mc-btn:active { transform: scale(0.96); }

  .mobile-hint { font-size: 11px; margin-top: 8px; color: rgba(220,240,255,.86); }
}
