/* style.css - Modern Arcade UI: readable typography, glassmorphic panels,
   vibrant gradients, soft elevation. Mobile-first. */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
    /* Brand accent colors — vivid but balanced against a dark glass surface */
    --c-primary: #34d399;
    --c-primary-dark: #059669;
    --c-gold: #fbbf24;
    --c-gold-dark: #d97706;
    --c-danger: #fb7185;
    --c-danger-dark: #e11d48;
    --c-purple: #a78bfa;
    --c-purple-dark: #7c3aed;
    --c-cyan: #22d3ee;
    --c-cyan-dark: #0891b2;
    --c-pink: #f472b6;
    --c-blue: #60a5fa;
    --c-blue-dark: #2563eb;

    /* Surfaces */
    --bg-1: #0f0e2e;
    --bg-2: #211d4f;
    --bg-3: #1a1440;
    --surface: rgba(30, 27, 66, 0.55);
    --surface-solid: #211d4a;
    --surface-2: rgba(15, 15, 35, 0.6);
    --border-soft: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.20);

    /* Text */
    --text-1: #f8fafc;
    --text-2: #cbd5e1;
    --text-3: #94a3b8;

    /* Fonts */
    --font-display: 'Baloo 2', 'Nunito', sans-serif;
    --font-body: 'Nunito', sans-serif;

    /* Radii & elevation */
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 22px;
    --r-full: 999px;
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.28);
    --shadow-md: 0 10px 26px rgba(0,0,0,0.38);
    --shadow-lg: 0 18px 46px rgba(0,0,0,0.5);
    --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-snap: cubic-bezier(0.2, 0.8, 0.2, 1);

    /* Back-compat aliases: several inline styles in index.php/admin.php/
       spectator.js reference these older var names directly. Point them at
       the new palette so those inline colors stay correct without having to
       touch every occurrence. */
    --mc-grass-light: var(--c-primary);
    --mc-grass-dark: var(--c-primary-dark);
    --mc-gold: var(--c-gold);
    --mc-diamond: var(--c-cyan);
    --mc-redstone: var(--c-danger);
    --mc-purple: var(--c-purple);
    --mc-pink: var(--c-pink);
}

/* Responsive typography: scale the ROOT font-size with the viewport so every
   rem-based size site-wide follows one curve. Floor raised from the old
   13px/0.55rem-heavy scale so small labels stay legible on phones. */
html {
    font-size: clamp(15px, 1vw + 10px, 19px);
}

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

html, body {
    touch-action: none;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    overflow-y: hidden;
}

body {
    font-family: var(--font-body);
    font-weight: 600;
    background:
        radial-gradient(circle at 15% 8%, rgba(52, 211, 153, 0.16) 0%, transparent 45%),
        radial-gradient(circle at 85% 12%, rgba(167, 139, 250, 0.20) 0%, transparent 42%),
        radial-gradient(circle at 50% 100%, rgba(34, 211, 238, 0.14) 0%, transparent 55%),
        linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
    height: 100dvh;
    color: var(--text-1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Ambient floating background glows — replaces the old flat scrolling
   "pixel cloud" strip with soft drifting light blobs for depth. */
.clouds-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.clouds-bg::before,
.clouds-bg::after {
    content: '';
    position: absolute;
    width: 46vw;
    height: 46vw;
    max-width: 520px;
    max-height: 520px;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.35;
    animation: driftGlow 22s ease-in-out infinite alternate;
}

.clouds-bg::before {
    top: -10%;
    left: -8%;
    background: radial-gradient(circle, var(--c-cyan) 0%, transparent 70%);
}

.clouds-bg::after {
    bottom: -14%;
    right: -8%;
    background: radial-gradient(circle, var(--c-purple) 0%, transparent 70%);
    animation-delay: -8s;
    animation-duration: 26s;
}

@keyframes driftGlow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(4vw, 3vh) scale(1.12); }
}

/* Main Container */
#app-container {
    width: 100%;
    max-width: 1400px;
    height: 100dvh;
    margin: 0 auto;
    padding: clamp(8px, 1.2vw, 18px);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 1.1vh, 16px);
    overflow: hidden;
}

.view-fullscreen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    z-index: 40;
    backdrop-filter: none;
}

/* Header & Banner */
header {
    width: 100%;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(10px, 1.4vh, 14px) clamp(14px, 2vw, 22px);
    background: linear-gradient(135deg, rgba(33, 29, 79, 0.85), rgba(15, 14, 46, 0.85));
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(14px);
}

body.fullscreen-active header {
    display: none;
}

.brand-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-1);
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-title span {
    background: linear-gradient(90deg, var(--c-cyan), var(--c-purple));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.user-quick-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-pill {
    background: linear-gradient(135deg, rgba(167,139,250,0.28), rgba(124,58,237,0.28));
    padding: 6px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-full);
    color: var(--text-1);
    font-weight: 800;
    font-size: 0.8rem;
    box-shadow: var(--shadow-sm);
}

/* Buttons: soft rounded, gradient fill, tactile press */
.btn-mc {
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    padding: 14px 20px;
    color: #fff;
    background: linear-gradient(180deg, #64748b, #475569);
    border: none;
    border-radius: var(--r-md);
    box-shadow: 0 4px 0 rgba(0,0,0,0.28), var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.12s var(--ease-snap), box-shadow 0.12s var(--ease-snap), filter 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
    touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
    .btn-mc:hover {
        transform: translateY(-2px);
        filter: brightness(1.08);
        box-shadow: 0 6px 0 rgba(0,0,0,0.28), var(--shadow-md);
    }
}

.btn-mc:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 1px 0 rgba(0,0,0,0.28);
    filter: brightness(1.05);
}

