/* DEWPOINT UI - "storybook kiln works".
   One design system, three skins. System fonts only; every shape is CSS or inline SVG.

   THE SYSTEM
   Tokens   colour  --ink (every outline and hard shadow) --paper --paper-2 (surfaces) --text --dim
                    --el --el-deep --el-ink (the element's accent and the text that sits on it)
                    --accent (the skin's second colour) --focus --good --warn
            type    --t-xs 12 / --t-sm 14 / --t-md 16 / --t-lg 20 / --t-xl 28 / --t-xxl (display)
            space   a 4 px grid: --s1 4 --s2 8 --s3 12 --s4 16 --s5 24 --s6 32
            shape   --r1 10 / --r2 16 / --r3 24 radii, --ow 3px outline, --sh 5px hard drop shadow
            motion  --spring (overshoots) --ease; all of it stops under reduced motion
   Skins    #ui[data-skin] = water (cool: cream paper, teal, coral) | fire (hot: charcoal, ember,
            gold) | clay (earthy: bone, terracotta, sage). A skin only sets tokens: there is one set
            of components.
   Parts    .btn (primary / quiet / danger / small), .icon-btn, .chip, .panel, .seg, .switch,
            range, .meter, .pips, element cards, level stops, the HUD's chips, bar and touch pads.
            Every interactive part has rest, hover, pressed, focus and disabled states, is at
            least 48 px in its smaller dimension, and sits inside the safe area. */

:root {
  /* ONE root scale token: below 360 x 360 the whole UI is laid out as if the window were that big and
     scaled down (src/ui/scale.js sets --ui-scale and html.ui-shrunk), so nothing wraps, clips or overflows.
     --uvw / --uvh are the window's width and height in the UI's own pixels (use them, not vw / vh). */
  --ui-scale: 1; --uvw: 100vw; --uvh: 100vh;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --t-xs: 12px; --t-sm: 14px; --t-md: 16px; --t-lg: 20px; --t-xl: 28px; --t-xxl: clamp(40px, calc(var(--uvw) * .125), 92px);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r1: 10px; --r2: 16px; --r3: 24px; --ow: 3px; --sh: 5px;
  --spring: cubic-bezier(.34, 1.56, .64, 1); --ease: cubic-bezier(.2, .8, .3, 1);
  /* water is the default skin (the boot screen and anything outside #ui) */
  --ink: #12303f; --paper: #fff7e6; --paper-2: #f0e4c8; --text: #12303f; --dim: #4d6a78;
  --el: #35bfc9; --el-deep: #14858f; --el-ink: #06282e; --accent: #ff8a6b; --accent-ink: #3d1408;
  --focus: #ff6a3d; --good: #2f9d62; --warn: #d8402a; --scrim: rgba(18, 48, 63, .46);
  --inv: #12303f; --inv-text: #fff7e6;      /* inverted chips: key caps, counters, the area line */
  --sky-a: #73bfe0; --sky-b: #ffdcc2;
}
#ui[data-skin="fire"] {
  --ink: #170a08; --paper: #2d1b1f; --paper-2: #402a2e; --text: #fff0dc; --dim: #d9b7a0;
  --el: #ff9a3c; --el-deep: #e2531a; --el-ink: #2a0f02; --accent: #ffd15c; --accent-ink: #3a2600;
  --focus: #fff2a8; --good: #ffd15c; --warn: #ff6a4a; --scrim: rgba(23, 10, 8, .6);
  --inv: #ffe7c4; --inv-text: #170a08;
  --sky-a: #1b2156; --sky-b: #ea8a6c;
}
#ui[data-skin="clay"] {
  --ink: #3a2a22; --paper: #f7efde; --paper-2: #e9dcc4; --text: #3a2a22; --dim: #6f5d50;
  --el: #e08e63; --el-deep: #b5613a; --el-ink: #2a140a; --accent: #9cc29a; --accent-ink: #1c3320;
  --focus: #58bd74; --good: #4f8a58; --warn: #c2432c; --scrim: rgba(58, 42, 34, .46);
  --inv: #3a2a22; --inv-text: #f7efde;
  --sky-a: #69b6c6; --sky-b: #f6ecd0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #f7e6dc; color: var(--text);
  font-family: var(--font); font-size: var(--t-md); line-height: 1.35;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  touch-action: none;
}
body { position: fixed; inset: 0; }

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#ui { position: absolute; inset: 0; pointer-events: none; color: var(--text); }
#ui > * { pointer-events: none; }
html.ui-shrunk { --uvw: calc(100vw / var(--ui-scale)); --uvh: calc(100vh / var(--ui-scale)); }
html.ui-shrunk #ui { right: auto; bottom: auto; width: calc(100% / var(--ui-scale)); height: calc(100% / var(--ui-scale)); transform: scale(var(--ui-scale)); transform-origin: 0 0; }
[hidden] { display: none !important; }
svg { display: block; }

/* ------------------------------------------------------------------ boot */
#boot {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: var(--s4);
  background: linear-gradient(180deg, #73bfe0 0%, #bfe6e4 46%, #ffdcc2 100%); color: var(--ink); text-align: center; padding: var(--s5);
  font-weight: 800; letter-spacing: .04em; transition: opacity .5s ease; z-index: 50;
}
#boot.gone { opacity: 0; pointer-events: none; }
#boot .boot-drop { width: 72px; height: 77px; animation: bob 1.4s ease-in-out infinite; filter: drop-shadow(0 6px 0 rgba(18, 48, 63, .25)); }
#boot.error { background: #fff7e6; }
@keyframes bob { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-8px) scale(.96, 1.05); } }

/* ------------------------------------------------------------------ parts */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 52px; padding: var(--s2) var(--s5); border-radius: var(--r2); border: var(--ow) solid var(--ink); cursor: pointer;
  background: var(--paper-2); color: var(--text); font: inherit; font-size: 17px; font-weight: 800; letter-spacing: .02em; text-align: center;
  box-shadow: 0 var(--sh) 0 var(--ink); transform: translateY(0);
  transition: transform .2s var(--spring), box-shadow .2s var(--spring), background-color .15s, filter .15s; touch-action: manipulation;
}
.btn svg { width: 22px; height: 22px; flex: 0 0 auto; }
/* a button's label is one line, never broken inside a word; only the long variable ones ("Next: <level>", the reset warning) may wrap, between words */
.btn > span { min-width: 0; white-space: nowrap; }
.btn.primary > span, .btn.danger > span { white-space: normal; overflow-wrap: break-word; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 calc(var(--sh) + 2px) 0 var(--ink); filter: brightness(1.05); }
.btn:active, .btn.pressed { transform: translateY(calc(var(--sh) - 1px)); box-shadow: 0 1px 0 var(--ink); transition-duration: .05s; }
.btn.primary { background: var(--el); color: var(--el-ink); min-height: 60px; font-size: 20px; font-weight: 900; letter-spacing: .03em; }
.btn.primary::after { content: ""; position: absolute; left: 10px; right: 10px; top: 5px; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .42); pointer-events: none; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 48px; font-size: var(--t-sm); padding: var(--s1) var(--s4); }
.btn.danger { background: var(--warn); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { cursor: default; filter: saturate(.3) brightness(.92); opacity: .62; transform: none; box-shadow: 0 2px 0 var(--ink); }
.icon-btn {
  width: 48px; height: 48px; padding: 10px; border-radius: var(--r2); border: var(--ow) solid var(--ink); background: var(--paper-2); color: var(--text); cursor: pointer; flex: 0 0 auto;
  box-shadow: 0 4px 0 var(--ink); transition: transform .2s var(--spring), box-shadow .2s var(--spring); touch-action: manipulation;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); transition-duration: .05s; }
