@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Roboto+Mono:wght@400;700&display=swap');

/* Hide scrollbar globally for all elements while maintaining scrollability */
::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}
* {
    -ms-overflow-style: none !important; /* IE and Edge */
    scrollbar-width: none !important; /* Firefox */
}

:root {
    /* Core Palette — Chess.com Warm Charcoal */
    --bg-base: #161512;
    --bg-surface: #262421;
    --bg-card: #302e2b;
    --bg-card-hover: #3d3a36;
    --bg-elevated: #48453f;
    --border: #3d3b38;
    --border-light: #5a5651;

    /* Brand Colors */
    --gold: #F5B041;
    --gold-glow: rgba(245, 176, 65, 0.4);
    --gold-dim: #D68F21;
    --emerald: #81b64c;
    --emerald-glow: rgba(129, 182, 76, 0.35);
    --silver: #BDC3C7;
    --silver-glow: rgba(189, 195, 199, 0.3);
    --red: #E74C3C;
    --red-glow: rgba(231, 76, 60, 0.35);
    --purple: #9B59B6;
    --blue: #3498DB;

    /* Text */
    --text-primary: #FFFFFF;
    --text-secondary: #b8b5b0;
    --text-muted: #8a8580;

    /* Typography */
    --font-sans: 'Outfit', sans-serif;
    --font-gaming: 'Outfit', sans-serif;
    --font-mono: 'Roboto Mono', monospace;

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
}

/* ---- Reset ---- */
*, *::before, *::after { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
}

button { 
    font-family: var(--font-sans); 
    cursor: pointer; 
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Suppress mobile tap highlight flickering */
canvas,
.board-container,
.btn-mobile-action,
.option-pill,
.btn-play-now,
.auth-tab,
.btn-auth-submit,
.btn-guest,
.btn-start-battle,
.btn-back-lobby,
.btn-to-lobby,
.btn-new-game,
.btn-action,
button,
a {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    outline: none;
}
button:active {
    transform: scale(0.92);
}
input { font-family: var(--font-sans); }

/* ==========================================================================
   Screen System — Only one screen visible at a time
   ========================================================================== */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease, transform 0.45s ease;
    transform: scale(0.97);
    z-index: 1;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    z-index: 10;
}

/* ==========================================================================
   SCREEN 1: Splash / Landing
   ========================================================================== */
.screen-splash {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 30%, #1a1400 0%, #0d0d0d 70%);
    overflow: hidden;
}

/* Floating game pieces in background */
.splash-floating {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.splash-float-piece {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-size: cover;
    opacity: 0.12;
    filter: blur(1px);
    animation: floatDrift 18s ease-in-out infinite;
}

.splash-float-piece:nth-child(1) { left: 10%; top: 20%; animation-delay: 0s; animation-duration: 22s; }
.splash-float-piece:nth-child(2) { left: 80%; top: 15%; animation-delay: -4s; animation-duration: 19s; }
.splash-float-piece:nth-child(3) { left: 25%; top: 70%; animation-delay: -8s; animation-duration: 24s; }
.splash-float-piece:nth-child(4) { left: 70%; top: 75%; animation-delay: -2s; animation-duration: 20s; }
.splash-float-piece:nth-child(5) { left: 50%; top: 45%; animation-delay: -6s; animation-duration: 26s; width: 80px; height: 80px; }
.splash-float-piece:nth-child(6) { left: 5%; top: 55%; animation-delay: -10s; animation-duration: 21s; }
.splash-float-piece:nth-child(7) { left: 90%; top: 50%; animation-delay: -3s; animation-duration: 23s; }
.splash-float-piece:nth-child(8) { left: 40%; top: 10%; animation-delay: -7s; animation-duration: 25s; }

@keyframes floatDrift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(20px, -30px) rotate(8deg); }
    50% { transform: translate(-15px, 15px) rotate(-5deg); }
    75% { transform: translate(10px, 25px) rotate(3deg); }
}

.splash-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: fadeSlideUp 1s ease-out;
}

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

.splash-logo {
    width: 140px;
    height: 140px;
    border-radius: 30px;
    box-shadow: 0 0 60px var(--gold-glow), 0 10px 40px rgba(0,0,0,0.5);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 40px var(--gold-glow), 0 10px 40px rgba(0,0,0,0.5); }
    50% { box-shadow: 0 0 80px var(--gold-glow), 0 10px 40px rgba(0,0,0,0.5); }
}

.splash-title {
    font-size: 56px;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, var(--gold) 0%, #FFF8DC 40%, var(--gold) 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    line-height: 1.1;
}

.splash-tagline {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center !important;
    max-width: 320px !important;
    margin: 0 auto !important;
    line-height: 1.5;
    display: block !important;
    width: 100%;
}

.splash-mascots {
    display: flex;
    gap: 40px;
    margin: 20px 0;
}

.splash-mascot {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    animation: mascotBob 4s ease-in-out infinite;
}

.splash-mascot:nth-child(1) { animation-delay: 0s; border-color: var(--gold-dim); }
.splash-mascot:nth-child(2) { animation-delay: -2s; border-color: var(--silver); }

