@import url('https://fonts.googleapis.com/css2?family=Aldrich&display=swap');

:root {
    --gf-view-w: 1600;
    --gf-view-h: 900;
    --gf-ui-scale: 1;

    /* Centralized Font Sizes (Adjust in ONE place) */
    --font-hud: 'Aldrich', monospace, sans-serif;
    --fs-xs: calc(11px * var(--gf-ui-scale));
    --fs-sm: calc(13px * var(--gf-ui-scale));
    --fs-md: calc(15px * var(--gf-ui-scale));
    --fs-lg: calc(18px * var(--gf-ui-scale));
    --fs-xl: calc(24px * var(--gf-ui-scale));
    --fs-2xl: calc(36px * var(--gf-ui-scale));

    /* Game-Grade Subterranean Cockpit Palette (Zero Tailwind/Indigo) */
    --col-void: #05070a;
    --col-cockpit-bg: rgba(9, 14, 20, 0.88);
    --col-cockpit-panel: rgba(14, 22, 32, 0.78);
    --col-cockpit-border: rgba(56, 189, 248, 0.28);
    --col-cyan: #00f2fe;
    --col-blue: #38bdf8;
    --col-amber: #f59e0b;
    --col-gold: #ffd700;
    --col-emerald: #10b981;
    --col-crimson: #ef4444;
    --col-text-main: #e2e8f0;
    --col-text-dim: #64748b;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: var(--col-void);
    color: var(--col-text-main);
    font-family: var(--font-hud);
    overflow: hidden;
    overflow-x: hidden !important;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#app-shell {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--col-void);
}

#app-shell.gf-cursor-hidden,
#app-shell.gf-cursor-hidden * {
    cursor: none !important;
}

#canvas-stage {
    position: absolute;
    overflow: hidden;
    background: #040609;
}

#gameCanvas {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
}

/* HUD Root & Dock / Overlay Modes */
#hud-layer {
    position: absolute;
    z-index: 30;
    pointer-events: none;
    font-family: var(--font-hud);
    text-transform: uppercase;
}

.hud-mode-overlay {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.hud-mode-outside {
    background: linear-gradient(180deg, rgba(10, 15, 22, 0.96), rgba(6, 9, 14, 0.99));
    border-color: rgba(0, 242, 254, 0.22);
    border-style: solid;
    border-width: 0;
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.85);
}

.hud-dock-bottom { border-top-width: 2px; }
.hud-dock-top    { border-bottom-width: 2px; }
.hud-dock-left   { border-right-width: 2px; }
.hud-dock-right  { border-left-width: 2px; }

/* HUD Anchor Slots */
.hud-slot {
    display: flex;
    align-items: center;
    gap: calc(10px * var(--gf-ui-scale));
    pointer-events: none;
}

.hud-mode-overlay .hud-slot {
    position: absolute;
    padding: calc(10px * var(--gf-ui-scale));
}

.hud-slot-top-left     { top: 0; left: 0; flex-wrap: wrap; }
.hud-slot-top-right    { top: 0; right: 0; justify-content: flex-end; flex-wrap: wrap; }
.hud-slot-bottom-left  { bottom: 0; left: 0; flex-wrap: wrap; }
.hud-slot-bottom-right { bottom: 0; right: 0; justify-content: flex-end; flex-wrap: wrap; }
.hud-slot-bottom-bar {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
}

.hud-mode-outside .hud-slot-bottom-bar {
    position: relative;
    height: 100%;
    padding: calc(6px * var(--gf-ui-scale)) calc(14px * var(--gf-ui-scale));
}

.hud-dir-vertical .hud-slot-bottom-bar {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overflow-y: auto;
}

/* Telemetry Modules (Chamfered Sci-Fi Instrument Clusters) */
.hud-cluster {
    display: flex;
    align-items: center;
    height: calc(42px * var(--gf-ui-scale));
    gap: calc(12px * var(--gf-ui-scale));
    background: var(--col-cockpit-panel);
    border: 1px solid var(--col-cockpit-border);
    padding: calc(4px * var(--gf-ui-scale)) calc(12px * var(--gf-ui-scale));
    clip-path: polygon(
        0 0,
        calc(100% - 7px) 0,
        100% 7px,
        100% 100%,
        7px 100%,
        0 calc(100% - 7px)
    );
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

#hud-cluster-roster {
    height: auto;
    min-height: calc(42px * var(--gf-ui-scale));
    align-items: stretch;
}

