/* Escape Hormuz: naval HUD look. Mobile first (390x844 portrait), desktop second. */
:root {
  --navy: #06121c; --navy-2: #0b1e2c; --panel: rgba(5, 16, 26, 0.78); --panel-solid: #0a1b28;
  --line: rgba(245, 165, 36, 0.35); --amber: #f5a524; --amber-hi: #ffc35a; --teal: #2ad1c9; --teal-dim: #1b7f7b;
  --red: #ff3b30; --green: #3ddc84; --text: #e8f1f7; --dim: #8fa6b5;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --font: "Saira Condensed", "Oswald", "Roboto Condensed", "Arial Narrow", system-ui, -apple-system, sans-serif;
  --stencil: "Saira Stencil One", "Saira Condensed", "Oswald", Impact, "Arial Narrow", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--navy); color: var(--text);
  font-family: var(--font); touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font-family: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
svg { display: block; }

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
.touch .t-keys { display: none !important; }
body:not(.touch) .t-touch { display: none !important; }

/* ---------------- HUD ---------------- */
.hud { position: absolute; inset: 0; display: none; }
.hud.show { display: block; }
.hud-lbl { font-size: 10px; font-weight: 700; letter-spacing: 0.16em; color: var(--dim); line-height: 1; }
.hud-top { position: absolute; top: calc(var(--sat) + 8px); left: calc(var(--sal) + 8px); right: calc(var(--sar) + 8px);
  display: flex; align-items: stretch; gap: 6px; }
.hull, .ro { background: var(--panel); border: 1px solid rgba(143, 166, 181, 0.18); border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); }
.hull { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  column-gap: 8px; row-gap: 5px; padding: 7px 9px 8px; align-items: center; }
.hull .hud-lbl { grid-column: 1; grid-row: 1; }
.hull-bar { grid-column: 1; grid-row: 2; height: 11px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; position: relative; }
.hull-bar i { position: absolute; inset: 0; transform-origin: left center; background: var(--green); transition: transform 0.25s ease-out, background-color 0.3s; }
.hull-bar::after { content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 9%, rgba(6, 18, 28, 0.85) 9% 10%); }
.hull-num { grid-column: 2; grid-row: 1 / span 2; font-size: 26px; font-weight: 800; line-height: 1; min-width: 2.2ch; text-align: right;
  font-variant-numeric: tabular-nums; color: var(--green); }
.hull[data-level="warn"] .hull-bar i { background: var(--amber); }
.hull[data-level="warn"] .hull-num { color: var(--amber); }
.hull[data-level="bad"] .hull-bar i { background: var(--red); }
.hull[data-level="bad"] .hull-num { color: var(--red); }
.hull.critical { animation: crit 0.8s ease-in-out infinite; }
@keyframes crit { 50% { box-shadow: 0 0 0 2px rgba(255, 59, 48, 0.75), 0 0 18px rgba(255, 59, 48, 0.55); } }
.ro { flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 6px 9px; min-width: 58px; }
.ro b { font-size: 22px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; margin-top: 4px; }
.ro-speed { flex-direction: row; flex-wrap: wrap; align-items: baseline; align-content: center; column-gap: 3px; min-width: 64px; }
.ro-speed .hud-lbl { flex-basis: 100%; }
.ro-speed b { color: var(--teal); }
.ro-speed small { font-size: 11px; font-weight: 700; color: var(--dim); letter-spacing: 0.08em; }