.btn-mc-primary {
    background: linear-gradient(180deg, #4ade80, var(--c-primary-dark));
}

.btn-mc-gold {
    background: linear-gradient(180deg, var(--c-gold), var(--c-gold-dark));
    color: #1c1400;
}

.btn-mc-purple {
    background: linear-gradient(180deg, var(--c-purple), var(--c-purple-dark));
}

.btn-mc-danger {
    background: linear-gradient(180deg, var(--c-danger), var(--c-danger-dark));
}

/* Views & Screens */
.view-panel {
    width: 100%;
    flex: 1;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: clamp(12px, 2vh, 24px);
    display: none;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(16px);
    overflow-y: auto;
}

.view-panel.active {
    display: flex;
}

/* Auth / Login Box */
.auth-box {
    width: 100%;
    max-width: 440px;
    margin: auto;
    background: linear-gradient(180deg, rgba(51,46,110,0.7), rgba(20,18,48,0.7));
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    padding: 28px;
    text-align: center;
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--border-soft);
    background: rgba(0,0,0,0.2);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-3);
    transition: background 0.2s ease, color 0.2s ease;
}

.auth-tab.active {
    background: linear-gradient(180deg, var(--c-primary), var(--c-primary-dark));
    color: #fff;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--c-gold);
    letter-spacing: 0.02em;
}

/* Icon-based auth screen: a big wordmark icon up top, and inputs identified
   by a small icon rather than a text label — keeps the login screen mostly
   icon, minimal text. */
.auth-logo {
    font-size: 2.6rem;
    line-height: 1;
    margin-bottom: 10px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.input-icon-group {
    position: relative;
    margin-bottom: 12px;
}

.input-icon-group .mc-input {
    padding-left: 42px;
}

.input-icon-group .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    pointer-events: none;
    opacity: 0.85;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-3);
    text-transform: uppercase;
}

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

.mc-input {
    width: 100%;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 14px;
    background: rgba(0,0,0,0.35);
    border: 2px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text-1);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mc-input::placeholder {
    color: var(--text-3);
    font-weight: 600;
}

.mc-input:focus {
    border-color: var(--c-cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.22);
}

/* -------------------------------------------------------------
   Dashboard Play/Profile tabs — splits what used to be one long
   5-card stacked column into two short screens, so neither needs
   scrolling to see everything on it.
   ------------------------------------------------------------- */
.dashboard-tabs {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.dashboard-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: var(--r-md);
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-soft);
    color: var(--text-3);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.dashboard-tab.active {
    background: linear-gradient(180deg, var(--c-primary), var(--c-primary-dark));
    color: #fff;
    border-color: transparent;
}

.dashboard-tab-panel {
    display: none;
    flex-direction: column;
    width: 100%;
    min-height: 0;
}

.dashboard-tab-panel.active {
    display: flex;
    flex: 1;
}

/* Open Rooms card grows to fill whatever's left below the mode-select grid
   (instead of guessing a fixed height) — generous on a tall screen, and its
   list still scrolls internally on its own if a short screen leaves it little
   room, rather than the whole dashboard needing to scroll. */
.open-rooms-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Dashboard Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

/* Tighter card chrome for the dashboard specifically — the gameplay/modal
   cards keep the roomier default .card-mc padding, but the dashboard packs
   several cards on one screen and needs to fit without scrolling. */
.card-compact {
    padding: 10px 12px;
    gap: 6px;
}

.card-compact .card-title {
    padding-bottom: 4px;
    font-size: 0.88rem;
}

/* Compact button variant for dense dashboard button stacks — still a
   comfortable touch target (~38px, above the 36px accessibility floor),
   just shorter than the roomy 50px default used for gameplay/modal buttons. */
.btn-compact {
    min-height: 38px;
    padding: 7px 14px;
    font-size: 0.74rem;
    gap: 6px;
}

/* Small square icon buttons (header mute/leaderboard, card refresh) */
.icon-btn {
    padding: 6px 12px;
    min-height: 36px;
}

/* Two-per-row, icon-led game list (replaces the old two-card grid) — a big
   icon on the left carries the identity, a short label does the rest, so
   the whole Play tab reads at a glance instead of needing full sentences
   per mode. */
.game-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
}

.game-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    min-height: 44px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-soft);
    border-left-width: 4px;
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    text-align: left;
    color: inherit;
    font-family: inherit;
    transition: transform 0.12s ease, background 0.15s ease;
    overflow: hidden;
}

.game-row:active {
    transform: scale(0.98);
    background: rgba(255,255,255,0.09);
}

.game-row-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.game-row-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-1);
    letter-spacing: 0.01em;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.game-row-tag {
    flex-shrink: 0;
    font-size: 0.5rem;
    font-weight: 700;
    color: var(--text-3);
    white-space: nowrap;
}

@media (max-width: 420px) {
    .game-row-label { font-size: 0.68rem; }
    .game-row-icon { font-size: 1.3rem; width: 24px; }
}

.game-row.accent-balloon { border-left-color: var(--c-primary); }
.game-row.accent-duel { border-left-color: var(--c-gold); }
.game-row.accent-marathon { border-left-color: var(--c-purple); }
.game-row.accent-fpv-ffa { border-left-color: var(--c-danger); }
.game-row.accent-fpv-team { border-left-color: var(--c-cyan); }
.game-row.accent-typing { border-left-color: #a78bfa; }

.pin-join-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.pin-join-row .mc-input {
    flex: 1;
    text-align: center;
    padding: 9px;
}

.icon-btn-sm {
    font-size: 0.75rem;
    padding: 4px 10px;
    min-height: 30px;
}

/* Player Card: XP is the "hero" stat shown full-width above the progress
   bar; everything else packs into a dense chip grid below instead of a
   tall stacked list of full-width rows. */
.stat-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-2);
}

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

.stat-chip {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    padding: 5px 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.stat-label {
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--text-3);
    letter-spacing: 0.02em;
}

