/* ==========================================================================
   GOMOKU PRESTIGE - PREMIUM STYLING SYSTEM (ENGLISH)
   ========================================================================== */

/* 1. CSS VARIABLES & THEME DEFINITIONS */
:root {
    --bg-dark: #070b14;
    --bg-card: rgba(15, 23, 42, 0.55);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    /* Neon glow palettes */
    --color-primary: #6366f1;
    --color-secondary: #06b6d4;
    --color-accent: #f43f5e;
    
    /* Piece colors */
    --color-x-light: #ff6b8b;
    --color-x-dark: #e11d48;
    --color-o-light: #38bdf8;
    --color-o-dark: #0284c7;
    
    /* Status colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    
    /* Fonts */
    --font-primary: 'Outfit', sans-serif;
    --font-header: 'Playfair Display', serif;
    
    /* Board variables (updated dynamically in JS) */
    --board-size: 15;
    --max-cell-size: 52px;
    --min-cell-size: 18px;
    --cell-size: clamp(var(--min-cell-size), min(85vw / var(--board-size), 65vh / var(--board-size)), var(--max-cell-size));
}

/* 2. BASE STYLES & RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-dark);
    color: #e2e8f0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Ambient glow backgrounds */
.bg-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
}

.glow-1 {
    width: 50vw;
    height: 50vw;
    top: -10vw;
    left: -10vw;
    background: radial-gradient(circle, var(--color-primary) 0%, transparent 80%);
}

.glow-2 {
    width: 60vw;
    height: 60vw;
    bottom: -15vw;
    right: -10vw;
    background: radial-gradient(circle, var(--color-secondary) 0%, transparent 80%);
}

/* Main wrapper */
#app-container {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Screen manager */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    max-height: 100%;
    animation: fadeIn 0.4s ease-out forwards;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 3. DESIGN PATTERNS: GLASSMORPHISM */
.glassmorphism {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

/* Buttons and Interactions */
button {
    font-family: var(--font-primary);
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 4. MAIN MENU SCREEN */
#main-menu {
    justify-content: center;
    align-items: center;
    max-width: 520px;
}

.menu-card {
    width: 100%;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    max-height: 85vh;
    overflow-y: auto;
}

/* Logo Styling */
.logo-container {
    text-align: center;
    margin-bottom: 5px;
}

.logo-icon-3d {
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.logo-icon-3d span {
    display: inline-block;
    width: 70px;
    height: 70px;
    line-height: 64px;
    border-radius: 18px;
    text-align: center;
    text-shadow: 0 5px 10px rgba(0,0,0,0.5);
    transform: perspective(300px) rotateX(15deg);
}

.x-glow {
    background: radial-gradient(circle at 35% 35%, #fff 0%, var(--color-x-light) 30%, var(--color-x-dark) 80%);
    box-shadow: 0 8px 16px rgba(225, 29, 72, 0.4), inset 0 -3px 6px rgba(0,0,0,0.4), inset 0 3px 6px rgba(255,255,255,0.4);
    color: #fff;
}

.o-glow {
    background: radial-gradient(circle at 35% 35%, #fff 0%, var(--color-o-light) 30%, var(--color-o-dark) 80%);
    box-shadow: 0 8px 16px rgba(2, 132, 199, 0.4), inset 0 -3px 6px rgba(0,0,0,0.4), inset 0 3px 6px rgba(255,255,255,0.4);
    color: #fff;
}

.game-title {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 40%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.accent-text {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.game-subtitle {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-top: 5px;
    letter-spacing: 1px;
}

/* Input Fields & Selectors */
.form-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-group input[type="text"] {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 12px;
    color: #fff;
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: all 0.3s;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
    background: rgba(15, 23, 42, 0.8);
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.difficulty-selector-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.btn-select {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
    color: #94a3b8;
    padding: 10px 4px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.82rem;
    text-align: center;
}

.btn-select:hover {
    border-color: var(--border-hover);
    color: #fff;
    background: rgba(30, 41, 59, 0.6);
}

.btn-select.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(6, 182, 212, 0.2) 100%);
    border-color: var(--color-secondary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.2);
}

/* Custom Size Wrapper */
.custom-size-wrapper {
    grid-column: span 4;
    margin-top: 4px;
}

.input-custom-size {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.3s;
}

.input-custom-size:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

/* Difficulty Button Colors when active */
.btn-select.diff-easy.active {
    border-color: var(--color-success);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.15);
}
.btn-select.diff-medium.active {
    border-color: var(--color-warning);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.15);
}
.btn-select.diff-hard.active {
    border-color: var(--color-accent);
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.2);
    background: rgba(244, 63, 94, 0.15);
}
.btn-select.diff-expert.active {
    border-color: #a855f7;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.2);
    background: rgba(168, 85, 247, 0.15);
    color: #e9d5ff;
}
.btn-select.diff-grandmaster.active {
    border-color: #ec4899;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.2);
    background: rgba(236, 72, 153, 0.15);
    color: #fce7f3;
}

.turn-selector {
    grid-template-columns: repeat(2, 1fr);
}

/* Warnings */
.warning-text {
    font-size: 0.75rem;
    color: var(--color-warning);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: pulseGlow 1.5s infinite ease-in-out;
}

.hidden {
    display: none !important;
}

/* Actions layout */
.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 800;
    padding: 16px;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
    letter-spacing: 1px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.45);
}

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