.hud-mode-overlay .hud-cluster {
    background: rgba(8, 12, 18, 0.58);
    border-color: rgba(0, 242, 254, 0.22);
}

.hud-field {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: calc(32px * var(--gf-ui-scale));
    gap: calc(3px * var(--gf-ui-scale));
}

#hud-cluster-roster .hud-field {
    height: auto;
}

.hud-label {
    font-size: var(--fs-xs);
    color: var(--col-text-dim);
    letter-spacing: 1.2px;
    line-height: 1;
    white-space: nowrap;
}

.hud-val {
    font-size: var(--fs-md);
    color: var(--col-text-main);
    letter-spacing: 1px;
    line-height: 1;
    height: calc(18px * var(--gf-ui-scale));
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

#hud-sec-race {
    min-width: calc(155px * var(--gf-ui-scale));
    font-variant-numeric: tabular-nums;
}

.hud-val-lg {
    font-size: var(--fs-lg);
    color: var(--col-cyan);
}

.hud-val-cyan    { color: var(--col-cyan); }
.hud-val-gold    { color: var(--col-gold); }
.hud-val-amber   { color: var(--col-amber); }
.hud-val-emerald { color: var(--col-emerald); }
.hud-val-crimson { color: var(--col-crimson); }

/* Fuel Gauge Bar */
.fuel-gauge-wrap {
    width: calc(96px * var(--gf-ui-scale));
    height: calc(18px * var(--gf-ui-scale));
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(245, 158, 11, 0.45);
    padding: 1px;
    position: relative;
    overflow: hidden;
}

.fuel-gauge-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ef4444 0%, #f59e0b 45%, #10b981 100%);
    transform-origin: left center;
    transform: scaleX(1);
    will-change: transform;
}

.fuel-gauge-ticks {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent calc(11px * var(--gf-ui-scale)),
        rgba(5, 7, 10, 0.75) calc(11px * var(--gf-ui-scale)),
        rgba(5, 7, 10, 0.75) calc(13px * var(--gf-ui-scale))
    );
    pointer-events: none;
}

/* Ship Lives Glyphs */
.lives-glyphs {
    font-size: var(--fs-lg);
    color: var(--col-crimson);
    letter-spacing: 2px;
    line-height: 1;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.55);
}

/* Dogfight Roster Component */
.df-roster {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--gf-ui-scale));
    flex-wrap: wrap;
}

.df-roster-vertical {
    flex-direction: column;
    align-items: stretch;
    gap: calc(4px * var(--gf-ui-scale));
    min-width: calc(145px * var(--gf-ui-scale));
}

.df-pilot-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(5px * var(--gf-ui-scale));
    padding: calc(2px * var(--gf-ui-scale)) calc(6px * var(--gf-ui-scale));
    background: rgba(0, 0, 0, 0.45);
    border-left: 3px solid var(--col-emerald);
    color: var(--col-emerald);
    font-size: var(--fs-xs);
}

.df-pilot-chip.team-foe {
    border-left-color: var(--col-crimson);
    color: var(--col-crimson);
}

/* Tactical Buttons */
.hud-actions {
    display: flex;
    align-items: center;
    gap: calc(6px * var(--gf-ui-scale));
    pointer-events: auto;
}

