:root {
  color-scheme: dark;
  --ink: #102b35;
  --cream: #fff4da;
  --amber: #ffd48d;
  --chrome: #102b35ed;
  --edge: clamp(16px, 3.2vw, 56px);
  font-family: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #195c72; }
button, a { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { text-decoration: none; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 6px #173643; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stage {
  position: relative; isolation: isolate; width: 100%; height: 100vh; height: 100dvh; overflow: hidden;
  color: var(--cream); background: #347e85; outline: none;
  --left: max(var(--edge), env(safe-area-inset-left)); --right: max(var(--edge), env(safe-area-inset-right));
  --top: max(var(--edge), env(safe-area-inset-top)); --bottom: max(var(--edge), env(safe-area-inset-bottom));
}
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; }
.top, .hud { position: absolute; z-index: 3; top: var(--top); }
.top { inset-inline: var(--left) var(--right); display: flex; justify-content: space-between; pointer-events: none; }
.tools { display: flex; gap: 7px; }
.tool, .pad button, .hud, .keybar { background: var(--chrome); border: 1px solid #a3d7d742; box-shadow: 0 2px 0 #031e2d45; }
.tool, .pad button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px;
  border-radius: 8px; line-height: 1; font-weight: 700; pointer-events: auto;
}
.home { padding: 0 12px 0 8px; font-size: .9rem; }
.tool:enabled:hover, .home:hover, .pad button:hover { background: #214754; }
.tool:disabled { color: #9cb4b7; background: #25414b; }
#sound[aria-pressed="true"] { color: var(--amber); }
.hud {
  left: 50%; transform: translateX(-50%); display: flex; border-radius: 10px; overflow: hidden;
}
.hud > div { padding: 6px clamp(10px, 1.8vw, 27px); display: grid; gap: 2px; min-width: 0; }
.hud > div + div { border-inline-start: 1px solid #c5eeeb36; }
.hud span { color: #c0dcd8; font-size: .75rem; line-height: 1.1; }
.hud strong { font-family: ui-monospace, Consolas, monospace; font-size: clamp(.95rem, 1.4vw, 1.28rem); line-height: 1.15; }
.hud strong { white-space: nowrap; }
#lives, #points { color: var(--amber); }
[data-mode="ready"] .hud { display: none; }
.veil {
  position: absolute; inset: 0; z-index: 1; display: flex; align-items: flex-end;
  padding: calc(var(--top) + 58px) var(--right) max(12.5vh,calc(var(--bottom) + 42px)) var(--left);
  background: linear-gradient(86deg,#082632e8 0%,#0a2934ce 20%,#0e2a3482 38%,transparent 66%),
              linear-gradient(0deg,#0a293d91,transparent 53%);
}
.panel { max-width: min(35rem, 47vw); }
.genre {
  display: flex; gap: 10px; align-items: center; margin: 0 0 12px;
  color: #ffe0a7; font-weight: 750; font-size: .83rem; letter-spacing: .12em; text-transform: uppercase;
}
.genre svg { width: 32px; height: 24px; stroke-width: 2.3; }
h1 { margin: 0; line-height: .96; font-size: clamp(2.45rem,5.95vw,7rem); letter-spacing: -.064em; text-wrap: balance; }
[data-mode="ready"] h1 {
  font-family: "Arial Black", "Segoe UI", system-ui, sans-serif; font-weight: 950; text-transform: uppercase;
  font-style: italic; white-space: nowrap; text-shadow: 0 4px 0 #c57854,0 7px 0 #173845;
}
#message { max-width: 41ch; margin: 17px 0 20px; color: #fff6e4; line-height: 1.5; font-size: clamp(1rem,1.48vw,1.17rem); }
.actions { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; }
.actions button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 17px; border-radius: 7px; font-weight: 750; }
.primary { background: var(--amber); border: 1px solid #ffedc1; color: var(--ink); box-shadow: 0 3px 0 #946344; }
.primary:hover { background: #ffe4aa; }
.primary svg { width: 18px; height: 18px; }
.alternate { background: #123744f2; border: 1px solid #a6ccc674; }
.alternate:hover { background: #27505a; }
.record { margin: 17px 0 0; color: #c3ddda; font-size: .84rem; }
.record b { color: var(--cream); padding-inline-start: 4px; }
.keybar, .pad { position: absolute; z-index: 2; bottom: var(--bottom); }
.keybar { right: var(--right); display: flex; align-items: center; gap: 15px; border-radius: 7px; padding: 6px 10px; color: #daece5; font-size: .8rem; }
.keybar span { display: flex; align-items: center; gap: 4px; }
kbd { padding: 1px 4px; border-radius: 3px; color: #fff6e4; background: #31515a; font: 600 .78rem/1.4 ui-monospace,monospace; }
.pad { left: var(--left); right: var(--right); display: none; justify-content: space-between; align-items: center; pointer-events: none; }
.steer { display: flex; gap: 8px; }
.pad button { user-select: none; -webkit-user-select: none; touch-action: none; width: 53px; height: 49px; }
.pad button[data-key="right"] svg { transform: rotate(180deg); }
.pad .jump { width: auto; padding: 0 13px; }
.pad button.on, .pad button:active { background: var(--amber); color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
noscript { position:absolute; z-index:4; inset:38% 8% auto; padding:20px; background:var(--ink); text-align:center; }
@media (max-width: 700px) {
  .veil { padding-bottom: max(9vh,calc(var(--bottom) + 24px)); }
  .panel { max-width: min(31rem, 88vw); }
  .hud { top: calc(var(--top) + 52px); }
}
@media (max-width: 850px) {
  .hud { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); width: min(16.5rem,calc(100% - var(--left) - var(--right))); }
  .hud > div { padding: 5px 9px; }
  .hud > div:nth-child(4) { border-inline-start: 0; }
  .hud > div:nth-child(n+4) { border-top: 1px solid #c5eeeb36; }
}
@media (orientation: portrait) {
  .veil { background: linear-gradient(0deg,#092632f8 0%,#0b2b36ef 19%,#0e303bb3 39%,transparent 64%); }
  .panel { max-width: min(32rem,100%); }
  h1 { font-size: clamp(2.45rem, 8.2vw, 4.1rem); }
}
@media (pointer: coarse), (max-width: 700px) {
  .keybar { display: none; }
  [data-mode="running"] .pad { display: flex; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .stage { --edge: 9px; }
  .hud { top: var(--top); }
  .veil { padding: calc(var(--top) + 52px) var(--right) max(14px,var(--bottom)) max(19px,var(--left)); }
  .panel { max-width: min(32rem,76vw); }
  h1 { font-size: clamp(2rem,5.5vw,3.3rem); }
  .genre { margin-bottom: 4px; font-size: .75rem; }
  #message { margin: 7px 0 9px; font-size: .95rem; line-height: 1.28; }
  .record { margin-top: 8px; }
  .keybar { display: none; }
}
@media (max-width: 540px) and (orientation: landscape) {
  .hud { top: calc(var(--top) + 46px); right: var(--right); left: auto; transform: none; }
  .hud > div { padding-inline: 5px; }
}
@media (max-height: 600px) and (orientation: portrait) {
  .veil { padding-bottom: var(--bottom); }
  .genre { margin-bottom: 8px; }
  #message { margin: 10px 0 12px; line-height: 1.36; }
  .record { margin-top: 11px; }
}

.stage-line { margin:13px 0 0; color:#a6eee0; font-size:.92rem; font-weight:750; }
.panel-detail { margin:0 0 13px; color:#bde8df; line-height:1.38; }
.panel-foot,.receipt { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.panel-foot { margin-top:19px; }
.panel-foot .record { margin:0; }
.receipt { margin:10px 0 16px; gap:7px; }
.receipt > span { padding:6px 9px; border-radius:4px; background:#0b3039de; font-size:.85rem; }
.receipt b, #medal-chip { color:var(--amber); }
.stage:not([data-mode="running"]) .hud,[data-mode="map"] .top,[data-mode="map"] .keybar { display:none; }
.keycap { padding:1px 4px; border-radius:3px; color:#fff6e4; background:#31515a; font:600 .78rem/1.4 ui-monospace,monospace; }
#ride-strip { position:absolute; z-index:2; left:var(--left); bottom:max(72px,12vh); max-width:min(330px,30vw); padding:9px 12px; border-left:3px solid #8bedd7; background:linear-gradient(90deg,#092d38ef,#092d38d9); border-radius:0 6px 6px 0; pointer-events:none; }
.ride-names { display:flex; align-items:baseline; flex-wrap:wrap; gap:2px 9px; font-size:.88rem; font-weight:800; }
#ride-board,.crest-meter { color:#a9d8ce; font-size:.68rem; }
#ride-goal { margin:3px 0; font-size:.8rem; line-height:1.2; }
#ride-metrics { display:flex; flex-wrap:wrap; gap:4px 9px; }
#ride-metrics>span { display:flex; gap:5px; font-size:.75rem; line-height:1.16; }
#ride-metrics b { color:var(--amber); }
#ride-metrics .complete b { color:#99ffd0; }
.crest-meter { display:flex; align-items:center; gap:6px; margin-top:3px; min-height:14px; }
.crest-meter i { display:block; flex:none; height:4px; width:44px; border-radius:2px; background:#578088; overflow:hidden; }
#crest-fill { display:block; height:100%; background:#b1f7d9; }
#ride-action { color:#ffe1a0; }
.tour { position:absolute; z-index:6; inset:0; display:flex; flex-direction:column; background:#103e48; color:#194047; }
.tour-bar { flex:none; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:max(9px,env(safe-area-inset-top)) max(16px,var(--right)) 9px max(16px,var(--left)); color:#fff4d8; background:#12353f; border-bottom:2px solid #ad9867; }
.tour-bar h2 { margin:0; font-size:clamp(1.08rem,2.15vw,1.8rem); letter-spacing:-.03em; }
.tour button { font-weight:700; border-radius:5px; }
.map-back { padding:8px 12px; border:1px solid #77a59f; color:#e6f5df; background:transparent; }
.stamp-count { font-size:.82rem; color:#d3e5ce; white-space:nowrap; }
.stamp-count b { color:#ffd996; }
.tour-body { flex:1; min-height:0; display:grid; grid-template-columns:minmax(0,1fr) minmax(320px,32%); }
.chart-wrap { min-width:0; min-height:0; position:relative; overflow:hidden; }
#tour-chart { position:absolute; inset:0; width:100%; height:100%; image-rendering:auto; cursor:pointer; }
.route-card { overflow:auto; min-height:0; align-content:center; display:grid; gap:clamp(9px,1.8vh,22px); color:#193d42; padding:clamp(16px,2.6vw,42px); background:repeating-linear-gradient(0deg,#ac9a6e0a 0 1px,transparent 1px 4px),#fff2d8; border-left:3px solid #b39d74; }
.stops,#boards,.dispatch { display:flex; gap:5px; }
.stops button,#boards button,.classic-btn,#classic-btn { color:#28515a; background:#fff8e9; border:1px solid #c5b995; }
.stops button { flex:1; min-width:0; padding:7px 0; font:700 .84rem/1.2 ui-monospace,monospace; }
.stops button.locked { color:#6f6c60; border-style:dashed; }
.stops button.cleared { box-shadow:inset 0 -3px #138466; }
.stops button[aria-pressed=true],#boards button[aria-pressed=true] { color:#fff8e9; background:#165661; border-color:#165661; }
.forecast,.mission-box>span,.quiver legend { color:#7c502c; font-weight:750; font-size:.76rem; }
.bay-info h3 { margin:3px 0 6px; font-size:clamp(1.55rem,3.1vw,3rem); line-height:1; letter-spacing:-.055em; }
.bay-info p,.quiver p { margin:0; line-height:1.32; font-size:.91rem; }
.mission-box { display:grid; gap:4px; padding:9px 12px; border-left:3px solid #e29f53; background:#f3e4c6; }
.mission-box strong { font-size:.96rem; line-height:1.2; }
.mission-box small { color:#74492e; }
.quiver { margin:0; padding:0; border:none; }
.quiver legend { margin-bottom:6px; padding:0; }
#boards button { flex:1; min-width:0; padding:7px 2px; font-size:.85rem; }
#board-detail { margin:5px 0 0; color:#385459; font-size:.8rem; }
#launch { border:1px solid #10414a; color:#fff5df; background:#165661; padding:10px 18px; }
#launch:disabled { color:#545d55; background:#e0d6bf; border-color:#b9b098; }
#map-length { color:#506661; font-size:.85rem; font-weight:750; margin-inline-start:8px; }
#classic-btn { justify-self:start; padding:5px 9px; font-size:.76rem; }
@media (orientation:portrait) {
  .tour-body { display:flex; flex-direction:column; }
  .chart-wrap { flex:1 1 0; min-height:96px; }
  .route-card { flex:0 0 auto; max-height:calc(100% - 96px); display:grid; align-content:start; padding:12px max(14px,var(--right)) max(10px,var(--bottom)) max(14px,var(--left)); gap:8px; border-left:none; border-top:2px solid #b39d74; }
  .tour-bar { gap:5px; }
  .tour-bar h2 { font-size:1.08rem; }
  #ride-strip { top:calc(var(--top) + 145px); bottom:auto; left:var(--left); max-width:calc(100% - var(--left) - var(--right)); padding:5px 8px; }
  #ride-goal { display:none; }
  .ride-names { font-size:.76rem; }
}
@media (max-height:620px) and (orientation:portrait) {
  .tour-bar { padding:5px 9px; }
  .tour-bar button { padding:6px 8px; }
  .route-card { gap:5px; padding:7px 12px max(6px,env(safe-area-inset-bottom)); }
  .bay-info h3 { font-size:1.48rem; margin:2px 0 3px; }
  .bay-info p,.mission-box strong { font-size:.82rem; }
  .mission-box { padding:5px 8px; gap:2px; }
  #boards button,.stops button,#launch { padding-block:5px; }
  .quiver legend { margin:0 0 2px; }
  .quiver p,#board-detail { font-size:.75rem; }
  .panel-foot { margin-top:11px; }
  .actions button { font-size:.85rem; min-height:40px; padding:6px 10px; }
  .hud { top:calc(var(--top) + 48px); width:calc(100% - var(--left) - var(--right)); }
  .hud > div { padding:3px 7px; gap:0; grid-template-rows:12px 16px; }
  .hud span { font-size:.69rem; line-height:12px; }
  .hud strong { font-size:.88rem; line-height:16px; }
  #ride-strip { top:calc(var(--top) + 119px); padding:3px 6px; }
  #ride-strip .ride-names { display:none; }
  #ride-strip .crest-meter { margin:1px 0 0; min-height:12px; }
}
@media (max-height:520px) and (orientation:landscape) {
  .tour-bar { padding:3px 12px; }
  .map-back { padding:5px 9px; }
  .tour-body { grid-template-columns:minmax(0,1fr) minmax(285px,44%); }
  .route-card { align-content:start; gap:4px; padding:8px 13px; }
  .bay-info h3 { font-size:1.4rem; margin:1px 0 3px; }
  .bay-info p,#board-detail,.mission-box strong { font-size:.76rem; }
  .mission-box { padding:4px 8px; gap:1px; }
  #boards button,.stops button,#launch { padding-block:4px; }
  .quiver legend { margin:0 0 2px; }
  #ride-strip { bottom:max(62px,var(--bottom)); padding:4px 8px; }
  #ride-goal { display:none; }
  .panel-foot { margin-top:8px; }
}

[data-mode="ready"] .veil {
  background: linear-gradient(0deg,#062534f2,transparent 71%), linear-gradient(90deg,#10333c90,transparent 68%),
    url("../../launcher-art/tidal-dash.webp") 56% center/cover;
}
[data-mode="ready"] h1 { color: #fff9e7; font-size: clamp(40px,8.2vw,138px); text-shadow: 0 3px 13px #10313d7f; }
[data-mode="ready"] .stage-line { color: #b8f5e3; }
[data-mode="ready"] .actions { margin-top: 16px; }
[data-mode="ready"] .primary { border: 0; border-radius: 16px 0 16px 0; background: #beeedb; color: #12383d; box-shadow: none; }
#message:empty, .stage .keybar { display: none; }
.control-note { width: fit-content; max-width: 100%; margin-top: 8px; }
.control-note summary { width: fit-content; cursor: pointer; color: #f0eee2; font-size: .85rem; padding: 6px 4px; }
.control-note p { margin: 0; padding: 9px 12px; max-width: 40ch; color: #e7f6f0; font-size: .88rem; line-height: 1.45; background: #082731f2; }
.control-note summary:focus-visible { outline: 2px solid #b5f5d4; outline-offset: 2px; }
@media(max-width:620px) {
  [data-mode="ready"] .veil { background:linear-gradient(0deg,#052631 0%,#052631de 28%,transparent 68%),url("../../launcher-art/tidal-dash.webp") 67% 45%/cover; }
}
@media(max-height:520px) { .veil:has(.control-note[open]) { align-items: start; overflow-y: auto; } }