.stat-value {
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-banner {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
}

/* Open rooms list: capped height with its own internal scroll — this is a
   dynamic, potentially-long live list, not static page content, so it gets
   to scroll on its own without the dashboard screen itself needing to. */
.open-rooms-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    align-content: start;
    gap: 8px;
    margin-top: 6px;
    flex: 1;
    min-height: 34px;
    overflow-y: auto;
}

.card-mc {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(10px);
}

.card-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-1);
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-2);
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.stat-flash {
    animation: mcStatFlash 1.1s ease infinite;
    font-weight: 900;
}

@keyframes mcStatFlash {
    0%, 100% { color: var(--c-primary); text-shadow: none; transform: scale(1); }
    50% { color: var(--c-gold); text-shadow: 0 0 12px rgba(251,191,36,0.85); transform: scale(1.12); }
}

.level-progress-bar {
    width: 100%;
    height: 20px;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-full);
    position: relative;
    overflow: hidden;
}

.level-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--c-primary-dark), var(--c-primary), var(--c-cyan));
    width: 0%;
    border-radius: var(--r-full);
    transition: width 0.5s var(--ease-snap);
}

/* Game Canvas Container */
#game-canvas-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #000;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

/* HUD Overlay */
.hud-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

.hud-pill {
    background: rgba(15, 14, 40, 0.82);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-full);
    padding: 9px 16px;
    font-size: 0.85rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
}

.hearts-container {
    display: flex;
    gap: 6px;
}

.pixel-heart {
    width: 20px;
    height: 20px;
    background: var(--c-danger);
    clip-path: path('M10 18 C 3 12, 0 8, 0 5 A5 5 0 0 1 10 3 A5 5 0 0 1 20 5 C 20 8, 17 12, 10 18 Z');
    display: inline-block;
    animation: pulseHeart 1.2s infinite ease-in-out;
    transition: background 0.3s ease, opacity 0.3s ease, transform 0.3s var(--ease-pop);
}

.pixel-heart.lost {
    background: #3f3f52 !important;
    opacity: 0.4;
    animation: none !important;
    transform: scale(0.85);
}

@keyframes pulseHeart {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.command-console {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 480px;
    display: flex;
    gap: 8px;
    z-index: 20;
    background: rgba(15, 14, 40, 0.88);
    padding: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.command-input {
    flex: 1;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    padding: 8px 12px;
    background: rgba(0,0,0,0.4);
    border: 2px solid var(--c-cyan);
    border-radius: var(--r-sm);
    color: var(--c-gold);
    outline: none;
    text-align: center;
    letter-spacing: 0.03em;
}

/* Combo / streak indicator — injected next to the HUD during gameplay */
.combo-badge {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    z-index: 12;
    background: linear-gradient(135deg, var(--c-gold), var(--c-danger));
    color: #1c1400;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    padding: 6px 18px;
    border-radius: var(--r-full);
    box-shadow: 0 0 24px rgba(251,191,36,0.6), var(--shadow-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.25s var(--ease-pop);
}

.combo-badge.show {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.combo-badge.pop {
    animation: comboPop 0.32s var(--ease-pop);
}

@keyframes comboPop {
    0% { transform: translateX(-50%) scale(1.35); }
    100% { transform: translateX(-50%) scale(1); }
}

/* Floating "+score" / "streak" text that pops off a hit */
.floating-score {
    position: absolute;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--c-gold);
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
    pointer-events: none;
    z-index: 14;
    animation: floatScoreUp 0.9s ease-out forwards;
}

@keyframes floatScoreUp {
    0% { transform: translateY(0) scale(0.8); opacity: 0; }
    15% { transform: translateY(-6px) scale(1.1); opacity: 1; }
    100% { transform: translateY(-46px) scale(1); opacity: 0; }
}

/* Whole-canvas shake, applied briefly on big hits / damage */
.screen-shake {
    animation: screenShake 0.32s ease-in-out;
}

@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-6px, 3px); }
    40% { transform: translate(5px, -4px); }
    60% { transform: translate(-4px, -2px); }
    80% { transform: translate(3px, 3px); }
}

/* -------------------------------------------------------------
   Virtual Touch Keypad
   ------------------------------------------------------------- */
.virtual-keypad {
    width: 100%;
    max-width: 800px;
    margin-top: 10px;
    background: rgba(15, 14, 40, 0.85);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    padding: 10px;
    touch-action: manipulation;
    z-index: 30;
    backdrop-filter: blur(10px);
}

@media (hover: hover) and (pointer: fine) {
    .virtual-keypad {
        display: none !important;
    }
}

.keypad-layout {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keypad-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.key-btn {
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 1rem;
    min-height: 48px;
    min-width: 44px;
    flex: 1;
    max-width: 72px;
    color: #fff;
    background: linear-gradient(180deg, #4b5aa8, #363f80);
    border: none;
    border-radius: 12px;
    box-shadow: 0 3px 0 rgba(0,0,0,0.3), var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.08s var(--ease-snap), box-shadow 0.08s var(--ease-snap), filter 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.key-btn:active, .key-btn.active {
    transform: translateY(2px) scale(0.95);
    box-shadow: 0 0 0 rgba(0,0,0,0.3);
    filter: brightness(1.25);
}

.key-btn-action {
    background: linear-gradient(180deg, var(--c-danger), var(--c-danger-dark));
}

.key-btn-enter {
    background: linear-gradient(180deg, var(--c-gold), var(--c-gold-dark));
    color: #1c1400;
    flex: 2;
    max-width: 160px;
    font-size: 0.9rem;
    font-weight: 800;
}

/* Mobile Media Queries (Mobile-First Stacking) */
@media (max-width: 768px) {
    header {
        padding: 8px 12px;
        flex-direction: column;
        gap: 6px;
    }

    .brand-title {
        font-size: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .key-btn {
        min-height: 44px;
        min-width: 30px;
        font-size: 0.85rem;
    }

    .key-btn-enter {
        font-size: 0.72rem;
    }
}

/* -------------------------------------------------------------
   Custom Modal Dialogue System
   ------------------------------------------------------------- */
.mc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(6, 6, 20, 0.65);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 15px;
}

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

.mc-modal-box {
    background: linear-gradient(180deg, rgba(51,46,110,0.96), rgba(20,18,48,0.98));
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 26px;
    width: 100%;
    max-width: 440px;
    text-align: center;
    animation: modalPop 0.28s var(--ease-pop);
}

@keyframes modalPop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.mc-modal-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--c-gold);
    margin-bottom: 14px;
}

.mc-modal-message {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-2);
    line-height: 1.55;
    margin-bottom: 16px;
}