@keyframes mascotBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.btn-play-now {
    margin-top: 10px;
    padding: 18px 60px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #1a1200;
    background: var(--gold);
    border: none;
    border-bottom: 5px solid var(--gold-dim);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 25px var(--gold-glow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-play-now:hover {
    background: #f7c665;
    transform: translateY(-2px);
    box-shadow: 0 10px 40px var(--gold-glow);
}

.btn-play-now:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.splash-version {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* ==========================================================================
   SCREEN 2: Auth (Login/Register)
   ========================================================================== */
.screen-auth {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 40%, #0f1a0a 0%, #0a0a0a 70%);
}

.auth-card {
    width: 420px;
    max-width: 92vw;
    background: rgba(28, 28, 28, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    animation: fadeSlideUp 0.5s ease-out;
}

.auth-logo-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.auth-logo {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.auth-logo-row h2 {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(90deg, var(--gold), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    padding: 3px;
    border: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Auth Forms */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form.hidden { display: none; }

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

.input-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.input-field {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px var(--emerald-glow);
}

.input-field::placeholder {
    color: var(--text-muted);
}

.btn-auth-submit {
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: var(--emerald);
    border: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    margin-top: 4px;
}

.btn-auth-submit:hover {
    background: #27ae60;
    box-shadow: 0 4px 15px var(--emerald-glow);
    transform: translateY(-1px);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.btn-guest {
    padding: 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--gold);
    background: rgba(212, 168, 67, 0.08);
    border: 1px solid rgba(212, 168, 67, 0.25);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-guest:hover {
    background: rgba(212, 168, 67, 0.15);
    border-color: var(--gold);
    box-shadow: 0 4px 15px var(--gold-glow);
}

/* ==========================================================================
   SCREEN 3: Main Lobby
   ========================================================================== */
.screen-lobby {
    flex-direction: column;
    background: var(--bg-base);
    overflow-y: auto;
}

/* Top Navigation Bar */
.lobby-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: linear-gradient(180deg, rgba(26, 29, 38, 0.95) 0%, rgba(18, 20, 28, 0.98) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    box-shadow: 0 4px 25px rgba(0,0,0,0.4);
    width: 100%;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.topbar-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(245, 176, 65, 0.3);
    box-shadow: 0 0 12px var(--gold-glow);
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.topbar-brand:hover .topbar-logo {
    transform: rotate(5deg) scale(1.05);
}

.topbar-title {
    font-family: var(--font-gaming);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.8px;
    background: linear-gradient(90deg, var(--gold), #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    word-break: keep-all;
    hyphens: none;
    flex-shrink: 0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Unified Player Profile Card */
.topbar-profile-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    flex-shrink: 0;
}

.topbar-profile-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(245, 176, 65, 0.35);
    box-shadow: 0 0 15px rgba(245, 176, 65, 0.12);
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--border-light);
    object-fit: cover;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.topbar-profile-card:hover .topbar-avatar {
    transform: scale(1.05);
}

.topbar-username {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    transition: color 0.2s ease;
    text-decoration: none !important;
}

.topbar-profile-card:hover .topbar-username {
    color: var(--gold-light);
}

.topbar-rating {
    font-size: 11px;
    font-weight: 700;
    color: var(--gold);
    background: rgba(245, 176, 65, 0.12);
    border: 1px solid rgba(245, 176, 65, 0.25);
    border-radius: 12px;
    padding: 2px 8px;
    letter-spacing: 0.5px;
    font-family: var(--font-gaming);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-topbar {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    font-family: var(--font-gaming);
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
}

.btn-topbar:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.btn-settings-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 16px;
    border-radius: 50%;
}

/* Lobby Body */
.lobby-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 32px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.lobby-dashboard {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 32px;
    width: 100%;
}

.lobby-main-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lobby-side-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lobby-heading {
    text-align: center;
    margin-bottom: 16px;
}

.lobby-heading h2 {
    font-family: var(--font-sans);
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.lobby-heading p {
    font-size: 14px;
    color: var(--text-muted);
}

/* Game Mode Cards - Grid Layout on Desktop */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    width: 100%;
}

.mode-card {
    background: linear-gradient(135deg, rgba(26, 29, 38, 0.75) 0%, rgba(18, 20, 28, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 16px 22px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-align: left;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.mode-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 1;
}

.mode-card:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.mode-card:hover::before { opacity: 1; }

.mode-card.card-ai::before { background: radial-gradient(circle at 10% 50%, var(--emerald-glow) 0%, transparent 60%); }
.mode-card.card-local::before { background: radial-gradient(circle at 10% 50%, var(--gold-glow) 0%, transparent 60%); }
.mode-card.card-online::before { background: radial-gradient(circle at 10% 50%, rgba(155, 89, 182, 0.2) 0%, transparent 60%); }
.mode-card.card-create-lobby::before { background: radial-gradient(circle at 10% 50%, rgba(230, 126, 34, 0.2) 0%, transparent 60%); }
.mode-card.card-join-lobby::before { background: radial-gradient(circle at 10% 50%, rgba(26, 188, 156, 0.2) 0%, transparent 60%); }
.mode-card.card-learn::before { background: radial-gradient(circle at 10% 50%, rgba(52, 152, 219, 0.2) 0%, transparent 60%); }

.mode-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    transition: all 0.35s ease;
}

.mode-icon {
    font-size: 32px;
}

.card-ai .mode-icon-wrapper {
    background: rgba(46, 204, 113, 0.08);
    border: 1px solid rgba(46, 204, 113, 0.25);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.05);
}
.card-local .mode-icon-wrapper {
    background: rgba(241, 196, 15, 0.08);
    border: 1px solid rgba(241, 196, 15, 0.25);
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.05);
}
.card-online .mode-icon-wrapper {
    background: rgba(155, 89, 182, 0.08);
    border: 1px solid rgba(155, 89, 182, 0.25);
    box-shadow: 0 0 15px rgba(155, 89, 182, 0.05);
}
.card-create-lobby .mode-icon-wrapper {
    background: rgba(230, 126, 34, 0.08);
    border: 1px solid rgba(230, 126, 34, 0.25);
    box-shadow: 0 0 15px rgba(230, 126, 34, 0.05);
}
.card-join-lobby .mode-icon-wrapper {
    background: rgba(26, 188, 156, 0.08);
    border: 1px solid rgba(26, 188, 156, 0.25);
    box-shadow: 0 0 15px rgba(26, 188, 156, 0.05);
}
.card-learn .mode-icon-wrapper {
    background: rgba(52, 152, 219, 0.08);
    border: 1px solid rgba(52, 152, 219, 0.25);
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.05);
}

.mode-card:hover .mode-icon-wrapper {
    transform: scale(1.1) rotate(5deg);
}

.card-ai:hover { border-color: rgba(46, 204, 113, 0.4); }
.card-local:hover { border-color: rgba(241, 196, 15, 0.4); }
.card-online:hover { border-color: rgba(155, 89, 182, 0.4); }
.card-create-lobby:hover { border-color: rgba(230, 126, 34, 0.4); }
.card-join-lobby:hover { border-color: rgba(26, 188, 156, 0.4); }
.card-learn:hover { border-color: rgba(52, 152, 219, 0.4); }

.mode-info-text {
    flex-grow: 1;
    z-index: 2;
}

.mode-card h3 {
    font-family: var(--font-gaming);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.mode-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

/* Hover title color per card */
.card-ai:hover h3          { color: var(--emerald); }
.card-local:hover h3       { color: var(--gold); }
.card-online:hover h3      { color: var(--purple); }
.card-create-lobby:hover h3 { color: #e67e22; }
.card-join-lobby:hover h3  { color: #1abc9c; }
.card-learn:hover h3       { color: var(--blue); }

.mode-card.card-online {
    opacity: 1;
    cursor: pointer;
}
.mode-card.card-online:hover {
    background: var(--bg-card-hover);
}

.badge-coming-soon {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--purple);
    background: rgba(155, 89, 182, 0.12);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: 20px;
    font-family: var(--font-sans);
    z-index: 3;
}

/* Sidebar Info Cards */
.profile-summary-card, .lobby-tip, .lobby-info-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.panel-title {
    font-family: var(--font-gaming);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    text-transform: uppercase;
    color: var(--text-primary);
    border-left: 3px solid var(--gold);
    padding-left: 10px;
}

/* Stats Layout */
.lobby-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.lobby-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.lobby-stat:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.lobby-stat-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-gaming);
    color: var(--gold);
    letter-spacing: 0.5px;
}

.lobby-stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Daily Tip Banner */
.lobby-tip {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(135deg, rgba(245, 176, 65, 0.04) 0%, rgba(18, 20, 28, 0.9) 100%);
    border: 1px solid rgba(245, 176, 65, 0.15);
}

.lobby-tip-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lobby-tip-icon {
    font-size: 22px;
}

.lobby-tip-title {
    font-family: var(--font-gaming);
    font-size: 16px;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lobby-tip-body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.lobby-tip-body strong { color: var(--gold); }

/* Game Info Card */
.lobby-info-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.lobby-info-mascots {
    display: flex;
    gap: -15px; /* Overlap avatars */
    justify-content: center;
    margin-bottom: 4px;
}

.info-mascot-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-surface);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.info-mascot-img:first-child {
    transform: translateX(10px);
    z-index: 2;
    border-color: rgba(245, 176, 65, 0.5);
}
.info-mascot-img:last-child {
    transform: translateX(-10px);
    z-index: 1;
    border-color: rgba(189, 195, 199, 0.5);
}

.lobby-info-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ==========================================================================
   SCREEN 4: Pre-Game Setup
   ========================================================================== */
.screen-pregame {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 60%, #171926 0%, #0b0c10 80%);
    gap: 20px;
    padding: 20px 30px;
    overflow-y: auto;
}

.pregame-heading {
    font-family: var(--font-gaming);
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-muted);
}

.pregame-title {
    font-family: var(--font-gaming);
    font-size: 38px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--gold) 0%, #fff 60%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: -10px;
    text-shadow: 0 0 20px rgba(245,176,65,0.15);
}

/* Side Selection */
.side-selection-container {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 650px;
    justify-content: center;
}

.side-selection {
    display: flex;
    gap: 0px;
    margin: 10px 0;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

.side-card {
    width: 250px;
    background: linear-gradient(135deg, rgba(26, 29, 38, 0.8) 0%, rgba(18, 20, 28, 0.95) 100%);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-align: center;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.side-card:hover {
    border-color: var(--border-light);
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}

.side-card.selected {
    transform: translateY(-8px) scale(1.03);
    z-index: 5;
}

#side-tiger.selected {
    border-color: var(--red);
    box-shadow: 0 0 35px var(--red-glow), 0 12px 40px rgba(0,0,0,0.5);
}

#side-rooster.selected {
    border-color: var(--emerald);
    box-shadow: 0 0 35px var(--emerald-glow), 0 12px 40px rgba(0,0,0,0.5);
}

.side-card.dimmed {
    opacity: 0.35;
    transform: scale(0.95);
    filter: grayscale(40%);
}

.side-mascot {
    width: 85px;
    height: 85px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-light);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    transition: all 0.4s;
}

#side-tiger.selected .side-mascot {
    border-color: var(--red);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

#side-rooster.selected .side-mascot {
    border-color: var(--emerald);
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
}

.side-card h3 {
    font-family: var(--font-gaming);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.side-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* VS Divider */
.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-gaming);
    font-size: 24px;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px dashed rgba(245, 176, 65, 0.4);
    z-index: 10;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.vs-divider span {
    z-index: 2;
}

.vs-divider::before, .vs-divider::after {
    content: '';
    position: absolute;
    background: linear-gradient(to bottom, transparent, rgba(245, 176, 65, 0.25), transparent);
    z-index: -1;
}

/* For vertical display (default desktop flex row side alignment) */
.vs-divider::before {
    width: 2px;
    height: 100px;
    top: -100px;
    left: calc(50% - 1px);
}

.vs-divider::after {
    width: 2px;
    height: 100px;
    bottom: -100px;
    left: calc(50% - 1px);
}

/* Difficulty & Timer Row */
.pregame-options {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.option-group label {
    font-family: var(--font-gaming);
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
}

.option-pills {
    display: flex;
    gap: 6px;
    background: #0f1015;
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

.option-pill {
    padding: 12px 26px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-gaming);
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.25s ease;
    cursor: pointer;
}

.option-pill:hover {
    color: var(--text-secondary);
}

.option-pill.active {
    background: var(--bg-card);
    color: var(--gold);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(245, 176, 65, 0.2);
}

/* Start Battle Button */
.btn-start-battle {
    padding: 14px 60px;
    font-size: 20px;
    font-weight: 800;
    font-family: var(--font-gaming);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #ffffff;
    background: #81b64c;
    border: none;
    border-bottom: 4px solid #5d8a32;
    border-radius: var(--radius-md);
    box-shadow: 0 6px 30px var(--emerald-glow);
    transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    margin-top: 6px;
}

.btn-start-battle:hover {
    background: #96c95f;
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(129, 182, 76, 0.4);
}

.btn-start-battle:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.btn-back-lobby {
    padding: 10px 24px;
    font-size: 16px;
    font-weight: 800;
    font-family: var(--font-gaming);
    letter-spacing: 0.5px;
    color: var(--gold);
    background: rgba(245, 176, 65, 0.12);
    border: 1.2px solid rgba(245, 176, 65, 0.5);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-back-lobby:hover {
    color: #12141c;
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 12px var(--gold-glow);
}

/* ==========================================================================
   SCREEN 5: Game Board
   ========================================================================== */
.screen-game {
    flex-direction: row;
    background: var(--bg-base);
    background-size: cover;
    background-position: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Main Board Area */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
    position: relative;
    gap: 8px;
}

/* Player Cards */
.player-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 10px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.25s ease;
}

.player-info { display: flex; align-items: center; gap: 12px; }

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 1.5px solid var(--border);
}

.player-details { display: flex; flex-direction: column; gap: 2px; }
.player-name { font-size: 19px; font-weight: 700; letter-spacing: 0.3px; }
.player-captured { font-size: 15px; color: var(--text-secondary); font-weight: 500; }

.player-timer {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 700;
    padding: 8px 14px;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.player-timer.active-turn {
    color: var(--text-primary);
    border-color: var(--emerald);
    box-shadow: 0 0 10px var(--emerald-glow);
    background: rgba(46, 204, 113, 0.08);
}

.landscape-tip-banner {
    width: 100%;
    max-width: 600px;
    background: rgba(245, 176, 65, 0.08);
    border: 1px dashed rgba(245, 176, 65, 0.25);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    text-align: center;
    color: var(--gold);
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.game-main.advanced-layout.portrait-layout .landscape-tip-banner {
    max-width: 600px;
}
.game-main.advanced-layout .landscape-tip-banner {
    max-width: 1000px;
}

/* Board Layout */
.board-wrapper {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 625px;
    align-items: stretch;
    transition: max-width 0.3s ease;
    touch-action: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}

/* Advanced board horizontal styling */
.game-main.advanced-layout .player-card,
.game-main.advanced-layout .review-bar {
    max-width: 1000px;
}
.game-main.advanced-layout .board-wrapper {
    max-width: 1020px;
}
.game-main.advanced-layout #game-board {
    max-width: 1000px;
    max-height: 560px;
}

/* Advanced board portrait (rotated 90deg) styling */
.game-main.advanced-layout.portrait-layout .player-card,
.game-main.advanced-layout.portrait-layout .review-bar {
    max-width: 600px;
}
.game-main.advanced-layout.portrait-layout .board-wrapper {
    max-width: 625px;
}
.game-main.advanced-layout.portrait-layout #game-board {
    max-width: 600px;
    max-height: 700px;
}


.eval-bar-container {
    width: 18px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
}

.eval-bar-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #596168, var(--silver));
    z-index: 0;
}

.eval-bar-value {
    background: linear-gradient(180deg, var(--gold), var(--gold-dim));
    width: 100%;
    height: 50%;
    transition: height 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    z-index: 1;
}

.eval-bar-text {
    position: absolute;
    width: 100%;
    text-align: center;
    bottom: 8px;
    font-family: var(--font-mono);
    font-size: 8px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    z-index: 2;
    pointer-events: none;
}

.board-container {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}

.board-container.board-transparent {
    background: transparent !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 0 15px rgba(255, 255, 255, 0.05) !important;
}

#game-board { 
    max-width: 600px; 
    max-height: 600px; 
    cursor: pointer; 
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}
#particle-canvas { 
    position: absolute; 
    inset: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
    z-index: 2; 
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}