.hud-actions .gbtn {
    height: calc(30px * var(--gf-ui-scale));
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gbtn {
    font-family: var(--font-hud);
    font-size: var(--fs-xs);
    color: var(--col-cyan);
    background: rgba(12, 20, 30, 0.88);
    border: 1px solid rgba(0, 242, 254, 0.38);
    padding: calc(6px * var(--gf-ui-scale)) calc(11px * var(--gf-ui-scale));
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.gbtn:hover {
    background: rgba(0, 242, 254, 0.18);
    border-color: var(--col-cyan);
    color: #fff;
}

.gbtn-emerald { color: var(--col-emerald); border-color: rgba(16, 185, 129, 0.45); }
.gbtn-emerald:hover { background: rgba(16, 185, 129, 0.18); border-color: var(--col-emerald); }

.gbtn-amber { color: var(--col-amber); border-color: rgba(245, 158, 11, 0.45); }
.gbtn-amber:hover { background: rgba(245, 158, 11, 0.18); border-color: var(--col-amber); }

.gbtn-crimson { color: var(--col-crimson); border-color: rgba(239, 68, 68, 0.45); }
.gbtn-crimson:hover { background: rgba(239, 68, 68, 0.18); border-color: var(--col-crimson); }

.gbtn-lg {
    font-size: var(--fs-md);
    padding: calc(9px * var(--gf-ui-scale)) calc(16px * var(--gf-ui-scale));
}

/* Isolated Debug Telemetry Panel */
#debug-hud-panel {
    position: absolute;
    z-index: 95;
    pointer-events: auto;
    background: rgba(6, 10, 16, 0.90);
    border: 1px solid rgba(0, 242, 254, 0.32);
    padding: calc(5px * var(--gf-ui-scale)) calc(9px * var(--gf-ui-scale));
    font-family: var(--font-hud);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-xs);
    color: var(--col-text-main);
    display: flex;
    flex-direction: column;
    gap: calc(6px * var(--gf-ui-scale));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.75);
    min-width: calc(430px * var(--gf-ui-scale));
}

.perf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(10px * var(--gf-ui-scale));
    cursor: pointer;
    white-space: nowrap;
    width: 100%;
}

.perf-hdr-left {
    display: flex;
    align-items: center;
    gap: calc(6px * var(--gf-ui-scale));
    font-family: ui-monospace, 'Cascadia Mono', 'Source Code Pro', Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.perf-metric {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}

.perf-metric b {
    display: inline-block;
    text-align: right;
}

#pf-fps, #pf-low { min-width: 2.2ch; }
#pf-cpu { min-width: 4.2ch; }
#dbg-ping { min-width: 3.2ch; }
#dbg-in, #dbg-out { min-width: 4.4ch; }

.perf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--col-emerald);
    display: inline-block;
}

.perf-dot.recording {
    background: var(--col-crimson);
    box-shadow: 0 0 8px var(--col-crimson);
}

.perf-sep { color: var(--col-text-dim); }
.perf-metric b { color: var(--col-cyan); }

.perf-hdr-btns {
    display: flex;
    gap: 4px;
}

.perf-btn {
    font-family: var(--font-hud);
    font-size: var(--fs-xs);
    background: rgba(15, 25, 38, 0.9);
    border: 1px solid rgba(0, 242, 254, 0.35);
    color: #fff;
    padding: 2px 6px;
    cursor: pointer;
}

.perf-btn:hover { background: rgba(0, 242, 254, 0.22); }

.perf-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid rgba(0, 242, 254, 0.2);
    padding-top: 6px;
    width: calc(290px * var(--gf-ui-scale));
}

.perf-section-title {
    color: var(--col-gold);
    font-size: var(--fs-xs);
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 2px;
}

.perf-kv-grid, .perf-toggle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.perf-pass-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.perf-pass-row {
    display: flex;
    justify-content: space-between;
}

.perf-toggle-btn {
    font-family: var(--font-hud);
    font-size: 9px;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid var(--col-crimson);
    color: var(--col-crimson);
    padding: 3px 4px;
    cursor: pointer;
}

.perf-toggle-btn.active {
    background: rgba(16, 185, 129, 0.16);
    border-color: var(--col-emerald);
    color: var(--col-emerald);
}

.debug-pos-top-left     { top: calc(8px * var(--gf-ui-scale)); left: calc(8px * var(--gf-ui-scale)); }
.debug-pos-top-right    { top: calc(8px * var(--gf-ui-scale)); right: calc(8px * var(--gf-ui-scale)); }
.debug-pos-bottom-left  { bottom: calc(8px * var(--gf-ui-scale)); left: calc(8px * var(--gf-ui-scale)); }
.debug-pos-bottom-right { bottom: calc(8px * var(--gf-ui-scale)); right: calc(8px * var(--gf-ui-scale)); }

/* Tactile 3D Keyboard Keycaps & Corner Hint Toast */
.keycap-grid {
    display: inline-grid;
    grid-template-columns: repeat(3, calc(30px * var(--gf-ui-scale)));
    gap: calc(4px * var(--gf-ui-scale));
    vertical-align: middle;
}

