* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(ellipse at center, #0a0a2a 0%, #050510 100%);
    color: #e0e0ff;
    min-height: 100vh;
    overflow-x: hidden;
}

.game-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
}

header {
    text-align: center;
    margin-bottom: 16px;
    position: relative;
}

header h1 {
    font-size: 2.4rem;
}

header h1 .title-gradient {
    background: linear-gradient(90deg, #7aa8ff 0%, #c896ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #9999cc;
    margin-top: 4px;
}

.btn-back {
    position: absolute;
    left: 0;
    top: 0;
    background: rgba(255,255,255,0.08);
    color: #e0e0ff;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

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

.main-content { display: flex; flex-direction: column; gap: 12px; }

.hud {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    background: rgba(20, 20, 50, 0.6);
    border: 1px solid rgba(120, 140, 220, 0.25);
    padding: 12px;
    border-radius: 12px;
}

.hud-item { text-align: center; }
.hud-label { font-size: 0.75rem; color: #8888bb; text-transform: uppercase; letter-spacing: 0.05em; }
.hud-value { font-size: 1.15rem; font-weight: 700; margin-top: 4px; }

.gas-bar {
    margin-top: 8px;
    height: 14px;
    background: rgba(0,0,0,0.4);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
}

.gas-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b 0%, #ffd56b 50%, #4ade80 100%);
    width: 100%;
    transition: width 0.1s linear;
}

@keyframes gasPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}

.gas-bar-fill.gas-low {
    background: linear-gradient(90deg, #ff3b3b 0%, #ff8c00 100%);
    animation: gasPulse 0.65s ease-in-out infinite;
}

#gasWarning {
    display: none;
    color: #ff6b6b;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 4px;
    letter-spacing: 0.03em;
    animation: gasPulse 0.65s ease-in-out infinite;
}

#gasWarning.visible { display: block; }

.canvas-wrap {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(120, 140, 220, 0.25);
    background: #000;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    background: #02020a;
}

.footer-hint {
    text-align: center;
    color: #8888bb;
    font-size: 0.85rem;
}

/* Overlays — scroll when the card is taller than the window (a long
   leaderboard on a short screen). The card centres itself with margin: auto
   rather than align-items: center, which would push its top off-screen
   where it can't be scrolled back to. */
.overlay-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 20, 0.85);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    backdrop-filter: blur(4px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.overlay-screen.hidden { display: none; }

.overlay-card {
    background: linear-gradient(160deg, #1a1a3a 0%, #0f0f25 100%);
    border: 1px solid rgba(120, 140, 220, 0.4);
    border-radius: 16px;
    padding: 28px;
    max-width: 520px;
    width: 100%;
    margin: auto 0;
    text-align: center;
    box-shadow: 0 20px 80px rgba(0,0,0,0.7);
}

.overlay-card h2 { font-size: 1.8rem; margin-bottom: 12px; }
.overlay-card p { color: #b0b0d0; margin-bottom: 10px; }

.control-hints {
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: 10px;
    margin: 16px 0;
    font-size: 0.9rem;
    color: #c0c0e0;
}

.control-hints div { margin: 4px 0; }

.key {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: monospace;
    font-weight: bold;
    margin: 0 2px;
}

.grade-picker { margin: 20px 0; }
.grade-picker label { display: block; margin-bottom: 8px; color: #b0b0d0; }

.ship-picker { margin: 20px 0; }
.ship-picker label { display: block; margin-bottom: 8px; color: #b0b0d0; }

.ship-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.ship-btn {
    background: rgba(255,255,255,0.05);
    color: #e0e0ff;
    border: 2px solid rgba(255,255,255,0.12);
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ship-btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); }

.ship-btn.selected {
    border-color: #7aa8ff;
    background: rgba(122, 168, 255, 0.15);
}

.ship-preview {
    display: block;
    border-radius: 6px;
}

.grade-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.grade-btn, .planet-style-btn {
    background: rgba(255,255,255,0.08);
    color: #e0e0ff;
    border: 2px solid rgba(255,255,255,0.15);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    min-width: 56px;
}

.grade-btn:hover, .planet-style-btn:hover { background: rgba(255,255,255,0.15); }

.grade-btn.selected, .planet-style-btn.selected {
    background: linear-gradient(135deg, #7aa8ff 0%, #c896ff 100%);
    border-color: transparent;
    color: #0a0a2a;
}

.btn-primary {
    background: linear-gradient(135deg, #7aa8ff 0%, #c896ff 100%);
    color: #0a0a2a;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(122, 168, 255, 0.4); }
.btn-primary.big { font-size: 1.2rem; padding: 16px 40px; margin: 12px 0; }

.btn-secondary {
    background: rgba(255,255,255,0.08);
    color: #e0e0ff;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
}

.btn-secondary:hover { background: rgba(255,255,255,0.15); }

.high-scores {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: left;
}

.high-scores h3 { text-align: center; margin-bottom: 12px; }

#highScoreList, #highScoreListEnd {
    list-style: none;
    counter-reset: rank;
}

#highScoreList li, #highScoreListEnd li {
    counter-increment: rank;
    padding: 6px 12px;
    margin: 4px 0;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

#highScoreList li::before, #highScoreListEnd li::before {
    content: counter(rank);
    font-weight: 700;
    color: #c896ff;
    min-width: 24px;
}

#highScoreList li.empty, #highScoreListEnd li.empty {
    justify-content: center;
    color: #8888bb;
    font-style: italic;
}

#highScoreList li.empty::before, #highScoreListEnd li.empty::before { content: ''; min-width: 0; }

.score-initials { font-weight: 700; font-family: monospace; }
.score-tier { font-size: 1rem; margin-left: auto; }
.score-distance { color: #b0b0d0; }
.score-grade { font-size: 0.8rem; color: #8888bb; }
.score-ts { font-size: 0.75rem; color: #6e6e9a; min-width: 4.5em; text-align: right; }

.hs-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
    justify-content: center;
}

.hs-tab {
    background: rgba(255,255,255,0.05);
    color: #b0b0d0;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
}

.hs-tab:hover { background: rgba(255,255,255,0.12); color: #e0e0ff; }

.hs-tab.active {
    background: linear-gradient(135deg, #7aa8ff 0%, #c896ff 100%);
    color: #0a0a2a;
    border-color: transparent;
}

.hs-mode-badge {
    font-size: 0.72rem;
    color: #ffa86b;
    font-weight: 500;
    margin-left: 8px;
    vertical-align: middle;
}

.initials-feedback {
    margin-top: 8px;
    min-height: 1.2em;
    color: #ff6b6b;
    font-size: 0.85rem;
}

/* Math modal */
.math-card { max-width: 460px; }

.math-reason {
    color: #ffd56b;
    font-weight: 600;
    margin-bottom: 12px;
}

.math-question {
    font-size: 2.4rem;
    margin: 16px 0;
    font-family: 'Courier New', monospace;
}

.math-question.stacked {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: fit-content;
    margin: 16px auto;
    font-size: 2.6rem;
    line-height: 1.05;
    padding: 4px 18px 4px 0;
}

.math-question.stacked .stk-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.5em;
    white-space: pre;
}

.math-question.stacked .stk-op {
    color: #ffd56b;
    min-width: 1ch;
    text-align: left;
}

.math-question.stacked .stk-num {
    text-align: right;
    white-space: pre;
}

.math-question.stacked .stk-bar {
    display: block;
    height: 3px;
    background: #e0e0ff;
    margin: 4px 0;
    border-radius: 2px;
}

/* Inline fraction inside a question — numerator over denominator */
.math-question .frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    line-height: 1;
    margin: 0 0.12em;
    font-size: 0.72em;
}

.math-question .frac .fr-n { padding: 0 0.28em 2px; }

.math-question .frac .fr-d {
    padding: 2px 0.28em 0;
    border-top: 3px solid #e0e0ff;
}

/* Fraction slider answer */
.frac-answer { margin: 6px auto 4px; width: min(360px, 100%); }
.frac-answer.hidden { display: none; }
.math-input.hidden { display: none; }

.frac-bar {
    position: relative;
    height: 42px;
    border-radius: 10px;
    border: 2px solid rgba(120, 140, 220, 0.45);
    background: rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.frac-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: linear-gradient(180deg, #7aa8ff, #4a6ed0);
    transition: width 0.08s linear;
}

.frac-ticks {
    position: absolute;
    inset: 0;
    display: flex;
}

.frac-ticks span {
    flex: 1 1 0;
    border-right: 1px solid rgba(224, 224, 255, 0.35);
}

.frac-ticks span:last-child { border-right: none; }

#fracSlider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    margin: 10px 0 4px;
    background: transparent;
}

#fracSlider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(120, 140, 220, 0.45);
}

#fracSlider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(120, 140, 220, 0.45);
}

#fracSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    margin-top: -11px;
    border-radius: 50%;
    background: #ffd56b;
    border: 3px solid #08081a;
    cursor: pointer;
}

#fracSlider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ffd56b;
    border: 3px solid #08081a;
    cursor: pointer;
}

#fracSlider:focus { outline: none; }
#fracSlider:focus::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(122, 168, 255, 0.4); }
#fracSlider:focus::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(122, 168, 255, 0.4); }

.frac-preview {
    min-height: 3.2rem;
    font-size: 2rem;
    font-family: 'Courier New', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4em;
}

.frac-preview .frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.frac-preview .frac .fr-n { padding: 0 0.3em 2px; }

.frac-preview .frac .fr-d {
    padding: 2px 0.3em 0;
    border-top: 3px solid #e0e0ff;
}

.frac-preview .frac-pct {
    align-self: flex-end;
    padding-bottom: 4px;
    font-size: 0.95rem;
    color: #9fb0e0;
}

.math-input {
    width: 200px;
    font-size: 1.8rem;
    padding: 12px;
    text-align: center;
    border: 2px solid rgba(120, 140, 220, 0.4);
    background: rgba(0,0,0,0.4);
    color: #e0e0ff;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
}

.math-input:focus { outline: none; border-color: #7aa8ff; }

.math-controls { margin: 16px 0; }

.math-feedback {
    min-height: 24px;
    font-weight: 600;
}

.math-feedback.correct { color: #4ade80; }
.math-feedback.wrong { color: #ff6b6b; }

.big-num {
    font-size: 1.6rem;
    font-weight: 700;
    color: #c896ff;
}

.high-score-entry {
    background: rgba(200, 150, 255, 0.1);
    border: 1px solid rgba(200, 150, 255, 0.3);
    border-radius: 10px;
    padding: 16px;
    margin: 16px 0;
}

.high-score-entry.hidden { display: none; }
.victory-note.hidden { display: none; }

.high-score-entry h3 { margin-bottom: 8px; }
.high-score-entry label { display: block; margin-bottom: 8px; color: #b0b0d0; }

#initialsInput {
    width: 100px;
    font-size: 1.5rem;
    padding: 10px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    border: 2px solid rgba(200, 150, 255, 0.4);
    background: rgba(0,0,0,0.4);
    color: #e0e0ff;
    border-radius: 8px;
    font-family: monospace;
    margin: 0 8px 12px 0;
}

#initialsInput:focus { outline: none; border-color: #c896ff; }

.game-over-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

@media (max-width: 700px) {
    .hud,
    #planetHud { grid-template-columns: repeat(3, 1fr); }
    .hud-item.gas,
    .hud-item.resources,
    .hud-item.cave { grid-column: span 3; }
    header h1 { font-size: 1.8rem; }
    .btn-back { position: static; margin-bottom: 8px; }
}

/* ── Trading Post ───────────────────────────────────────────────────────── */
.shop-card {
    max-width: 560px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.shop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.shop-head h2 { font-size: 1.5rem; margin-bottom: 2px; }
.shop-subtitle { font-size: 0.85rem; color: #9a9ac4; margin: 0; }

.token-chip {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #ffe9a8;
    background: rgba(250, 204, 21, 0.16);
    border: 1px solid rgba(250, 204, 21, 0.55);
    white-space: nowrap;
}

.token-chip.hidden { display: none; }

.shop-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.chest-chip {
    font-family: inherit;
    cursor: pointer;
}

.shop-preview {
    display: block;
    width: 100%;
    height: auto;
    margin: 14px 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(120, 140, 220, 0.3);
    background: #05050f;
}

.shop-tabs {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.shop-tab {
    background: rgba(255,255,255,0.06);
    color: #b8b8dd;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.shop-tab:hover { background: rgba(255,255,255,0.12); }

.shop-tab.active {
    background: linear-gradient(135deg, #7aa8ff 0%, #c896ff 100%);
    border-color: transparent;
    color: #0a0a2a;
}

.shop-body {
    flex: 1 1 auto;
    overflow-y: auto;
    margin: 12px 0 4px;
    padding-right: 4px;
    text-align: left;
    min-height: 120px;
}

.shop-group { margin-bottom: 14px; }

.shop-group-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8888bb;
    margin-bottom: 6px;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
}

.shop-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 9px 6px;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    color: #e0e0ff;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.12);
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.shop-item:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }

.si-emoji { font-size: 1.5rem; line-height: 1.1; }
.si-name { font-size: 0.82rem; font-weight: 700; line-height: 1.15; }
.si-desc { font-size: 0.68rem; color: #9a9ac4; line-height: 1.2; }

.si-badge {
    font-size: 0.68rem;
    font-weight: 700;
    color: #ffe9a8;
    background: rgba(250, 204, 21, 0.14);
    border-radius: 999px;
    padding: 1px 8px;
    margin-top: 2px;
}

.shop-item.owned { border-color: rgba(122, 168, 255, 0.5); }
.shop-item.owned .si-badge { color: #bcd4ff; background: rgba(122, 168, 255, 0.16); }

.shop-item.equipped {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
}
.shop-item.equipped .si-badge { color: #0a2a12; background: #4ade80; }

/* Staged: previewed on the ship, not paid for until Continue */
.shop-item.staged {
    border-color: #facc15;
    background: rgba(250, 204, 21, 0.14);
    border-style: dashed;
}
.shop-item.staged .si-badge { color: #2a1f02; background: #facc15; }

.shop-item.maxed { border-color: rgba(74, 222, 128, 0.45); }
.shop-item.maxed .si-badge { color: #a7f3d0; background: rgba(74, 222, 128, 0.16); }

/* Still clickable — the click is what surfaces the "not enough tokens" toast */
.shop-item.locked { opacity: 0.42; }

.shop-toast {
    min-height: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffe9a8;
    opacity: 0;
    transition: opacity 0.2s;
}

.shop-toast.visible { opacity: 1; }

.shop-hint {
    font-size: 0.75rem;
    color: #7a7aa8;
    margin: 2px 0 0;
}

.shop-card .btn-primary.big { margin: 10px 0 0; }

.shop-summary {
    font-size: 0.9rem;
    color: #b0b0d0;
}

.shop-summary.hidden { display: none; }

/* Treasure chest popup — above the Trading Post it opens from */
.chest-overlay { z-index: 110; }
.chest-card { max-width: 440px; }
.chest-card h2 { margin-bottom: 4px; }

.chest-canvas {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 14px;
    border-radius: 12px;
    border: 1px solid rgba(250, 204, 21, 0.4);
    background: #05050f;
}

@media (max-width: 560px) {
    .shop-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
    .shop-card { padding: 16px; }
}

/* ── Planet stage ───────────────────────────────────────────────────────── */
.hud.hidden,
.hud-item.hidden,
.footer-hint.hidden { display: none; }

#planetHud { grid-template-columns: 1fr 1fr 1fr 2.4fr; }

.cave-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
    margin-top: 2px;
    font-weight: 700;
}

.btn-secondary.cave-exit {
    padding: 4px 12px;
    font-size: 0.85rem;
}

.hud-item.resources {
    flex: 1 1 auto;
    min-width: 180px;
}

.res-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 2px;
}

.res-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #e0e0ff;
    background: color-mix(in srgb, var(--res) 22%, transparent);
    border: 1px solid color-mix(in srgb, var(--res) 60%, transparent);
    transition: background 0.2s, border-color 0.2s;
}

.res-chip.done {
    background: rgba(74, 222, 128, 0.22);
    border-color: rgba(74, 222, 128, 0.75);
    color: #b7f7cd;
}

.res-chip .res-emoji { font-size: 0.95rem; line-height: 1; }
.res-chip .res-count { font-variant-numeric: tabular-nums; }

.victory-note {
    color: #4ade80;
    font-weight: 700;
    font-size: 1.05rem;
}

.score-breakdown {
    color: #8888bb;
    font-size: 0.92rem;
}

.score-breakdown span {
    color: #b0b0d0;
    font-variant-numeric: tabular-nums;
}

/* ── TURBO warp map (warp.js) ───────────────────────────────────────────────
   Ten columns, one per tier. The space row is joined into a left-to-right
   timeline; each planet and maze hangs off the node above it. */
.warp-card { max-width: 980px; }
.warp-sub { font-size: 0.95rem; }

.warp-map-wrap {
    overflow-x: auto;
    margin: 8px -8px 0;
    padding: 4px 8px 10px;
    overscroll-behavior-x: contain;
}

.warp-map {
    display: grid;
    grid-template-columns: repeat(10, minmax(82px, 1fr));
    min-width: 820px;
}

.warp-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.warp-tier {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--glow);
    white-space: nowrap;
    margin-bottom: 22px;           /* room for the "Here" pill above a space node */
}

/* The timeline — a rail through the centre of every space icon, with a
   chevron pointing on to the next belt */
.warp-track {
    position: relative;
    align-self: stretch;
    display: flex;
    justify-content: center;
}
.warp-track::before {
    content: '';
    position: absolute;
    top: 23px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(200,150,255,0.25), rgba(122,168,255,0.55));
}
.warp-col:first-child .warp-track::before { left: 50%; }
.warp-col:last-child .warp-track::before { right: 50%; }
.warp-col:not(:last-child) .warp-track::after {
    content: '';
    position: absolute;
    top: 19px;
    right: -5px;
    border: 5.5px solid transparent;
    border-left: 8px solid rgba(122,168,255,0.8);
}

.warp-branch {
    width: 3px;
    height: 20px;
    background: color-mix(in srgb, var(--glow) 55%, transparent);
}
.warp-branch.off { opacity: 0.25; }

.warp-node {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 0 2px;
    color: #c8c8ee;
    font: inherit;
    cursor: pointer;
}
.warp-node:disabled { cursor: not-allowed; }

.warp-icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
    transition: transform 0.15s, box-shadow 0.15s;
}
.warp-node:not(:disabled):hover .warp-icon,
.warp-node:focus-visible .warp-icon { transform: scale(1.12); }
.warp-node:focus-visible { outline: none; }
.warp-node:focus-visible .warp-label { text-decoration: underline; }

.warp-label { font-size: 0.72rem; font-weight: 700; }

/* Space — a patch of starfield ringed in the tier colour */
.warp-node.space .warp-icon {
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--tier) 70%, var(--glow));
    background:
        radial-gradient(1.5px 1.5px at 30% 30%, #fff 90%, transparent),
        radial-gradient(1px 1px at 70% 40%, #fff 90%, transparent),
        radial-gradient(1px 1px at 45% 75%, #fff 90%, transparent),
        radial-gradient(1.5px 1.5px at 78% 72%, #fff 90%, transparent),
        radial-gradient(circle, color-mix(in srgb, var(--tier) 30%, #05051a), #02020a);
    box-shadow: 0 0 10px color-mix(in srgb, var(--glow) 45%, transparent);
}
.warp-node.space .warp-icon::after { content: '🚀'; font-size: 1.1rem; }

/* Planet — a lit sphere in the tier colour with a thin ring */
.warp-node.planet .warp-icon {
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%,
        color-mix(in srgb, var(--glow) 85%, #fff),
        var(--tier) 55%,
        color-mix(in srgb, var(--tier) 45%, #000));
    box-shadow: 0 0 12px color-mix(in srgb, var(--glow) 50%, transparent);
}
.warp-node.planet .warp-icon::before {
    content: '';
    position: absolute;
    inset: 17px -9px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--glow) 70%, transparent);
    transform: rotate(-18deg);
}

/* Maze — a dark tile scored with corridors */
.warp-node.maze .warp-icon {
    width: 42px;
    height: 42px;
    margin: 3px 0;
    border-radius: 8px;
    border: 2px solid color-mix(in srgb, var(--tier) 70%, var(--glow));
    background:
        linear-gradient(90deg, transparent 20%, color-mix(in srgb, var(--tier) 70%, #444) 20% 30%, transparent 30% 60%, color-mix(in srgb, var(--tier) 70%, #444) 60% 70%, transparent 70%) 0 0 / 100% 50% no-repeat,
        linear-gradient(transparent 40%, color-mix(in srgb, var(--tier) 70%, #444) 40% 50%, transparent 50%) 0 0 / 70% 100% no-repeat,
        linear-gradient(transparent 70%, color-mix(in srgb, var(--tier) 70%, #444) 70% 80%, transparent 80%) 100% 0 / 60% 100% no-repeat,
        #07070f;
}
.warp-chest {
    position: absolute;
    right: -10px;
    bottom: -8px;
    font-size: 0.95rem;
}

.warp-node.past .warp-icon { opacity: 0.55; }
.warp-node.past .warp-label { color: #8080a8; }
.warp-node.off { opacity: 0.25; }

.warp-node.current .warp-icon {
    box-shadow: 0 0 0 3px #0f0f25, 0 0 0 6px #facc15, 0 0 18px #facc15;
    animation: warp-pulse 1.4s ease-in-out infinite;
}
.warp-node.current .warp-label { color: #facc15; }

.warp-node.next .warp-icon { box-shadow: 0 0 0 3px #0f0f25, 0 0 0 5px #4ade80; }
.warp-node.next .warp-label { color: #86efac; }

@keyframes warp-pulse {
    50% { box-shadow: 0 0 0 3px #0f0f25, 0 0 0 6px #facc15, 0 0 28px #facc15; }
}
@media (prefers-reduced-motion: reduce) {
    .warp-node.current .warp-icon { animation: none; }
}

.warp-here {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.68rem;
    font-weight: 700;
    color: #0a0a2a;
    background: #facc15;
    border-radius: 999px;
    padding: 1px 7px;
}
/* Below the space row the pill sits over the branch it hangs from */
.warp-node.current { z-index: 2; }
.warp-node.planet .warp-here,
.warp-node.maze .warp-here { top: -18px; }

.warp-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}
.warp-actions .btn-primary:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.warp-hint {
    margin: 10px 0 0 !important;
    font-size: 0.8rem;
    color: #8080a8 !important;
}

/* "BETA" pill on the Explore 3D style button */
.beta-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #ffb366;
    color: #1b1033;
    font-size: 0.6em;
    font-weight: 800;
    letter-spacing: 0.06em;
    vertical-align: middle;
}
