/* ═══════════════════════════════════════════════════════════════════════════
   OFFSHORE RACING — Professional Nautical UI
   Inspired by B&G / Raymarine instrument aesthetics
   ═══════════════════════════════════════════════════════════════════════════ */

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

:root {
    /* ── Core palette ──────────────────────────────────────────────────── */
    --bg-deep:       #020810;
    --bg-panel:      rgba(6, 14, 32, 0.88);
    --bg-glass:      rgba(6, 18, 40, 0.45);
    --bg-inset:      rgba(4, 10, 26, 0.70);
    --bg-hover:      rgba(15, 30, 65, 0.80);

    /* B&G-style instrument colors */
    --inst-bg:       rgba(0, 8, 22, 0.40);
    --inst-border:   rgba(0, 185, 210, 0.30);
    --inst-glow:     rgba(0, 185, 210, 0.12);

    /* Accent palette */
    --accent-cyan:         #00b9d2;
    --accent-cyan-bright:  #00d4f0;
    --accent-cyan-dim:     rgba(0, 185, 210, 0.5);
    --accent-cyan-hover:   #00cce8;
    --accent-orange:       #e8810a;
    --accent-orange-dim:   rgba(232, 129, 10, 0.5);
    --accent-green:        #1ec86d;
    --accent-green-dim:    rgba(30, 200, 109, 0.4);
    --accent-violet:       #8b78f0;
    --accent-sky:          #29aadf;
    --accent-mint:         #22d3a4;
    --accent-amber:        #f5a623;

    /* Text */
    --text-primary:   #e8f0fa;
    --text-secondary: #6e8aad;
    --text-dim:       rgba(110, 138, 173, 0.55);
    --text-bright:    #ffffff;

    /* Borders */
    --border-subtle:  rgba(255, 255, 255, 0.06);
    --border-medium:  rgba(255, 255, 255, 0.12);
    --border-strong:  rgba(255, 255, 255, 0.20);
    --border-cyan:    rgba(0, 185, 210, 0.35);
    --border-orange:  rgba(232, 129, 10, 0.35);
    --border-green:   rgba(30, 200, 109, 0.35);

    /* Status */
    --status-green: #1ec86d;
    --status-red:   #e84545;

    /* Spacing */
    --gap-xs: 4px;
    --gap-sm: 8px;
    --gap-md: 12px;
    --gap-lg: 16px;
    --gap-xl: 24px;

    /* Typography */
    --text-xs:   10px;
    --text-sm:   11px;
    --text-base: 13px;
    --text-lg:   15px;
    --text-xl:   18px;
    --text-2xl:  24px;

    /* Radius */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  18px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-panel: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255,255,255,0.1);
    --shadow-card:  0 4px 16px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255,255,255,0.1);
    --shadow-glow-cyan:   none;
    --shadow-glow-orange: none;
    --shadow-glow-green:  none;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-med:  0.25s ease;
    --transition-slow: 0.4s ease;
}

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

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-deep);
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#cesiumContainer {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
}