.keycap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: calc(30px * var(--gf-ui-scale));
    height: calc(28px * var(--gf-ui-scale));
    padding: 0 calc(6px * var(--gf-ui-scale));
    background: linear-gradient(180deg, #273244 0%, #151c28 100%);
    border: 1px solid #475569;
    border-bottom: 3px solid #090d14;
    border-radius: 4px;
    color: var(--col-cyan);
    font-family: var(--font-hud);
    font-size: var(--fs-sm);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
}

.keycap-fire {
    color: var(--col-amber);
    border-color: rgba(245, 158, 11, 0.65);
}

#tactical-hint-toast {
    position: absolute;
    bottom: calc(68px * var(--gf-ui-scale));
    right: calc(18px * var(--gf-ui-scale));
    z-index: 80;
    width: calc(350px * var(--gf-ui-scale));
    max-width: 92vw;
    background: var(--col-cockpit-bg);
    border: 1px solid var(--col-cyan);
    padding: calc(12px * var(--gf-ui-scale));
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.85);
    display: none;
    pointer-events: auto;
}

/* Unified Game Modal System */
.gmodal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(180deg, #161c29 0%, #0c1018 100%);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.95), inset 0 0 20px rgba(0,0,0,0.5);
    padding: calc(32px * var(--gf-ui-scale)) calc(38px * var(--gf-ui-scale));
    display: none;
    flex-direction: column;
    z-index: 220;
    max-width: 96vw;
    max-height: min(95vh, 880px);
    overflow: hidden !important;
    overflow-wrap: break-word;
    word-break: break-word;
}

.gmodal::before {
    content: '';
    position: absolute;
    inset: -24px;
    pointer-events: none;
    z-index: 10;
    border: 96px solid transparent;
    border-image: var(--gf-modal-border-img) 120 stretch;
}

.gmodal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.gmodal-body, #leaderboard-content, #active-rooms-list, .hud-dir-vertical .hud-slot-bottom-bar {
    scrollbar-width: thin;
    scrollbar-color: #8e6c46 rgba(5, 7, 10, 0.85); /* Bronze scrollbar */
}

.gmodal-body::-webkit-scrollbar,
#leaderboard-content::-webkit-scrollbar,
#active-rooms-list::-webkit-scrollbar,
.hud-dir-vertical .hud-slot-bottom-bar::-webkit-scrollbar {
    width: 6px;
    height: 4px;
}

.gmodal-body::-webkit-scrollbar-track,
#leaderboard-content::-webkit-scrollbar-track,
#active-rooms-list::-webkit-scrollbar-track,
.hud-dir-vertical .hud-slot-bottom-bar::-webkit-scrollbar-track {
    background: rgba(5, 7, 10, 0.85);
}

.gmodal-body::-webkit-scrollbar-thumb,
#leaderboard-content::-webkit-scrollbar-thumb,
#active-rooms-list::-webkit-scrollbar-thumb,
.hud-dir-vertical .hud-slot-bottom-bar::-webkit-scrollbar-thumb {
    background: #8e6c46;
    border-radius: 2px;
}

#leaderboard-modal {
    max-height: 90vh;
}

#leaderboard-content {
    flex: 0 0 auto;
    height: min(55vh, 480px);
    overflow-y: auto;
}

#flight-log-modal {
    width: min(820px, 94vw) !important;
}

.flight-log-row {
    display: grid;
    grid-template-columns: 58px 1fr auto auto;
    align-items: center;
    gap: 12px;
    background: rgba(8, 13, 20, 0.72);
    padding: 7px 12px;
    border: 1px solid rgba(56, 189, 248, 0.16);
    border-left: 3px solid rgba(56, 189, 248, 0.38);
    font-size: var(--fs-xs);
}

.flight-log-row.is-highscore {
    border-left-color: var(--col-gold);
}

.flight-log-row.has-unread-comms {
    border-color: rgba(0, 242, 254, 0.55);
    background: rgba(0, 242, 254, 0.09);
}

@keyframes gf-soft-pulse {
    0%, 100% { border-color: var(--col-gold); color: #fff; box-shadow: 0 0 12px rgba(255, 215, 0, 0.55); }
    50% { border-color: var(--col-cyan); color: var(--col-cyan); box-shadow: 0 0 4px rgba(0, 242, 254, 0.25); }
}

.comms-unread-pulse {
    animation: gf-soft-pulse 1.8s ease-in-out infinite !important;
}

.comms-unread-pulse::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--col-gold);
    box-shadow: 0 0 6px var(--col-gold);
}