/* -------------------------------------------------------------
   Lobby Player Slots
   ------------------------------------------------------------- */
.lobby-slots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    width: 100%;
    margin: 10px 0;
}

.player-slot {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    padding: 12px 8px;
    text-align: center;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.player-slot.ready {
    box-shadow: var(--shadow-sm), 0 0 0 2px var(--c-primary), 0 0 16px rgba(52,211,153,0.4);
    transform: translateY(-2px);
}

.player-slot.is-bot {
    position: relative;
    background: linear-gradient(180deg, rgba(167,139,250,0.16), rgba(30,27,66,0.9));
    border-color: rgba(167,139,250,0.35);
}

.bot-tag {
    position: absolute;
    top: -8px;
    right: -6px;
    background: linear-gradient(135deg, var(--c-purple), var(--c-purple-dark));
    color: #fff;
    font-size: 0.55rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: var(--r-full);
    box-shadow: var(--shadow-sm);
}

.slot-avatar {
    font-size: 1.9rem;
    margin-bottom: 6px;
}

.lobby-bot-hint {
    width: 100%;
    max-width: 520px;
    text-align: center;
    background: rgba(167,139,250,0.14);
    border: 1px solid rgba(167,139,250,0.35);
    border-radius: var(--r-md);
    padding: 8px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--c-purple);
    margin-bottom: 8px;
}

/* Costume Picker */
.costume-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 4px 0;
}

.costume-option {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    padding: 8px 10px;
    text-align: center;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-2);
    min-width: 64px;
    flex: 1;
    transition: transform 0.15s var(--ease-snap), box-shadow 0.15s ease;
}

.costume-option .costume-icon {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 2px;
}

.costume-option.active {
    box-shadow: var(--shadow-sm), 0 0 0 2px var(--c-gold), 0 0 16px rgba(251,191,36,0.4);
    color: var(--c-gold);
    transform: translateY(-2px);
}

/* Team Select (FPV Team Mode) */
#fpv-team-select {
    display: none;
    gap: 12px;
    margin: 10px 0;
    justify-content: center;
}