/* Cesium cleanup */
.cesium-widget-credits { display: none !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
@keyframes chip-appear {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slide-up {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes dot-pulse {
    0%, 100% { opacity: 0.8; }
    50%      { opacity: 1; }
}
@keyframes dot-pulse-orange {
    0%, 100% { opacity: 0.8; }
    50%      { opacity: 1; }
}
@keyframes wp-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes compass-glow-pulse {
    0%, 100% { box-shadow: 0 0 0 1px var(--border-cyan), inset 0 0 10px rgba(0,0,0,0.5); }
    50%      { box-shadow: 0 0 0 1px var(--accent-cyan), inset 0 0 10px rgba(0,0,0,0.5); }
}
    50%      { box-shadow: 0 0 0 1px var(--accent-cyan-bright), inset 0 0 30px rgba(0,0,0,0.9), 0 0 20px rgba(0,185,210,0.15); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   OVERLAY & UI STRUCTURE
   ═══════════════════════════════════════════════════════════════════════════ */
#ui-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GLASS PANEL — Base component
   ═══════════════════════════════════════════════════════════════════════════ */
.glass-panel {
    background: rgba(6, 18, 40, 0.45);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: var(--gap-lg);
    pointer-events: auto;
    box-shadow: var(--shadow-card);
    position: relative;
}

/* Top edge highlight — glass feel */
.glass-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 16px; right: 16px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
    border-radius: var(--radius-pill);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════════════ */
h1, h2, h3 { margin: 0; }

h1 {
    font-size: var(--text-lg);
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text-bright);
}

h2 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   WS STATUS
   ═══════════════════════════════════════════════════════════════════════════ */
#ws-text {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    margin-left: auto;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot.connected {
    background-color: var(--status-green);
    box-shadow: 0 0 8px var(--status-green);
    animation: dot-pulse 2.5s ease-in-out infinite;
}

.dot.disconnected {
    background-color: var(--status-red);
    box-shadow: 0 0 8px var(--status-red);
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
}



/* ═══════════════════════════════════════════════════════════════════════════
   STATUS BADGE
   ═══════════════════════════════════════════════════════════════════════════ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--gap-xs);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.4px;
    background: rgba(232, 129, 10, 0.1);
    color: var(--accent-orange);
    border: 1px solid var(--border-orange);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════════════════ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

input, select {
    background: rgba(4, 10, 26, 0.80);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 9px 12px;
    font-family: 'Inter', sans-serif;
    font-size: var(--text-sm);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    width: 100%;
    box-sizing: border-box;
}

input:focus, select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(0, 185, 210, 0.15);
}

label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.neon-btn {
    background: rgba(0, 185, 210, 0.15);
    color: var(--accent-cyan);
    border: 1px solid var(--border-cyan);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1;
    position: relative;
}

.neon-btn:hover:not(:disabled) {
    background: rgba(0, 185, 210, 0.25);
    border-color: var(--accent-cyan-bright);
    color: #fff;
}

.neon-btn:active:not(:disabled) { background: rgba(0, 185, 210, 0.35); }

.neon-btn.secondary {
    background: rgba(232, 129, 10, 0.1);
    border: 1px solid var(--border-orange);
    color: var(--accent-orange);
    font-weight: 600;
}

.neon-btn.secondary:hover:not(:disabled) {
    background: rgba(232, 129, 10, 0.2);
    border-color: var(--accent-orange);
    color: #fff;
}

.neon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FEEDBACK
   ═══════════════════════════════════════════════════════════════════════════ */
.feedback {
    font-size: 10px;
    min-height: 12px;
    text-align: center;
    font-weight: 600;
}

.feedback.success { color: var(--status-green); }
.feedback.error   { color: var(--status-red); }

.race-feedback {
    font-size: 10px;
    min-height: 12px;
    text-align: center;
    font-weight: 600;
}
.race-feedback.success { color: var(--status-green); }
.race-feedback.error   { color: var(--status-red); }

/* ═══════════════════════════════════════════════════════════════════════════
   HEADER BAR (full browser width: title · centred menu · status)
   ═══════════════════════════════════════════════════════════════════════════ */
.app-header {
    position: absolute;
    top: 16px; left: 16px; right: 16px;     /* floating: full width, inset from the edges */
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 1fr auto 1fr;   /* title | centred nav | status */
    align-items: center;
    gap: var(--gap-md);
    padding: 10px 20px;
    pointer-events: auto;
    z-index: 200;
    background: var(--bg-glass);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    animation: card-in 0.4s ease;
}
.hdr-title { justify-self: start; white-space: nowrap; }
.hdr-right { justify-self: end; display: flex; align-items: center; gap: var(--gap-md); }

/* Centre menu — text links with the same hover/active treatment the navbar had. */
.hdr-nav {
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 4px;
}
.hdr-link {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.hdr-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.08); }
.hdr-link.active { color: var(--accent-cyan); background: rgba(0,185,210,0.12); }

/* Hamburger — hidden on desktop, shown on mobile. */
.hdr-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px; height: 34px;
    padding: 8px;
    box-sizing: border-box;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.hdr-burger span {
    display: block;
    width: 100%; height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
}

@media (max-width: 1023px) {
    .app-header {
        top: 12px; left: 12px; right: 12px;   /* floating, tighter inset on mobile */
        grid-template-columns: 1fr auto;   /* title | (status + burger); nav floats out of flow */
        padding: 10px 14px;
    }
    .hdr-burger { display: flex; }
    #ws-text { display: none; }             /* the dot conveys status on mobile; text is desktop-only */
    .eng-label { display: none; }           /* engine pulse dot is enough on mobile; label is desktop-only */
    /* Nav collapses into a dropdown panel under the header, toggled by the burger. */
    .hdr-nav {
        position: absolute;
        top: 100%;
        right: 0;
        left: auto;
        margin-top: 8px;
        min-width: 180px;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 8px;
        background: rgba(6, 18, 40, 0.94);   /* opaque so links read clearly over the globe */
        backdrop-filter: blur(16px) saturate(1.2);
        -webkit-backdrop-filter: blur(16px) saturate(1.2);
        border: 1px solid rgba(255,255,255,0.18);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-panel);
        display: none;
    }
    .hdr-nav.open { display: flex; }
    .hdr-link {
        padding: 11px 12px;
        text-align: left;
        font-size: 14px;
        color: var(--text-primary);          /* full-contrast in the dropdown, not muted */
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TELEMETRY CARD — B&G / Raymarine style
   ═══════════════════════════════════════════════════════════════════════════ */
#telemetry-card {
    background: rgba(6, 18, 40, 0.45);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 10px 12px;
    pointer-events: auto;
    box-shadow: var(--shadow-panel);
    position: relative;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* While a heading/TWA command is staged (pre-Apply), the card shows PREDICTED
   instruments — flag it with an amber accent + corner badge so the player knows
   these aren't live server values yet. Cleared on Apply-confirm or Cancel. */
#telemetry-card.staged-preview {
    border-color: rgba(245, 166, 35, 0.7);
    box-shadow: var(--shadow-panel), 0 0 0 1px rgba(245, 166, 35, 0.35) inset;
}
#telemetry-card.staged-preview::after {
    content: "PREDICTED";
    position: absolute;
    top: -7px;
    right: 10px;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #06122a;
    background: var(--accent-amber);
    padding: 1px 5px;
    border-radius: 6px;
    pointer-events: none;
}

/* ── Keyboard key chips (info card shortcuts) ──────────────────────────────── */
.kbd {
    display: inline-block;
    min-width: 18px;
    padding: 2px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-bottom-width: 2px;
    border-radius: 5px;
}

/* ── Map animation mode toggle (Off / Wind / Currents) ─────────────────────── */
.anim-mode-toggle {
    display: flex;
    gap: 0;
    margin-top: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}
.anim-mode-btn {
    flex: 1;
    padding: 6px 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    font-size: var(--text-xs, 11px);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.anim-mode-btn:last-child { border-right: none; }
.anim-mode-btn:hover { background: rgba(255, 255, 255, 0.10); color: var(--text-primary); }
.anim-mode-btn.active {
    background: var(--accent-cyan, #00b9d2);
    color: #06122a;
}
.anim-mode-btn[data-anim-mode="current"].active {
    background: #48cae4;   /* water teal so the active state reads as "currents" */
}

.tc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0,185,210,0.12);
    cursor: default;
}

.tc-boatname {
    font-size: var(--text-base);
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.tc-coords {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 9px;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 2px;
    letter-spacing: 0.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Telemetry-header timer (elapsed / countdown). Kept compact so it never
   squeezes the boat name + coordinates into a second row. */
#global-countdown {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.tc-status-pill {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    background: rgba(0, 185, 210, 0.10);
    color: var(--accent-cyan);
    border: 1px solid var(--border-cyan);
    flex-shrink: 0;
}

.tc-status-pill.grounded {
    background: rgba(232, 68, 68, 0.12);
    color: #e84545;
    border-color: rgba(232, 68, 68, 0.35);
}

.tc-section-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(0, 212, 240, 0.75);
    margin: 6px 0 var(--gap-xs);
    padding-left: 2px;
}

/* 3-column layout */
.tc-columns-container {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr;
    gap: var(--gap-sm);
}

.tc-column { min-width: 0; }

/* Instrument cells — B&G style */
.tc-instr-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
}

.tc-instr {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    background: var(--inst-bg);
    border: 1px solid rgba(0,185,210,0.12);
    border-radius: var(--radius-sm);
    padding: 5px 9px;
    position: relative;
    overflow: hidden;
}

/* Subtle left accent bar on instrument */
.tc-instr::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 2px;
    background: var(--accent-cyan-dim);
    border-radius: 1px;
}

.tc-lbl {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(232, 240, 250, 0.60);
}