#modal-footer {
}

.chit-progress-container {
    margin-bottom: 12px;
    width: 100%;
}

.chit-progress-track {
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #8e6c46;
    border-radius: 4px;
    overflow: hidden;
}

.chit-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4af37 0%, #f9e596 100%);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    transition: width 0.4s ease;
}

.chit-catalog-summary {
    font-size: var(--fs-sm);
    margin-bottom: 16px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Achievement-style Chat Chit Commendation Catalog (#65) */
.chit-catalog-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    align-content: start;
    gap: 16px;
    padding-right: 8px;
}

.chit-feat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(30, 38, 48, 0.8) 0%, rgba(20, 26, 36, 0.9) 100%);
    border: 2px solid #3c4b63;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chit-feat-card.unlocked {
    border-color: #d4af37;
    background: linear-gradient(180deg, rgba(35, 30, 20, 0.9) 0%, rgba(20, 18, 14, 0.95) 100%);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.2), inset 0 0 20px rgba(212, 175, 55, 0.05);
}

.chit-feat-card.locked {
    opacity: 0.8;
}

.chit-emblem-frame {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 50%, #2a3648, #141c28);
    border: 2px solid #5a6b82;
    border-radius: 6px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8), 0 4px 10px rgba(0, 0, 0, 0.5);
}

.chit-feat-card.unlocked .chit-emblem-frame {
    border-color: #f9e596;
    background: radial-gradient(circle at 50% 50%, #4a3c1c, #1a150a);
    box-shadow: inset 0 0 20px rgba(249, 229, 150, 0.3), 0 0 15px rgba(249, 229, 150, 0.4);
}

.chit-emblem-glyph {
    font-size: 32px;
    line-height: 1;
}

.chit-feat-card.unlocked .chit-emblem-glyph {
    text-shadow: 0 0 12px rgba(249, 229, 150, 0.8);
}

.chit-feat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chit-feat-top-row {
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-wrap: wrap;
}

.chit-feat-title {
    font-size: var(--fs-lg);
    color: #fff;
    letter-spacing: 1.2px;
}

.chit-feat-card.unlocked .chit-feat-title {
    color: var(--col-gold);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.chit-feat-desc {
    font-size: var(--fs-xs);
    color: var(--col-text-main);
    line-height: 1.45;
}

.chit-feat-card.unlocked .chit-feat-desc {
    color: #4dcbb5;
}

.chit-feat-meta {
    font-size: 10px;
    color: var(--col-text-dim);
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.chit-meta-action {
    color: #4dcbb5;
    display: flex;
    align-items: center;
}

.chit-meta-claim {
    color: var(--col-gold);
}

.chit-badge {
    font-size: 9px;
    padding: 2px 7px;
    border-radius: 2px;
    letter-spacing: 0.8px;
}

.chit-badge-vault { background: transparent; color: var(--col-text-dim); }
.chit-badge-locked { background: rgba(100, 116, 139, 0.2); color: var(--col-text-dim); padding: 4px 10px; border-radius: 12px; }

.gmodal-header {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: 2px solid rgba(142, 108, 70, 0.4);
    padding-bottom: calc(16px * var(--gf-ui-scale));
    margin-bottom: calc(20px * var(--gf-ui-scale));
    padding-right: calc(44px * var(--gf-ui-scale));
    min-height: calc(32px * var(--gf-ui-scale));
}

.gmodal-title {
    font-size: var(--fs-lg);
    color: var(--col-gold);
    letter-spacing: 1.5px;
    line-height: 1.3;
    margin: 0;
}

.gmodal-close {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 4px;
    color: #fff;
    width: calc(32px * var(--gf-ui-scale));
    height: calc(32px * var(--gf-ui-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    font-family: var(--font-hud);
    font-size: var(--fs-md);
    transition: background 0.2s, border-color 0.2s;
}

.gmodal-close:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.8);
}

.ginput {
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid var(--col-cyan);
    color: #fff;
    font-family: var(--font-hud);
    font-size: var(--fs-xl);
    text-align: center;
    padding: calc(8px * var(--gf-ui-scale));
    text-transform: uppercase;
    outline: none;
    width: 100%;
}

#alias-input {
    text-transform: none;
}

/* Leaderboard Tables & Tabs */
.board-cats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(8px * var(--gf-ui-scale));
    margin-bottom: calc(10px * var(--gf-ui-scale));
    padding-bottom: calc(8px * var(--gf-ui-scale));
    border-bottom: 1px solid rgba(0, 242, 254, 0.16);
}

.board-cats-left {
    display: flex;
    gap: calc(6px * var(--gf-ui-scale));
    flex-wrap: wrap;
}

.board-cat-btn {
    font-family: var(--font-hud);
    font-size: var(--fs-xs);
    background: rgba(10, 16, 24, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.28);
    color: var(--col-text-dim);
    padding: calc(5px * var(--gf-ui-scale)) calc(12px * var(--gf-ui-scale));
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.board-cat-btn.active {
    background: rgba(0, 242, 254, 0.22);
    border-color: var(--col-cyan);
    color: #fff;
}

.board-cat-btn.follow-filter.active {
    background: rgba(255, 215, 0, 0.18);
    border-color: var(--col-gold);
    color: var(--col-gold);
}

.board-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: calc(6px * var(--gf-ui-scale));
    margin-bottom: calc(12px * var(--gf-ui-scale));
}

.board-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-hud);
    font-size: var(--fs-xs);
    background: rgba(15, 24, 36, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--col-text-dim);
    padding: calc(6px * var(--gf-ui-scale)) calc(12px * var(--gf-ui-scale));
    cursor: pointer;
    text-transform: uppercase;
}

