/* Tratok Sky Quest (10 Oct 2026). Tratok design system: Sora for display, DM Sans for text, ember and teal
   on the dark canvas, glass panels. A game screen, so a single dark theme on purpose. */
:root {
    --ember: #E85D3A;
    --ember-glow: #FF7B5C;
    --ember-deep: #C43D1E;
    --teal: #2ECDA7;
    --teal-deep: #1A9B7A;
    --amber: #F5A623;
    --gold: #F0C040;
    --void: #0B0E17;
    --abyss: #111827;
    --white: #FFFFFF;
    --snow: #F1F5F9;
    --mist: #94A3B8;
    --ghost: #64748B;
    --glass: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.09);
    --panel: rgba(13, 17, 28, 0.94);
    --topbar-h: 52px;
    --radius: 16px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    min-height: 100dvh;
    background: var(--void);
    color: var(--snow);
    font: 400 15px/1.55 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: var(--teal); }

#bg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.sky-glow {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(700px circle at 15% 10%, rgba(232, 93, 58, 0.14), transparent 60%),
        radial-gradient(700px circle at 85% 90%, rgba(46, 205, 167, 0.11), transparent 60%);
}

/* Top bar: the same brand mark as the other Tratok sites */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 60;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: linear-gradient(180deg, rgba(11, 14, 23, 0.96), rgba(11, 14, 23, 0.82));
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--white); min-width: 0; }
.brand img { width: 28px; height: 28px; flex-shrink: 0; }
.brand-name { font: 700 1.05rem 'Sora', sans-serif; letter-spacing: -0.01em; }
.brand-tag {
    font: 700 0.62rem 'Sora', sans-serif; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--teal); background: rgba(46, 205, 167, 0.12); border: 1px solid rgba(46, 205, 167, 0.22);
    padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
    width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; cursor: pointer;
    background: var(--glass); border: 1px solid var(--glass-border); color: var(--snow);
    transition: background 0.2s, transform 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn[hidden] { display: none; }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg path:first-child { fill: currentColor; stroke: none; }
#pause-button svg path { fill: none; stroke: currentColor; stroke-width: 2.6; }
#sound-button .ic-off { display: none; }
#sound-button[aria-pressed="false"] .ic-on { display: none; }
#sound-button[aria-pressed="false"] .ic-off { display: block; }

/* The play field: everything below the top bar */
#game-container {
    position: fixed; z-index: 2; left: 0; right: 0; bottom: 0;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    display: flex; align-items: center; justify-content: center;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#gameCanvas { display: block; touch-action: none; cursor: pointer; }
@media (min-width: 760px) {
    #game-container { padding: 14px; }
    #gameCanvas { border-radius: 18px; border: 1px solid var(--glass-border); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); }
}