.tc-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.5px;
}
.tc-val.cyan   { color: #2ee4ff; text-shadow: 0 0 10px rgba(46, 228, 255, 0.35); }
.tc-val.mint   { color: #34f0c0; text-shadow: 0 0 10px rgba(52, 240, 192, 0.35); }
.tc-val.sky    { color: #4fc7ff; text-shadow: 0 0 10px rgba(79, 199, 255, 0.35); }
.tc-val.violet { color: #b3a3ff; text-shadow: 0 0 10px rgba(179, 163, 255, 0.35); }

.tc-unit {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    color: rgba(232, 240, 250, 0.50);
    font-weight: 600;
    margin-left: 2px;
}

.tc-val-row {
    display: flex;
    align-items: baseline;
    gap: 1px;
}

/* Wind / Current env panels */
.tc-env-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap-xs);
    padding: var(--gap-sm) var(--gap-xs);
    background: var(--inst-bg);
    border: 1px solid rgba(0,185,210,0.12);
    border-radius: var(--radius-sm);
}

.tc-env-vals { width: 100%; }

.tc-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 2px var(--gap-xs);
    gap: var(--gap-xs);
}

.tc-row .tc-lbl { width: auto; }

.tc-arrow-ring {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 185, 210, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tc-curr-ring { border-color: rgba(139, 120, 240, 0.25); }

.tc-arrow-svg {
    width: 20px;
    height: 20px;
    display: block;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.tc-cardinal {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    font-weight: 700;
    color: rgba(0, 185, 210, 0.8);
    letter-spacing: 0.5px;
}

.tc-arrow-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.twa-side-badge {
    display: inline-block;
    margin-left: 3px;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.twa-side-badge.port {
    background: rgba(232, 68, 68, 0.15);
    color: #e84545;
    border: 1px solid rgba(232, 68, 68, 0.3);
}

.twa-side-badge.stbd {
    background: rgba(30, 200, 109, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(30, 200, 109, 0.3);
}

.tc-mobile-summary { display: none; }
.tc-mobile-toggle  { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   COMMANDER — Command Panel Card
   ═══════════════════════════════════════════════════════════════════════════ */
.commander {
    display: none;
    width: 320px;
    box-sizing: border-box;
    flex-direction: column;
    gap: 0;
    position: absolute;
    bottom: 20px;
    right: 20px;
    left: auto;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    background: rgba(6, 18, 40, 0.45);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    padding: 12px 14px;
    pointer-events: auto;
}
.commander.show { display: flex; }

/* ═══════════════════════════════════════════════════════════════════════════
   RACES CARD (Centered Floating Panel)
   ═══════════════════════════════════════════════════════════════════════════ */
.races-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(600px, 94vw);   /* wider on desktop; clamps to viewport on mobile */
    background: rgba(6, 18, 40, 0.45);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    padding: var(--gap-lg);
    pointer-events: auto;
    z-index: 100;
}

.races-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-md);
    padding-bottom: var(--gap-sm);
    border-bottom: 1px solid var(--border-subtle);
}

.races-header h3 {
    margin: 0;
    font-size: var(--text-md);
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMMAND CARD — Compact, task-focused layout
   ═══════════════════════════════════════════════════════════════════════════ */

/* Main command layout: wide flex row */
/* Boat / Maneuver tab switcher */
.cmd-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    background: rgba(0,0,0,0.25);
    border-radius: var(--radius-pill);
    padding: 3px;
}
.cmd-tab {
    flex: 1;
    padding: 5px 8px;
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.cmd-tab:hover {
    color: var(--text-primary);
}
.cmd-tab.active {
    background: rgba(0,185,210,0.15);
    color: var(--accent-cyan);
}

/* ── Profile hub ──────────────────────────────────────────────────────── */
.hub-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.12) inset;
}
.hub-stat-grid {
    display: flex;
    gap: 8px;
}
.hub-stat {
    flex: 1;
    background: rgba(0,0,0,0.25);
    border-radius: 10px;
    padding: 12px 6px;
    text-align: center;
}
.hub-stat-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}
.hub-stat-lbl {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-top: 4px;
}
.hub-elo-pos { color: #34d399; }
.hub-elo-neg { color: #f87171; }
.hub-elo-zero { color: var(--text-secondary); }

/* Two-column command body: compact controls (left) + big compass (right). */
.cmd-body-2col {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 11px;
    margin-bottom: 0;
}

/* The visible boat name now lives in the telemetry card; keep #my-boat-chip in the DOM
   (commander.js writes the name into it + toggles its display) but pull it out of flow
   so it never adds a row or a flex gap to the card. */
#my-boat-chip {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Compass container — the PRIMARY steering input, so it gets the right column and as
   much size as the 320px card allows. The compact button grid on the left needs ~150px
   for three columns; the rest (~132px) goes to the compass. Vertically centred against
   the taller left column. */
#compass-rose-container {
    flex: 0 0 132px;
    width: 132px;
    height: 132px;
    align-self: center;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}
#compass-rose-container svg {
    width: 100%;
    height: 100%;
}

/* Left control column — takes the remaining width beside the compass. */
.cmd-left-col {
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex: 1 1 0;
    min-width: 0;
    justify-content: flex-start;
}

/* Compact 3×2 action grid. Fixed cell rows keep the card short; grid-template-areas
   place each button by name so DOM order (Apply/Cancel wrapped together) is free to
   differ from visual order. */
.cmd-btn-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 32px;
    gap: 5px;
    grid-template-areas:
        "apply  fly orbit"
        "cancel twa tack";
}

/* Generic compact card button — shared shell for all six grid buttons. Glass theme to match
   the site's .glass-panel / .hdr-link language: a frosted translucent fill (NOT an opaque
   dark box), Inter uppercase, one 8px size so every label fits on a single line and all six
   boxes read identically. */
.cmd-gbtn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    min-width: 0;
    padding: 0 1px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--text-primary);
    border-radius: 7px;
    font-family: 'Inter', sans-serif;
    font-size: 7.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.05;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.cmd-gbtn:hover { border-color: rgba(255, 255, 255, 0.30); background: rgba(255, 255, 255, 0.13); color: #fff; }
.cmd-gbtn:active { transform: translateY(1px); }

/* Active state — TWA lock engaged (#cmd-twa-row) or orbit-cam engaged (#btn-orbit-cam):
   a cyan glass tint (frosted, not a solid block) so it reads active while staying on-theme. */
.cmd-gbtn.active {
    background: rgba(0, 185, 210, 0.28);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan-bright);
}
.cmd-gbtn.active:hover {
    background: rgba(0, 185, 210, 0.40);
    border-color: var(--accent-cyan-bright);
    color: #fff;
}