.icon-btn.ghost { visibility: hidden; }
/* focus: one ring for everything, in the skin's loudest colour, with the ink outside it so it shows on any ground */
.btn:focus-visible, .icon-btn:focus-visible, .el-card:focus-visible, .stop:focus-visible, .tab:focus-visible, .seg-btn:focus-visible, .form-slot:focus-visible, .hud-pause:focus-visible, .hud-hint:focus-visible,
.menus.show-focus .kf {
  outline: 4px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 3px var(--ink), 0 0 0 10px var(--ink);
  z-index: 2;
}
.menus.show-focus .btn.kf, .btn:focus-visible { transform: translateY(-2px); }
:focus:not(:focus-visible) { outline: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 2px 10px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--paper); color: var(--text); font-size: var(--t-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip.el { background: var(--el); color: var(--el-ink); }
.chip.accent { background: var(--accent); color: var(--accent-ink); }
.pips { display: inline-flex; gap: 3px; }
.pip { width: 20px; height: 20px; display: block; color: var(--dim); opacity: .7; }
.pip.got { color: var(--accent); opacity: 1; filter: drop-shadow(0 1.5px 0 var(--ink)); }
#ui[data-skin="fire"] .pip.got { color: var(--accent); }

/* ------------------------------------------------------------------ HUD */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top {
  position: absolute; left: calc(12px + var(--sal)); right: calc(12px + var(--sar)); top: calc(10px + var(--sat));
  display: flex; align-items: flex-start; gap: var(--s2); min-height: 48px;
}
.hud-where { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin-right: auto; }
.hud-name {
  max-width: 100%; padding: 5px 12px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper); color: var(--text);
  font-weight: 900; letter-spacing: .03em; font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 3px 0 var(--ink);
}
.hud-area { max-width: 100%; padding: 1px 10px; border-radius: 999px; border: 2px solid var(--ink); background: var(--inv); color: var(--inv-text); font-size: var(--t-xs); font-weight: 700; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .92; }
.hud-area:empty { display: none; }
.hud-shards { display: flex; gap: 4px; flex: 0 0 auto; height: 48px; align-items: center; padding: 0 12px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper); box-shadow: 0 3px 0 var(--ink); }
.hud-shard { width: 24px; height: 24px; color: var(--dim); opacity: .6; display: block; transition: transform .35s var(--spring); }
.hud-shard.got { color: var(--accent); opacity: 1; filter: drop-shadow(0 2px 0 var(--ink)); transform: scale(1.18) rotate(-6deg); }
.hud-shard.pop { animation: pip-pop .6s var(--spring); }
.hud-pause {
  pointer-events: auto; flex: 0 0 auto; width: 48px; height: 48px; padding: 11px; border-radius: var(--r2); border: var(--ow) solid var(--ink);
  background: var(--paper); color: var(--text); cursor: pointer; touch-action: none; box-shadow: 0 4px 0 var(--ink); transition: transform .2s var(--spring), box-shadow .2s var(--spring);
}
.hud-pause:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.hud-pause:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* the area banner: the name of each area, once, as the hero walks into it */
.hud-banner {
  position: absolute; left: 50%; top: calc(74px + var(--sat)); transform: translateX(-50%); max-width: calc(var(--uvw) - 32px - var(--sal) - var(--sar));
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; pointer-events: none;
}
.hud-banner-eyebrow { position: relative; z-index: 1; margin-bottom: -11px; white-space: nowrap; padding: 2px 12px; border-radius: 999px; background: var(--el); color: var(--el-ink); border: 2px solid var(--ink); font-size: var(--t-xs); font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.hud-banner-name {
  padding: 15px 22px 8px; border-radius: var(--r2); background: var(--paper); color: var(--text); border: var(--ow) solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  font-size: clamp(20px, calc(var(--uvw) * .036), 30px); font-weight: 900; letter-spacing: .02em; line-height: 1.15; transform: rotate(-1.2deg);
}
.hud-banner.in { animation: banner-in .55s var(--spring) both; }
.hud-banner.out { animation: banner-out .35s ease-in both; }
@keyframes banner-in { from { opacity: 0; transform: translateX(-50%) translateY(-18px) scale(.8); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes banner-out { to { opacity: 0; transform: translateX(-50%) translateY(-10px); } }
.hud.paused .hud-banner, .hud.paused .touch, .hud.paused .formbar, .hud.paused .hud-meter, .hud.paused .hud-toast { visibility: hidden; }
/* small notices under the top bar: "Checkpoint" */
.hud-toast {
  position: absolute; left: 50%; top: calc(66px + var(--sat)); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 14px 4px 10px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  font-size: var(--t-sm); font-weight: 900; letter-spacing: .06em; white-space: nowrap; animation: toast 1.5s var(--ease) both; pointer-events: none;
}
.hud-toast svg { width: 18px; height: 18px; }
@keyframes toast { 0% { opacity: 0; transform: translateX(-50%) translateY(8px) scale(.7); } 14% { opacity: 1; transform: translateX(-50%) scale(1.06); } 22%, 78% { opacity: 1; transform: translateX(-50%); } 100% { opacity: 0; transform: translateX(-50%) translateY(-8px); } }
/* respawn: the picture blinks shut round the middle and opens again */
.hud-blink { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 55%, transparent 0, transparent var(--hole, 120%), var(--ink) calc(var(--hole, 120%) + 1px)); animation: blink-iris .5s ease-out both; }
@property --hole { syntax: "<percentage>"; inherits: false; initial-value: 120%; }
@keyframes blink-iris { 0% { --hole: 14%; opacity: .9; } 100% { --hole: 120%; opacity: 0; } }

/* Hints never sit over the play: the hero is framed at the centre with the way ahead above it, so the
   card lives in a corner (desktop: bottom-left, beside the form bar) or under the top bar. */
.hud-hint {
  pointer-events: auto; position: absolute; left: calc(16px + var(--sal)); bottom: calc(20px + var(--sab));
  width: max-content; max-width: min(380px, calc(var(--uvw) * .5 - 210px));
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left;
  padding: 10px 14px 9px 16px; border-radius: var(--r2) var(--r2) var(--r2) 4px; border: var(--ow) solid var(--ink);
  background: var(--paper); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; line-height: 1.38; cursor: pointer; touch-action: none;
  box-shadow: 0 5px 0 var(--ink);
}
.hud-hint::before { content: ""; position: absolute; left: -3px; top: -3px; bottom: -3px; width: 10px; border-radius: var(--r2) 0 0 4px; background: var(--el); border: var(--ow) solid var(--ink); border-right: 0; }
.hud-hint-text { padding-left: 6px; }
.hud-hint.in { animation: hint-in .45s var(--spring); }
.hud.paused .hud-hint { visibility: hidden; }
.hud-hint-more { padding-left: 6px; font-size: 11px; color: var(--dim); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.hud-hint-x { display: none; }
@keyframes hint-in { from { opacity: 0; transform: translateY(14px) scale(.9); } to { opacity: 1; transform: none; } }
/* narrow desktop windows: not enough room beside the form bar, so go under the top bar instead */
@media (max-width: 899px) {
  .hud-hint {
    left: 50%; bottom: auto; top: calc(70px + var(--sat)); transform: translateX(-50%);
    max-width: min(520px, calc(var(--uvw) - 28px - var(--sal) - var(--sar))); border-radius: var(--r2);
  }
  .hud-hint::before { border-radius: var(--r2) 0 0 var(--r2); }
  .hud-hint.in { animation-name: hint-in-c; }
}
@keyframes hint-in-c { from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(.9); } to { opacity: 1; transform: translateX(-50%); } }

/* form bar (desktop): four chunky keys */
.formbar {
  position: absolute; left: 50%; bottom: calc(18px + var(--sab)); transform: translateX(-50%);
  display: flex; gap: 10px; padding: 10px 10px 12px; border-radius: 26px; background: var(--paper); border: var(--ow) solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  pointer-events: auto;
}
.form-slot, .touch-form {
  position: relative; width: 62px; height: 62px; border-radius: 18px; border: var(--ow) solid var(--ink);
  background: var(--paper-2); color: var(--fc, var(--dim)); cursor: pointer; padding: 0; font: inherit; touch-action: none;
  box-shadow: 0 4px 0 var(--ink); transition: transform .22s var(--spring), box-shadow .22s var(--spring), background-color .15s; overflow: hidden;
}
.form-icon { position: absolute; inset: 11px; display: block; filter: drop-shadow(0 1.5px 0 var(--ink)); }
.form-key {
  position: absolute; left: 4px; top: 3px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 6px; background: var(--inv); color: var(--inv-text);
  font-size: 10.5px; font-weight: 900; line-height: 16px; text-align: center;
}
.form-lock { position: absolute; right: 3px; bottom: 3px; width: 20px; height: 20px; padding: 3px; border-radius: 50%; background: var(--inv); color: var(--inv-text); display: none; }
.form-slot:hover:not(.locked) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.form-slot:active:not(.locked), .touch-form.pressed { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); transition-duration: .05s; }
.form-slot.locked, .touch-form.locked { filter: saturate(.2); opacity: .55; box-shadow: 0 2px 0 var(--ink); cursor: default; }
.form-slot.locked .form-lock, .touch-form.locked .form-lock { display: block; }
.form-slot.active, .touch-form.active { transform: translateY(-6px); background: var(--fc, var(--el)); color: var(--paper); box-shadow: 0 10px 0 var(--ink); }
.form-slot.active .form-icon, .touch-form.active .form-icon { color: #fff; }
.form-slot.pending, .touch-form.pending { border-style: dashed; }
/* the gauge on a button: a bar along the bottom edge of every form that spends it (water: steam) */
.form-gauge { display: none; }
.has-gauge .form-gauge {
  display: block; position: absolute; left: 6px; right: 6px; bottom: 5px; height: 8px; border-radius: 5px; background: var(--ink); overflow: hidden; border: 1.5px solid var(--ink);
}
.has-gauge .form-gauge::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--g, 100%); border-radius: 3px;
  background: #fff; transition: width .08s linear;
}
.has-gauge .form-icon { inset: 7px 11px 15px; }
.has-gauge.low .form-gauge::after { background: var(--warn); }
.has-gauge.draining .form-gauge::after { background: var(--accent); animation: blink .25s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
/* a gauge with a bar of its own (fire: heat; clay: moisture). Desktop: above the form bar. Touch: above the form grid. */
.hud-meter {
  position: absolute; left: 50%; bottom: calc(112px + var(--sab)); transform: translateX(-50%); width: 300px; height: 30px;
  display: flex; align-items: center; gap: 8px; padding: 0 10px 0 4px; border-radius: 999px;
  background: var(--paper); border: var(--ow) solid var(--ink); box-shadow: 0 4px 0 var(--ink); color: var(--el);
}
.hud-meter-icon { flex: 0 0 auto; width: 22px; height: 22px; padding: 2px; border-radius: 50%; background: var(--ink); display: block; }
.hud-meter-bar { position: relative; flex: 1 1 auto; height: 12px; border-radius: 6px; background: var(--ink); overflow: hidden; }
.hud-meter-bar::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--g, 100%); border-radius: 6px;
  background: linear-gradient(90deg, var(--el-deep), var(--el) 55%, var(--accent)); transition: width .1s linear;
}
/* ticks: the bar reads as a scale, not a smear */
.hud-meter-bar::before { content: ""; position: absolute; inset: 0; z-index: 1; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), var(--ink) calc(10% - 2px) 10%); opacity: .55; }
.hud-meter.spending { animation: meter-hot .5s ease-in-out infinite alternate; }
@keyframes meter-hot { to { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px color-mix(in srgb, var(--el) 55%, transparent); } }
.hud-meter.low .hud-meter-bar::after { background: var(--warn); }
.hud-meter.draining .hud-meter-bar::after { animation: blink .25s steps(2) infinite; }
.hud.is-touch .hud-meter { left: auto; right: calc(12px + var(--sar)); bottom: calc(286px + var(--sab)); transform: none; width: 152px; }
/* a form there is not enough gauge left to switch to */
.hud[data-element]:not([data-element="water"]) .form-slot.low:not(.active), .hud[data-element]:not([data-element="water"]) .touch-form.low:not(.active) { filter: saturate(.3); opacity: .6; }