/* Overlays and panels */
.overlay {
    position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
    padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 12px) 14px calc(14px + env(safe-area-inset-bottom));
    background: rgba(6, 8, 14, 0.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
/* hidden menus leave the tab order too, so a keyboard never lands on a button nobody can see */
.overlay.visible { opacity: 1; pointer-events: auto; visibility: visible; transition: opacity 0.3s ease; }
.panel {
    position: relative; width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto; overscroll-behavior: contain;
    background: var(--panel); border: 1px solid var(--glass-border); border-radius: 22px;
    padding: 26px 22px 22px; text-align: center;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.panel::before {
    content: ''; position: absolute; top: 0; left: 22px; right: 22px; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, var(--ember), var(--amber), var(--teal));
}
.overlay.visible .panel { animation: panelIn 0.45s var(--ease); }
@keyframes panelIn { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel h1 { font: 800 clamp(1.6rem, 6vw, 2rem)/1.1 'Sora', sans-serif; color: var(--white); letter-spacing: -0.02em; margin-bottom: 8px; text-wrap: balance; }
.panel h2 { font: 700 0.95rem 'Sora', sans-serif; color: var(--white); }
.kicker { font: 600 0.68rem 'Sora', sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--teal); margin-bottom: 6px; }
.lede { color: var(--mist); max-width: 34ch; margin: 0 auto 18px; }
.muted { color: var(--mist); }
.mark-float { width: 64px; height: 64px; display: block; margin: 0 auto 12px; animation: markFloat 3s ease-in-out infinite; filter: drop-shadow(0 8px 24px rgba(240, 192, 64, 0.25)); }
@keyframes markFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.panel-small { max-width: 340px; }
.stack { display: grid; gap: 10px; margin-top: 16px; }

.loading-bar { width: 180px; height: 4px; margin: 16px auto 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.loading-bar-fill { height: 100%; width: 40%; border-radius: 4px; background: linear-gradient(90deg, var(--ember), var(--amber)); animation: load 1.2s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    min-height: 46px; padding: 0 20px; width: 100%;
    border-radius: 14px; border: 1px solid transparent; cursor: pointer; text-decoration: none;
    font: 600 0.95rem 'Sora', sans-serif; letter-spacing: 0.01em;
    transition: transform 0.15s, box-shadow 0.25s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .link-btn:focus-visible, .icon-btn:focus-visible, .brand:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.btn-lg { min-height: 54px; font-size: 1.05rem; }
.btn-primary { background: linear-gradient(135deg, var(--ember), var(--ember-deep)); color: var(--white); box-shadow: 0 8px 26px rgba(232, 93, 58, 0.35); }
.btn-primary:hover { box-shadow: 0 10px 32px rgba(232, 93, 58, 0.45); }
.btn-ghost { background: var(--glass); border-color: var(--glass-border); color: var(--snow); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn-tratok { background: var(--snow); color: var(--void); }
.btn-tratok:hover { background: var(--white); }
.btn-tratok img { width: 22px; height: 22px; }
.link-btn { background: none; border: 0; cursor: pointer; color: var(--mist); font-size: 0.88rem; text-decoration: underline; text-underline-offset: 3px; padding: 6px 4px; }
.link-btn:hover { color: var(--white); }

/* Start screen */
.player-box { margin: 14px 0 4px; display: grid; gap: 8px; justify-items: center; }
.player-box .btn-tratok { min-height: 46px; }
.player-box .hint { color: var(--mist); font-size: 0.84rem; max-width: 32ch; }
.player-line { color: var(--snow); font-size: 0.92rem; }
.player-line strong { color: var(--white); }
.player-line .sep { color: var(--ghost); margin: 0 6px; }
.notice { border-radius: 12px; padding: 10px 12px; margin: -4px 0 14px; font-size: 0.86rem; text-align: left; background: rgba(46, 205, 167, 0.08); border: 1px solid rgba(46, 205, 167, 0.25); color: #9EF0DA; }
.notice.is-error { background: rgba(232, 93, 58, 0.08); border-color: rgba(232, 93, 58, 0.3); color: #FFB4A2; }
.notice[hidden], .chip-mission[hidden], .badges[hidden], .liveries[hidden], .mini-note[hidden], .save-note[hidden] { display: none; }
.chip-mission {
    display: grid; gap: 2px; margin: 14px 0 6px; padding: 10px 12px; border-radius: 12px; text-align: left;
    background: rgba(245, 166, 35, 0.07); border: 1px solid rgba(245, 166, 35, 0.2);
}
.chip-label { font: 700 0.64rem 'Sora', sans-serif; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); }
#daily-desc { color: var(--snow); font-size: 0.88rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 2px; }
.badge-chip { font-size: 0.74rem; padding: 3px 9px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-border); color: var(--mist); }
.liveries { margin: 8px 0 0; }
.liveries .label { display: block; font: 600 0.64rem 'Sora', sans-serif; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ghost); margin-bottom: 6px; }
.livery-btn { width: 28px; height: 28px; margin: 0 4px; border-radius: 50%; cursor: pointer; border: 2px solid rgba(255, 255, 255, 0.18); }
.livery-btn[aria-pressed="true"] { border-color: var(--white); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12); }

/* How to play */
.tips { list-style: none; display: grid; gap: 8px; margin: 14px 0 18px; text-align: left; }
.tips li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 12px; border-radius: 12px; background: var(--glass); border: 1px solid var(--glass-border); font-size: 0.9rem; color: var(--mist); }
.tips strong { color: var(--white); font-weight: 600; }
.tip-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.tip-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-ember { background: rgba(232, 93, 58, 0.14); color: var(--ember-glow); }
.ic-teal { background: rgba(46, 205, 167, 0.13); color: var(--teal); }
.ic-amber { background: rgba(245, 166, 35, 0.13); color: var(--amber); }
.ic-gold { background: rgba(240, 192, 64, 0.12); }

/* Game over */
.panel-over { padding-top: 22px; }
.over-miles { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 2px 0 4px; }
#final-score { font: 800 clamp(2.6rem, 12vw, 3.4rem)/1 'Sora', sans-serif; color: var(--gold); font-variant-numeric: tabular-nums; }
.over-miles .unit { font: 600 1rem 'Sora', sans-serif; color: var(--mist); }
.stars { display: flex; gap: 6px; justify-content: center; margin: 6px 0 12px; }
.star { width: 26px; height: 26px; fill: rgba(255, 255, 255, 0.1); transition: fill 0.4s, transform 0.4s var(--ease); }
.star.earned { fill: var(--gold); transform: scale(1.12); }
.over-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.over-stats div { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 12px; padding: 8px 6px; }
.over-stats dt { font: 600 0.62rem 'Sora', sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ghost); }
.over-stats dd { font: 700 1rem 'Sora', sans-serif; color: var(--white); font-variant-numeric: tabular-nums; }
.save-note { margin: 2px 0 8px; font-size: 0.86rem; color: var(--mist); }
.save-note strong { color: var(--white); }
.save-note a { font-weight: 600; }
.mini-note { margin: 6px 0; padding: 8px 10px; border-radius: 10px; font-size: 0.82rem; background: var(--glass); border: 1px solid var(--glass-border); color: var(--mist); }
.mini-note.is-done { color: #9EF0DA; border-color: rgba(46, 205, 167, 0.3); background: rgba(46, 205, 167, 0.07); }
.lb-title { margin: 14px 0 8px; text-align: left; }
.leaderboard { list-style: none; display: grid; gap: 4px; max-height: min(32vh, 260px); overflow-y: auto; text-align: left; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: var(--glass); font-size: 0.88rem; }
.lb-rank { width: 26px; font: 700 0.85rem 'Sora', sans-serif; color: var(--ghost); font-variant-numeric: tabular-nums; }
.rank-1 .lb-rank { color: var(--gold); }
.rank-2 .lb-rank { color: #CBD5E1; }
.rank-3 .lb-rank { color: #D69E6A; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--snow); }
.lb-score { font: 600 0.85rem 'Sora', sans-serif; color: var(--white); font-variant-numeric: tabular-nums; }
.lb-row.is-you { background: rgba(46, 205, 167, 0.1); border: 1px solid rgba(46, 205, 167, 0.3); }
.lb-row.is-you .lb-name { color: #9EF0DA; }
.lb-gap { text-align: center; color: var(--ghost); font-size: 0.8rem; padding: 2px 0; }
.lb-empty { color: var(--mist); font-size: 0.86rem; padding: 10px; text-align: center; border-radius: 10px; background: var(--glass); }
.over-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 16px; }
.over-actions .btn-ghost { width: auto; }
.over-links { margin-top: 10px; display: flex; gap: 10px; justify-content: center; align-items: center; color: var(--ghost); font-size: 0.88rem; }
.over-links a { color: var(--mist); }

/* The button under the tips stays in view while the tips scroll on a short screen. */
.panel-foot { position: sticky; bottom: -22px; margin: 0 -22px -22px; padding: 12px 22px 22px; background: linear-gradient(180deg, rgba(13, 17, 28, 0), var(--panel) 30%); }

@media (max-width: 380px) {
    .panel { padding: 22px 16px 18px; }
    .brand-name { display: none; }
}
@media (max-height: 760px) {
    .tips { gap: 6px; margin: 10px 0 8px; }
    .tips li { padding: 8px 10px; font-size: 0.84rem; line-height: 1.4; }
    .tip-ic { width: 28px; height: 28px; }
}
@media (max-height: 700px) {
    .mark-float { width: 44px; height: 44px; margin-bottom: 6px; }
    .lede { margin-bottom: 12px; }
    .btn-lg { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
    .mark-float, .loading-bar-fill { animation: none; }
    .overlay.visible .panel { animation: none; }
}