.secondary-actions {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    flex: 1;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--border-color);
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 12px;
    border-radius: 12px;
}

.btn-secondary:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: var(--border-hover);
    color: #fff;
}

/* 5. GAME SCREEN STYLING */
#game-screen {
    max-width: 900px;
    gap: 15px;
}

/* Game Header */
.game-header {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 15px;
}

.btn-icon-back {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
}

.btn-icon-back:hover {
    background: rgba(255, 255, 255, 0.12);
}

.player-vs-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.player-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: all 0.3s;
    min-width: 140px;
    position: relative;
}

.player-badge.active {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.player-human.active {
    border-color: rgba(229, 29, 72, 0.4);
    box-shadow: 0 0 15px rgba(225, 29, 72, 0.2);
}

.player-ai.active {
    border-color: rgba(2, 132, 199, 0.4);
    box-shadow: 0 0 15px rgba(2, 132, 199, 0.2);
}

.badge-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    color: #94a3b8;
}

.player-human .badge-avatar {
    color: var(--color-x-light);
}

.player-ai .badge-avatar {
    color: var(--color-o-light);
}

.badge-info {
    display: flex;
    flex-direction: column;
}

.badge-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
}

.player-badge.active .badge-name {
    color: #fff;
}

.badge-piece {
    font-size: 0.75rem;
    font-weight: 800;
}

.text-x {
    color: var(--color-x-light);
}

.text-o {
    color: var(--color-o-light);
}

.vs-text {
    font-size: 0.8rem;
    font-weight: 800;
    color: #475569;
}

/* AI Thinking loader */
.thinking-spinner {
    display: flex;
    gap: 4px;
    align-items: center;
    position: absolute;
    right: 12px;
}

.thinking-spinner span {
    width: 6px;
    height: 6px;
    background: var(--color-o-light);
    border-radius: 50%;
    animation: bounceThinking 0.6s infinite alternate;
}

.thinking-spinner span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-spinner span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounceThinking {
    from { transform: translateY(0); opacity: 0.3; }
    to { transform: translateY(-6px); opacity: 1; }
}

/* Dashboard Stats */
.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 10px;
    gap: 8px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: #f8fafc;
}