/* ------------------------------------------------------------------ touch controls */
.touch { display: none; position: absolute; inset: 0; pointer-events: none; }
.hud.is-touch .touch { display: block; }
.hud.is-touch .formbar { display: none; }
/* Touch hint: a slim strip under the top bar, 2-3 short lines. The card itself lets touches through
   (camera drags and the stick work right across it); only the close mark takes taps. */
.hud.is-touch .hud-hint {
  left: 50%; bottom: auto; top: calc(66px + var(--sat)); transform: translateX(-50%);
  width: max-content; max-width: min(440px, calc(var(--uvw) - 24px - var(--sal) - var(--sar)));
  align-items: flex-start; text-align: left; min-height: 48px; justify-content: center;
  padding: 6px 50px 7px 14px; border-radius: var(--r2); border-width: 2px;
  font-size: 13px; line-height: 1.3; background: color-mix(in srgb, var(--paper) 90%, transparent);
  box-shadow: 0 3px 0 var(--ink);
  pointer-events: none;
  z-index: 4;                                    /* above the touch layer, so its close mark can be tapped */
}
.hud.is-touch .hud-hint::before { left: -2px; top: -2px; bottom: -2px; width: 8px; border-width: 2px; border-radius: var(--r2) 0 0 var(--r2); }
.hud.is-touch .hud-hint .hud-hint-more { display: none; }
.hud.is-touch .hud-hint .hud-hint-x {
  display: flex; align-items: center; justify-content: center; pointer-events: auto; touch-action: none;
  position: absolute; right: 0; top: 0; bottom: 0; width: 48px; min-height: 48px; font-size: 24px; font-weight: 900; line-height: 1; color: var(--text);
}
.hud.is-touch .hud-hint.in { animation-name: hint-in-c; }
.hud.is-touch .hud-banner { top: calc(74px + var(--sat)); }
.touch > * { pointer-events: auto; touch-action: none; }
.touch-orbit { position: absolute; left: 44%; right: 0; top: calc(62px + var(--sat)); bottom: 0; }
.touch-stickzone { position: absolute; left: 0; width: 44%; top: 38%; bottom: 0; }
.touch-stick {
  position: absolute; left: calc(92px + var(--sal)); top: calc(100% - 100px - var(--sab)); width: 124px; height: 124px; margin: -62px 0 0 -62px;
  border-radius: 50%; border: var(--ow) solid var(--ink); background: color-mix(in srgb, var(--paper) 42%, transparent);
  box-shadow: inset 0 0 0 10px color-mix(in srgb, var(--paper) 30%, transparent);
  pointer-events: none; transition: opacity .2s, transform .25s var(--spring); opacity: .8;
}
.touch-stick.active { opacity: 1; transform: scale(1.05); background: color-mix(in srgb, var(--paper) 62%, transparent); }
.touch-knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: var(--el); border: var(--ow) solid var(--ink); box-shadow: 0 4px 0 var(--ink), inset 0 6px 0 rgba(255, 255, 255, .4);
}
.touch-jump {
  position: absolute; right: calc(18px + var(--sar)); bottom: calc(24px + var(--sab)); width: 88px; height: 88px; border-radius: 50%; padding: 22px;
  color: var(--accent-ink); background: var(--accent); border: var(--ow) solid var(--ink);
  box-shadow: 0 6px 0 var(--ink), inset 0 7px 0 rgba(255, 255, 255, .38); transition: transform .2s var(--spring), box-shadow .2s var(--spring);
}
.touch-jump.pressed { transform: translateY(5px) scale(.96); box-shadow: 0 1px 0 var(--ink), inset 0 7px 0 rgba(255, 255, 255, .38); transition-duration: .04s; }
.touch-forms {
  position: absolute; right: calc(12px + var(--sar)); bottom: calc(126px + var(--sab));
  display: grid; grid-template-columns: 62px 62px; gap: 10px; padding: 8px 8px 10px; border-radius: 24px;
  background: color-mix(in srgb, var(--paper) 55%, transparent); border: 2px solid color-mix(in srgb, var(--ink) 55%, transparent);
}
.touch-form.active { transform: translateY(-4px) scale(1.04); box-shadow: 0 8px 0 var(--ink); }