.icon-btn { pointer-events: auto; width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; cursor: pointer;
  background: var(--panel); border: 1px solid rgba(143, 166, 181, 0.25); border-radius: 6px; color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.off { color: var(--dim); }
.icon-btn:active { transform: scale(0.94); }
.hud-sound { align-self: center; }

.route { position: absolute; top: calc(var(--sat) + 70px); left: calc(var(--sal) + 8px); right: calc(var(--sar) + 8px);
  background: var(--panel); border: 1px solid rgba(143, 166, 181, 0.18); border-radius: 6px; padding: 6px 10px 9px; }
.route-labels { display: flex; justify-content: space-between; align-items: baseline; font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; color: var(--dim); margin-bottom: 6px; }
.route-labels span:last-child { color: var(--teal); }
.route-labels .route-pct { color: var(--amber); font-size: 12px; font-variant-numeric: tabular-nums; }
.route-track { position: relative; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); }
.route-fill { position: absolute; inset: 0; border-radius: 4px; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, var(--teal-dim), var(--teal)); }
.route-narrows { position: absolute; top: -3px; bottom: -3px; border-radius: 2px; z-index: 1;
  background: repeating-linear-gradient(135deg, rgba(255, 59, 48, 0.55) 0 4px, rgba(255, 59, 48, 0.18) 4px 8px);
  border-left: 1px solid rgba(255, 59, 48, 0.9); border-right: 1px solid rgba(255, 59, 48, 0.9); }
.route-narrows span { position: absolute; top: 15px; left: 50%; transform: translateX(-50%); font-size: 8px; font-weight: 700;
  letter-spacing: 0.18em; color: #ff8a80; white-space: nowrap; }
.route-ship { position: absolute; top: 50%; left: 0; width: 22px; height: 12px; margin: -6px 0 0 -11px; z-index: 2;
  background: var(--amber); clip-path: polygon(0 18%, 70% 18%, 100% 50%, 70% 82%, 0 82%);
  filter: drop-shadow(0 0 4px rgba(245, 165, 36, 0.9)); transition: left 0.2s linear; }
.route-ship.in-narrows { background: #ff6a4d; filter: drop-shadow(0 0 6px rgba(255, 59, 48, 0.95)); }

.hud-chaff { position: absolute; top: calc(var(--sat) + 128px); right: calc(var(--sar) + 10px); display: flex; align-items: center; gap: 6px;
  background: var(--panel); border-radius: 5px; padding: 5px 8px; }
.touch .hud-chaff { display: none; }
.pips { display: flex; gap: 4px; }
.pips i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--amber); }
.pips i.on { background: var(--amber); box-shadow: 0 0 6px rgba(245, 165, 36, 0.8); }

@media (min-width: 760px) {
  .hud-top, .route { right: auto; width: 560px; }
  .hud-chaff { right: auto; left: calc(var(--sal) + 8px); }
}

/* ---------------- threats ---------------- */
.threat-layer { position: absolute; top: calc(var(--sat) + 142px); bottom: calc(var(--sab) + 18px);
  left: calc(var(--sal) + 16px); right: calc(var(--sar) + 16px); }
.tarrow { position: absolute; left: 0; top: 0; width: 0; height: 0; display: none; will-change: transform; --c: var(--amber); }
.tarrow[data-kind="rocket"] { --c: var(--red); }
.tarrow[data-kind="mine"] { --c: #ffd27a; }
.tarrow .chev { position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; color: var(--c);
  filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.9)); }