.team-btn-red { background: linear-gradient(180deg, #fb7185, #be123c) !important; }
.team-btn-blue { background: linear-gradient(180deg, #60a5fa, #1d4ed8) !important; }

/* -------------------------------------------------------------
   Match Debrief Screen
   ------------------------------------------------------------- */
.debrief-box {
    width: 100%;
    max-width: 480px;
    margin: auto;
    background: linear-gradient(180deg, rgba(51,46,110,0.75), rgba(20,18,48,0.85));
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px;
    text-align: center;
}

.grade-stamp {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--c-gold);
    text-shadow: 0 0 30px rgba(251,191,36,0.6);
    border: 3px solid var(--c-gold);
    border-radius: var(--r-md);
    padding: 6px 24px;
    margin: 10px 0 18px;
    animation: gradeStampIn 0.5s var(--ease-pop);
}

@keyframes gradeStampIn {
    0% { transform: scale(0) rotate(-15deg); opacity: 0; }
    100% { transform: scale(1) rotate(-4deg); opacity: 1; }
}

.badges-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.badge-card {
    background: linear-gradient(135deg, var(--c-gold), var(--c-gold-dark));
    color: #1c1400;
    font-weight: 800;
    font-size: 0.78rem;
    padding: 10px;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------
   Leaderboard Table
   ------------------------------------------------------------- */
.lb-filter-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.lb-filter-chip {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-soft);
    background: rgba(255,255,255,0.04);
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.lb-filter-chip:active {
    transform: scale(0.94);
}

.lb-filter-chip.active {
    background: linear-gradient(180deg, var(--c-primary), var(--c-primary-dark));
    border-color: var(--c-primary);
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.lb-table th, .lb-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

.lb-table th {
    color: var(--c-gold);
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.lb-table td {
    font-weight: 700;
    color: var(--text-2);
}

.lb-table tbody tr {
    transition: background 0.15s ease;
}

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

.lb-table .rank-1 { color: var(--c-gold); font-weight: 900; text-shadow: 0 0 10px rgba(251,191,36,0.5); }
.lb-table .rank-2 { color: #e2e8f0; font-weight: 900; }
.lb-table .rank-3 { color: #fb923c; font-weight: 900; }

/* -------------------------------------------------------------
   Typing with KR Sir
   ------------------------------------------------------------- */
.typing-sir-bubble {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translate(-50%, -8px);
    z-index: 15;
    max-width: min(80vw, 460px);
    background: #fff;
    color: #1a1a2e;
    border-radius: var(--r-lg);
    padding: 10px 16px;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.85rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s var(--ease-pop);
}

.typing-sir-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 8px 0 8px;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
}

.typing-sir-bubble.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.typing-console {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 640px;
    z-index: 20;
    background: rgba(15, 14, 40, 0.9);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 14px 18px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.typing-live-text {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: clamp(0.95rem, 2.6vw, 1.3rem);
    line-height: 1.6;
    text-align: center;
    letter-spacing: 0.01em;
    word-break: break-word;
}

.typing-live-text .ty-correct { color: var(--c-primary); }
.typing-live-text .ty-wrong { color: var(--c-danger); background: rgba(251,113,133,0.18); border-radius: 3px; }
.typing-live-text .ty-pending { color: var(--text-3); }
.typing-live-text .ty-cursor { border-left: 2px solid var(--c-gold); animation: tyCursorBlink 1s step-end infinite; }

@keyframes tyCursorBlink {
    0%, 50% { border-color: var(--c-gold); }
    51%, 100% { border-color: transparent; }
}

@media (max-width: 768px) {
    .typing-sir-bubble { font-size: 0.72rem; padding: 8px 12px; top: 16%; }
    .typing-console { padding: 10px 12px; bottom: 10px; }
}

/* -------------------------------------------------------------
   FPV Paintball: Raycaster Canvas + HUD
   ------------------------------------------------------------- */
#fpv-canvas-container, #spectator-canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border: none;
    overflow: hidden;
    touch-action: none;
}

#spectator-canvas-container {
    display: flex;
    flex-direction: column;
}

#spectator-main {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

#fpv-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.fpv-hud-top {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 15;
}

.fpv-vitals {
    background: rgba(10, 9, 30, 0.82);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 0.78rem;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.fpv-hud-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    pointer-events: none;
}

.fpv-matchbar {
    display: flex;
    gap: 8px;
    background: rgba(10, 9, 30, 0.82);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-full);
    padding: 6px 12px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
}

.fpv-matchbar-item {
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
}

/* Small reserve-count badge next to the health/ammo readouts — dims when
   empty or not currently useful, lights gold when there's something to
   spend (see updateHud()'s myHpBag/myAmmoBag "ready" toggle). */
.fpv-bag-indicator {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--text-3);
    background: rgba(0,0,0,0.35);
    border-radius: var(--r-full);
    padding: 1px 7px;
    margin-left: 4px;
    vertical-align: middle;
    transition: color 0.2s ease, background 0.2s ease;
}

.fpv-bag-indicator.ready {
    color: #1a1408;
    background: var(--c-gold);
}

/* Med Shield regen buff badge — invisible until active, then pulses teal. */
.fpv-regen-indicator {
    display: inline-block;
    font-size: 0.8rem;
    margin-left: 2px;
    opacity: 0;
    filter: grayscale(1);
    transition: opacity 0.2s ease, filter 0.2s ease;
}

.fpv-regen-indicator.active {
    opacity: 1;
    filter: none;
    animation: fpvRegenPulse 0.9s ease-in-out infinite alternate;
}

@keyframes fpvRegenPulse {
    from { transform: scale(0.95); }
    to   { transform: scale(1.15); }
}

/* Prominent kill callout — bigger and more central than the scrolling
   killfeed list, for "something important just happened" visibility. */
.fpv-kill-banner {
    position: absolute;
    top: 110px;
    left: 50%;
    transform: translate(-50%, -10px);
    z-index: 16;
    background: rgba(10, 9, 30, 0.88);
    border: 1px solid var(--c-gold);
    border-radius: var(--r-full);
    padding: 7px 18px;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-1);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s var(--ease-pop);
}

.fpv-kill-banner .killer { color: var(--c-primary); }
.fpv-kill-banner .victim { color: var(--c-danger); }

.fpv-kill-banner.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.fpv-kill-banner.self {
    border-color: var(--c-danger);
    box-shadow: var(--shadow-md), 0 0 20px rgba(251,113,133,0.4);
}

.fpv-kill-banner.team-kill {
    border-color: #facc15;
    color: #fde68a;
    box-shadow: var(--shadow-md), 0 0 20px rgba(250,204,21,0.4);
}

@media (max-width: 768px) {
    .fpv-kill-banner { top: 100px; font-size: 0.7rem; padding: 6px 14px; }
    .fpv-matchbar-item { font-size: 0.62rem; }
}

/* Match-over winner announcement — big, central, gold, shown for a few
   seconds before finishMatch() hands off to the personal debrief screen. */
.fpv-winner-banner {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 5, 20, 0);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease, background 0.35s ease;
}

.fpv-winner-banner.show {
    opacity: 1;
    background: rgba(6, 5, 20, 0.55);
}

.fpv-winner-banner-text {
    background: linear-gradient(180deg, rgba(30,24,4,0.95), rgba(10,9,30,0.95));
    border: 2px solid var(--c-gold);
    border-radius: var(--r-lg);
    padding: 22px 36px;
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--c-gold);
    text-align: center;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(251,191,36,0.35);
    transform: scale(0.85);
    transition: transform 0.35s var(--ease-pop);
}

.fpv-winner-banner.show .fpv-winner-banner-text {
    transform: scale(1);
}

@media (max-width: 768px) {
    .fpv-winner-banner-text { font-size: 1rem; padding: 16px 24px; }
}

.fpv-bar-track {
    width: 100%;
    height: 12px;
    background: rgba(0,0,0,0.45);
    border-radius: var(--r-full);
    overflow: hidden;
}

.fpv-bar-fill-health {
    height: 100%;
    border-radius: var(--r-full);
    background: linear-gradient(90deg, var(--c-primary), var(--c-primary));
    transition: width 0.2s ease, background 0.3s ease;
}

.fpv-bar-fill-ammo {
    height: 100%;
    border-radius: var(--r-full);
    background: linear-gradient(90deg, var(--c-gold), var(--c-gold-dark));
    transition: width 0.2s ease;
}

.fpv-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 12;
    transition: transform 0.1s ease;
}

.fpv-crosshair::before, .fpv-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255,255,255,0.9);
    border-radius: 2px;
    transition: background 0.1s ease, box-shadow 0.1s ease;
}

.fpv-crosshair::before { top: 10px; left: 3px; width: 16px; height: 2px; }
.fpv-crosshair::after { top: 3px; left: 10px; width: 2px; height: 16px; }

.fpv-crosshair.hit-flash::before, .fpv-crosshair.hit-flash::after {
    background: var(--c-danger);
}