/* Review Bar */
.review-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 600px;
    padding: 8px 16px;
    background: rgba(30, 58, 95, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(99, 179, 237, 0.3);
    border-radius: var(--radius-md);
    animation: fadeSlideUp 0.25s ease-out;
}

.review-btn {
    font-size: 16px;
    font-weight: 700;
    padding: 6px 14px;
    border: 1px solid rgba(99, 179, 237, 0.25);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.3);
    color: rgba(255,255,255,0.8);
    transition: all 0.15s;
    line-height: 1;
}

.review-btn:hover {
    background: rgba(99, 179, 237, 0.2);
    color: #fff;
}

.review-exit-btn {
    margin-left: 10px;
    font-size: 12px;
    padding: 6px 12px;
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.3);
    color: #f5a5a5;
}

.review-exit-btn:hover {
    background: rgba(231, 76, 60, 0.3);
    color: #fff;
}

/* Mobile Game Controls (Chess.com Style) */
.mobile-game-controls {
    display: none;
}

/* Right Sidebar */
.game-sidebar {
    width: 340px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 16px;
    overflow-y: auto;
}

.game-sidebar::-webkit-scrollbar { width: 4px; }
.game-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand img { width: 30px; height: 30px; border-radius: 6px; }
.sidebar-brand span { font-size: 16px; font-weight: 800; color: var(--gold); }

.btn-to-lobby {
    padding: 6.5px 12px;
    font-size: 11.5px;
    font-weight: 800;
    background: rgba(245, 176, 65, 0.12);
    border: 1.2px solid rgba(245, 176, 65, 0.5);
    border-radius: var(--radius-sm);
    color: var(--gold);
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-to-lobby:hover { 
    color: #12141c; 
    background: var(--gold); 
    border-color: var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
}

/* Sidebar Controls */
.ctrl-section { display: flex; flex-direction: column; gap: 10px; }

.ctrl-section h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 700;
}