#compass-rose-svg {
    border-radius: 50%;
    background: rgba(0, 8, 22, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 4px 10px rgba(0,0,0,0.3);
    touch-action: none;
    cursor: crosshair;
    display: block;
}

/* ── Helm-rose redesign: needle easing + effect animations ───────────────────── */
/* Smooth glide for data-driven needles (COG/wind/current). The heading lubber's own
   easing is set inline and disabled during a finger-drag for 1:1 tracking. */
#cr-cog-needle, #cr-twa-needle, #cr-cur-needle { transition: transform 0.4s cubic-bezier(.3,.7,.2,1); }
#cr-twa-needle, #cr-cur-needle, #cr-data-arc, #cr-pulse, #cr-hdg-needle, #cr-hdg-tip { pointer-events: none; }
#cr-data-arc { filter: drop-shadow(0 0 3px rgba(0,0,0,0.6)); transition: stroke-width .2s ease; }

/* Amber pulse ring loops while a command is staged — mirrors the telemetry card's
   amber "predicted" state, so the rose flashes whenever input is pending. */
#cr-pulse.cr-pulse-loop { animation: crPulseLoop 1.3s ease-in-out infinite; }
@keyframes crPulseLoop {
    0%, 100% { opacity: .30; filter: none; }
    50%      { opacity: .95; filter: drop-shadow(0 0 5px rgba(245,166,35,0.85)); }
}
/* One-shot amber flash (discrete inputs via flashInput()). */
#cr-pulse.cr-flash { animation: crFlash .55s ease-out; }
@keyframes crFlash {
    0%   { opacity: .75; transform: scale(.82); }
    100% { opacity: 0;   transform: scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
    #cr-pulse.cr-pulse-loop, #cr-pulse.cr-flash { animation: none; }
}

/* Live degree readout centered inside compass */
.cmd-hdg-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -55%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    gap: 1px;
}

.cmd-hdg-center-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -1px;
    line-height: 1;
}

.cmd-hdg-center-unit {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Status & Legend Row */
.cmd-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 4px;
}

/* Row 1 of the left column. Idle = collapsed to zero height (no reserved blank line);
   any real state (pending/committed/submitting/error/editing) expands it. */
.cmd-readout-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--accent-orange);
    height: 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s;
}

.cmd-readout-status.pending,
.cmd-readout-status.committed,
.cmd-readout-status.submitting,
.cmd-readout-status.error,
.cmd-readout-status.editing {
    height: auto;
    opacity: 1;
}
.cmd-readout-status.committed { color: var(--accent-green); }
.cmd-readout-status.submitting {
    color: var(--accent-cyan);
    animation: pulse 1s infinite alternate;
}
.cmd-readout-status.error { color: var(--status-red); }

.cmd-compass-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

/* Bottom Actions Row */
.cmd-action-row {
    display: flex;
    align-items: stretch;
    width: 100%;
    gap: 8px;
    height: 32px;
}

/* TWA lock mini */
.cmd-twa-mini {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,8,22,0.70);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.cmd-twa-mini:hover {
    border-color: rgba(255,255,255,0.18);
}

/* TWA-lock ON changes ONLY the toggle switch (below), not the whole row — the label and
   box stay identical to the off state, just like the Anemometer toggle. */

.cmd-twa-label-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* (label stays var(--text-primary) when active — only the toggle switch recolours) */

/* custom toggle */
.cmd-twa-toggle {
    width: 32px;
    height: 18px;
    border-radius: 9px;
    background: rgba(255,255,255,0.12);
    border: 1px solid var(--border-medium);
    position: relative;
    flex-shrink: 0;
    transition: all 0.25s;
}

.cmd-twa-toggle::after {
    content: '';
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: rgba(255,255,255,0.6);
    top: 2px; left: 2px;
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

.cmd-twa-mini.active .cmd-twa-toggle {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.cmd-twa-mini.active .cmd-twa-toggle::after {
    transform: translateX(14px);
    background: #fff;
    box-shadow: none;
}

/* TWA-lock toggle + Tack/gybe share one row; the toggle flexes, tack is a fixed square. */
.cmd-twa-tack-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
}
.btn-tack-mini {
    flex: 0 0 auto;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,8,22,0.70);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}
.btn-tack-mini:hover { border-color: rgba(255,255,255,0.18); background: rgba(0,185,210,0.14); }
.btn-tack-mini:active { transform: scale(0.96); }

/* Apply + Cancel wrapper. display:contents removes the wrapper box so the two buttons
   become direct items of .cmd-btn-grid (placed via grid-area). commander.js still toggles
   this element's display to hide BOTH buttons during a maneuver-node edit. */
.cmd-apply-row {
    display: contents;
}

/* Apply / Cancel are coloured by COMMAND STATUS (driven by _syncApplyButtons in
   commander.js): pending → Apply green + Cancel red; submitting/committed → both greyed
   (disabled). Cancel is only shown while a command is staged. */
.btn-cancel-mini, .btn-apply-mini {
    font-size: 7.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    border-radius: 7px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
}
.btn-cancel-mini:active:not(:disabled), .btn-apply-mini:active:not(:disabled) {
    transform: translateY(1px);
}

/* Cancel — shown only while pending, so its resting state is RED. */
.btn-cancel-mini {
    background: rgba(220, 38, 38, 0.12);
    color: #ff6b6b;
    border: 1px solid rgba(220, 38, 38, 0.50);
}
.btn-cancel-mini:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.25);
    color: #fff;
    border-color: rgba(220, 38, 38, 0.75);
}

/* Apply — idle/committed is greyed (disabled); pending is GREEN (.is-ready). */
.btn-apply-mini {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}
.btn-apply-mini.is-ready {
    background: rgba(30, 200, 109, 0.16);
    color: var(--accent-green);
    border-color: rgba(30, 200, 109, 0.55);
}
.btn-apply-mini.is-ready:hover:not(:disabled) {
    background: rgba(30, 200, 109, 0.28);
    color: #fff;
    border-color: var(--accent-green);
}

/* Greyed-out state for submitting/committed (both buttons). */
.btn-apply-mini:disabled, .btn-cancel-mini:disabled, .btn-cancel-mini.is-busy {
    opacity: 0.4;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-subtle);
    cursor: not-allowed;
}