.tarrow .chev svg { width: 100%; height: 100%; }
.tarrow[data-kind="mine"] .chev { left: -11px; top: -11px; width: 22px; height: 22px; opacity: 0.85; }
.tarrow[data-kind="rocket"] .chev svg { animation: blink 0.4s steps(2, jump-none) infinite; }
.tarrow .eta { position: absolute; left: 0; top: 14px; transform: translateX(-50%); font-size: 13px; font-weight: 800;
  color: #fff; background: var(--red); padding: 0 5px; border-radius: 3px; line-height: 17px; font-variant-numeric: tabular-nums; }
.tarrow .eta:empty { display: none; }
.tarrow.onscreen .chev { display: none; }
.tarrow.onscreen .eta { top: -34px; box-shadow: 0 0 10px rgba(255, 59, 48, 0.7); }
@keyframes blink { 50% { opacity: 0.35; } }

.incoming { position: absolute; top: calc(var(--sat) + 150px); left: 50%; transform: translateX(-50%); display: none;
  flex-direction: column; align-items: center; padding: 6px 22px 7px; border-radius: 4px; text-align: center;
  background: repeating-linear-gradient(135deg, rgba(255, 59, 48, 0.92) 0 12px, rgba(190, 25, 20, 0.92) 12px 24px);
  box-shadow: 0 0 24px rgba(255, 59, 48, 0.6); color: #fff; white-space: nowrap; }
.incoming.on { display: flex; animation: incoming 0.5s ease-in-out infinite alternate; }
.inc-main { font-family: var(--stencil); font-size: 30px; line-height: 1; letter-spacing: 0.08em; }
.inc-sub { font-size: 12px; font-weight: 800; letter-spacing: 0.22em; margin-top: 2px; }
@keyframes incoming { from { opacity: 1; } to { opacity: 0.55; } }

.vignette { position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(255, 40, 30, 0.35) 70%, rgba(200, 0, 0, 0.85) 100%); }
.dmg-tag { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); opacity: 0; white-space: nowrap;
  font-family: var(--stencil); font-size: clamp(34px, 11vw, 64px); letter-spacing: 0.04em; color: #fff;
  text-shadow: 0 0 2px #000, 0 3px 0 #7a0a05, 0 0 22px rgba(255, 59, 48, 0.9); }
.dmg-tag[data-kind="ground"], .dmg-tag[data-kind="gun"] { font-size: clamp(26px, 8vw, 46px); color: #ffd9a0; }

.hint { position: absolute; left: 50%; top: calc(var(--sat) + 236px); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  text-align: center; font-size: 13px; font-weight: 700; letter-spacing: 0.1em; color: var(--text); opacity: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.hint.show { animation: hint 5.5s ease forwards; }
body:not([data-state="playing"]) .hint { display: none; }
@keyframes hint { 0% { opacity: 0; } 8%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------------- touch layer (built by input.js) ---------------- */
#touch-layer { position: fixed; inset: 0; z-index: 5; pointer-events: none; touch-action: none; }
body[data-state="playing"] #touch-layer { pointer-events: auto; }
.joy { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity 0.12s; will-change: transform; }
.joy.on { opacity: 1; }
.joy-ring { position: absolute; left: -64px; top: -64px; width: 128px; height: 128px; border-radius: 50%;
  border: 2px solid rgba(245, 165, 36, 0.65); background: radial-gradient(circle, rgba(6, 18, 28, 0.15), rgba(6, 18, 28, 0.45));
  box-shadow: inset 0 0 18px rgba(245, 165, 36, 0.18); }
.joy-ring::before, .joy-ring::after { content: ""; position: absolute; background: rgba(245, 165, 36, 0.35); }
.joy-ring::before { left: 50%; top: 10px; bottom: 10px; width: 1px; }
.joy-ring::after { top: 50%; left: 10px; right: 10px; height: 1px; }
.joy-knob { position: absolute; left: -27px; top: -27px; width: 54px; height: 54px; border-radius: 50%; margin: 0;
  background: radial-gradient(circle at 35% 30%, var(--amber-hi), var(--amber) 55%, #b46f05); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); }
.joy-hint { display: none; position: absolute; left: calc(var(--sal) + 34px); bottom: calc(var(--sab) + 40px); width: 112px; height: 112px;
  border-radius: 50%; border: 2px dashed rgba(245, 165, 36, 0.5); place-items: center; pointer-events: none; }
.joy-hint span::before { content: "DRAG"; font-size: 13px; font-weight: 800; letter-spacing: 0.2em; color: rgba(245, 165, 36, 0.85); }
.touch[data-state="playing"] #touch-layer:not(.used) .joy-hint { display: grid; animation: hintpulse 1.4s ease-in-out infinite; }
@keyframes hintpulse { 50% { opacity: 0.45; transform: scale(0.94); } }

#chaff-btn { position: absolute; right: calc(var(--sar) + 18px); bottom: calc(var(--sab) + 26px); width: 88px; height: 88px; border-radius: 50%;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer;
  background: radial-gradient(circle at 50% 35%, #1a3346, #0a1b28 70%); border: 3px solid var(--amber); color: var(--amber);
  box-shadow: 0 0 0 4px rgba(6, 18, 28, 0.55), 0 4px 16px rgba(0, 0, 0, 0.55); touch-action: none; }
body[data-state="playing"] #chaff-btn { display: flex; }
#chaff-btn svg { width: 34px; height: 34px; margin-top: -4px; }
.chaff-label { font-size: 11px; font-weight: 800; letter-spacing: 0.16em; line-height: 1; }
.chaff-count { position: absolute; top: -6px; right: -6px; min-width: 28px; height: 28px; border-radius: 14px; padding: 0 6px;
  display: grid; place-items: center; font-size: 17px; font-weight: 800; background: var(--amber); color: #1a1205;
  border: 2px solid var(--navy); font-variant-numeric: tabular-nums; }
.chaff-key { display: none; }
#chaff-btn.empty { border-color: #4a5a66; color: #5f717e; }
#chaff-btn.empty .chaff-count { background: #4a5a66; color: #c9d3da; }
#chaff-btn.urge { animation: urge 0.45s ease-in-out infinite alternate; }
@keyframes urge { to { border-color: var(--red); color: #fff; box-shadow: 0 0 0 6px rgba(255, 59, 48, 0.45), 0 0 28px rgba(255, 59, 48, 0.85); } }
#chaff-btn.fire { animation: fire 0.35s ease-out; }
@keyframes fire { 0% { transform: scale(0.88); background: #6b4a10; } 100% { transform: scale(1); } }
#chaff-btn:active { transform: scale(0.94); }
body:not(.touch) #chaff-btn { width: 76px; height: 76px; }
body:not(.touch) #chaff-btn .chaff-key { display: block; position: absolute; bottom: -20px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.18em; color: var(--dim); }
body:not(.touch) #chaff-btn svg { width: 28px; height: 28px; }

/* ---------------- screens ---------------- */
.screen { position: absolute; inset: 0; display: none; pointer-events: auto; overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.screen.show { display: block; }
.sound-toggle { position: absolute; top: calc(var(--sat) + 10px); right: calc(var(--sar) + 10px); z-index: 3; }
[data-state="playing"] > .sound-toggle { display: none; }

.btn { pointer-events: auto; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px;
  padding: 0 26px; border: 0; cursor: pointer; font-size: 22px; font-weight: 800; letter-spacing: 0.14em; line-height: 1;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px); transition: transform 0.08s, filter 0.15s; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.btn.primary { background: linear-gradient(180deg, var(--amber-hi), var(--amber) 60%, #d98a0c); color: #1a1205;
  box-shadow: 0 6px 22px rgba(245, 165, 36, 0.35); }
.btn.ghost { background: rgba(232, 241, 247, 0.08); color: var(--text); box-shadow: inset 0 0 0 1.5px rgba(232, 241, 247, 0.35); }
.btn.ghost svg { width: 20px; height: 20px; }
@media (hover: hover) { .btn.primary:hover { filter: brightness(1.08); } .btn.ghost:hover { background: rgba(232, 241, 247, 0.14); } }

/* Menu: phone = full-bleed art; desktop = live scene + art card. */
.menu { background: linear-gradient(180deg, rgba(6, 18, 28, 0.82), rgba(6, 18, 28, 0.35) 40%, rgba(6, 18, 28, 0.55) 70%, rgba(6, 18, 28, 0.92)); }
.menu-bg { position: absolute; inset: 0; background-size: cover; background-position: center 42%; opacity: 0; transition: opacity 0.6s; }
.menu.has-art .menu-bg { opacity: 1; }
.menu-bg::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(4, 12, 20, 0.88) 0%, rgba(4, 12, 20, 0.45) 26%, rgba(4, 12, 20, 0) 40%,
    rgba(4, 12, 20, 0.1) 52%, rgba(4, 12, 20, 0.78) 66%, rgba(4, 12, 20, 0.95) 100%); }
.menu-art { display: none; }
.menu-inner { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; justify-content: space-between;
  gap: 24px; padding: calc(var(--sat) + 22px) calc(var(--sar) + 20px) calc(var(--sab) + 20px) calc(var(--sal) + 20px);
  max-width: 560px; margin: 0 auto; }
.menu-head { text-align: center; display: flex; flex-direction: column; align-items: center; }
.emblem { width: 56px; height: 56px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(245, 165, 36, 0.5), 0 0 20px rgba(245, 165, 36, 0.3); margin-bottom: 10px; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.26em; color: var(--teal); }
.title { font-family: var(--stencil); font-weight: 400; line-height: 0.88; margin: 8px 0 10px; display: flex; flex-direction: column; align-items: center;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.55), 0 0 30px rgba(0, 0, 0, 0.6); }
.title span:first-child { font-size: clamp(34px, 11vw, 60px); letter-spacing: 0.3em; margin-right: -0.3em; color: var(--text); }
.title span:last-child { font-size: clamp(64px, 20.5vw, 116px); letter-spacing: 0.02em; color: var(--amber); }
.pitch { font-size: 19px; font-weight: 600; letter-spacing: 0.02em; color: var(--text); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9); }
.menu-foot { display: flex; flex-direction: column; gap: 14px; }
.howto { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.howto li { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 6px; background: rgba(5, 16, 26, 0.8);
  border-left: 3px solid var(--amber); }
.howto li svg { width: 34px; height: 34px; flex: 0 0 34px; color: var(--amber); }
.howto b { display: block; font-size: 15px; font-weight: 800; letter-spacing: 0.14em; color: var(--amber); line-height: 1.1; }
.howto li > div { font-size: 15px; line-height: 1.25; min-width: 0; }
.howto span { font-size: 15px; font-weight: 500; line-height: 1.25; color: var(--text); }
.howto b { margin-bottom: 2px; }
.howto em { font-style: normal; color: #ff6b61; font-weight: 700; }
.sail { width: 100%; min-height: 64px; font-size: 28px; letter-spacing: 0.3em; }
.sail .arrow { font-size: 18px; letter-spacing: 0; }
.menu-note { text-align: center; font-size: 12px; font-weight: 600; letter-spacing: 0.12em; color: var(--dim); }
.menu.show .menu-head { animation: rise 0.7s ease-out both; }
.menu.show .menu-foot { animation: rise 0.7s 0.15s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

@media (max-height: 700px) {
  .emblem { display: none; }
  .title span:last-child { font-size: clamp(54px, 17vw, 90px); }
  .howto li { padding: 7px 10px; }
  .howto span { font-size: 14px; }
  .menu-inner { gap: 14px; }
}

@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .menu { background: linear-gradient(90deg, rgba(4, 12, 20, 0.92) 0%, rgba(4, 12, 20, 0.7) 45%, rgba(4, 12, 20, 0.3) 100%); }
  .menu-bg { display: none; }
  .menu-art { display: block; position: absolute; right: 6vw; top: 50%; height: min(84vh, 760px); aspect-ratio: 9 / 16;
    transform: translateY(-50%); background-size: cover; background-position: center; border-radius: 10px;
    border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 6px rgba(6, 18, 28, 0.6); opacity: 0; transition: opacity 0.6s; }
  .menu.has-art .menu-art { opacity: 1; }
  .menu-inner { margin: 0 0 0 7vw; max-width: 540px; justify-content: center; gap: 36px; }
  .menu-head { text-align: left; align-items: flex-start; }
  .title { align-items: flex-start; }
  .title span:first-child { font-size: 48px; }
  .title span:last-child { font-size: 112px; }
  .sail { width: auto; align-self: flex-start; min-width: 260px; }
  .menu-note { text-align: left; }
}

/* End screens */
.end { background: radial-gradient(ellipse at center, rgba(4, 12, 20, 0.45), rgba(4, 12, 20, 0.88)); animation: fadein 0.6s ease-out both; }
.end[data-result="lost"] { background: radial-gradient(ellipse at center, rgba(40, 6, 4, 0.45), rgba(10, 4, 6, 0.9)); animation-delay: 0.3s; }
@keyframes fadein { from { opacity: 0; } }
.card { position: relative; width: min(420px, calc(100% - 28px)); margin: calc(var(--sat) + 64px) auto calc(var(--sab) + 24px);
  padding: 22px 20px 18px; background: rgba(6, 18, 28, 0.9); border: 1px solid rgba(143, 166, 181, 0.2); border-top: 4px solid var(--amber);
  border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); text-align: center; animation: rise 0.6s 0.25s ease-out both; }
.end[data-result="lost"] .card { border-top-color: var(--red); animation-delay: 0.7s; }
@media (min-height: 760px) { .card { margin-top: max(calc(var(--sat) + 64px), 12vh); } }
.end-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.24em; color: var(--teal); }
.end[data-result="lost"] .end-kicker { color: #ff8a80; }
.end-title { font-family: var(--stencil); font-weight: 400; font-size: clamp(40px, 12.5vw, 58px); line-height: 0.95; margin: 8px 0 10px; color: var(--amber);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5); }
.end[data-result="lost"] .end-title { color: var(--red); }
.rating { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 4px; }
.rating[hidden] { display: none; }
.stars { display: flex; gap: 6px; font-size: 40px; line-height: 1; }
.stars i { font-style: normal; color: rgba(232, 241, 247, 0.18); }
.stars i.on { color: var(--amber); text-shadow: 0 0 16px rgba(245, 165, 36, 0.7); animation: pop 0.4s ease-out both; }
.stars i.on:nth-child(2) { animation-delay: 0.15s; } .stars i.on:nth-child(3) { animation-delay: 0.3s; }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } 70% { transform: scale(1.25); } }
.rank { font-size: 16px; font-weight: 800; letter-spacing: 0.3em; color: var(--text); }
.end-route { margin: 6px 4px 4px; }
.end-route[hidden] { display: none; }
.end-route .route-track { height: 10px; }
.end-route .route-fill { background: linear-gradient(90deg, var(--teal-dim), #ff6a4d); }
.end-route .route-ship { background: #ff6a4d; }
.end-route .route-labels { margin: 7px 0 0; }
.end-sub { font-size: 16px; font-weight: 500; color: var(--text); margin: 8px 0 12px; line-height: 1.3; }
.end-sub b { color: var(--amber); }
.stats { display: grid; grid-template-columns: 1fr; text-align: left; border-top: 1px solid rgba(143, 166, 181, 0.18); }
.stat { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 2px; border-bottom: 1px solid rgba(143, 166, 181, 0.12); }
.stat dt { font-size: 13px; font-weight: 700; letter-spacing: 0.16em; color: var(--dim); }
.stat dd { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat.hl dd { color: var(--amber); }
.stat.good dd { color: var(--green); } .stat.warn dd { color: var(--amber); } .stat.bad dd { color: var(--red); }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.actions .again { flex: 1 1 auto; font-size: 22px; }
.actions .share { flex: 0 0 auto; padding: 0 16px; font-size: 16px; }
.end-note { margin-top: 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; color: var(--dim); }
.touch .end-note { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------------- win: thank-you call ---------------- */
.thanks { background: radial-gradient(ellipse at 50% 40%, rgba(20, 40, 80, 0.55), rgba(4, 10, 22, 0.92)); animation: fadein 0.5s ease-out both; }
.thanks-wrap { width: min(400px, calc(100% - 28px)); margin: calc(var(--sat) + 28px) auto calc(var(--sab) + 24px);
  display: flex; flex-direction: column; align-items: center; text-align: center; }
.thanks-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.24em; color: var(--teal); margin-bottom: 14px;
  animation: blink 1s steps(2, jump-none) 3; }
.bubble { position: relative; z-index: 2; background: #fff; color: #0d1b2a; border: 3px solid #0d1b2a; border-radius: 22px;
  padding: 14px 18px; font-family: var(--stencil); font-size: clamp(22px, 6.6vw, 30px); line-height: 1.08; letter-spacing: 0.01em;
  box-shadow: 0 6px 0 #0d1b2a, 0 12px 30px rgba(0, 0, 0, 0.45); margin-bottom: 22px; max-width: 100%;
  animation: bubblepop 0.5s cubic-bezier(.2, 1.6, .4, 1) 0.35s both; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -21px; margin-left: -14px; width: 28px; height: 22px;
  background: #fff; border: 3px solid #0d1b2a; border-top: 0; clip-path: polygon(0 0, 100% 0, 30% 100%);
  border-radius: 0 0 4px 4px; }
@keyframes bubblepop { from { transform: scale(0.3) translateY(30px); opacity: 0; } }
.thanks-art { width: min(340px, 84vw, 46vh); aspect-ratio: 1; border-radius: 18px; overflow: hidden;
  border: 3px solid var(--amber); box-shadow: 0 0 0 6px rgba(245, 165, 36, 0.18), 0 18px 40px rgba(0, 0, 0, 0.55);
  animation: rise 0.6s ease-out both; }
.thanks-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thanks-next { margin-top: 22px; width: 100%; max-width: 340px; }

/* ---------------- coin: ticker pill, CA bar, in-play chip (coin-ui.js) ---------------- */
.coin-pill { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 4px 12px; border-radius: 999px;
  background: rgba(5, 16, 26, 0.82); border: 1px solid var(--line); font-size: 14px; letter-spacing: 0.12em; }
.coin-pill b { color: var(--amber); font-weight: 800; font-size: 16px; letter-spacing: 0.06em; }
.coin-pill-state { font-size: 11px; font-weight: 700; color: var(--green); letter-spacing: 0.16em; }
.coin-pill-state[hidden] { display: none; }
.coin-announce { margin-top: 8px; font-size: 14px; font-weight: 700; color: var(--amber-hi); letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9); }
.coin-announce[hidden] { display: none; }

.cabar { pointer-events: auto; width: 100%; }
.cabar-live { display: none; align-items: stretch; gap: 6px; }
.cabar.is-live .cabar-live { display: flex; }
.cabar.is-live .cabar-preview { display: none; }
.cabar-preview { text-align: center; font-size: 13px; font-weight: 700; letter-spacing: 0.14em; color: var(--dim);
  padding: 10px 12px; border: 1px dashed rgba(143, 166, 181, 0.35); border-radius: 6px; background: rgba(5, 16, 26, 0.7); }
.cabar button, .cabar a { font-family: inherit; min-height: 44px; border-radius: 6px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.ca-code { flex: 1 1 auto; min-width: 0; padding: 0 10px; background: rgba(5, 16, 26, 0.86); border: 1px solid rgba(143, 166, 181, 0.3);
  color: var(--text); justify-content: flex-start !important; }
.ca-k { font-size: 11px; font-weight: 800; letter-spacing: 0.16em; color: var(--dim); }
.ca-code code { font: 600 14px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; overflow: hidden; text-overflow: ellipsis; }
.ca-copy { flex: 0 0 auto; padding: 0 12px; background: rgba(42, 209, 201, 0.14); border: 1px solid var(--teal-dim); color: var(--teal);
  font-size: 14px; font-weight: 800; letter-spacing: 0.12em; }
.ca-copy svg { width: 16px; height: 16px; }
.cabar.copied .ca-copy { background: var(--teal); color: #04201f; }
.ca-buy { flex: 0 0 auto; padding: 0 14px; background: var(--green); color: #04210f; border: 0; font-size: 15px; font-weight: 800; letter-spacing: 0.08em; }
.ca-buy:active, .ca-copy:active, .ca-code:active { transform: scale(0.97); }
.cabar-end { margin-top: 12px; }
.cabar-thanks { margin-top: 14px; max-width: 340px; }
body.stream .cabar, body.stream .coin-chip { display: none !important; }
.ca-code code { text-overflow: clip; }
@media (max-width: 430px) {
  .cabar-live { gap: 5px; }
  .cabar:not(.cabar-chip) .ca-k { display: none; }
  .ca-code { padding: 0 8px; justify-content: center !important; }
  .ca-code code { font-size: 13px; }
  .ca-copy { padding: 0 10px; font-size: 13px; }
  .ca-buy { padding: 0 10px; font-size: 14px; }
}
@media (max-width: 340px) { .ca-copy span { display: none; } }

.coin-chip { display: none; position: absolute; z-index: 4; right: calc(var(--sar) + 8px); top: calc(var(--sat) + 128px);
  flex-direction: column; align-items: flex-end; pointer-events: none; }
body.coin-live[data-state="playing"] .coin-chip { display: flex; }
.chip-btn { pointer-events: auto; min-height: 44px; min-width: 44px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; cursor: pointer; color: var(--text); }
.chip-btn b { color: var(--amber); font-size: 15px; font-weight: 800; letter-spacing: 0.06em; }
.chip-caret { font-size: 12px; color: var(--dim); transition: transform 0.15s; }
.coin-chip.open .chip-caret { transform: rotate(180deg); }
.chip-panel { display: none; margin-top: 6px; padding: 6px; width: min(300px, calc(100vw - 24px)); background: var(--panel-solid);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.coin-chip.open .chip-panel { display: block; }
.cabar-chip .cabar-live { flex-wrap: wrap; }
.cabar-chip .ca-code { flex-basis: 100%; }
.cabar-chip .ca-copy, .cabar-chip .ca-buy { flex: 1 1 0; }
/* the chip takes the CHAFF pips' corner, so on narrow keyboard screens they move left */
body.coin-live .hud-chaff { right: auto; left: calc(var(--sal) + 8px); }
@media (min-width: 760px) { .coin-chip { top: calc(var(--sat) + 8px); } }

/* ---------------- ?stream=1: livestream overlay ---------------- */
body.stream .hud-top, body.stream .hud-chaff, body.stream .hint, body.stream #chaff-btn, body.stream .joy-hint,
body.stream .sound-toggle, body.stream .thanks-next, body.stream .end .actions, body.stream .end-note { display: none !important; }
body.stream .route { top: calc(var(--sat) + 8px); }
body.stream .threat-layer { top: calc(var(--sat) + 80px); }
body.stream .incoming { top: calc(var(--sat) + 86px); }
body.stream #touch-layer { pointer-events: none !important; }
body.stream .menu { display: none !important; }
.stream-ov { position: fixed; inset: 0; z-index: 20; pointer-events: none; font-family: var(--font); }
.so-top { position: absolute; top: calc(var(--sat) + 74px); left: calc(var(--sal) + 10px); display: flex; gap: 8px; align-items: center; }
.so-live { background: var(--red); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: 0.16em; padding: 3px 8px; border-radius: 3px;
  animation: incoming 0.9s ease-in-out infinite alternate; }
.so-auto { font-size: 12px; font-weight: 700; letter-spacing: 0.18em; color: var(--text); text-shadow: 0 1px 4px #000; }
.so-bot { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px calc(var(--sar) + 14px) calc(var(--sab) + 18px) calc(var(--sal) + 14px);
  text-align: center; background: linear-gradient(180deg, transparent, rgba(4, 12, 20, 0.78) 38%, rgba(4, 12, 20, 0.94)); }
.so-tick { font-family: var(--stencil); font-size: clamp(56px, 17vw, 130px); line-height: 0.95; color: var(--amber);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.6), 0 0 34px rgba(245, 165, 36, 0.45); }
.so-ca { margin-top: 8px; display: inline-flex; align-items: baseline; gap: 8px; max-width: 100%; padding: 6px 10px; border-radius: 6px;
  background: rgba(5, 16, 26, 0.9); border: 1px solid var(--line); }
.so-ca span { font-size: 12px; font-weight: 800; letter-spacing: 0.16em; color: var(--dim); }
.so-ca code { font: 700 clamp(10.5px, 3.1vw, 24px)/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; color: var(--text); word-break: break-all; }
.stream-ov:not(.is-live) .so-ca code { font-family: var(--font); letter-spacing: 0.12em; color: var(--dim); }
.so-play { margin-top: 10px; font-size: clamp(15px, 4.4vw, 30px); font-weight: 700; letter-spacing: 0.06em; color: var(--text); }
.so-play b { color: var(--teal); }