.select-input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 9px 30px 9px 10px;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23707070' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.select-input:focus { border-color: var(--emerald); box-shadow: 0 0 0 2px var(--emerald-glow); }
.select-input option { background: var(--bg-base); color: var(--text-primary); }

/* Theme Selector */
.theme-selector-row { display: flex; gap: 8px; }

.theme-preview-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    cursor: pointer;
    padding: 3px;
    background: transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.theme-preview-btn span {
    display: block;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 4px;
}

.theme-preview-btn:hover { border-color: var(--border-light); transform: scale(1.08); }
.theme-preview-btn.active { border-color: var(--emerald); box-shadow: 0 0 10px var(--emerald-glow); }

/* Checkbox */
.settings-checkbox-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-checkbox-row label { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.settings-checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--emerald); cursor: pointer; }

/* Reserves */
.reserves-display {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reserves-count { font-size: 15px; font-weight: 600; color: var(--text-secondary); }

.reserves-icons { display: flex; gap: 5px; flex-wrap: wrap; }

.reserve-token {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-image: url('assets/rooster.png');
    background-size: cover;
    border: 1px solid var(--silver);
    opacity: 0.8;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s;
    cursor: pointer;
}

.reserve-token:hover { transform: scale(1.15); border-color: var(--emerald); opacity: 1; }
.reserve-token.selected { border-color: var(--emerald); box-shadow: 0 0 10px var(--emerald); transform: scale(1.2); opacity: 1; }

/* Move Log */
.move-log {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    flex-grow: 1;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    max-height: 220px;
    position: relative;
}

.move-log::-webkit-scrollbar { width: 4px; }
.move-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.move-log-placeholder {
    color: var(--text-muted);
    text-align: center;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    pointer-events: none;
    font-size: 11px;
}

.move-list { list-style-position: inside; }

.move-log-item {
    display: grid;
    grid-template-columns: 28px 1fr 1fr;
    padding: 5px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
}

.move-log-item:nth-child(even) { background: rgba(255,255,255,0.01); }
.move-index { color: var(--text-muted); font-weight: bold; }

.move-span {
    color: var(--text-primary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.move-span:hover { background: var(--bg-card-hover); }
.move-span.highlighted { background: rgba(46, 204, 113, 0.15); color: #80eaad; font-weight: bold; }

/* Move Log Badges */
.move-icon-badge {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: inline-block;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), inset 0 0.5px 1px rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
}
.tiger-badge {
    background-image: url('assets/tiger_mascot.png');
    border: 1.2px solid var(--gold, #f5b041);
    box-shadow: 0 0 4px rgba(245, 176, 65, 0.4), 0 1px 3px rgba(0, 0, 0, 0.4);
}
.rooster-badge {
    background-image: url('assets/rooster_mascot.png');
    border: 1.2px solid var(--emerald, #2ecc71);
    box-shadow: 0 0 4px rgba(46, 204, 113, 0.4), 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Move Quality Badges */
.move-quality-badge {
    display: inline-block;
    font-size: 8px;
    font-weight: 800;
    font-family: var(--font-mono);
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.2;
    margin-left: 2px;
}

.mq-brilliant { background: rgba(27, 173, 166, 0.2); color: #1bada6; border: 1px solid rgba(27, 173, 166, 0.4); }
.mq-great { background: rgba(92, 139, 176, 0.2); color: #5c8bb0; border: 1px solid rgba(92, 139, 176, 0.4); }
.mq-good { background: rgba(46, 204, 113, 0.15); color: #2ecc71; border: 1px solid rgba(46, 204, 113, 0.3); }
.mq-inaccuracy { background: rgba(230, 167, 20, 0.15); color: #e6a714; border: 1px solid rgba(230, 167, 20, 0.3); }
.mq-mistake { background: rgba(230, 143, 44, 0.15); color: #e68f2c; border: 1px solid rgba(230, 143, 44, 0.3); }
.mq-blunder { background: rgba(231, 76, 60, 0.2); color: #e74c3c; border: 1px solid rgba(231, 76, 60, 0.4); }

.move-span.quality-brilliant { border-left: 2px solid #1bada6; padding-left: 6px; }
.move-span.quality-great { border-left: 2px solid #5c8bb0; padding-left: 6px; }
.move-span.quality-inaccuracy { border-left: 2px solid #e6a714; padding-left: 6px; }
.move-span.quality-mistake { border-left: 2px solid #e68f2c; padding-left: 6px; }
.move-span.quality-blunder { border-left: 2px solid #e74c3c; padding-left: 6px; }

/* Action Buttons */
.btn-action {
    font-size: 13px;
    font-weight: 700;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.2);
    color: var(--text-secondary);
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.btn-action:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); border-color: var(--border-light); }
.btn-action:active { transform: scale(0.97); }

.btn-new-game {
    width: 100%;
    padding: 13px;
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
    background: #81b64c;
    border: none;
    border-bottom: 4px solid #5d8a32;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.btn-new-game:hover {
    background: #96c95f;
    box-shadow: 0 4px 15px var(--emerald-glow);
    transform: translateY(-1px);
}

.action-row {
    display: grid;
    grid-template-columns: 1.15fr 1.15fr 0.7fr 0.7fr 1.15fr 1.1fr;
    gap: 4px;
}

.action-row .btn-action {
    padding: 9px 2px;
    font-size: 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-sm {
    padding: 9px 6px;
    font-size: 11px;
}

.keyboard-hint {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    padding: 4px 0;
    letter-spacing: 0.3px;
}

.flex-grow { flex-grow: 1; }

/* ==========================================================================
   SCREEN 6: Game Over Overlay
   ========================================================================== */
.screen-gameover {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.screen-gameover.active {
    display: flex;
}

.gameover-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    max-width: 460px;
    width: 92%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    animation: fadeSlideUp 0.4s ease-out;
}

.gameover-icon { font-size: 56px; }

.gameover-title {
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gameover-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.gameover-rating-change {
    padding: 6px 18px;
    font-size: 14px;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--emerald);
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.25);
    border-radius: 20px;
}

.gameover-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    padding: 14px;
    background: var(--bg-base);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.go-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px;
}

.go-stat-value {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.go-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gameover-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
}

.gameover-buttons button {
    flex: 1;
    padding: 14px;
    font-size: 14px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.gameover-buttons button:hover {
    color: var(--text-primary);
    border-color: var(--border-light);
}

.gameover-buttons .btn-primary-go {
    background: var(--emerald);
    border: none;
    color: #0d0d0d;
    font-weight: 800;
}

.gameover-buttons .btn-primary-go:hover {
    background: #27ae60;
    box-shadow: 0 4px 15px var(--emerald-glow);
}

/* ==========================================================================
   Modals (Rules, Cropper)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

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

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    padding: 30px;
    position: relative;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    animation: fadeSlideUp 0.3s ease-out;
}

.btn-close-modal {
    position: absolute;
    top: 14px;
    right: 18px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-close-modal:hover { color: var(--text-primary); }

.modal-card h2 {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.modal-content {
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.modal-content::-webkit-scrollbar { width: 4px; }
.modal-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.modal-content strong { color: var(--text-primary); }
.modal-content h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-primary); margin-top: 8px; }
.modal-content ul { list-style: disc; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.modal-content code { font-family: var(--font-mono); background: var(--bg-base); padding: 2px 6px; border-radius: 4px; color: var(--gold); }

/* Cropper */
.cropper-card { max-width: 650px; }
.cropper-wrapper {
    width: 100%;
    height: 360px;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.cropper-wrapper img { max-width: 100%; display: block; }

.cropper-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1200px) {
    body { overflow-y: auto; height: auto; }

    .screen-game { flex-direction: column; position: relative; height: auto; }
    .game-sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); }
    .game-main { padding: 10px; min-height: auto; }
    .board-wrapper { max-width: 95vw; gap: 6px !important; }
    .eval-bar-container { width: 10px !important; border-radius: 2px !important; }
    .eval-bar-text { display: none !important; }

    /* Lobby Dashboard mobile */
    .lobby-dashboard { grid-template-columns: 1fr; gap: 24px; }
    .lobby-body { padding: 24px 16px; }
    .lobby-heading h2 { font-size: 24px; text-align: center; }
    .lobby-heading p { text-align: center; font-size: 13px; }
    .mode-grid { gap: 12px; }
    .mode-card { padding: 16px 20px; gap: 16px; }
    .mode-icon-wrapper { width: 54px; height: 54px; border-radius: 14px; }
    .mode-icon { font-size: 28px; }
    .mode-card h3 { font-size: 18px; }
    .mode-card p { font-size: 12px; }

    /* Lobby Topbar tablet scaling */
    .lobby-topbar { padding: 10px 18px; }
    .topbar-brand { gap: 8px; }
    .topbar-title { font-size: 18px; }
    .topbar-user { gap: 8px; }
    .topbar-profile-card { gap: 8px; padding: 3px 10px 3px 3px; }
    .topbar-avatar { width: 28px; height: 28px; }
    .topbar-username { font-size: 13px; max-width: 160px; }
    .topbar-rating { font-size: 10px; padding: 1px 6px; }
    .btn-settings-toggle { width: 30px; height: 30px; font-size: 13px; }
    .btn-topbar { padding: 5px 10px; font-size: 11.5px; }

    /* Pre-Game Setup mobile */
    .screen-pregame {
        justify-content: flex-start;
        padding-top: 40px;
        padding-bottom: 40px;
    }
    .side-selection-container { max-width: 100%; }
    .side-selection {
        flex-direction: row;
        gap: 16px;
        align-items: center;
        justify-content: center;
    }
    .side-card {
        width: 210px;
        padding: 16px 14px;
        gap: 8px;
    }
    .side-mascot {
        width: 70px;
        height: 70px;
    }
    .side-card h3 {
        font-size: 16px;
    }
    .side-card p {
        font-size: 11px;
        line-height: 1.3;
    }
    
    .vs-divider {
        margin: 0;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    .vs-divider::before {
        width: 40px;
        height: 2px;
        top: 50%;
        left: -40px;
        transform: translateY(-50%);
        display: block;
    }
    .vs-divider::after {
        width: 40px;
        height: 2px;
        top: 50%;
        right: -40px;
        left: auto;
        transform: translateY(-50%);
        display: block;
    }

    /* Mobile Game Controls */
    .mobile-game-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 10px;
        width: 100%;
        max-width: 600px;
        margin: 12px 0 6px 0;
        z-index: 5;
    }

    .btn-mobile-action {
        flex: 1;
        max-width: 64px;
        height: 48px;
        border-radius: var(--radius-md);
        background: linear-gradient(135deg, rgba(32, 38, 54, 0.95) 0%, rgba(23, 27, 38, 0.98) 100%);
        border: 1px solid var(--border);
        color: var(--text-primary);
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        cursor: pointer;
        transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .btn-mobile-action:hover {
        background: var(--bg-card-hover);
        border-color: var(--border-light);
        transform: translateY(-2px);
    }

    .btn-mobile-action:active {
        transform: scale(0.9);
    }

    .btn-rotate-board {
        background: linear-gradient(135deg, rgba(245, 176, 65, 0.15) 0%, rgba(23, 27, 38, 0.98) 100%) !important;
        border-color: rgba(245, 176, 65, 0.3) !important;
        color: var(--gold) !important;
    }
    .btn-rotate-board:hover {
        border-color: var(--gold) !important;
        box-shadow: 0 0 12px var(--gold-glow) !important;
    }

    .splash-title { font-size: 36px; }
    .splash-mascots { gap: 20px; }
    .splash-mascot { width: 80px; height: 80px; }
}

/* Pause Overlay Styles */
.pause-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

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

.pause-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 15px 45px rgba(0,0,0,0.6);
    animation: fadeSlideUp 0.3s ease-out;
}

.pause-icon {
    font-size: 40px;
    animation: pulsePause 2s infinite ease-in-out;
}

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

.pause-card h2 {
    font-size: 24px;
    font-weight: 900;
    color: var(--text-primary);
    margin: 0;
}

.btn-resume-game {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 800;
    color: #0d0d0d;
    background: var(--emerald);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-resume-game:hover {
    background: #27ae60;
    box-shadow: 0 4px 15px var(--emerald-glow);
    transform: translateY(-1px);
}

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

/* ==========================================================================
   Settings Drawer & Custom Switch Styles
   ========================================================================== */
.settings-drawer {
    position: fixed;
    top: 0;
    right: -360px;
    width: 340px;
    height: 100vh;
    background: rgba(15, 17, 24, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 2px solid var(--gold);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
    z-index: 2500;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-drawer.open {
    transform: translateX(-360px);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(23, 27, 38, 0.4);
}

.settings-header h2 {
    font-family: var(--font-gaming);
    font-size: 22px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.5px;
}

.btn-close-settings {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-close-settings:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.settings-body {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-section h3 {
    font-family: var(--font-gaming);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.setting-info label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.setting-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Custom Dropdown Select */
.select-container {
    position: relative;
    width: 100%;
}

.select-setting {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%23F5B041' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: all 0.2s ease;
    user-select: text;
    -webkit-user-select: text;
}

.select-setting:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

.select-setting option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Custom Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

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

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-light);
    transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-radius: 26px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

input:checked + .switch-slider {
    background-color: var(--emerald);
    box-shadow: 0 0 12px var(--emerald-glow);
}

input:checked + .switch-slider:before {
    transform: translateX(22px);
}

/* Rotation Effect on Settings Gear Toggle */
.btn-settings-toggle {
    transition: transform 0.3s ease, color 0.3s ease;
}

.btn-settings-toggle:hover {
    transform: rotate(45deg) scale(1.1);
    color: var(--gold) !important;
}

.btn-settings-toggle:active {
    transform: rotate(45deg) scale(0.95);
}

/* Settings Drawer Mobile Responsive Override */
@media (max-width: 600px) {
    .settings-drawer {
        width: 100%;
        right: -100%;
    }
    .settings-drawer.open {
        transform: translateX(-100%);
    }
    
    /* Game Mode Cards Stack Layout on Mobile */
    .mode-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
}

/* Firebase Google Auth Button styling */
.btn-auth-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm, 8px);
    color: var(--text-primary, #fff);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 12px;
    backdrop-filter: blur(10px);
}
.btn-auth-google:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}
.btn-auth-google:active {
    transform: translateY(0) scale(0.98);
}
.google-icon {
    display: block;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    padding: 2px;
    box-sizing: content-box;
}

/* Matchmaking Modal */
.matchmaking-card {
    text-align: center;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 380px;
}
.matchmaking-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--gold, #f5b041);
    border-radius: 50%;
    animation: matchmaking-spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    position: relative;
    box-shadow: 0 0 15px rgba(245, 176, 65, 0.25);
}
@keyframes matchmaking-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.matchmaking-details {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}
#matchmaking-timer {
    font-family: monospace;
    font-weight: bold;
    color: var(--gold, #f5b041);
}

/* ============================================================
   NEW FEATURES: TABS, CHAT, VOICE & RANDOM DRAW
   ============================================================ */

/* Sidebar Tabs */
.sidebar-tab-btn {
    transition: all 0.2s ease-in-out;
}
.sidebar-tab-btn:hover {
    color: var(--text-primary) !important;
    background: rgba(255, 255, 255, 0.05) !important;
}
.sidebar-tab-btn.active {
    background: var(--gold, #f5b041) !important;
    color: #12141c !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Random Draw Button Active State */
#btn-side-random {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#btn-side-random:hover {
    border-color: rgba(245, 176, 65, 0.5) !important;
    transform: translateY(-1px);
}
#btn-side-random.active {
    border-color: var(--gold, #f5b041) !important;
    background: linear-gradient(135deg, rgba(245, 176, 65, 0.15) 0%, rgba(18, 20, 28, 0.95) 100%) !important;
    box-shadow: 0 0 15px rgba(245, 176, 65, 0.3) !important;
}
.side-card {
    transition: all 0.3s ease;
}
.side-card.dimmed {
    opacity: 0.35;
    filter: grayscale(80%);
    pointer-events: auto; /* Allow clicking to select again */
}

/* Voice Chat Panel & Microphone Button */
.voice-panel {
    transition: all 0.3s ease;
}
#btn-mic-toggle {
    transition: all 0.2s ease;
}
#btn-mic-toggle:not(:disabled):hover {
    transform: scale(1.05);
}
#btn-mic-toggle.active {
    background: #e74c3c !important;
    border-color: #c0392b !important;
}
#btn-mic-toggle.unmuted {
    background: var(--emerald, #2ecc71) !important;
    border-color: #27ae60 !important;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.4);
}

/* Chat Messages */
.chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: fadeSlideUp 0.2s ease-out;
}
.chat-msg .msg-sender {
    font-size: 10px;
    font-weight: 700;
    color: var(--gold, #f5b041);
}
.chat-msg .msg-text {
    color: var(--text-primary, #ffffff);
}
.chat-msg .msg-time {
    font-size: 9px;
    color: var(--text-muted, rgba(255,255,255,0.4));
    align-self: flex-end;
}
.chat-msg.msg-me {
    align-self: flex-end;
    background: rgba(245, 176, 65, 0.12);
    border: 1px solid rgba(245, 176, 65, 0.25);
    border-bottom-right-radius: 2px;
}
.chat-msg.msg-them {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 2px;
}
.chat-msg.msg-system {
    align-self: center;
    max-width: 95%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-style: italic;
    font-size: 11px;
    text-align: center;
    border-radius: 6px;
    padding: 6px 10px;
}

/* Custom Lobby CSS styling */
.screen-waiting-lobby {
    background: var(--bg-base);
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 10;
}

.lobby-waiting-card {
    background: rgba(20, 22, 30, 0.95);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 36px 40px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-xl), 0 0 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 24px;
    text-align: center;
}

.waiting-title {
    font-family: var(--font-gaming);
    font-size: 26px;
    background: linear-gradient(135deg, var(--gold) 0%, #fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.waiting-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: -12px;
}

.room-code-container {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room-code-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.room-code-display-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.room-code-value {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(245, 176, 65, 0.4);
}

.btn-copy-code {
    background: rgba(245, 176, 65, 0.1);
    border: 1px solid var(--gold);
    color: var(--gold);
    font-size: 13px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy-code:hover {
    background: var(--gold);
    color: #000;
    box-shadow: 0 0 10px rgba(245, 176, 65, 0.4);
}

.lobby-setup-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.setup-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-light);
}

.lobby-players-status {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.player-status-row {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 18px;
    gap: 14px;
    transition: all 0.25s;
}

.player-status-row.waiting-guest {
    border-style: dashed;
    background: rgba(0, 0, 0, 0.15);
}

.player-avatar-mini {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.player-name-mini {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    text-align: left;
    color: var(--text-light);
}

.player-role-badge {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
}

.player-role-badge.host {
    background: rgba(245, 176, 65, 0.15);
    color: var(--gold);
}

.player-role-badge.guest {
    background: rgba(46, 204, 113, 0.15);
    color: var(--emerald);
}

.pulse-text {
    animation: waitingPulse 1.8s infinite ease-in-out;
}

@keyframes waitingPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; color: var(--emerald); }
}

.btn-cancel-lobby {
    background: rgba(231, 76, 60, 0.1);
    border: 1.5px solid var(--red);
    color: var(--red);
    font-size: 14px;
    font-weight: 700;
    padding: 12px;
    width: 100%;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel-lobby:hover {
    background: var(--red);
    color: #fff;
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.4);
}

#btn-start-waiting-lobby {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    border: 2px solid #34d399 !important;
    border-radius: var(--radius-md) !important;
    font-weight: 800 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    cursor: pointer;
    animation: emerald-pulse 2s infinite ease-in-out;
}

#btn-start-waiting-lobby:hover {
    transform: translateY(-2px) scale(1.03) !important;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.7) !important;
    border-color: #6ee7b7 !important;
}

#btn-start-waiting-lobby:active {
    transform: translateY(1px) scale(0.98) !important;
}

.join-lobby-card {
    max-width: 380px !important;
    padding: 32px 28px !important;
    text-align: center;
}

@media (max-width: 480px) {
    .lobby-topbar {
        padding: 8px 10px;
    }
    .topbar-brand {
        gap: 6px;
    }
    .topbar-logo {
        width: 28px;
        height: 28px;
    }
    .topbar-title {
        display: none; /* Hide brand text on mobile viewports to prevent layout overflow */
    }
    .topbar-user {
        gap: 6px;
    }
    .topbar-profile-card {
        gap: 6px;
        padding: 2px 8px 2px 2px;
    }
    .topbar-avatar {
        width: 26px;
        height: 26px;
    }
    .topbar-username {
        font-size: 11.5px;
        max-width: 140px;
    }
    .topbar-rating {
        font-size: 9.5px;
        padding: 1px 5px;
    }
    .btn-settings-toggle {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    /* Hide the topbar logout button on mobile - fully accessible inside Settings Drawer */
    .lobby-topbar #btn-logout {
        display: none;
    }
}

/* Pregame Setup Compact Layout for Mobile */
@media (max-width: 600px) {
    .screen-pregame {
        padding-top: 15px;
        padding-bottom: 15px;
        justify-content: flex-start;
        overflow-y: auto;
    }
    .pregame-heading {
        font-size: 12px !important;
        margin-bottom: 2px !important;
    }
    .pregame-title {
        font-size: 20px !important;
        margin-bottom: 8px !important;
    }
    .side-selection-container {
        gap: 8px !important;
        max-width: 340px !important;
        margin: 0 auto !important;
    }
    .side-selection {
        flex-direction: row !important;
        justify-content: center !important;
        gap: 8px !important;
        margin: 4px 0 !important;
    }
    .side-card {
        width: 125px !important;
        padding: 10px 8px !important;
        gap: 6px !important;
        border-radius: 12px !important;
        transform: none !important;
    }
    .side-card.selected {
        transform: scale(1.04) !important;
    }
    .side-card:hover {
        transform: scale(1.02) !important;
    }
    .side-mascot {
        width: 48px !important;
        height: 48px !important;
    }
    .side-card h3 {
        font-size: 12.5px !important;
        margin: 0 !important;
        white-space: nowrap;
    }
    .side-card p {
        display: none !important; /* Hide descriptions on mobile to save vertical space */
    }
    .vs-divider {
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
        margin: 0 !important;
    }
    .vs-divider::before,
    .vs-divider::after {
        display: none !important; /* Hide line borders on mobile */
    }
    #btn-side-random {
        padding: 10px !important;
        font-size: 12.5px !important;
        max-width: 260px !important;
        margin-top: 4px !important;
    }
    .pregame-options {
        gap: 12px !important;
        margin-top: 10px !important;
        margin-bottom: 16px !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    .option-group {
        gap: 4px !important;
    }
    .option-group label {
        font-size: 10.5px !important;
        letter-spacing: 1px !important;
    }
    .option-pills {
        gap: 4px !important;
    }
    .option-pill {
        padding: 6px 12px !important;
        font-size: 11px !important;
        min-width: 75px !important;
    }
    .btn-start-battle {
        padding: 10px 32px !important;
        font-size: 16px !important;
        width: 100% !important;
        max-width: 260px !important;
        letter-spacing: 1px !important;
        border-bottom-width: 3px !important;
        margin-top: 4px !important;
    }
    .btn-back-lobby {
        padding: 8px 20px !important;
        font-size: 12px !important;
        margin-top: 6px !important;
    }
}


/* ==========================================================================
   ZEN MODE — Maximize Board View
   ========================================================================== */

/* Zen toggle button styling */
.btn-zen-toggle {
    position: relative;
}
.btn-zen-toggle.zen-active {
    background: linear-gradient(135deg, rgba(245, 176, 65, 0.25) 0%, rgba(23, 27, 38, 0.98) 100%) !important;
    border-color: var(--gold) !important;
    color: var(--gold) !important;
    box-shadow: 0 0 14px var(--gold-glow) !important;
}

/* ---- Hide everything except board + controls ---- */
.screen-game.zen-mode .eval-bar-container,
.screen-game.zen-mode .game-sidebar,
.screen-game.zen-mode .review-bar,
.screen-game.zen-mode .landscape-tip-banner,
.screen-game.zen-mode #btn-mobile-sound,
.screen-game.zen-mode #btn-mobile-settings {
    display: none !important;
}

/* ---- Sleek floating HUD timers in zen mode ---- */
.screen-game.zen-mode #player-opponent {
    display: flex !important;
    position: fixed !important;
    top: 80px !important;
    right: calc(50% + 6px) !important;
    left: auto !important;
    z-index: 20000 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: auto !important;
    max-width: 45% !important;
    padding: 0 !important;
}

.screen-game.zen-mode #player-user {
    display: flex !important;
    position: fixed !important;
    top: 80px !important;
    left: calc(50% + 6px) !important;
    right: auto !important;
    z-index: 20000 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: auto !important;
    max-width: 45% !important;
    padding: 0 !important;
}

.screen-game.zen-mode .player-card .player-info {
    display: none !important;
}

.screen-game.zen-mode .player-card .player-timer {
    font-size: 14px !important;
    padding: 6px 10px !important;
    background: rgba(10, 12, 18, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: var(--radius-sm) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    color: var(--text-secondary) !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.screen-game.zen-mode #player-opponent .player-timer::before {
    content: "Opponent Timer: " !important;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.screen-game.zen-mode #player-user .player-timer::before {
    content: "User Timer: " !important;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.screen-game.zen-mode .player-card .player-timer.active-turn {
    border-color: var(--emerald) !important;
    box-shadow: 0 0 12px var(--emerald-glow), 0 4px 12px rgba(0,0,0,0.5) !important;
    background: rgba(46, 204, 113, 0.2) !important;
    color: var(--text-primary) !important;
}

/* ---- Game Main fills entire viewport ---- */
.screen-game.zen-mode .game-main {
    padding: 0 !important;
    gap: 0 !important;
    justify-content: center !important;
    align-items: center !important;
    height: 100vh !important;
    min-height: 100vh !important;
    width: 100vw !important;
    background: #0a0c12;
    overflow: hidden !important;
    position: relative !important;
}

/* ---- Board wrapper fills available space ---- */
.screen-game.zen-mode .board-wrapper {
    max-width: none !important;
    width: auto !important;
    flex: 1;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    overflow: hidden;
    padding: 8px;
    margin-top: 96px !important;
    height: calc(100vh - 96px) !important;
}

/* ---- Board container fills the wrapper ---- */
.screen-game.zen-mode .board-container {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    max-height: none !important;
    max-width: none !important;
}

/* ---- Canvas uses full space ---- */
.screen-game.zen-mode #game-board {
    max-width: none !important;
    max-height: none !important;
}

/* ---- Controls bar floating at top — always visible in zen ---- */
.screen-game.zen-mode .mobile-game-controls {
    display: flex !important; /* Show even on desktop */
    position: fixed;
    top: 12px;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    margin: 0 !important;
    padding: 8px 16px !important;
    max-width: 520px !important;
    width: 90% !important;
    gap: 12px !important;
    background: linear-gradient(135deg, rgba(20, 24, 35, 0.95) 0%, rgba(14, 17, 26, 0.98) 100%) !important;
    z-index: 20000 !important;
    justify-content: center !important;
    align-items: center !important;
    border-radius: 18px;
    border: 1.5px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Bigger buttons in zen mode for clear visibility */
.screen-game.zen-mode .btn-mobile-action {
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    min-width: 48px !important;
    max-width: 80px !important;
    height: 48px !important;
    font-size: 20px !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: var(--text-primary) !important;
    z-index: 20001 !important;
    opacity: 1 !important;
    visibility: visible !important;
    margin: 0 !important;
    flex: 1 !important;
    transition: all 0.2s ease;
}

.screen-game.zen-mode .btn-mobile-action:hover,
.screen-game.zen-mode .btn-mobile-action:active {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: var(--gold) !important;
    transform: scale(1.08) !important;
}

/* Force body and screen-game scroll lock in Zen mode */
body.zen-mode-active {
    overflow: hidden !important;
    height: 100vh !important;
    min-height: 100vh !important;
    width: 100vw !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
}

.screen-game.zen-mode {
    height: 100vh !important;
    min-height: 100vh !important;
    overflow: hidden !important;
    flex-direction: column !important;
    position: relative !important;
}

/* ==========================================================================
   SWIPE BACK INDICATOR
   ========================================================================== */
.swipe-back-indicator {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateX(-100%) translateY(-50%);
    width: 40px;
    height: 80px;
    background: linear-gradient(135deg, rgba(245, 176, 65, 0.3) 0%, rgba(245, 176, 65, 0.1) 100%);
    border-radius: 0 20px 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.2s ease;
    pointer-events: none;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(245, 176, 65, 0.2);
    border-left: none;
}

.swipe-back-indicator.visible {
    opacity: 0.6;
}

.swipe-back-indicator.ready {
    background: linear-gradient(135deg, rgba(245, 176, 65, 0.6) 0%, rgba(245, 176, 65, 0.3) 100%);
    opacity: 1 !important;
    border-color: rgba(245, 176, 65, 0.5);
    box-shadow: 0 0 20px rgba(245, 176, 65, 0.3);
}

.swipe-back-arrow {
    font-size: 28px;
    font-weight: 700;
    color: var(--gold, #f5b041);
    text-shadow: 0 0 8px rgba(245, 176, 65, 0.5);
    line-height: 1;
}

/* ==========================================================================
   NAVIGATION BACK BUTTON
   ========================================================================== */
.btn-nav-back {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(32, 38, 54, 0.9) 0%, rgba(23, 27, 38, 0.95) 100%);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    line-height: 1;
    padding: 0;
}

.btn-nav-back:hover {
    background: var(--bg-card-hover);
    border-color: var(--gold);
    color: var(--gold);
    transform: translateX(-2px);
}

.btn-nav-back:active {
    transform: scale(0.9);
}

/* ==========================================================================
   CUSTOM CONFIRMATION DIALOG
   ========================================================================== */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 20px;
}

.dialog-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.dialog-card {
    background: linear-gradient(135deg, rgba(26, 30, 42, 0.98) 0%, rgba(18, 21, 32, 0.99) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 32px 28px 24px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dialog-overlay.active .dialog-card {
    transform: scale(1) translateY(0);
}

.dialog-icon {
    font-size: 48px;
    margin-bottom: 12px;
    line-height: 1;
}

.dialog-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    letter-spacing: 0.3px;
}

.dialog-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 24px 0;
    line-height: 1.6;
}

.dialog-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.dialog-btn {
    flex: 1;
    padding: 14px 20px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
}

.dialog-btn-cancel {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.dialog-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.dialog-btn-confirm {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.8) 0%, rgba(192, 57, 43, 0.9) 100%);
    color: #fff;
    border: 1px solid rgba(231, 76, 60, 0.3);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.2);
}

.dialog-btn-confirm:hover {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.95) 0%, rgba(192, 57, 43, 1) 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.3);
}

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

/* ==========================================================================
   Enhancements: Zen Mode, Premium Buttons, Tutorial Slides & Modal Targets
   ========================================================================== */

/* 2. Premium Buttons Highlights */
#btn-play-now {
    position: relative;
    overflow: hidden;
    background: var(--gold) !important;
    border: none !important;
    border-bottom: 5px solid var(--gold-dim) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 6px 25px var(--gold-glow) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    cursor: pointer;
    z-index: 1;
    animation: gold-pulse 2s infinite ease-in-out;
}

#btn-start-battle,
#btn-submit-join-lobby {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f5b041 0%, #d48c27 100%) !important;
    border: 2px solid #f8c471 !important;
    border-radius: 14px !important;
    font-weight: 800 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(245, 176, 65, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    cursor: pointer;
    z-index: 1;
    animation: gold-pulse 2s infinite ease-in-out;
}

#btn-join-room {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    border: 2px solid #34d399 !important;
    border-radius: 14px !important;
    font-weight: 800 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    cursor: pointer;
    z-index: 1;
    animation: emerald-pulse 2s infinite ease-in-out;
}

#btn-play-now::before,
#btn-start-battle::before,
#btn-submit-join-lobby::before,
#btn-join-room::before {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    transition: 0.75s;
    pointer-events: none;
    z-index: 2;
}

#btn-play-now:hover::before,
#btn-start-battle:hover::before,
#btn-submit-join-lobby:hover::before,
#btn-join-room:hover::before {
    left: 125%;
    transition: 0.75s ease-in-out;
}