/* Legacy aliases kept for JS compat */
.btn-twa-lock { display: none !important; }
.heading-display { display: none !important; }
.heading-value-box { display: none !important; }
.heading-value-num { display: none !important; }
.heading-value-deg { display: none !important; }
.heading-value-label { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   MANEUVER SECTION
   ═══════════════════════════════════════════════════════════════════════════ */
/* Shown as a tab pane next to cmd-body-wide — no separator needed */
.maneuver-section {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.maneuver-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 8px;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--gap-sm);
    font-family: 'JetBrains Mono', monospace;
}

.maneuver-list {
    display: flex;
    flex-direction: column;
    gap: var(--gap-xs);
    margin-bottom: var(--gap-md);
}

.maneuver-node {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--inst-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 7px var(--gap-sm);
    font-size: 10px;
    gap: var(--gap-xs);
}

.maneuver-node .node-index { color: var(--accent-cyan); font-weight: 800; margin-right: var(--gap-xs); font-family: 'JetBrains Mono', monospace; }
.maneuver-node .node-desc  { color: var(--text-primary); flex: 1; font-size: 10px; }
.maneuver-node .node-time  { color: var(--accent-orange); font-weight: 700; margin-right: var(--gap-xs); font-size: 9px; font-family: 'JetBrains Mono', monospace; }

.maneuver-node .btn-remove-node {
    background: transparent;
    border: none;
    color: var(--status-red);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}
.maneuver-node .btn-remove-node:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════════════
   MANEUVERS — merged into the command card (chips + inline stepper editor)
   ═══════════════════════════════════════════════════════════════════════════ */
.mnv-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}
.mnv-title {
    color: var(--accent-cyan);
    font-size: 14px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}
/* Node-slot row — three slots aligned under the three button columns above. Each chip is
   one-third of the row width (minus the two 5px gaps); a 4th+ chip overflows and the row
   scrolls horizontally, same as before. */
.mnv-chips {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: thin;
}
.mnv-chips::-webkit-scrollbar { height: 5px; }
.mnv-chips::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }

/* Scroll mode (≥ 3 maneuvers): the row itself stops scrolling — the add (+) is pinned
   one slot wide on the left and the numbered chips ride in their own scroller (.mnv-scroll)
   so only the maneuvers move. JS sets each chip's flex-basis to the measured slot width so
   they stay aligned with the button columns above. */
.mnv-chips.scroll-mode {
    overflow: hidden;
}
.mnv-chips.scroll-mode .mnv-add-fixed {
    flex-shrink: 0;
}
.mnv-scroll {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 3px;
    scrollbar-width: thin;
}
.mnv-scroll::-webkit-scrollbar { height: 5px; }
.mnv-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }

.mnv-chip {
    flex: 0 0 calc((100% - 10px) / 3);
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mnv-chip.filled {
    background: rgba(0,185,210,0.14);
    border: 1px solid rgba(0,185,210,0.5);
    color: var(--accent-cyan-bright);
}
/* Hover a numbered node → brighten to signal it opens the editor. */
.mnv-chip.filled:hover {
    background: rgba(0,185,210,0.28);
    border-color: var(--accent-cyan);
}
/* Selected (open) node → solid AMBER + glow. Cyan hover is invisible on touch, so the
   selected state carries the signal: amber stands clear of the all-cyan card, matching
   the amber the telemetry card uses for predicted courses. */
.mnv-chip.filled.sel {
    background: var(--accent-amber);
    border-color: var(--accent-amber);
    color: #3a2400;
    box-shadow: 0 0 10px rgba(245, 166, 35, 0.45);
}
/* Hover the selected (open) node → brighten slightly to signal a re-click closes the editor. */
.mnv-chip.filled.sel:hover {
    background: #ffb733;
    border-color: #ffb733;
}
.mnv-chip.add {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.18);
    color: var(--text-secondary);
}
.mnv-chip.add:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.mnv-chip.empty {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    cursor: default;
}

/* Inline editor */
.mnv-editor { margin-top: 4px; }
.mnv-edit-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.mnv-edit-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}
.mnv-edit-actions { display: flex; align-items: center; gap: 10px; }

/* HDG ⇄ TWA type toggle */
.mnv-type2 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}
.mnv-type2-lbl { color: var(--text-secondary); transition: color 0.15s; }
.mnv-type2-track {
    width: 32px;
    height: 18px;
    border-radius: 9px;
    background: rgba(255,255,255,0.14);
    position: relative;
    transition: background 0.2s;
}
.mnv-type2-knob {
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #fff;
    top: 3px; left: 3px;
    transition: left 0.18s;
}
/* HDG selected (knob left) */
.mnv-type2.is-hdg #mnv-lbl-hdg, .mnv-type2.is-hdg .mnv-type2-lbl:first-child { color: var(--accent-cyan-bright); }
.mnv-type2.is-hdg .mnv-type2-track { background: var(--accent-cyan); }
/* TWA selected (knob right) */
.mnv-type2.is-twa #mnv-lbl-twa { color: #48cae4; }
.mnv-type2.is-twa .mnv-type2-track { background: #48cae4; }
.mnv-type2.is-twa .mnv-type2-knob { left: 17px; }

/* Trash-bin delete button */
.mnv-del {
    background: transparent;
    border: none;
    color: var(--status-red);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    transition: opacity 0.15s;
}
.mnv-del:hover { opacity: 1; }

/* Stepper row: 6 buttons + a compact readout. min-width:0 lets the buttons shrink
   so the readout box never pushes out of the 320px card. */
.mnv-step-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.mnv-steppers {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 4px;
}
.mnv-steppers button {
    flex: 1 1 0;
    min-width: 0;
    padding: 5px 0;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.mnv-steppers button:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.mnv-steppers button:active { transform: scale(0.95); }
/* "tack/gybe" takes ~two button slots and a smaller label so it fits on one line. */
.mnv-steppers .mnv-tack {
    flex: 2 1 0;
    font-size: 9px;
    letter-spacing: 0;
    white-space: nowrap;
    color: var(--accent-cyan);
    border-color: rgba(0,185,210,0.30);
}
.mnv-steppers .mnv-tack:hover { background: rgba(0,185,210,0.14); color: #fff; }
.mnv-readout {
    flex: 0 0 46px;
    text-align: center;
    padding: 5px 2px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-cyan-bright);
    white-space: nowrap;
}

/* ── Task 4 — Edit node button */
.btn-edit-node {
    background: transparent;
    border: none;
    color: var(--accent-cyan);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}
.btn-edit-node:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════════════
   FLY TO ROW
   ═══════════════════════════════════════════════════════════════════════════ */
.cmd-fly-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 185, 210, 0.08);
    border: 1px solid rgba(0, 185, 210, 0.2);
    border-radius: var(--radius-sm);
    padding: 0 6px 0 8px;
    height: 32px;
}