.board-tab-star {
    color: var(--col-text-dim);
    font-size: var(--fs-sm);
    line-height: 1;
    cursor: pointer;
}

.board-tab-star.starred {
    color: var(--col-gold);
}

.board-tab.active {
    color: #fff;
    border-color: var(--col-cyan);
    background: rgba(0, 242, 254, 0.16);
}

.board-tab.top10-highlight {
    border-color: var(--col-gold);
    color: var(--col-gold);
}

.board-pane { display: none; }
.board-pane.active { display: block; }

.board-card {
    background: rgba(8, 13, 20, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: calc(12px * var(--gf-ui-scale));
}

.board-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-hud);
    font-size: var(--fs-sm);
}

.board-table th {
    border-bottom: 1px solid rgba(0, 242, 254, 0.25);
    padding: calc(6px * var(--gf-ui-scale));
    text-align: left;
    color: var(--col-text-dim);
}

.board-table td {
    padding: calc(6px * var(--gf-ui-scale));
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    height: calc(36px * var(--gf-ui-scale));
    vertical-align: middle;
}

.row-me td { color: var(--col-emerald) !important; }
.row-current td { background: rgba(16, 185, 129, 0.14); }
.age-badge {
    font-size: var(--fs-xs);
    color: var(--col-text-dim);
    margin-left: 6px;
}

/* Personal Best Trophy Cards (All 3 Top PBs grouped per discipline) */
.pb-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
    padding: 6px 0;
}

.pb-trophy-card {
    background: linear-gradient(180deg, rgba(12, 20, 32, 0.92), rgba(6, 10, 16, 0.96));
    border: 1px solid rgba(0, 242, 254, 0.32);
    padding: 12px;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pb-trophy-card.pb-card-highlight {
    border-color: var(--col-gold);
    box-shadow: 0 0 22px rgba(255, 215, 0, 0.25);
}

.pb-card-header {
    font-size: var(--fs-sm);
    color: var(--col-gold);
    letter-spacing: 1.5px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.22);
    padding-bottom: 5px;
    text-align: center;
}

.pb-card-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pb-slot-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.45);
    border-left: 3px solid rgba(100, 116, 139, 0.45);
}

.pb-slot-1 { border-left-color: var(--col-gold); }
.pb-slot-2 { border-left-color: var(--col-cyan); }
.pb-slot-3 { border-left-color: var(--col-amber); }
.pb-slot-current { background: rgba(16, 185, 129, 0.16); }

.pb-medal {
    font-size: var(--fs-xs);
    min-width: 22px;
}
.pb-medal-1 { color: var(--col-gold); }
.pb-medal-2 { color: var(--col-cyan); }
.pb-medal-3 { color: var(--col-amber); }