@media (max-height: 430px) {
  .touch-jump { width: 78px; height: 78px; padding: 19px; bottom: calc(14px + var(--sab)); }
  .touch-forms { bottom: calc(102px + var(--sab)); grid-template-columns: 54px 54px; gap: 8px; padding: 6px 6px 8px; }
  .touch-form { width: 54px; height: 54px; border-radius: 16px; }
  .touch-form .form-icon { inset: 9px; }
  .touch-form.has-gauge .form-icon { inset: 6px 9px 14px; }
  .hud.is-touch .hud-meter { bottom: calc(244px + var(--sab)); width: 136px; height: 26px; }
  .touch-stick { top: calc(100% - 82px - var(--sab)); width: 108px; height: 108px; margin: -54px 0 0 -54px; }
  .touch-stickzone { top: 22%; }
  .hud-top { top: calc(6px + var(--sat)); }
  .hud-banner, .hud.is-touch .hud-banner { top: calc(68px + var(--sat)); }
  .hud-banner-name { padding: 13px 16px 5px; font-size: 20px; }
  /* landscape phone: keep the hint clear of the form buttons on the right */
  .hud.is-touch .hud-hint {
    top: calc(60px + var(--sat)); left: calc(12px + var(--sal)); right: auto; transform: none;
    width: max-content; max-width: min(460px, calc(var(--uvw) - 190px - var(--sal) - var(--sar)));
    padding: 5px 48px 5px 14px; font-size: 12.5px; line-height: 1.28;
  }
  .hud.is-touch .hud-hint.in { animation: none; }
}