.cmd-fly-name {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-cyan);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
}

.btn-fly-mini {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 6px;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;   /* never wrap "Fly To" onto a second line */
}

.btn-fly-mini:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
}

/* Tiny camera button sits next to "Fly To"; padding tightened so the icon-only
   button stays compact. Active = orbit mode engaged. */
.btn-cam-mini {
    padding: 4px;
}

.btn-cam-mini.active {
    color: #00121a;
    background: var(--accent-cyan);
    border-radius: var(--radius-sm);
}

.btn-cam-mini.active:hover {
    color: #00121a;
    background: var(--accent-cyan);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RACE PANEL
   ═══════════════════════════════════════════════════════════════════════════ */
.race-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Race selector */
#race-select {
    width: 100%;
    box-sizing: border-box;
    font-size: 11px;
    padding: 8px 10px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

#race-select option {
    background: #0a1428;
    color: #e2e8f0;
}

/* Active race chip */
.active-race-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-sm);
    padding: 8px var(--gap-md);
    background: rgba(232, 129, 10, 0.08);
    border: 1px solid var(--border-orange);
    border-radius: var(--radius-md);
}

.arc-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.arc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-orange);
    box-shadow: var(--shadow-glow-orange);
    flex-shrink: 0;
    animation: dot-pulse-orange 2.5s ease-in-out infinite;
}

.arc-name {
    font-size: var(--text-xs);
    font-weight: 800;
    color: var(--accent-orange);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.arc-leave {
    flex-shrink: 0;
    padding: 4px 8px;
    font-size: 9px;
    border-color: rgba(232, 129, 10, 0.45);
    color: rgba(232, 129, 10, 0.85);
}

.arc-leave:hover {
    background: rgba(232, 129, 10, 0.15) !important;
    box-shadow: 0 0 10px rgba(232, 129, 10, 0.25) !important;
}

/* Practice mode chip variant */
.active-race-chip.practice-mode {
    background: rgba(15,25,52,0.60);
    border-color: var(--border-medium);
}

.active-race-chip.practice-mode .arc-dot {
    background: var(--text-secondary);
    box-shadow: none;
    animation: none;
}

.active-race-chip.practice-mode .arc-name { color: var(--text-secondary); }
.active-race-chip.practice-mode .arc-leave {
    border-color: var(--border-medium);
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LEADERBOARD
   ═══════════════════════════════════════════════════════════════════════════ */
#leaderboard-section { margin-top: 4px; }

.lb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.lb-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-family: 'JetBrains Mono', monospace;
}

.lb-refresh-btn {
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 10px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}
.lb-refresh-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}

.lb-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 700;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lb-table td {
    padding: 6px 6px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
    font-size: var(--text-xs);
}

.lb-table tr:last-child td { border-bottom: none; }
.lb-table tr:hover td     { background: rgba(15,30,65,0.60); }

.rank-medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 10px;
}

.rank-1 { background: rgba(255,215,0,0.2);   color: #ffd700; box-shadow: 0 0 6px rgba(255,215,0,0.3); }
.rank-2 { background: rgba(192,192,192,0.2); color: #c0c0c0; box-shadow: 0 0 6px rgba(192,192,192,0.2); }
.rank-3 { background: rgba(205,127,50,0.2);  color: #cd7f32; box-shadow: 0 0 6px rgba(205,127,50,0.2); }
.rank-n { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

.lb-wp-badge {
    display: inline-block;
    background: rgba(0, 185, 210, 0.1);
    border: 1px solid var(--border-cyan);
    color: var(--accent-cyan);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    font-size: 9px;
    font-weight: 800;
}

.lb-finish-badge {
    display: inline-block;
    background: rgba(30,200,109,0.12);
    border: 1px solid rgba(30,200,109,0.3);
    color: var(--accent-green);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 9px;
    font-weight: 700;
}

.lb-my-row td { background: rgba(30, 200, 109, 0.05) !important; }

.lb-me-badge {
    display: inline-block;
    background: rgba(30, 200, 109, 0.18);
    border: 1px solid rgba(30, 200, 109, 0.4);
    color: var(--accent-green);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-right: 3px;
    vertical-align: middle;
}



/* ═══════════════════════════════════════════════════════════════════════════
   OBSERVER NOTICE
   ═══════════════════════════════════════════════════════════════════════════ */
.observer-notice {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
    padding: var(--gap-lg);
    background: rgba(4,10,26,0.70);
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: var(--gap-sm);
}

.obs-icon { font-size: 20px; opacity: 0.8; }
.obs-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.obs-sub { font-size: 10px; color: var(--text-secondary); line-height: 1.4; }

/* ═══════════════════════════════════════════════════════════════════════════
   BOTTOM NAVBAR
   ═══════════════════════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════════════════════
   TOOLS MENU
   ═══════════════════════════════════════════════════════════════════════════ */
.tools-menu {
    position: absolute;
    bottom: 20px;
    left: var(--gap-lg);
    z-index: 100;
    min-width: 180px;
    border-radius: var(--radius-lg);
    background: var(--bg-glass);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-panel);
    padding: 12px 14px;
    display: none;
    pointer-events: auto;
    animation: card-in 0.2s ease;
}

.tools-menu .switch {
    transform: scale(0.85);
    margin-right: -4px;
}

.tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-sm);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.tools-header h3 {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'JetBrains Mono', monospace;
}

.tools-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--gap-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Forecast steppers (GFS wind / HYCOM current) ──────────────────────────── */
.fc-stepper {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}
.fc-src-label {
    flex: 1;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}
.fc-arrow {
    flex: 0 0 auto;
    width: 22px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}
.fc-arrow:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: var(--text-primary); }
.fc-arrow:disabled { opacity: 0.25; cursor: default; }
.fc-window {
    flex: 0 0 72px;
    width: 72px;
    height: 26px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    /* Fade the peeking neighbour values toward both edges of the box. */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 28%, #000 72%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, #000 28%, #000 72%, transparent 100%);
}
.fc-track {
    display: flex;
    height: 100%;
    align-items: center;
    transition: transform 0.18s ease;
    will-change: transform;
}
.fc-cell {
    flex: 0 0 52px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    opacity: 0.55;
    font-family: 'JetBrains Mono', monospace;
    transition: opacity 0.18s ease, color 0.18s ease;
}
.fc-cell.active { opacity: 1; font-weight: 700; }
.fc-stepper[data-src="gfs"]   .fc-cell.active { color: var(--accent-cyan-bright); }
.fc-stepper[data-src="hycom"] .fc-cell.active { color: #48cae4; }
/* Active OFF value = muted grey (not accent), so a selected ON value stands out as the
   highlighted one. More specific than the per-source rules above so it wins. */
.fc-stepper[data-src="gfs"]   .fc-cell.active.off-active,
.fc-stepper[data-src="hycom"] .fc-cell.active.off-active { color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════════════════
   TOGGLE SWITCH
   ═══════════════════════════════════════════════════════════════════════════ */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.15);
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}
input:checked + .slider { background-color: var(--accent-cyan); }
input:focus + .slider   { box-shadow: 0 0 1px var(--accent-cyan); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
#toast-container {
    position: fixed;
    top: var(--gap-lg);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: var(--gap-sm);
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: var(--bg-glass);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 3px solid var(--accent-cyan);
    color: var(--text-primary);
    padding: var(--gap-md) var(--gap-lg);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    box-shadow: var(--shadow-panel);
    animation: slide-up var(--transition-fast) ease-out;
}
.toast.error   { border-left-color: var(--status-red); }
.toast.success { border-left-color: var(--accent-green); }

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 4, 16, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: auto;
}