/* ================= 3D CHESSBOARD SYSTEM ================= */
.board-viewport {
    flex: 1;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(5, 7, 13, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: inset 0 10px 30px rgba(0,0,0,0.5);
    /* manipulation: cho phép tap/click nhưng vẫn chặn pinch-zoom trên iOS Safari */
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.board-zoom-container {
    transform-origin: center center;
    transition: transform 0.1s cubic-bezier(0.1, 0.8, 0.3, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.board-3d-wrapper {
    perspective: 1000px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(var(--board-size), var(--cell-size));
    grid-template-rows: repeat(var(--board-size), var(--cell-size));
    background: linear-gradient(145deg, #161e2e, #0b111e);
    border: 8px solid #2d3748;
    border-radius: 16px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.6), 
        0 1px 1px rgba(255, 255, 255, 0.15), 
        inset 0 10px 20px rgba(0, 0, 0, 0.8);
    position: relative;
    /* iOS Safari: rotateX + preserve-3d gây invisible children, dùng flat */
    -webkit-transform: rotateX(8deg);
    transform: rotateX(8deg);
    -webkit-transform-style: flat;
    transform-style: flat;
}

/* 3D Cell slots */
.cell {
    position: relative;
    background: #0f172a;
    border-radius: 4px;
    margin: 2px;
    box-shadow: 
        inset 2px 2px 5px rgba(0,0,0,0.85), 
        inset -1px -1px 2px rgba(255,255,255,0.04);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Hover effects */
.cell:hover::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 4px;
    box-shadow: inset 0 0 8px rgba(6, 182, 212, 0.6);
    background: rgba(6, 182, 212, 0.05);
}

/* Winning glowing cells */
.cell-winning {
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6), inset 0 0 10px rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.15) !important;
    animation: glowWinning 0.8s infinite alternate;
}

@keyframes glowWinning {
    from { box-shadow: 0 0 10px rgba(16, 185, 129, 0.4), inset 0 0 8px rgba(16, 185, 129, 0.4); }
    to { box-shadow: 0 0 22px rgba(16, 185, 129, 0.8), inset 0 0 15px rgba(16, 185, 129, 0.7); }
}

/* Cell hint glowing style */
.cell-hint {
    box-shadow: 0 0 15px var(--color-warning), inset 0 0 10px var(--color-warning);
    background: rgba(245, 158, 11, 0.15) !important;
    animation: glowHint 0.8s infinite alternate;
    z-index: 8;
}

@keyframes glowHint {
    from { box-shadow: 0 0 8px rgba(245, 158, 11, 0.4), inset 0 0 6px rgba(245, 158, 11, 0.4); }
    to { box-shadow: 0 0 18px rgba(245, 158, 11, 0.8), inset 0 0 12px rgba(245, 158, 11, 0.7); }
}

/* Last placed cell helper */
.cell-last-move::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
    top: 5px;
    right: 5px;
    z-index: 5;
}

/* 6. GLOSSY 3D PIECES */
.piece {
    width: 82%;
    height: 82%;
    border-radius: 50%;
    position: relative;
    /* iOS Safari: tách transform-style và filter riêng để tránh compositing bug */
    -webkit-transform-style: flat;
    transform-style: flat;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    animation: dropPiece 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.25) both;
    -webkit-animation: dropPiece 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.25) both;
    /* Box-shadow thay thế filter drop-shadow để tương thích iOS */
    box-shadow: 0 6px 10px rgba(0,0,0,0.55);
    will-change: transform, opacity;
}