/* ------------------------------------------------------------------ menus */
.menus { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: calc(14px + var(--sat)) calc(14px + var(--sar)) calc(14px + var(--sab)) calc(14px + var(--sal)); }
.menus.on { display: flex; pointer-events: auto !important; }
.menus.on > * { pointer-events: auto; }
.menus.dim { background: var(--scrim); }
.menus.dim::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5; background-image: radial-gradient(var(--ink) 1.2px, transparent 1.6px); background-size: 14px 14px; mask-image: linear-gradient(180deg, transparent 0%, #000 100%); -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 100%); }

.panel {
  position: relative; width: min(440px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s5); border-radius: var(--r3); background: var(--paper); border: var(--ow) solid var(--ink);
  box-shadow: 0 8px 0 var(--ink), 0 22px 40px rgba(0, 0, 0, .28);
  animation: panel-in .42s var(--spring) both;
}
.panel.wide { width: min(860px, 100%); }
@keyframes panel-in { from { opacity: 0; transform: translateY(26px) scale(.93) rotate(-1deg); } to { opacity: 1; transform: none; } }
.menus.back .panel { animation-name: panel-back; }
@keyframes panel-back { from { opacity: 0; transform: translateY(-16px) scale(.96); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.panel-head h2 { margin: 0; flex: 1 1 auto; min-width: 0; text-align: center; font-size: var(--t-lg); font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.panel-tag {
  align-self: center; margin: -30px 0 -2px; padding: 4px 18px 5px; border-radius: 999px; background: var(--el); color: var(--el-ink); border: var(--ow) solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  font-size: var(--t-sm); font-weight: 900; letter-spacing: .16em; text-transform: uppercase; transform: rotate(-2deg);
}
.sub { margin: -4px 0 0; text-align: center; color: var(--dim); font-weight: 700; }
.note { margin: 0; color: var(--dim); font-size: var(--t-sm); font-weight: 600; text-align: center; }
.scroll { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; display: flex; flex-direction: column; gap: var(--s3); padding: 4px 6px 10px 4px; margin: 0 -4px; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--ink) transparent; }
.btn-col { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); align-self: center; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ------------------------------------------------------------------ title: choose your element */
.menus.screen-title { align-items: stretch; justify-content: center; background: linear-gradient(180deg, transparent 0%, transparent 38%, color-mix(in srgb, var(--ink) 58%, transparent) 100%); }
.title {
  width: min(940px, 100%); display: grid; grid-template-rows: auto 1fr auto auto auto; gap: var(--s3); justify-items: center; align-content: stretch;
  animation: title-in .5s var(--ease) both;
}
@keyframes title-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* The wordmark's ink reaches past its box (half the outline, the hard drop shadow, and the tilt lifts one end
   and drops the other), so the tagline sits a whole ink-width below it: they never touch. */
.logo { --stroke: clamp(7px, calc(var(--uvw) * .015), 12px); --drop: clamp(5px, calc(var(--uvw) * .01), 9px); display: flex; flex-direction: column; align-items: center; gap: calc(var(--stroke) / 2 + var(--drop) + 8px); margin-top: calc(var(--uvh) * .02); max-width: 100%; }
.logo-word {
  margin: 0; font-size: var(--t-xxl); font-weight: 900; letter-spacing: .08em; line-height: 1; color: #fff; padding: .04em .1em .16em .18em; white-space: nowrap;
  -webkit-text-stroke: var(--stroke) var(--ink); paint-order: stroke fill;
  text-shadow: 0 var(--drop) 0 var(--ink);
  transform: rotate(-2deg);
}
.logo-word span { display: inline-block; color: var(--el); animation: logo-pop .7s var(--spring) both; animation-delay: calc(var(--i) * 45ms); }
.logo-word span:nth-child(odd) { color: #fff; }
@keyframes logo-pop { from { opacity: 0; transform: translateY(24px) scale(.6) rotate(-10deg); } to { opacity: 1; transform: none; } }
.tagline { margin: 0; padding: 4px 14px; border-radius: 999px; background: var(--inv); color: var(--inv-text); font-size: var(--t-sm); font-weight: 700; letter-spacing: .02em; text-align: center; transform: rotate(-1deg); }
.el-cards { grid-row: 3; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); width: 100%; align-items: end; }
.el-card {
  --c: var(--ec); position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 148px; padding: 10px 10px 12px;
  border-radius: var(--r3); border: var(--ow) solid var(--ec-ink); background: var(--ec-paper); color: var(--ec-text); font: inherit; cursor: pointer; text-align: center;
  box-shadow: 0 6px 0 var(--ec-ink); transition: transform .3s var(--spring), box-shadow .3s var(--spring), filter .2s; touch-action: manipulation;
}
.el-card:hover:not(.locked):not(.on) { transform: translateY(-4px) rotate(-1deg); box-shadow: 0 10px 0 var(--ec-ink); }
.el-card:active:not(.locked) { transform: translateY(4px); box-shadow: 0 2px 0 var(--ec-ink); transition-duration: .05s; }
.el-card.on { transform: translateY(-12px) scale(1.04); box-shadow: 0 16px 0 var(--ec-ink); cursor: default; background: var(--ec); color: var(--ec-on); }
.el-card.on::after { content: ""; position: absolute; left: 50%; bottom: -30px; width: 22px; height: 12px; margin-left: -11px; background: var(--ec-ink); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.el-hero { width: 84px; height: 89px; margin-top: -34px; filter: drop-shadow(0 5px 0 rgba(0, 0, 0, .22)); transition: transform .3s var(--spring); }
.el-card.on .el-hero { animation: hero-idle 2.4s ease-in-out infinite; }
@keyframes hero-idle { 0%, 100% { transform: translateY(0) scale(1.14) rotate(-3deg); } 50% { transform: translateY(-7px) scale(1.14, 1.2) rotate(3deg); } }
.el-name { font-weight: 900; font-size: 22px; letter-spacing: .1em; text-transform: uppercase; line-height: 1.05; }
.el-who { font-size: var(--t-xs); font-weight: 800; letter-spacing: .06em; opacity: .82; }
.el-progress { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: auto; width: 100%; font-size: var(--t-xs); font-weight: 900; font-variant-numeric: tabular-nums; }
.el-bar { position: relative; flex: 1 1 auto; max-width: 110px; height: 10px; border-radius: 6px; background: var(--ec-ink); border: 2px solid var(--ec-ink); overflow: hidden; }
.el-bar::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--p, 0%); border-radius: 3px; background: #fff; }
.el-card:not(.on) .el-bar::after { background: var(--ec); }
.el-card.locked { cursor: default; filter: saturate(.25); }
.el-card.locked .el-hero { opacity: .7; }
.el-soon { position: absolute; right: -8px; top: 26px; padding: 3px 12px; border-radius: 6px; background: var(--ec-ink); color: var(--ec-paper); font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; transform: rotate(9deg); display: inline-flex; align-items: center; gap: 4px; }
.el-soon svg { width: 12px; height: 12px; }
/* each card wears its own element's colours whatever skin the screen is in */
.el-card[data-element="water"] { --ec: #35bfc9; --ec-on: #06282e; --ec-ink: #12303f; --ec-paper: #fff7e6; --ec-text: #12303f; }
.el-card[data-element="fire"] { --ec: #ff9a3c; --ec-on: #2a0f02; --ec-ink: #170a08; --ec-paper: #2d1b1f; --ec-text: #fff0dc; }
.el-card[data-element="clay"] { --ec: #e08e63; --ec-on: #2a140a; --ec-ink: #3a2a22; --ec-paper: #f7efde; --ec-text: #3a2a22; }
.el-detail {
  grid-row: 4; width: min(620px, 100%); display: grid; grid-template-columns: 1fr auto; column-gap: var(--s4); row-gap: 2px; align-items: center;
  padding: 10px 16px 11px; border-radius: var(--r2); background: var(--paper); border: var(--ow) solid var(--ink); box-shadow: 0 5px 0 var(--ink);
}
.el-detail-name { font-weight: 900; font-size: var(--t-lg); line-height: 1.1; }
.el-detail-name small { font-size: var(--t-sm); font-weight: 800; color: var(--dim); letter-spacing: .04em; }
.el-detail-pitch { grid-column: 1; font-size: var(--t-sm); font-weight: 600; color: var(--dim); }
.el-detail-count { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: var(--t-sm); font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.el-detail-count span { display: inline-flex; align-items: center; gap: 5px; }
.el-detail-count svg { width: 18px; height: 18px; color: var(--accent); filter: drop-shadow(0 1.5px 0 var(--ink)); }
.title-actions { grid-row: 5; width: min(620px, 100%); display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 12px; align-items: end; margin-bottom: calc(var(--uvh) * .01); }

/* ------------------------------------------------------------------ level select: the journey */
.tabs { display: flex; gap: var(--s2); }
.tab {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 50px; padding: 4px 8px;
  border-radius: var(--r2); border: var(--ow) solid var(--ink); background: var(--paper-2); color: var(--text);
  font: inherit; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; font-size: var(--t-sm); cursor: pointer; touch-action: manipulation;
  box-shadow: 0 4px 0 var(--ink); transition: transform .22s var(--spring), box-shadow .22s var(--spring);
}
.tab:hover:not(.locked):not(.on) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.tab.on { background: var(--el); color: var(--el-ink); transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); cursor: default; }
.tab-icon { width: 30px; height: 32px; flex: 0 0 auto; }
.tab.locked { filter: saturate(.2); opacity: .6; cursor: default; }
.tab-lock { width: 14px; height: 14px; flex: 0 0 auto; }
.road-head { display: flex; align-items: baseline; justify-content: center; gap: var(--s2); flex-wrap: wrap; margin: -2px 0 0; font-weight: 900; font-size: var(--t-lg); text-align: center; }
.road-head small { font-size: var(--t-sm); color: var(--dim); font-weight: 800; }
.chapter { position: relative; border-radius: var(--r2); border: var(--ow) solid var(--ink); background: var(--paper-2); overflow: hidden; flex: 0 0 auto; }
.chapter-head {
  display: flex; align-items: center; gap: var(--s2); padding: 8px 12px; color: var(--ch-text, #12303f); border-bottom: var(--ow) solid var(--ink);
  background: linear-gradient(90deg, var(--ch-a, #73bfe0), var(--ch-b, #ffdcc2));
}
.chapter-num { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: var(--inv); color: var(--inv-text); font-weight: 900; font-size: var(--t-sm); line-height: 30px; text-align: center; }
.chapter-head h3 { margin: 0; flex: 1 1 auto; min-width: 0; font-size: var(--t-md); font-weight: 900; letter-spacing: .04em; line-height: 1.15; }
.chapter-head h3 small { display: block; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.chapter-count { flex: 0 0 auto; padding: 2px 9px; border-radius: 999px; background: var(--inv); color: var(--inv-text); font-size: var(--t-xs); font-weight: 900; font-variant-numeric: tabular-nums; }
/* the road: a dashed line the stops sit on */
.stops { position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: var(--s3); padding: 14px 12px 14px; }
.stops::before { content: ""; position: absolute; left: 30px; right: 30px; top: 37px; border-top: 4px dashed color-mix(in srgb, var(--ink) 45%, transparent); }
.stop {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: 10px; row-gap: 3px; align-items: center; text-align: left;
  min-height: 92px; padding: 9px 10px 9px 9px; border-radius: var(--r2); border: var(--ow) solid var(--ink); background: var(--paper);
  color: var(--text); font: inherit; cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .22s var(--spring), box-shadow .22s var(--spring); touch-action: manipulation;
}
.stop:hover:not(:disabled) { transform: translateY(-3px) rotate(-.6deg); box-shadow: 0 7px 0 var(--ink); }
.stop:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); transition-duration: .05s; }
.stop-node {
  grid-row: 1 / 3; width: 46px; height: 46px; border-radius: 50%; border: var(--ow) solid var(--ink); background: var(--paper-2); color: var(--text);
  display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.stop-node svg { width: 24px; height: 24px; }
.stop.done .stop-node { background: var(--good); color: #fff; }
.stop.next .stop-node { background: var(--el); color: var(--el-ink); animation: node-pulse 1.3s ease-in-out infinite; }
@keyframes node-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--el) 70%, transparent); } 50% { box-shadow: 0 0 0 9px transparent; } }
.stop-name { font-weight: 900; font-size: 15.5px; line-height: 1.15; overflow-wrap: anywhere; }
.stop-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stop-time { display: inline-flex; align-items: center; gap: 3px; font-size: var(--t-xs); font-weight: 800; color: var(--dim); font-variant-numeric: tabular-nums; }
.stop-time svg { width: 13px; height: 13px; }
.stop-areas { grid-column: 1 / -1; display: flex; align-items: flex-start; flex-wrap: wrap; gap: 4px 5px; min-height: 16px; font-size: 11px; font-weight: 700; color: var(--dim); line-height: 1.2; }
.stop-areas i { flex: 0 0 auto; margin-top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); opacity: .55; }
.stop-areas span { min-width: 0; }
.stop-badge { position: absolute; right: -6px; top: -10px; padding: 1px 9px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); border: 2px solid var(--ink); font-size: 10.5px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; transform: rotate(5deg); }
.stop.locked { background: var(--paper-2); color: var(--dim); cursor: default; box-shadow: 0 2px 0 var(--ink); filter: saturate(.4); }
.stop.locked .stop-node { background: var(--inv); color: var(--inv-text); }
.stop.locked .stop-name { opacity: .8; }

/* ------------------------------------------------------------------ settings */
.row { display: flex; align-items: center; gap: var(--s3); min-height: 52px; padding: 2px 10px; border-radius: var(--r1); background: var(--paper-2); border: 2px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.row.end { justify-content: flex-end; background: none; border: 0; padding: 0; }
.row-label { flex: 1 1 40%; font-weight: 800; display: flex; flex-direction: column; min-width: 0; }
.row-label small { font-weight: 600; color: var(--dim); font-size: var(--t-xs); }
.row output { width: 46px; text-align: right; color: var(--text); font-weight: 900; font-variant-numeric: tabular-nums; font-size: var(--t-sm); }
input[type=range] { flex: 1 1 45%; min-width: 90px; height: 48px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; touch-action: pan-y; cursor: pointer; border-radius: 12px; }
input[type=range]::-webkit-slider-runnable-track { height: 12px; border-radius: 7px; background: var(--ink); }
input[type=range]::-moz-range-track { height: 12px; border-radius: 7px; background: var(--ink); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -9px; border-radius: 50%; background: var(--el); border: var(--ow) solid var(--ink); box-shadow: 0 3px 0 var(--ink), inset 0 4px 0 rgba(255, 255, 255, .45); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--el); border: var(--ow) solid var(--ink); }
input[type=range]:focus-visible, .menus.show-focus input[type=range].kf { outline: 4px solid var(--focus); outline-offset: 0; box-shadow: none; }
.switch { position: relative; width: 62px; height: 36px; flex: 0 0 auto; }
.switch input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); margin: 0; opacity: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; border-radius: 18px; background: var(--paper); border: var(--ow) solid var(--ink); transition: background-color .15s; pointer-events: none; }
.switch-track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 26px; height: 26px; border-radius: 50%; background: var(--dim); border: 2px solid var(--ink); transition: transform .28s var(--spring), background-color .15s; }
.switch input:checked + .switch-track { background: var(--el); }
.switch input:checked + .switch-track::after { transform: translateX(26px); background: #fff; }
.switch input:focus-visible + .switch-track, .menus.show-focus .switch input.kf + .switch-track { outline: 4px solid var(--focus); outline-offset: 3px; }
.seg { display: flex; border-radius: var(--r1); overflow: hidden; border: var(--ow) solid var(--ink); flex: 0 0 auto; background: var(--ink); gap: 2px; }
.seg-btn { min-width: 62px; min-height: 48px; padding: 6px 10px; border: 0; background: var(--paper); color: var(--text); font: inherit; font-weight: 800; cursor: pointer; }
.seg-btn.on { background: var(--el); color: var(--el-ink); font-weight: 900; }
.seg-btn:focus-visible, .menus.show-focus .seg-btn.kf { outline-offset: -4px; box-shadow: none; }

/* ------------------------------------------------------------------ pause: where you are on the journey */
.journey { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--r2); background: var(--paper-2); border: 2px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.journey-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-size: var(--t-xs); font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.journey ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.journey li { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); font-weight: 700; color: var(--dim); line-height: 1.25; }
.journey li i { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper); }
.journey li.seen i { background: var(--good); }
.journey li.here { color: var(--text); font-weight: 900; }
.journey li.here i { background: var(--el); box-shadow: 0 0 0 3px color-mix(in srgb, var(--el) 45%, transparent); }