.regatta-card {
    width: 360px;
    padding: var(--gap-xl);
    text-align: center;
}

.regatta-card h2 {
    color: var(--accent-cyan);
    margin-bottom: var(--gap-sm);
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-family: 'JetBrains Mono', monospace;
}

.regatta-card h1 {
    font-size: var(--text-lg);
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text-bright);
}

.regatta-card .countdown {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 32px;
    font-weight: 800;
    color: var(--accent-orange);
    background: rgba(232, 129, 10, 0.08);
    padding: var(--gap-md);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(232, 129, 10, 0.3);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
    letter-spacing: 2px;
}

/* Auth card */
.auth-card { padding: var(--gap-xl); }

.reg-tabs {
    display: flex;
    gap: var(--gap-xs);
    margin-bottom: var(--gap-lg);
    background: rgba(4,10,26,0.70);
    border-radius: var(--radius-sm);
    padding: 3px;
    border: 1px solid var(--border-subtle);
}

.reg-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: var(--text-sm);
    font-weight: 700;
    padding: 8px 0;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.reg-tab:hover:not(.active) { color: var(--text-primary); background: rgba(15,30,65,0.80); }
.reg-tab.active {
    background: rgba(0,185,210,0.12);
    color: var(--accent-cyan);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

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

.reg-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0 0 10px;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOTTOM SHEET — Add Maneuver
   ═══════════════════════════════════════════════════════════════════════════ */
.bottom-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background: rgba(6, 14, 32, 0.97);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-medium);
    border-top-color: rgba(0,185,210,0.2);
    padding: 20px 16px 24px;
    box-sizing: border-box;
    transition: bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: center;
}

.bottom-sheet.show { bottom: 0; }

.bottom-sheet-content {
    width: 100%;
    max-width: 420px;
}

.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.bottom-sheet-header h3 {
    margin: 0;
    color: var(--accent-cyan);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.bottom-sheet-header .btn-close-sheet {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition-fast);
}
.bottom-sheet-header .btn-close-sheet:hover { color: var(--text-primary); }

.stepper-group {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

/* ── Compact maneuver form (2-row layout) ───────────────────────────────── */
.mnv-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.mnv-row input[type="number"] {
    /* tighter padding so inputs match the toggle/stepper height */
    padding: 8px 10px;
}
.mnv-steppers {
    flex: 1;
    margin-bottom: 0;
}
/* segmented HDG/TWA toggle */
.mnv-seg {
    display: inline-flex;
    flex: none;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(4, 10, 26, 0.80);
}
.mnv-seg-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.6px;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.mnv-seg-btn + .mnv-seg-btn {
    border-left: 1px solid var(--border-medium);
}
.mnv-seg-btn.active {
    background: rgba(0, 185, 210, 0.22);
    color: var(--accent-cyan);
}
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.stepper-btn {
    flex: 1;
    background: rgba(0,185,210,0.08);
    border: 1px solid rgba(0,185,210,0.20);
    color: var(--accent-cyan);
    padding: 8px 0;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: 'Inter', sans-serif;
}
.stepper-btn:hover {
    background: rgba(0,185,210,0.16);
    border-color: rgba(0,185,210,0.40);
}

/* ═══════════════════════════════════════════════════════════════════════════
   WAYPOINT MARKERS
   ═══════════════════════════════════════════════════════════════════════════ */
.wp-label-dot { animation: wp-pulse 2s ease-in-out infinite; }

/* ═══════════════════════════════════════════════════════════════════════════
   LOBBY RACE CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.race-lobby-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 14px 16px;
    position: relative;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.race-lobby-card:hover {
    border-color: rgba(0,185,210,0.3);
    background: rgba(0,185,210,0.04);
}
.race-lobby-card img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.race-lobby-card-body { flex: 1; overflow: hidden; }
.race-lobby-card-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--accent-cyan);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.race-lobby-card-time { font-size: 12px; color: var(--text-secondary); }
.race-lobby-card-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}
.race-lobby-boats-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-orange);
}

/* ═══════════════════════════════════════════════════════════════════════════
   EVENT STRIP — shared horizontal event switcher (lobby + races-card)
   ═══════════════════════════════════════════════════════════════════════════ */
.event-strip-header {
    color: var(--accent-cyan);
    font-size: 11px;
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-family: 'JetBrains Mono', monospace;
}

.event-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 10px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}
.event-strip::-webkit-scrollbar { height: 6px; }
.event-strip::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.18);
    border-radius: var(--radius-pill);
}
.event-strip::-webkit-scrollbar-track { background: transparent; }

.event-strip-msg {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 16px 4px;
}

.event-card {
    flex: 0 0 auto;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 12px;
    scroll-snap-align: start;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.event-card:hover {
    border-color: rgba(0,185,210,0.3);
    background: rgba(0,185,210,0.04);
}

/* Pinned current event (races-card) — highlighted, button-less */
.event-card.is-current {
    border-color: var(--accent-cyan);
    background: rgba(0,185,210,0.08);
    box-shadow: 0 0 0 1px var(--accent-cyan-dim) inset;
}

.event-card-img {
    width: 100%;
    height: 96px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.event-card-img.practice-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    background: linear-gradient(135deg, rgba(0,185,210,0.18), rgba(139,120,240,0.18));
}

.event-card-body { flex: 1; min-height: 0; }
.event-card-name {
    font-size: 15px;
    font-weight: 800;
    color: var(--accent-cyan);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.event-card-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.event-card-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-orange);
}