.pb-slot-val {
    font-size: var(--fs-xs);
    color: #fff;
}

/* Title Acquired Flash Banner */
#title-acquired-flash {
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 265;
    pointer-events: none;
    display: none;
    padding: calc(12px * var(--gf-ui-scale)) calc(28px * var(--gf-ui-scale));
    background: linear-gradient(90deg, rgba(8, 14, 22, 0.96), rgba(20, 32, 48, 0.98), rgba(8, 14, 22, 0.96));
    border: 2px solid var(--col-gold);
    color: var(--col-gold);
    font-family: var(--font-hud);
    font-size: var(--fs-xl);
    letter-spacing: 2.5px;
    text-align: center;
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.85);
    box-shadow: 0 0 42px rgba(255, 215, 0, 0.45), inset 0 0 18px rgba(255, 215, 0, 0.25);
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
    animation: gf-title-flash-anim 3.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes gf-title-flash-anim {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.65);
        filter: brightness(2.5);
    }
    12% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.06);
        filter: brightness(1.6);
    }
    22% {
        transform: translate(-50%, -50%) scale(1.0);
        filter: brightness(1.0);
    }
    82% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -58%) scale(0.96);
    }
}

/* Announcements & Touch Controls */
#server-banner {
    position: absolute;
    top: calc(74px * var(--gf-ui-scale));
    left: 50%;
    transform: translateX(-50%);
    z-index: 260;
    pointer-events: none;
    display: none;
    background: var(--col-cockpit-bg);
    border: 1px solid var(--col-gold);
    color: var(--col-gold);
    padding: calc(8px * var(--gf-ui-scale)) calc(20px * var(--gf-ui-scale));
    font-size: var(--fs-md);
    letter-spacing: 1.5px;
    text-align: center;
}

#playfield-announce {
    position: absolute;
    top: 24%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 85;
    pointer-events: none;
    display: none;
    font-size: var(--fs-2xl);
    letter-spacing: 2px;
    text-shadow: 0 0 22px rgba(0, 0, 0, 0.95);
}

#mode-status-badge {
    position: absolute;
    top: calc(16px * var(--gf-ui-scale));
    left: 50%;
    transform: translateX(-50%);
    z-index: 88;
    pointer-events: auto;
    cursor: pointer;
    display: none;
    background: rgba(14, 22, 32, 0.92);
    border: 1px solid var(--col-amber);
    color: var(--col-amber);
    padding: calc(6px * var(--gf-ui-scale)) calc(16px * var(--gf-ui-scale));
    font-size: var(--fs-sm);
    letter-spacing: 1.5px;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.75);
}

#objective-complete-bar {
    position: absolute;
    top: calc(52px * var(--gf-ui-scale));
    left: 50%;
    transform: translateX(-50%);
    z-index: 89;
    pointer-events: auto;
    display: none;
    align-items: center;
    gap: calc(12px * var(--gf-ui-scale));
    background: rgba(9, 18, 26, 0.94);
    border: 1px solid var(--col-emerald);
    color: var(--col-emerald);
    padding: calc(6px * var(--gf-ui-scale)) calc(14px * var(--gf-ui-scale));
    font-size: var(--fs-sm);
    letter-spacing: 1.4px;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.85);
}

#touch-controls {
    position: absolute;
    bottom: calc(28px * var(--gf-ui-scale));
    left: calc(28px * var(--gf-ui-scale));
    right: calc(28px * var(--gf-ui-scale));
    display: none;
    justify-content: space-between;
    z-index: 60;
    pointer-events: none;
}

@media (hover: none) and (pointer: coarse) {
    #touch-controls { display: flex; }
}

.tbtn {
    width: calc(68px * var(--gf-ui-scale));
    height: calc(68px * var(--gf-ui-scale));
    background: var(--col-cockpit-panel);
    border: 1px solid var(--col-cyan);
    color: #fff;
    font-size: var(--fs-xl);
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 calc(8px * var(--gf-ui-scale));
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.tbtn-fire {
    width: calc(84px * var(--gf-ui-scale));
    height: calc(84px * var(--gf-ui-scale));
    border-color: var(--col-crimson);
    background: rgba(239, 68, 68, 0.35);
}

.dpad, .action-pad { display: flex; align-items: flex-end; }