@keyframes emerald-pulse {
    0% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3); }
    50% { box-shadow: 0 0 25px rgba(16, 185, 129, 0.75), inset 0 1px 1px rgba(255, 255, 255, 0.4); }
    100% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3); }
}

@keyframes gold-pulse {
    0% { box-shadow: 0 0 10px rgba(245, 176, 65, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3); }
    50% { box-shadow: 0 0 25px rgba(245, 176, 65, 0.75), inset 0 1px 1px rgba(255, 255, 255, 0.4); }
    100% { box-shadow: 0 0 10px rgba(245, 176, 65, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3); }
}

#btn-play-now:hover,
#btn-join-room:hover {
    transform: translateY(-2px) scale(1.03) !important;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.7) !important;
    border-color: #6ee7b7 !important;
}

#btn-start-battle:hover,
#btn-submit-join-lobby:hover {
    transform: translateY(-2px) scale(1.03) !important;
    box-shadow: 0 8px 25px rgba(245, 176, 65, 0.7) !important;
    border-color: #fce4b3 !important;
}

#btn-play-now:active,
#btn-start-battle:active,
#btn-submit-join-lobby:active,
#btn-join-room:active {
    transform: translateY(1px) scale(0.98) !important;
}

/* 3. Interactive Tutorial Slides & Mini Diagrams */
.rules-card {
    max-width: 680px !important;
    width: 95% !important;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rules-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.tutorial-slides-container {
    position: relative;
    min-height: 380px;
}

.tutorial-slide {
    display: none;
    flex-direction: column;
    gap: 16px;
    animation: fadeIn 0.3s ease;
}

.tutorial-slide.active {
    display: flex;
}

.tutorial-slide-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
    border-bottom: 1.5px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.tutorial-mascots-intro {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 15px 0;
}

.tutorial-mascot-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: transform 0.2s;
}