@keyframes dropPiece {
    0%   { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

@-webkit-keyframes dropPiece {
    0%   { -webkit-transform: scale(1.5); opacity: 0; }
    100% { -webkit-transform: scale(1);   opacity: 1; }
}

/* X - Pink/Red glossy cross */
.piece-x {
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
}

.piece-x::before, .piece-x::after {
    content: '';
    position: absolute;
    width: 18%;
    height: 84%;
    border-radius: 6px;
    background: radial-gradient(circle at 35% 25%, #ffd2dc 0%, var(--color-x-light) 30%, var(--color-x-dark) 85%, #880824 100%);
    box-shadow: 
        2px 4px 6px rgba(0,0,0,0.4),
        inset 1px 1px 2px rgba(255,255,255,0.7),
        inset -1px -1px 3px rgba(0,0,0,0.5);
}

.piece-x::before {
    transform: rotate(45deg);
}

.piece-x::after {
    transform: rotate(-45deg);
}

/* O - Glowing Blue glossy torus */
.piece-o {
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, var(--color-o-light) 30%, var(--color-o-dark) 75%, #083c66 100%);
    box-shadow: 
        0 6px 8px rgba(0,0,0,0.4),
        inset 2px 2px 4px rgba(255,255,255,0.7),
        inset -2px -2px 4px rgba(0,0,0,0.6);
}

.piece-o::after {
    content: '';
    position: absolute;
    width: 50%;
    height: 50%;
    background: #0f172a;
    border-radius: 50%;
    top: 25%;
    left: 25%;
    box-shadow: 
        inset 1px 1px 3px rgba(0,0,0,0.8),
        1px 1px 2px rgba(255,255,255,0.06);
}

/* Winning overlay line — overlays exactly the chessboard grid */
.winning-line-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* No separate transform: inherits perspective from .board-3d-wrapper */
    overflow: visible;
}

.winning-line-path {
    fill: none;
    stroke: var(--color-success);
    stroke-width: 6;
    stroke-linecap: round;
    filter: drop-shadow(0 0 12px var(--color-success)) drop-shadow(0 0 4px #fff);
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawLine 1.2s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

/* 7. GAME CONTROL TOOLBAR */
.game-footer {
    display: flex;
    justify-content: space-around;
    padding: 12px;
    gap: 12px;
}

.btn-control {
    flex: 1;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
    color: #94a3b8;
    border-radius: 12px;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 1.1rem;
    position: relative;
}

.btn-control:hover {
    background: rgba(30, 41, 59, 0.7);
    color: #fff;
    border-color: var(--border-hover);
}

.btn-control:active {
    transform: scale(0.95);
}

.btn-text {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-count {
    position: absolute;
    top: -5px;
    right: 15px;
    background: var(--color-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 6px var(--color-primary);
}

/* 8. MODALS & POPUPS */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    backdrop-filter: blur(8px);
    animation: fadeInModal 0.3s forwards;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 26px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    position: relative;
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
}

.modal-large {
    max-width: 820px;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-modal {
    background: transparent;
    color: #94a3b8;
    font-size: 1.8rem;
    line-height: 1;
}

.btn-close-modal:hover {
    color: #fff;
}

/* Leaderboard Specifics */
.leaderboard-filters-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 5px;
}

@media (min-width: 600px) {
    .leaderboard-filters-bar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.filter-toggle {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.btn-toggle {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}

.leaderboard-tabs {
    display: flex;
    gap: 6px;
    background: rgba(15, 23, 42, 0.6);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.scrollable-tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.scrollable-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex: 1;
    background: transparent;
    color: #94a3b8;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: #fff;
    box-shadow: 0 4px 10px rgba(99,102,241,0.25);
}

.table-responsive {
    overflow-x: auto;
    max-height: 38vh;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.4);
    margin-bottom: 5px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
}

.leaderboard-table th {
    background: rgba(30, 41, 59, 0.5);
    color: #cbd5e1;
    font-weight: 600;
}

.leaderboard-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.leaderboard-table tr:last-child td {
    border-bottom: none;
}

.rank-gold { color: #f59e0b; font-weight: 800; }
.rank-silver { color: #cbd5e1; font-weight: 800; }
.rank-bronze { color: #b45309; font-weight: 800; }

/* Personal Match History */
.personal-history-section {
    margin-top: 15px;
    border-top: 1px dashed var(--border-color);
    padding-top: 15px;
}

.personal-history-section h3 {
    font-size: 1rem;
    font-weight: 800;
    color: #cbd5e1;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.history-win { color: var(--color-success); font-weight: 600; }
.history-draw { color: var(--color-warning); font-weight: 600; }
.history-loss { color: var(--color-danger); font-weight: 600; }

.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: #64748b;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state i {
    font-size: 2.2rem;
}

/* Modals footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Rules list styling */
.rules-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.rules-content h3 {
    font-size: 1rem;
    color: #fff;
    margin-top: 5px;
}

.rules-content ul {
    list-style-type: none;
    padding-left: 0;
}

.rules-content li {
    margin-bottom: 8px;
    position: relative;
    padding-left: 20px;
}

.rules-content li::before {
    content: '✦';
    position: absolute;
    left: 0;
    color: var(--color-secondary);
}

.score-formula-box {
    background: rgba(99, 102, 241, 0.08);
    border: 1px dashed rgba(99, 102, 241, 0.4);
    padding: 14px;
    border-radius: 12px;
    margin-top: 8px;
}

.score-formula-box p {
    color: #fff;
    margin-bottom: 8px;
}

.font-bold {
    font-weight: 700;
}

/* 9. GAMEOVER DIALOG SPECIFICS */
.text-center {
    text-align: center;
}

.victory-light-effect {
    position: absolute;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    animation: rotateGlow 8s infinite linear;
}

@keyframes rotateGlow {
    to { transform: translateX(-50%) rotate(360deg); }
}

.gameover-icon {
    font-size: 4rem;
    margin-bottom: -5px;
    filter: drop-shadow(0 8px 15px rgba(245, 158, 11, 0.3));
}

.gameover-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 30%, #f59e0b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.gameover-subtitle {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-top: -10px;
}

.gameover-stats {
    display: flex;
    justify-content: space-around;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 16px;
    margin: 10px 0;
}

.over-stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.over-stat-box .lbl {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
}

.over-stat-box .val {
    font-size: 1.1rem;
    font-weight: 800;
}

.highscore-badge {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-primary) 100%);
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 8px 16px;
    border-radius: 20px;
    align-self: center;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
    margin: 5px 0;
}

.ranking-pos-txt {
    font-size: 0.85rem;
    color: var(--color-success);
    font-weight: 600;
    margin-top: 5px;
}

.animate-pulse {
    animation: pulseGlow 1.5s infinite ease-in-out;
}

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

.modal-actions-stacked {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.modal-actions-stacked button {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
}

/* 10. ADS SYSTEM STYLING */
.ads-overlay-screen {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(12px);
    animation: fadeInModal 0.25s forwards;
}

.ads-loading-card {
    padding: 35px 25px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.ads-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.08);
    border-top: 4px solid var(--color-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ads-loading-card h3 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.ads-loading-card p {
    font-size: 0.85rem;
    color: #94a3b8;
}

.btn-skip-ads {
    background: rgba(255,255,255,0.06);
    color: #cbd5e1;
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    margin-top: 5px;
}

.btn-skip-ads:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}

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

/* 11. TOAST NOTIFICATION */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--color-primary);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* AI thinking overlay on board */
.board-thinking-overlay {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(1px);
    pointer-events: all;
}

.thinking-dialog {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border-radius: 30px;
    font-weight: 600;
}

/* Ripple effect styling */
.ripple {
    position: relative;
    overflow: hidden;
}

/* 12. RESPONSIVENESS AND MOBILE OPTIMIZATION */
@media (max-width: 768px) {
    #app-container {
        padding: 10px;
    }
    
    .screen {
        max-height: 96vh;
    }
    
    .menu-card {
        padding: 24px;
        gap: 20px;
    }
    
    .logo-icon-3d {
        font-size: 2.8rem;
        gap: 10px;
    }
    
    .logo-icon-3d span {
        width: 55px;
        height: 55px;
        line-height: 50px;
        border-radius: 12px;
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .btn-primary {
        padding: 14px;
        font-size: 1rem;
    }

    .difficulty-selector-5 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* In game modifications */
    .game-header {
        padding: 8px 12px;
    }
    
    .player-badge {
        padding: 4px 10px;
        min-width: 110px;
    }
    
    .badge-name {
        max-width: 65px;
        font-size: 0.75rem;
    }
    
    .badge-avatar {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
    }
    
    .stats-bar {
        padding: 8px;
    }
    
    .stat-value {
        font-size: 0.95rem;
    }
    
    .game-footer {
        padding: 8px;
        gap: 8px;
    }
    
    .btn-control {
        padding: 8px 4px;
        font-size: 0.95rem;
    }
    
    .btn-text {
        font-size: 0.65rem;
    }
    
    .chessboard {
        border-width: 5px;
        border-radius: 12px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 1.1rem;
    }
    
    .leaderboard-table th, .leaderboard-table td {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .difficulty-selector-5 {
        grid-template-columns: repeat(2, 1fr);
    }
    .difficulty-selector-5 button:last-child {
        grid-column: span 2;
    }
    .secondary-actions {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    .secondary-actions button {
        width: 100%;
    }
}

/* Custom modern range inputs for audio sliders */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
    transition: background 0.3s;
}
input[type="range"]:hover {
    background: rgba(255, 255, 255, 0.18);
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
    transition: transform 0.1s ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}
input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
    transition: transform 0.1s ease;
}
input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.25);
}

/* ================= PRE-GAME LAUNCH SCREEN ================= */
.launch-screen-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999; /* Above normal modals */
    background: radial-gradient(circle at center, #0f172a 0%, #05070d 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1), visibility 0.6s;
}

.launch-screen-overlay:not(.active) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.launch-card {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 900px;
    height: 520px;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 35px 70px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 10;
}

.launch-banner-container {
    width: 48%;
    position: relative;
    overflow: hidden;
    background: #000;
}

.launch-banner-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.02);
    transition: transform 12s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.launch-screen-overlay.active .launch-banner-img {
    transform: scale(1.12);
}

.launch-banner-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, transparent 60%, rgba(15, 23, 42, 0.95) 100%);
}

.launch-content {
    width: 52%;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(10px);
}

.launch-category-tag {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #94a3b8;
    background: rgba(2, 132, 199, 0.12);
    border: 1px solid rgba(2, 132, 199, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

.launch-title {
    font-size: 2.4rem;
    font-weight: 800;
    color: #fff;
    margin-top: 20px;
    letter-spacing: 1px;
    line-height: 1.2;
}

.launch-desc {
    font-size: 0.95rem;
    color: #94a3b8;
    line-height: 1.6;
    margin-top: 15px;
}

.launch-actions {
    margin-top: 30px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.btn-launch-play {
    width: 100%;
    padding: 18px 30px;
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    border: none;
    border-radius: 16px;
    color: #fff;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.btn-launch-play:hover {
    transform: scale(1.04) translateY(-2px);
    box-shadow: 0 15px 35px rgba(124, 58, 237, 0.6), 0 0 15px rgba(168, 85, 247, 0.4);
    filter: brightness(1.1);
}

.btn-launch-play:active {
    transform: scale(0.98) translateY(0);
}

/* Button pulse animations */
@keyframes buttonPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 10px 30px rgba(124, 58, 237, 0.4); }
    50% { transform: scale(1.03); box-shadow: 0 14px 40px rgba(124, 58, 237, 0.65), 0 0 20px rgba(168, 85, 247, 0.5); }
}

.btn-launch-play.pulse-animation:not(.hidden) {
    animation: buttonPulse 2.5s infinite ease-in-out;
}

/* Loader Styles */
.launch-init-loader {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.launch-progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.launch-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #7c3aed, #a855f7);
    border-radius: 3px;
    transition: width 0.08s ease-out;
}

.launch-init-text {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.launch-loading-container {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 16px;
    width: 100%;
}

.launch-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(124, 58, 237, 0.2);
    border-top: 3px solid #a855f7;
    border-radius: 50%;
    animation: launchSpin 0.8s infinite linear;
}

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

.launch-status-text {
    font-size: 0.95rem;
    color: #f8fafc;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.launch-footer-credits {
    font-size: 0.75rem;
    color: #475569;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}

/* Responsive Media Queries for Launch Screen */
@media (max-width: 768px) {
    .launch-card {
        flex-direction: column;
        height: auto;
        max-height: 90vh;
    }
    
    .launch-banner-container {
        width: 100%;
        height: 180px;
    }
    
    .launch-banner-overlay {
        background: linear-gradient(to bottom, transparent 40%, rgba(15, 23, 42, 0.95) 100%);
    }
    
    .launch-content {
        width: 100%;
        padding: 24px;
    }
    
    .launch-title {
        font-size: 1.8rem;
        margin-top: 10px;
    }
    
    .launch-desc {
        font-size: 0.85rem;
        margin-top: 10px;
    }
    
    .launch-actions {
        margin-top: 20px;
    }
    
    .btn-launch-play {
        padding: 14px 20px;
        font-size: 1.15rem;
    }
}

/* ==========================================================================
   8. NEW RESPONSIVE RESPONSIVENESS AND LAYOUT SYSTEM
   ========================================================================== */

/* Layout Wrapper */
.game-layout-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Default Sidebar Panel (Hidden for Mobile/Tablet) */
.sidebar-panel {
    display: none;
}

.mobile-hud-container {
    display: block;
}

/* Ensure buttons meet minimum touch target guidelines */
.btn-control, .btn-secondary, .btn-primary, .btn-select, .btn-sidebar, .btn-fullscreen-pc {
    min-height: 44px;
}

/* Audio Quick Toggles layout on setup screen */
.audio-toggles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Responsive Breakpoints */

/* 1. Mobile Layout Override (max-width: 600px) */
@media (max-width: 600px) {
    body {
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
    
    #game-screen {
        padding: 5px;
    }
    
    .game-layout-wrapper {
        justify-content: space-between;
        height: 100%;
    }
    
    .game-header {
        padding: 6px;
        border-radius: 12px;
        margin-bottom: 4px;
    }
    
    .player-badge {
        padding: 4px 8px;
        min-width: 95px;
    }
    
    .badge-name {
        max-width: 55px;
        font-size: 0.7rem;
    }
    
    .badge-avatar {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
    
    .stats-bar {
        padding: 6px;
        border-radius: 10px;
        margin-bottom: 4px;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    .stat-value {
        font-size: 0.85rem;
    }
    
    .board-viewport {
        margin: 4px 0;
        border-radius: 12px;
    }
    
    .game-footer {
        padding: 6px;
        gap: 6px;
        border-radius: 12px;
    }
    
    .btn-control {
        padding: 6px 2px;
    }
    
    .btn-text {
        font-size: 0.6rem;
    }
}

/* 2. Tablet Layout Override (601px - 1024px) */
@media (min-width: 601px) and (max-width: 1024px) {
    .game-layout-wrapper {
        justify-content: space-around;
        padding: 10px;
    }
    
    .board-viewport {
        max-height: 60vh;
        margin: 15px 0;
    }
}

/* 3. Desktop Layout Override (1025px+) */
@media (min-width: 1025px) {
    .game-layout-wrapper {
        display: grid;
        grid-template-columns: 1fr 340px;
        gap: 24px;
        padding: 20px;
        height: 100%;
        box-sizing: border-box;
    }
    
    /* Hide top/bottom HUD elements on Desktop PC */
    .mobile-hud-container {
        display: none !important;
    }
    
    .board-viewport {
        grid-column: 1;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0;
        padding: 0;
        border-radius: 24px;
    }
    
    /* Sidebar styling */
    .sidebar-panel {
        display: flex;
        flex-direction: column;
        grid-column: 2;
        height: 100%;
        max-height: 100%;
        padding: 20px;
        background: rgba(15, 23, 42, 0.65);
        backdrop-filter: blur(16px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 24px;
        color: #f8fafc;
        overflow-y: auto;
        box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
        gap: 15px;
        align-self: center;
    }
    
    .sidebar-header {
        text-align: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        padding-bottom: 10px;
        margin-bottom: 5px;
    }
    
    .sidebar-logo {
        font-size: 1.35rem;
        font-weight: 800;
        letter-spacing: 1px;
        color: #fff;
        margin: 0;
    }
    
    .sidebar-tagline {
        font-size: 0.75rem;
        color: #64748b;
        margin: 2px 0 0 0;
    }
    
    .sidebar-section {
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        padding-bottom: 12px;
    }
    
    .sidebar-section:last-of-type {
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .sidebar-section h3 {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: var(--color-secondary);
        margin-bottom: 8px;
        margin-top: 0;
        font-weight: 800;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .sidebar-info-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 5px 0;
    }
    
    .info-label {
        font-size: 0.8rem;
        color: #94a3b8;
    }
    
    .info-value {
        font-size: 0.85rem;
        font-weight: 700;
        color: #f8fafc;
    }
    
    .sidebar-controls-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .btn-sidebar {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 6px;
        padding: 10px;
        font-size: 0.8rem;
        font-weight: 700;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.06);
        color: #f8fafc;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .btn-sidebar:hover {
        background: var(--color-primary);
        border-color: var(--color-primary);
        box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
        transform: translateY(-1px);
    }
    
    .btn-sidebar:active {
        transform: translateY(0);
    }
    
    .sidebar-audio-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 6px;
    }
    
    .sidebar-audio-row label {
        font-size: 0.8rem;
        color: #94a3b8;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .sidebar-audio-row input[type="checkbox"] {
        width: 16px;
        height: 16px;
        accent-color: var(--color-primary);
        cursor: pointer;
    }
    
    .btn-fullscreen-pc {
        margin-top: 10px;
        width: 100%;
        padding: 10px;
        background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
        border: none;
        border-radius: 12px;
        color: white;
        font-weight: 800;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 6px;
        font-size: 0.8rem;
        transition: transform 0.2s, box-shadow 0.2s;
    }
    
    .btn-fullscreen-pc:hover {
        transform: scale(1.02);
        box-shadow: 0 5px 12px rgba(6, 182, 212, 0.4);
    }
    
    .btn-fullscreen-pc.hidden {
        display: none !important;
    }
}

/* ==========================================================================
   9. IFRAME COMPATIBILITY & EMBED OPTIMIZATIONS
   ========================================================================== */

/* Remove or disable resize handles and draggable dividers */
* {
    resize: none !important;
}

.split-pane, .resizer, .draggable-divider, .divider {
    display: none !important;
}

/* Clean scrollbar behaviors for internal scrolled components */
.menu-card, .sidebar-panel, .launch-card {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.menu-card::-webkit-scrollbar, 
.sidebar-panel::-webkit-scrollbar,
.launch-card::-webkit-scrollbar {
    width: 6px;
}

.menu-card::-webkit-scrollbar-thumb,
.sidebar-panel::-webkit-scrollbar-thumb,
.launch-card::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Iframe Safe Layout System */
body.iframe-mode {
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
}

body.iframe-mode #app-container,
body.iframe-mode .game-shell,
body.iframe-mode #app {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

body.iframe-mode #main-menu,
body.iframe-mode .setup-screen,
body.iframe-mode #game-screen,
body.iframe-mode .game-screen,
body.iframe-mode #launch-screen,
body.iframe-mode .launch-screen {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

body.iframe-mode .game-layout-wrapper {
    width: 100% !important;
    height: 100% !important;
    padding: 12px !important;
    box-sizing: border-box !important;
}

body.iframe-mode .sidebar-panel {
    max-height: 100% !important;
}

body.iframe-mode .launch-card {
    max-height: 95vh !important;
    max-height: 95dvh !important;
    max-width: 95% !important;
    height: auto !important;
    overflow-y: auto !important;
}



/* ==========================================================================
   11. SIMULATED FULLSCREEN MODE (CSS FALLBACK)
   ========================================================================== */
body.simulated-fullscreen-active {
    overflow: hidden !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.simulated-fullscreen-active #app-container {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    z-index: 999999 !important;
    background: radial-gradient(circle at center, #0f172a 0%, #05070d 100%) !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

body.simulated-fullscreen-active .launch-screen-overlay {
    display: none !important;
}

body.simulated-fullscreen-active #game-screen,
body.simulated-fullscreen-active #main-menu {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    padding: 12px !important;
    box-sizing: border-box !important;
}