/* Clear, unmissable "you're lined up, take the shot!" feedback — a kid
   should never have to guess whether the aim is good. */
.fpv-crosshair.on-target {
    transform: translate(-50%, -50%) scale(1.3);
}

.fpv-crosshair.on-target::before, .fpv-crosshair.on-target::after {
    background: var(--c-primary);
    box-shadow: 0 0 10px 2px rgba(52, 211, 153, 0.9);
}

/* Friendly fire is real — a teammate in your sights is a "stop" signal, not
   a "go", so it gets its own distinct warning color rather than reusing the
   enemy green. See getAimLockState() in fpv_engine.js. */
.fpv-crosshair.on-teammate {
    transform: translate(-50%, -50%) scale(1.15);
}

.fpv-crosshair.on-teammate::before, .fpv-crosshair.on-teammate::after {
    background: #facc15;
    box-shadow: 0 0 10px 2px rgba(250, 204, 21, 0.9);
}

.fpv-teammate-warning {
    position: absolute;
    top: calc(50% + 22px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    background: rgba(120, 53, 15, 0.9);
    border: 1px solid #facc15;
    color: #fde68a;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: var(--r-full);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.fpv-teammate-warning.show {
    opacity: 1;
    animation: fpvDangerTextPulse 0.6s ease-in-out infinite alternate;
}

.fpv-killfeed {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
    z-index: 15;
    pointer-events: none;
}

.fpv-killfeed-item {
    background: rgba(10, 9, 30, 0.85);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 5px 10px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-1);
    animation: fpvKillfeedIn 0.25s var(--ease-snap);
    backdrop-filter: blur(6px);
}

.fpv-killfeed-item.team-kill {
    border-color: #facc15;
    color: #fde68a;
}

@keyframes fpvKillfeedIn {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.fpv-minimap {
    position: absolute;
    bottom: 12px;
    left: 12px;
    width: 116px;
    height: 116px;
    background: rgba(10, 9, 30, 0.75);
    border: 2px solid var(--c-cyan);
    border-radius: 50%;
    box-shadow: 0 0 18px rgba(34,211,238,0.3), var(--shadow-sm);
    z-index: 15;
}

/* -------------------------------------------------------------
   FPV Match-Start Cinematic: drop plane + parachuting players, then a
   3-2-1 countdown, before the real arena/controls take over.
   ------------------------------------------------------------- */
.fpv-intro-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #2e86de 0%, #89d4f7 55%, #2f5d2a 100%);
    overflow: hidden;
}

.fpv-intro-overlay.active {
    display: flex;
}

.fpv-intro-sky {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

/* Drifting cloud layer for depth — plain soft ellipses, tiled and slowly
   panning opposite the plane's direction. */
.fpv-intro-clouds {
    position: absolute;
    inset: -10% -10% 40% -10%;
    background-image:
        radial-gradient(ellipse 90px 30px at 10% 30%, rgba(255,255,255,0.55), transparent 70%),
        radial-gradient(ellipse 130px 40px at 40% 60%, rgba(255,255,255,0.4), transparent 70%),
        radial-gradient(ellipse 100px 32px at 70% 20%, rgba(255,255,255,0.5), transparent 70%),
        radial-gradient(ellipse 110px 34px at 90% 55%, rgba(255,255,255,0.35), transparent 70%);
    background-repeat: repeat-x;
    background-size: 60% 100%;
    animation: fpvCloudDrift 14s linear infinite;
    opacity: 0.8;
}

@keyframes fpvCloudDrift {
    from { background-position: 0 0, 0 0, 0 0, 0 0; }
    to { background-position: -600px 0, -600px 0, -600px 0, -600px 0; }
}

/* Ground silhouette so the drop reads against terrain, not empty gradient. */
.fpv-intro-ground {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 18%;
    background: linear-gradient(180deg, rgba(0,0,0,0.12), rgba(0,0,0,0.32));
    clip-path: polygon(0% 40%, 8% 25%, 18% 45%, 30% 15%, 42% 38%, 55% 10%, 68% 32%, 80% 12%, 92% 30%, 100% 18%, 100% 100%, 0% 100%);
}

/* ---- Plane: built from CSS shapes (not a flipped emoji glyph, which read
   muddy and inconsistent) — a simple sleek silhouette with a tail fin,
   swept wing, a red accent stripe, and a fading contrail. ---- */
.fpv-intro-plane {
    position: absolute;
    top: 14%;
    left: -14%;
    width: 90px;
    height: 34px;
    filter: drop-shadow(0 8px 14px rgba(0,0,0,0.45));
}

.fpv-intro-plane .plane-fuselage {
    position: absolute;
    left: 10px; top: 12px;
    width: 72px; height: 12px;
    background: linear-gradient(180deg, #eef2f7, #b9c4d0);
    border-radius: 8px 16px 16px 8px;
}

.fpv-intro-plane .plane-tail {
    position: absolute;
    left: 4px; top: 2px;
    width: 0; height: 0;
    border-style: solid;
    border-width: 0 10px 20px 0;
    border-color: transparent transparent #b9c4d0 transparent;
}

.fpv-intro-plane .plane-wing {
    position: absolute;
    left: 34px; top: 16px;
    width: 30px; height: 22px;
    background: #dde4ea;
    clip-path: polygon(0% 0%, 100% 40%, 60% 100%, 0% 60%);
    transform-origin: top left;
    animation: fpvWingBank 1.4s ease-in-out infinite alternate;
}

.fpv-intro-plane .plane-stripe {
    position: absolute;
    left: 18px; top: 16px;
    width: 58px; height: 4px;
    background: var(--c-danger);
    border-radius: 2px;
}

@keyframes fpvWingBank {
    from { transform: scaleY(1); }
    to { transform: scaleY(0.82); }
}

.fpv-intro-contrail {
    position: absolute;
    right: 100%;
    top: 16px;
    width: 140px;
    height: 6px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.75));
    border-radius: 4px;
}