.tutorial-mascot-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.05);
}

.tutorial-mascot-img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    margin-bottom: 10px;
}

.tutorial-mascot-card h4 {
    margin-bottom: 6px;
    font-size: 16px;
}

.tutorial-intro-text {
    line-height: 1.6;
    color: var(--text-secondary);
    text-align: center;
}

.tutorial-flex-row {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.tutorial-sub-section {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.tutorial-sub-section h4 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-align: center;
}

.tutorial-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 12px 0;
}

.board-mini-grid {
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mini-row {
    display: flex;
    gap: 12px;
    z-index: 2;
}

.mini-node {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
}

.mini-node.tiger {
    background: rgba(245, 176, 65, 0.15);
    border: 1.5px solid var(--gold);
}

.mini-node.tiger.trapped {
    background: rgba(231, 76, 60, 0.15);
    border: 1.5px solid var(--red);
}

.mini-node.rooster {
    background: rgba(16, 185, 129, 0.15);
    border: 1.5px solid var(--emerald);
}

.mini-node.rooster-stack {
    background: rgba(16, 185, 129, 0.2);
    border: 1.5px solid var(--emerald);
}

.stack-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--emerald);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-node.target-spot {
    border: 1.5px dashed var(--gold);
    color: var(--gold);
    font-weight: 700;
}