.event-card-action { margin-top: auto; }
.event-btn { width: 100%; padding: 8px 10px; font-size: 13px; }

.event-current-tag {
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--accent-cyan);
    padding: 6px 0;
}
.event-past-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-align: center;
}

.event-reg-form {
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.event-class-select { width: 100%; }
.event-confirm-btn { width: 100%; padding: 8px 10px; font-size: 13px; }
.event-feedback { font-size: 11px; }
.event-feedback:empty { display: none; }

/* Leaderboard scroll wrapper — cap at ~5 rows, scroll the rest, sticky header */
.lb-scroll {
    max-height: 168px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.lb-scroll::-webkit-scrollbar { width: 6px; }
.lb-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.18);
    border-radius: var(--radius-pill);
}
.lb-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-panel);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING SCREEN — full-screen blocking overlay during lobby/event load
   ═══════════════════════════════════════════════════════════════════════════ */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at center, rgba(6, 18, 40, 0.92), rgba(2, 8, 16, 0.97));
    backdrop-filter: blur(10px) saturate(1.1);
    -webkit-backdrop-filter: blur(10px) saturate(1.1);
    pointer-events: auto;            /* swallow every pan / click while loading */
    opacity: 1;
    transition: opacity 0.35s ease;
}
.loading-screen.fade-out { opacity: 0; }

.loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(0, 185, 210, 0.15);
    border-top-color: var(--accent-cyan);
    box-shadow: 0 0 18px rgba(0, 185, 210, 0.25);
    animation: loading-spin 0.9s linear infinite;
}
@keyframes loading-spin { to { transform: rotate(360deg); } }

.loading-phrase {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.4px;
    min-height: 1.2em;
    text-align: center;
    opacity: 1;
    transition: opacity 0.22s ease;
    /* Shimmer sweep like an active "thinking" indicator. */
    background: linear-gradient(
        90deg,
        var(--text-secondary) 0%,
        var(--text-bright) 25%,
        var(--text-secondary) 50%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: loading-shimmer 2.4s linear infinite;
}
@keyframes loading-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR — Mobile (no sidebar on desktop anymore)
   ═══════════════════════════════════════════════════════════════════════════ */
.sidebar {
    /* Not used on desktop — all cards are floating */
}

/* ═══════════════════════════════════════════════════════════════════════════
   DESKTOP LAYOUT — Floating card arrangement
   ═══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {

    /* Header: floating card top-left (already handled above) */
    /* Telemetry card: floating, below header */
    #telemetry-card {
        position: absolute;
        top: 90px;
        right: 20px;
        width: 320px;
        max-width: 360px;
        animation: card-in 0.5s ease 0.1s both;
    }

    #telemetry-card.collapsed .tc-columns-container { display: flex !important; }
    #telemetry-card.collapsed .tc-mobile-summary    { display: none !important; }
    .tc-mobile-toggle { display: none !important; }

    /* Commander: floating card bottom-left */
    .commander {
        position: absolute;
        bottom: 20px;
        right: 20px;
        width: 320px;
        max-height: calc(100vh - 110px);
        min-height: 0;
        display: none;
        animation: card-in 0.3s ease;
        /* glass panel style is already on .commander */
    }

    .commander.show {
        display: flex;
    }

    /* Observer notice - centered in map area */
    #observer-note {
        position: absolute;
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%);
        min-width: 280px;
        margin-right: 160px; /* offset for card column (now on the right) */
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
    #ui-overlay { padding: 0; }

    .header {
        position: absolute;
        top: 12px;
        left: 12px;
        right: 12px;
    }

    /* Telemetry: drawer under header */
    #telemetry-card {
        position: absolute;
        top: 78px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        border-radius: var(--radius-lg);
        z-index: 25;
        transition: all 0.3s ease;
    }

    #telemetry-card.collapsed .tc-columns-container { display: none; }
    #telemetry-card.collapsed .tc-mobile-summary    { display: flex !important; }
    #telemetry-card.collapsed .tc-mobile-toggle     { transform: rotate(180deg); }
    .tc-mobile-toggle { display: inline-block !important; transition: transform 0.3s ease; }

    /* Commander: bottom popup */
    .commander {
        position: absolute;
        left: 12px;
        right: 12px;
        bottom: 16px;
        width: auto;
        max-height: 50vh;
        overflow-y: auto;
    }

    .commander.show { display: flex; }

    /* Fly To is shown on mobile, but the handler uses an instant setView there
       instead of the animated flyTo: the arc flight balloons to high altitude
       mid-transition and loads too much tile/wind data at once, which crashed
       the mobile tab. setView lands directly on the boat with no wide-area
       transit. See the btn-fly-to click handler in viewer.js. */

    /* Smaller text on mobile commander */
    .commander .panel-tab { font-size: 9px; padding: 6px 0; }
    .commander label { font-size: 9px; }
    .commander input, .commander select { padding: 8px 10px; font-size: 12px; }
    .commander .neon-btn { padding: 8px 10px; font-size: 11px; }

    /* Telemetry mobile sizing */
    .tc-boatname    { font-size: 0.8rem; max-width: 140px; }
    .tc-val         { font-size: 0.85rem; }
    .tc-lbl         { font-size: 0.45rem; }
    .tc-unit        { font-size: 0.5rem; }
    .tc-section-label { font-size: 0.45rem; margin: 4px 0 2px; }
    .tc-coords      { font-size: 0.5rem; }
    .tc-instr-grid  { gap: 4px; }
    .tc-instr       { padding: 4px 6px; }
    .tc-env-row     { gap: 4px; padding: 4px; margin-bottom: 4px; }
    .tc-arrow-ring  { width: 26px; height: 26px; }
    .tc-arrow-svg   { width: 14px; height: 14px; }

    /* Scale down compass on mobile */
    #compass-rose-svg { max-width: 180px !important; }
}

@media (max-width: 768px) {
    .glass-panel { padding: 12px; }
    .tc-columns-container { gap: 6px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TC MOBILE SUMMARY
   ═══════════════════════════════════════════════════════════════════════════ */
.tc-mobile-summary {
    display: none;
    justify-content: space-around;
    font-size: 12px;
    margin-bottom: 4px;
}