.fpv-intro-overlay.fly .fpv-intro-plane {
    animation: fpvPlaneFly 3.2s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

@keyframes fpvPlaneFly {
    0% { left: -14%; top: 16%; transform: rotate(-2deg); }
    45% { top: 20%; transform: rotate(1deg); }
    55% { top: 19%; transform: rotate(1deg); }
    100% { left: 108%; top: 12%; transform: rotate(-3deg); }
}

.fpv-intro-dropzone {
    position: absolute;
    inset: 0;
}

/* ---- Jumpers: a quick tumbling free-fall, then the chute snaps open
   (a visible scale/opacity pop, not just a fade) and drift slows with a
   gentle pendulum sway before landing. ---- */
.fpv-intro-jumper {
    position: absolute;
    top: 14%;
    text-align: center;
    animation: fpvJumperDrop 3s cubic-bezier(0.3, 0, 0.7, 1) forwards;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35));
}

.fpv-intro-jumper .body-icon {
    display: block;
    font-size: 1.5rem;
    animation: fpvJumperTumble 3s ease forwards;
}

.fpv-intro-jumper .chute {
    display: block;
    font-size: 1.3rem;
    opacity: 0;
    transform: scale(0.2);
    animation: fpvChuteOpen 3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.fpv-intro-jumper .name {
    display: block;
    font-size: 0.55rem;
    font-weight: 800;
    font-family: var(--font-body);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    white-space: nowrap;
}

.fpv-intro-jumper .dust {
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 34px;
    height: 10px;
    transform: translateX(-50%) scale(0);
    background: radial-gradient(ellipse, rgba(255,255,255,0.85), transparent 70%);
    border-radius: 50%;
    animation: fpvDustPuff 3s ease forwards;
}

@keyframes fpvJumperDrop {
    0% { top: 14%; }
    55% { top: 60%; }
    100% { top: 82%; }
}

/* Order flips: free-fall spin first, chute-open sway after — driven by
   swapping which child is visible partway through via opacity, so both
   animations can share one timeline without a mid-animation class swap. */
.fpv-intro-jumper .body-icon {
    animation-name: fpvJumperTumble;
}

@keyframes fpvJumperTumble {
    0% { opacity: 1; transform: rotate(0deg); }
    50% { opacity: 1; transform: rotate(320deg); }
    58% { opacity: 0; transform: rotate(340deg); }
    100% { opacity: 0; }
}

@keyframes fpvChuteOpen {
    0%, 48% { opacity: 0; transform: scale(0.2); }
    58% { opacity: 1; transform: scale(1.25) translateY(-4px); }
    68%, 90% { opacity: 1; transform: scale(1) rotate(-4deg); }
    100% { opacity: 1; transform: scale(1) rotate(3deg); }
}

@keyframes fpvDustPuff {
    0%, 92% { opacity: 0; transform: translateX(-50%) scale(0); }
    96% { opacity: 0.9; transform: translateX(-50%) scale(1.4); }
    100% { opacity: 0; transform: translateX(-50%) scale(2.2); }
}

.fpv-intro-caption {
    position: relative;
    z-index: 2;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1rem, 3vw, 1.6rem);
    color: #fff;
    text-shadow: 0 3px 10px rgba(0,0,0,0.6);
    letter-spacing: 0.06em;
    opacity: 0;
}

.fpv-intro-overlay.show-caption .fpv-intro-caption {
    animation: fpvFadeInOut 2.4s ease forwards;
}

@keyframes fpvFadeInOut {
    0% { opacity: 0; transform: translateY(8px); }
    15%, 75% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; }
}

.fpv-intro-countdown {
    position: relative;
    z-index: 2;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(3rem, 12vw, 6rem);
    color: var(--c-gold);
    text-shadow: 0 0 30px rgba(251,191,36,0.7), 0 4px 10px rgba(0,0,0,0.6);
}

.fpv-intro-countdown.pop {
    animation: fpvCountdownPop 0.75s var(--ease-pop);
}