.mini-node.highlighted-spot {
    border: 1.5px dashed var(--emerald);
    background: rgba(16, 185, 129, 0.08);
}

.mini-node.captured-rooster {
    background: rgba(231, 76, 60, 0.2);
    border: 1.5px solid var(--red);
}

.mini-path {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    z-index: 1;
}

.mini-path.vertical {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
}

.mini-path.horizontal {
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
}

.mini-path.horizontal-long {
    left: 16px;
    right: 16px;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
}

.diagram-arrow {
    font-size: 20px;
    color: var(--text-secondary);
}

.win-conditions-container {
    display: flex;
    gap: 16px;
    margin-top: 10px;
}

.win-card {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.win-card.tiger-win {
    background: rgba(245, 176, 65, 0.04);
}

.win-card.tiger-win h4 {
    color: var(--gold);
    margin-bottom: 8px;
}

.win-card.rooster-win {
    background: rgba(16, 185, 129, 0.04);
}

.win-card.rooster-win h4 {
    color: var(--emerald);
    margin-bottom: 8px;
}

.win-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tutorial-concluding-note {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

.tutorial-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1.5px solid var(--border);
}

.btn-tutorial-prev,
.btn-tutorial-next {
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--border);
    border: 1px solid transparent;
    color: var(--text-primary);
}