/* ------------------------------------------------------------------ level complete: a celebration */
.win-flash {
  position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; overflow: hidden;
  animation: win-bloom 2.6s ease-out forwards;
}
.win-flash::before {
  content: ""; position: absolute; left: 50%; top: 52%; width: 200vmax; height: 200vmax; margin: -100vmax 0 0 -100vmax;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--accent) 55%, transparent) 0 10deg, transparent 10deg 20deg);
  mask-image: radial-gradient(circle, #000 0, transparent 46%); -webkit-mask-image: radial-gradient(circle, #000 0, transparent 46%);
  animation: rays 14s linear infinite;
}
@keyframes rays { to { transform: rotate(360deg); } }
.win-flash.out { opacity: 0 !important; transition: opacity .25s; animation-play-state: paused; }
.win-banner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; animation: win-banner 2.6s var(--spring) forwards; }
.win-eyebrow { padding: 4px 18px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); border: var(--ow) solid var(--ink); box-shadow: 0 4px 0 var(--ink); font-weight: 900; letter-spacing: .24em; text-transform: uppercase; font-size: var(--t-sm); transform: rotate(-3deg); }
.win-name { color: #fff; font-weight: 900; font-size: clamp(30px, calc(var(--uvw) * .07), 60px); letter-spacing: .03em; text-align: center; padding: 0 16px; line-height: 1.05; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); }
@keyframes win-bloom { 0% { opacity: 0; } 10% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }
@keyframes win-banner { 0% { opacity: 0; transform: scale(.4) rotate(-8deg); } 16% { opacity: 1; transform: scale(1.06) rotate(1deg); } 24%, 78% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-24px); } }
.complete-panel { overflow: visible; padding-top: var(--s5); gap: var(--s3); }
.complete-rays { position: absolute; inset: -60px -40px auto -40px; height: 260px; pointer-events: none; z-index: -1; overflow: hidden; border-radius: 50%; }
.complete-rays::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 560px; height: 560px; margin: -280px 0 0 -280px;
  background: repeating-conic-gradient(from 0deg, var(--accent) 0 12deg, transparent 12deg 24deg); opacity: .8;
  mask-image: radial-gradient(circle, #000 20%, transparent 62%); -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 62%);
  animation: rays 18s linear infinite;
}
.complete-name { margin: 0; text-align: center; font-size: var(--t-xl); font-weight: 900; line-height: 1.1; }
.big-pips { display: flex; justify-content: center; gap: 14px; margin: 2px 0; }
.big-pips .pip { width: 58px; height: 58px; padding: 9px; border-radius: 50%; background: var(--paper-2); border: var(--ow) solid var(--ink); opacity: 1; color: var(--dim); }
.big-pips .pip.got { background: var(--el); color: #fff; box-shadow: 0 4px 0 var(--ink); filter: none; }
.big-pips .pip.old { background: var(--paper-2); color: var(--accent); box-shadow: 0 2px 0 var(--ink); }
.big-pips .pip.pop { animation: pip-pop .65s var(--spring) backwards; }
@keyframes pip-pop { 0% { transform: scale(0) rotate(-60deg); opacity: 0; } 70% { transform: scale(1.25) rotate(8deg); opacity: 1; } 100% { transform: none; } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); text-align: center; }
.stats > div { position: relative; padding: 8px 4px 9px; border-radius: var(--r1); background: var(--paper-2); border: 2px solid color-mix(in srgb, var(--ink) 30%, transparent); display: flex; flex-direction: column; animation: stat-in .5s var(--spring) backwards; }
.stats > div:nth-child(2) { animation-delay: .1s; } .stats > div:nth-child(3) { animation-delay: .2s; }
@keyframes stat-in { from { opacity: 0; transform: translateY(12px) scale(.9); } to { opacity: 1; transform: none; } }
.stat-k { font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.stat-v { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stats > div.best { background: var(--accent); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.stats > div.best .stat-k, .stats > div.best .stat-v { color: var(--accent-ink); }
.confetti { position: absolute; left: 0; right: 0; top: -20px; height: 0; pointer-events: none; }
.confetti i { position: absolute; top: 0; left: calc(var(--x) * 1%); width: 10px; height: 16px; border-radius: 3px; background: var(--c); border: 2px solid var(--ink); animation: confetti calc(1.5s + var(--d) * 1s) cubic-bezier(.2, .6, .4, 1) calc(var(--d) * .5s) both; }
@keyframes confetti { 0% { transform: translateY(0) rotate(0) scale(0); opacity: 1; } 12% { transform: translateY(-46px) rotate(120deg) scale(1); opacity: 1; } 100% { transform: translateY(340px) rotate(calc(600deg * var(--s))); opacity: 0; } }

/* ------------------------------------------------------------------ the wipe between screens */
.wipe { position: absolute; inset: 0; pointer-events: none; background: var(--ink); clip-path: circle(0 at 50% 55%); z-index: 40; }
.wipe.in { animation: wipe-in .26s ease-in both; pointer-events: auto; }
.wipe.out { animation: wipe-out .42s var(--ease) both; }
@keyframes wipe-in { from { clip-path: circle(0 at 50% 55%); } to { clip-path: circle(150vmax at 50% 55%); } }
@keyframes wipe-out { from { clip-path: circle(150vmax at 50% 55%); opacity: 1; } to { clip-path: circle(150vmax at 50% 55%); opacity: 0; } }

/* ------------------------------------------------------------------ sizes */
/* phones in portrait */
@media (max-width: 640px) {
  .panel { padding: var(--s3) var(--s3) var(--s4); border-radius: 22px; }
  .title { gap: 10px; }
  .el-cards { gap: var(--s2); }
  .el-card { min-height: 126px; padding: 8px 4px 10px; border-radius: 20px; }
  .el-hero { width: 64px; height: 68px; margin-top: -28px; }
  .el-name { font-size: 17px; letter-spacing: .06em; }
  .el-who { font-size: 11px; }
  .el-bar { max-width: 46px; }
  /* one line across the dimmed hero, so the element's name below it stays readable */
  .el-soon { right: auto; left: 50%; top: 12px; font-size: 9px; padding: 2px 6px; letter-spacing: .04em; white-space: nowrap; transform: translateX(-50%) rotate(-7deg); }
  .el-detail { padding: 8px 12px 9px; column-gap: var(--s3); }
  .el-detail-name { font-size: 17px; }
  .el-detail-pitch { font-size: 13px; }
  .title-actions { grid-template-columns: 1fr 1fr; }
  .title-actions .primary { grid-column: 1 / -1; }
  .stops { grid-template-columns: 1fr; padding: 10px 10px 12px; gap: 10px; }
  .stops::before { left: 41px; right: auto; top: 20px; bottom: 20px; border-top: 0; border-left: 4px dashed color-mix(in srgb, var(--ink) 45%, transparent); }
  .stop { min-height: 76px; }
  .tab > span:not(.tab-icon):not(.tab-lock) { display: none; }
  .tab.on > span:not(.tab-icon) { display: inline; }
  .stat-v { font-size: 19px; }
}
@media (max-width: 380px) {
  .hud-name { font-size: 13px; padding: 5px 10px; }
  .el-name { font-size: 15px; }
  .big-pips .pip { width: 50px; height: 50px; }
  .btn { padding-left: var(--s3); padding-right: var(--s3); }
}
/* landscape phones: everything in two columns, nothing taller than the screen */
@media (max-height: 480px) {
  .panel { padding: 12px 14px 14px; gap: 8px; border-radius: 20px; }
  .panel:not(.wide) { width: min(620px, 100%); }
  .btn { min-height: 48px; font-size: 15px; padding: 6px 8px; gap: 6px; letter-spacing: 0; }
  .btn svg { width: 18px; height: 18px; }
  .btn.primary { min-height: 52px; font-size: 17px; padding-left: 14px; padding-right: 14px; }
  .btn-col { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 10px; }
  .btn-col .primary { grid-column: 1 / -1; }
  .panel-tag { margin-top: -24px; font-size: 12px; padding: 2px 14px 3px; }
  .title { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: auto 1fr auto; column-gap: var(--s4); row-gap: 6px; align-items: end; }
  .logo { grid-column: 1; grid-row: 1; margin-top: 0; align-items: flex-start; }
  .logo-word { font-size: clamp(34px, calc(var(--uvh) * .12), 58px); -webkit-text-stroke-width: 7px; text-shadow: 0 5px 0 var(--ink); }
  .tagline { display: none; }
  .el-cards { grid-column: 1; grid-row: 3; gap: 8px; }
  .el-card { min-height: 104px; padding: 6px 4px 8px; border-radius: 18px; }
  .el-card.on { transform: translateY(-8px) scale(1.03); box-shadow: 0 12px 0 var(--ec-ink); }
  .el-card.on::after { display: none; }
  .el-hero { width: 54px; height: 57px; margin-top: -22px; }
  .el-name { font-size: 15px; }
  .el-who { display: none; }
  .el-detail { grid-column: 2; grid-row: 1 / 3; align-self: end; width: 100%; }
  .title-actions { grid-column: 2; grid-row: 3; width: 100%; grid-template-columns: 1fr 1fr; margin-bottom: 0; }
  .title-actions .primary { grid-column: 1 / -1; }
  .complete-panel { padding-top: 14px; }
  .complete-name { font-size: 22px; }
  .big-pips .pip { width: 44px; height: 44px; padding: 7px; }
  .complete-body { display: grid; grid-template-columns: 1fr 1.1fr; gap: 12px; align-items: center; }
  .stat-v { font-size: 17px; }
  .row { min-height: 48px; }
  .journey ol { flex-direction: row; flex-wrap: wrap; gap: 3px 12px; }
  .road-head { font-size: var(--t-md); }
  .tab { min-height: 48px; }
  .stop { min-height: 76px; }
}
@media (min-width: 900px) and (min-height: 600px) {
  .el-card { min-height: 190px; padding: 12px 14px 16px; }
  .el-hero { width: 112px; height: 119px; margin-top: -48px; }
  .el-name { font-size: 28px; }
  .el-who { font-size: var(--t-sm); }
}

/* ------------------------------------------------------------------ reduced motion: nothing springs, spins or flies */
@media (prefers-reduced-motion: reduce) {
  .panel, .title, .hud-hint.in, .big-pips .pip.pop, .logo-word span, #boot .boot-drop, .el-card.on .el-hero, .stats > div, .stop.next .stop-node, .win-flash::before, .complete-rays::before, .hud-meter.spending { animation: none !important; }
  .confetti, .hud-blink { display: none; }
}
body.reduced-motion .panel, body.reduced-motion .title, body.reduced-motion .hud-hint.in, body.reduced-motion .big-pips .pip.pop, body.reduced-motion .logo-word span, body.reduced-motion .el-card.on .el-hero,
body.reduced-motion .stats > div, body.reduced-motion .stop.next .stop-node, body.reduced-motion .win-flash::before, body.reduced-motion .complete-rays::before, body.reduced-motion .hud-meter.spending, body.reduced-motion .hud-shard.pop { animation: none !important; }
body.reduced-motion .confetti, body.reduced-motion .hud-blink { display: none; }
body.reduced-motion .hud-banner.in, body.reduced-motion .hud-banner.out, body.reduced-motion .hud-toast, body.reduced-motion .win-banner { animation-name: plain-fade !important; }
body.reduced-motion .hud-banner.out { animation-direction: reverse !important; }
body.reduced-motion .hud-toast, body.reduced-motion .win-banner { animation-name: plain-flash !important; }
body.reduced-motion .wipe.in, body.reduced-motion .wipe.out { animation: none; clip-path: none; opacity: 0; }
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { transition-duration: .01s !important; }
@keyframes plain-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes plain-flash { 0%, 100% { opacity: 0; } 15%, 80% { opacity: 1; } }

/* on narrow screens and on touch the hint card and the area banner share the strip under the top bar: the hint waits */
@media (max-width: 899px) { .hud.has-banner .hud-hint { visibility: hidden; } }
.hud.is-touch.has-banner .hud-hint { visibility: hidden; }
.hud.has-banner .hud-toast { top: calc(150px + var(--sat)); }
/* form icons: the form's own colour, deepened to show on light paper (as it is on Fire's dark paper) */
.form-slot, .touch-form { color: color-mix(in srgb, var(--fc, var(--dim)) 55%, var(--ink)); }
#ui[data-skin="fire"] .form-slot, #ui[data-skin="fire"] .touch-form { color: var(--fc, var(--dim)); }
.form-slot.active, .touch-form.active { color: var(--ink); }
.form-slot.active .form-icon, .touch-form.active .form-icon { color: var(--ink); filter: none; }
.form-slot.active .form-key { background: var(--paper); color: var(--text); }
.ic { display: inline-flex; width: 22px; height: 22px; flex: 0 0 auto; }
.btn.small .ic { width: 18px; height: 18px; }
.btn.primary .ic { width: 24px; height: 24px; }