@keyframes fpvCountdownPop {
    0% { transform: scale(0.3); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Team callout: teammate-spotted-enemy directional arrow + text. Sits
   dead-center, above the crosshair, so it reads as "look this way" without
   permanently blocking the view (only shown for a few seconds per callout). */
/* Both callouts below live in the bottom-right, well clear of the crosshair
   at dead-center (50%/50%) and the action-button column hugging the right
   edge — a center-screen warning was covering the exact spot players need
   to see clearly to aim. */
.fpv-spotted-alert {
    position: absolute;
    bottom: 165px;
    right: 90px;
    z-index: 16;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.fpv-spotted-alert.active {
    display: flex;
}

.fpv-spotted-arrow {
    font-size: 2.4rem;
    color: var(--c-danger);
    text-shadow: 0 0 16px rgba(251,113,133,0.9), 0 2px 4px rgba(0,0,0,0.6);
    animation: fpvSpottedPulse 0.7s ease-in-out infinite alternate;
    transform-origin: center;
}

@keyframes fpvSpottedPulse {
    from { opacity: 0.6; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1.08); }
}

.fpv-spotted-text {
    background: rgba(10, 9, 30, 0.85);
    border: 1px solid var(--c-danger);
    border-radius: var(--r-full);
    padding: 5px 14px;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--c-danger);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

/* Immediate personal danger warning: a pulsing yellow edge-vignette across
   the whole viewport (impossible to miss even out of the corner of your
   eye) plus a small text chip — an enemy is right on top of you RIGHT NOW,
   LOS or not. See updateDangerAlert(). */
.fpv-danger-vignette {
    position: absolute;
    inset: 0;
    z-index: 13;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fpv-danger-vignette.active {
    opacity: 1;
    animation: fpvDangerPulse 0.85s ease-in-out infinite alternate;
}

@keyframes fpvDangerPulse {
    from { box-shadow: inset 0 0 60px 6px rgba(250, 204, 21, 0.35); }
    to   { box-shadow: inset 0 0 100px 16px rgba(250, 204, 21, 0.65); }
}

.fpv-danger-alert {
    position: absolute;
    bottom: 100px;
    right: 90px;
    z-index: 14;
    background: rgba(120, 53, 15, 0.88);
    border: 1px solid #facc15;
    color: #fde68a;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 6px 16px;
    border-radius: var(--r-full);
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fpv-danger-alert.active {
    opacity: 1;
    animation: fpvDangerTextPulse 0.85s ease-in-out infinite alternate;
}

@keyframes fpvDangerTextPulse {
    from { transform: scale(0.97); }
    to   { transform: scale(1.03); }
}

@media (max-width: 768px) {
    .fpv-danger-alert { font-size: 0.68rem; padding: 5px 12px; right: 70px; bottom: 90px; }
    .fpv-spotted-alert { right: 70px; bottom: 155px; }
}

/* Proximity compass: a scrolling directional strip across the top-center of
   the HUD, independent from the minimap (which deliberately never shows
   enemies) — this one senses nearby threats by "sound/thermal/radio" within
   a short range, through walls. */
.fpv-compass-wrap {
    position: absolute;
    top: 66px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    pointer-events: none;
    max-width: calc(100% - 220px);
}

#fpv-compass {
    display: block;
    width: min(50vw, 380px);
    max-width: 100%;
    height: 34px;
    background: rgba(10, 9, 30, 0.72);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-full);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(6px);
}

@media (max-width: 768px) {
    .fpv-compass-wrap { top: auto; bottom: 165px; max-width: calc(100% - 24px); }
    #fpv-compass { width: min(80vw, 320px); height: 30px; }
}

.fpv-interaction-prompt {
    position: absolute;
    bottom: 135px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 9, 30, 0.88);
    border: 1px solid var(--c-gold);
    border-radius: var(--r-full);
    padding: 7px 16px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--c-gold);
    z-index: 15;
    display: none;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.fpv-interaction-prompt.downed {
    border-color: var(--c-danger);
    color: var(--c-danger);
    font-size: 0.9rem;
    padding: 10px 20px;
    animation: fpv-downed-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes fpv-downed-pulse {
    from { opacity: 0.75; }
    to { opacity: 1; }
}

.fpv-damage-flash {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, transparent 40%, rgba(255,0,60,0.35) 100%);
    opacity: 0;
    pointer-events: none;
    z-index: 11;
    transition: opacity 0.15s ease;
}

.fpv-damage-flash.active { opacity: 1; }

.fpv-damage-flash.downed {
    background: radial-gradient(circle, rgba(200,0,30,0.15) 30%, rgba(180,0,20,0.55) 100%);
}

.fpv-floating-dmg {
    position: absolute;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--c-danger);
    text-shadow: 0 2px 6px rgba(0,0,0,0.7);
    pointer-events: none;
    z-index: 13;
    animation: fpvDmgFloat 0.8s ease forwards;
}

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

/* Mobile touch controls: virtual joystick (move) + look pad + action buttons */
.fpv-touch-controls {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
}

.fpv-joystick-zone {
    position: absolute;
    left: 15px;
    bottom: 15px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.10);
    border: 2px solid rgba(255,255,255,0.35);
    pointer-events: auto;
    touch-action: none;
}

.fpv-joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.55);
    border: 2px solid #fff;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.fpv-look-zone {
    position: absolute;
    right: 0;
    top: 0;
    width: 55%;
    height: 100%;
    pointer-events: auto;
    touch-action: none;
}

.fpv-action-buttons {
    position: absolute;
    right: 15px;
    bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

.fpv-action-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(251,113,133,0.9), rgba(225,29,72,0.9));
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    touch-action: manipulation;
}

.fpv-action-btn.secondary {
    background: linear-gradient(180deg, rgba(96,165,250,0.9), rgba(37,99,235,0.9));
    width: 52px;
    height: 52px;
    font-size: 1.05rem;
}

.fpv-action-btn.secondary.small {
    width: 42px;
    height: 42px;
    font-size: 0.85rem;
    background: linear-gradient(180deg, rgba(251,191,36,0.9), rgba(217,119,6,0.9));
}

@media (hover: hover) and (pointer: fine) {
    .fpv-touch-controls { display: none; }
}

#fpv-lock-modal .keypad-layout { margin-top: 10px; }

.fpv-lock-timer {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--c-danger);
    margin-top: 8px;
    display: none;
}

/* -------------------------------------------------------------
   Admin Dashboard extras
   ------------------------------------------------------------- */
.lb-table input.mc-input {
    padding: 7px 9px;
}

/* -------------------------------------------------------------
   Spectator Broadcast
   ------------------------------------------------------------- */
#spectator-map-canvas {
    position: relative;
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    min-height: 0;
    background: #0a0a12;
    display: block;
}

#spectator-topbar {
    position: relative;
    flex: 0 0 auto;
    height: 48px;
    background: rgba(10, 9, 30, 0.9);
    border-bottom: 1px solid var(--c-cyan);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    z-index: 20;
}

#spectator-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--c-gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spectator-player-list {
    position: static;
    flex: 0 0 220px;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    background: rgba(10, 9, 30, 0.85);
    border-left: 1px solid var(--border-soft);
    padding: 8px;
    font-size: 0.7rem;
    font-weight: 700;
}

.spectator-player-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    margin-bottom: 4px;
}

.spectator-player-row:hover {
    background: rgba(255,255,255,0.08);
}

.spectator-player-row.eliminated { opacity: 0.5; }

#spectator-canvas-container .fpv-killfeed {
    top: 58px;
    left: 10px;
    right: auto;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .spectator-player-list { flex: 0 0 150px; }

    .fpv-minimap {
        bottom: 10px;
        left: 145px;
        width: 72px;
        height: 72px;
    }
}