.btn-tutorial-prev:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-tutorial-next {
    background: var(--gold);
    color: #12141c;
}

.btn-tutorial-next:hover:not(:disabled) {
    box-shadow: 0 0 10px var(--gold-glow);
}

.tutorial-dots {
    display: flex;
    gap: 8px;
}

.tutorial-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: background 0.2s;
}

.tutorial-dot.active {
    background: var(--gold);
}

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

/* 4. Touch Target Sizes for Close/X Buttons & Settings Icon scaling */
.btn-close-modal,
.btn-close-settings {
    width: 44px !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 24px !important;
    color: var(--text-secondary) !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    padding: 0 !important;
}

.btn-close-modal {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
}

.btn-close-modal:hover,
.btn-close-settings:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: var(--gold) !important;
    border-color: rgba(245, 176, 65, 0.4) !important;
    box-shadow: 0 0 10px rgba(245, 176, 65, 0.2) !important;
}

/* Settings Toggle button */
.btn-settings-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 42px !important;
    height: 42px !important;
    font-size: 20px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
}

@media (max-width: 1200px) {
    .btn-settings-toggle {
        width: 38px !important;
        height: 38px !important;
        font-size: 18px !important;
    }
}

@media (max-width: 600px) {
    .btn-settings-toggle {
        width: 36px !important;
        height: 36px !important;
        font-size: 16px !important;
    }
    .tutorial-flex-row {
        flex-direction: column;
        gap: 12px;
    }
    .win-conditions-container {
        flex-direction: column;
    }
}

/* ==========================================================================
   PWA Install Banner (Chess.com Style)
   ========================================================================== */
.pwa-install-banner {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 480px;
    background: rgba(48, 46, 43, 0.95);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    z-index: 100;
    backdrop-filter: blur(12px);
    display: none; /* Controlled via JS */
    animation: pwaSlideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pwaSlideUp {
    from { transform: translate(-50%, 60px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pwa-app-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1.5px solid var(--gold);
    box-shadow: 0 0 15px var(--gold-glow);
}

.pwa-text-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.pwa-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.pwa-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
}

.btn-pwa-install {
    background: var(--emerald);
    color: var(--text-primary);
    border: 1px solid #6c9e3b;
    border-bottom: 3px solid #557e2d;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    box-shadow: 0 0 12px var(--emerald-glow);
}

.btn-pwa-install:hover {
    background: #8ec359;
    transform: translateY(-1px);
}

.btn-pwa-install:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
}



