:root {
  --paper: #f3ecdd;
  --paper-2: #fbf7ee;
  --paper-edge: #e3d8c1;
  --ink: #2b2520;
  --ink-dim: rgba(43, 37, 32, 0.62);
  --ink-faint: rgba(43, 37, 32, 0.16);
  --pen: #2d5da8;
  --red: #c4432f;
  --gold: #e7a93a;
  --hi: rgba(242, 201, 76, 0.55);
  --hand: "Caveat", "Segoe Print", cursive;
  --ui: "Nunito", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

/* no 100dvh here: in an iOS home-screen app it leaves out the status bar and a strip of page shows below */
#app { position: fixed; inset: 0; }

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  /* a bold ring with a white edge, so the pen stays visible over dark ink */
  cursor: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2032%2032%22%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%229%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%224.5%22/%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%229%22%20fill%3D%22none%22%20stroke%3D%22%232b2520%22%20stroke-width%3D%222%22/%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%222.6%22%20fill%3D%22%232b2520%22%20stroke%3D%22%23fff%22%20stroke-width%3D%221.6%22/%3E%3C/svg%3E") 16 16, crosshair;
}

.ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- top HUD ---------- */
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  pointer-events: none;
}

.score { line-height: 1; }
.score-row { display: flex; align-items: baseline; gap: 4px; }
#dist {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 46px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.unit { font-family: var(--hand); font-size: 24px; color: var(--ink-dim); }
.score-sub {
  display: flex;
  gap: 12px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
#hud-best:empty { display: none; }
.score-row { gap: 12px !important; align-items: center !important; }
.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 7px;
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.8);
  border: 1.5px solid rgba(43, 37, 32, 0.18);
  font: 800 14px/1 var(--ui);
  color: #8a5a10;
  font-variant-numeric: tabular-nums;
}
.coin-pill .ico { width: 15px; height: 15px; color: #c98a14; }
.coin-pill.pop { animation: pop 0.3s ease-out; }
/* Relaxed pace: an ink stamp beside the score */
.relaxed-stamp {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(61, 122, 74, 0.75);
  box-shadow: inset 0 0 0 2px rgba(251, 247, 238, 0.9), inset 0 0 0 3.5px rgba(61, 122, 74, 0.55);
  background: rgba(251, 247, 238, 0.7);
  color: #3d7a4a;
  transform: rotate(-14deg);
  animation: stamp-in 0.35s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.relaxed-stamp[hidden] { display: none; }
.relaxed-stamp .ico { width: 16px; height: 16px; }
@keyframes stamp-in { from { transform: rotate(-14deg) scale(1.8); opacity: 0; } to { transform: rotate(-14deg) scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .relaxed-stamp { animation: none; } }

.combo {
  position: absolute;
  left: 50%;
  top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%) scale(0.8);
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 6px 14px 8px;
  border-radius: 14px;
  background: rgba(251, 247, 238, 0.85);
  border: 2px solid var(--ink);
  box-shadow: 2px 3px 0 rgba(43, 37, 32, 0.14);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.combo.on { opacity: 1; transform: translateX(-50%) scale(1); }
.combo.bump { animation: bump 0.28s ease-out; }
@keyframes bump { 40% { transform: translateX(-50%) scale(1.18) rotate(-3deg); } }
.combo-x { grid-row: span 2; font-family: var(--hand); font-weight: 700; font-size: 34px; line-height: 0.9; color: var(--red); }
.combo-label { font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim); }
.combo-bar { display: block; width: 72px; height: 4px; border-radius: 4px; background: rgba(43, 37, 32, 0.12); overflow: hidden; }
.combo-bar i { display: block; height: 100%; width: 100%; background: var(--red); transform-origin: left; }

.actions { display: flex; gap: 8px; position: relative; z-index: 6; }
/* the top bar stays usable over every card; it is hidden while the splash is up */
body.splashing .hud-top, body.splashing .ink-hud, body.splashing .actions { visibility: hidden; }

.icon-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
  background: var(--paper-2);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 3px 0 rgba(43, 37, 32, 0.14);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.icon-btn .ico { grid-area: 1 / 1; }
.icon-btn:hover { background: #fff; transform: translateY(-1px) rotate(-2deg); }
.icon-btn:active { transform: translateY(1px); box-shadow: 1px 1px 0 rgba(43, 37, 32, 0.14); }
.icon-btn:focus-visible, .cta:focus-visible { outline: 3px solid var(--pen); outline-offset: 3px; }
.icon-btn .ico-off { display: none; }
.icon-btn.off .ico-on { display: none; }
.icon-btn.off .ico-off { display: block; }
#btn-music.off { color: var(--ink-dim); }
#btn-music.off::after {
  content: "";
  grid-area: 1 / 1;
  width: 24px;
  height: 2px;
  background: var(--red);
  border-radius: 2px;
  transform: rotate(-40deg);
}

/* ---------- ink HUD ---------- */
.ink-hud {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px 8px 10px;
  border-radius: 14px;
  background: rgba(251, 247, 238, 0.78);
  border: 1.5px solid var(--ink-faint);
  pointer-events: none;
}
.slots { display: flex; gap: 6px; }
.slot {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--pen);
  transition: transform 0.2s;
}
.slot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--pen) calc(var(--p, 1) * 360deg), rgba(45, 93, 168, 0.14) 0);
  -webkit-mask: radial-gradient(circle, transparent 13px, #000 14px);
  mask: radial-gradient(circle, transparent 13px, #000 14px);
}
.slot .ico { width: 18px; height: 18px; fill: var(--pen); stroke: var(--pen); }
.slot.used .ico { fill: none; opacity: 0.45; }
.slot.pop { animation: pop 0.35s ease-out; }
@keyframes pop { 40% { transform: scale(1.25); } }
.ink-hud.shake { animation: shake 0.32s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.ink-len {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ink-len .ico { width: 16px; height: 16px; color: var(--ink-dim); }
.ink-len.low { color: var(--red); }

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(243, 236, 221, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.overlay.show { opacity: 1; visibility: visible; }
.overlay .card { transform: translateY(12px) rotate(-1.2deg); transition: transform 0.4s cubic-bezier(0.2, 1.4, 0.4, 1); }
.overlay.show .card { transform: translateY(0) rotate(-1.2deg); }

.card {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 30px 28px 22px;
  background: var(--paper-2);
  border: 2px solid var(--ink);
  border-radius: 6px 12px 8px 14px;
  text-align: center;
  box-shadow: 6px 8px 0 rgba(43, 37, 32, 0.1), 0 20px 50px rgba(80, 60, 30, 0.18);
}
.card.small { width: min(330px, 100%); }
.tape {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 96px;
  height: 26px;
  transform: translateX(-50%) rotate(3deg);
  background: rgba(231, 169, 58, 0.45);
  border-left: 2px dashed rgba(255, 255, 255, 0.5);
  border-right: 2px dashed rgba(255, 255, 255, 0.5);
}

h1 {
  margin: 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 62px;
  line-height: 0.95;
  letter-spacing: 0.01em;
}
h2 { margin: 4px 0 18px; font-family: var(--hand); font-weight: 700; font-size: 38px; line-height: 1; }
.tag {
  display: inline-block;
  margin: 6px 0 20px;
  padding: 0 6px;
  font-family: var(--hand);
  font-size: 24px;
  font-weight: 500;
  background: linear-gradient(transparent 55%, var(--hi) 55%, var(--hi) 90%, transparent 90%);
}

.hints { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 12px; text-align: left; }
.hints li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.4; color: var(--ink-dim); font-weight: 500; }
.hint-ico {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 50% 45% 55% 48%;
  color: var(--pen);
}
.hint-ico.red { color: var(--red); }
.hint-ico .ico { width: 16px; height: 16px; }

/* anything marked hidden stays hidden, whatever display its own style sets (a .cta is inline-flex) */
[hidden] { display: none !important; }

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 190px;
  height: 52px;
  padding: 0 26px;
  border: 2px solid var(--ink);
  border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
  background: var(--pen);
  color: #fff;
  font: 800 17px/1 var(--ui);
  cursor: pointer;
  box-shadow: 3px 4px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
}
.cta .ico { width: 18px; height: 18px; }
.cta:hover { transform: translate(-1px, -1px) rotate(-1deg); box-shadow: 4px 5px 0 var(--ink); }
.cta:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }

.sub { margin: 14px 0 0; font-family: var(--hand); font-size: 22px; color: var(--ink-dim); }
.sub:empty { display: none; }
.keys { margin: 8px 0 0; font-size: 12px; color: var(--ink-dim); letter-spacing: 0.03em; }
@media (orientation: portrait) and (max-width: 700px) {
  .keys { display: none; }
}

.cause { margin: 0; font-family: var(--hand); font-size: 26px; color: var(--red); }
.tip { margin: 2px 0 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--pen); }
.tip .ico { width: 16px; height: 16px; flex: none; }
.big { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 92px; line-height: 0.95; font-variant-numeric: tabular-nums; }
.big small { font-size: 36px; margin-left: 4px; color: var(--ink-dim); }
.big-label { margin: -4px 0 0; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.stats { flex-wrap: wrap; gap: 10px 22px !important; }
.best-pill {
  display: none;
  align-items: center;
  gap: 6px;
  width: max-content;
  margin: 8px auto 0;
  padding: 5px 12px 5px 9px;
  border: 1.5px solid var(--red);
  border-radius: 999px;
  background: rgba(196, 67, 47, 0.1);
  color: var(--red);
  font: 800 12px/1 var(--ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.best-pill .ico { width: 14px; height: 14px; fill: currentColor; }
.best-pill.show { display: flex; animation: best-pop 0.4s 0.3s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes best-pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.stats { display: flex; justify-content: center; gap: 28px; margin: 12px 0 18px; }
.stats div { display: flex; flex-direction: column; align-items: center; }
.stats dt { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.stats dd { margin: 2px 0 0; font-family: var(--hand); font-weight: 700; font-size: 28px; }

@media (max-width: 560px) {
  .combo { top: calc(90px + env(safe-area-inset-top)); padding: 3px 9px 4px; column-gap: 6px; border-width: 1.5px; border-radius: 11px; }
  .combo-x { font-size: 22px; }
  .combo-label { font-size: 9px; }
  .combo-bar { width: 54px; height: 3px; }
  #dist { font-size: 40px; }
  .icon-btn { width: 38px; height: 38px; }
  .actions { gap: 6px; }
  h1 { font-size: 54px; }
}

@media (max-height: 460px) {
  .card { padding: 20px 22px 16px; }
  h1 { font-size: 46px; }
  .tag { margin-bottom: 10px; font-size: 21px; }
  .hints { gap: 7px; margin-bottom: 14px; }
  .hints li { font-size: 13.5px; }
  .hint-ico { width: 26px; height: 26px; }
  .cta { height: 46px; }
  .big { font-size: 72px; }
  .stats { margin: 6px 0 12px; }
  .ink-hud { padding: 6px 12px 6px 8px; }
  .slot { width: 30px; height: 30px; }
  .slot::before { -webkit-mask: radial-gradient(circle, transparent 11px, #000 12px); mask: radial-gradient(circle, transparent 11px, #000 12px); }
}

@media (prefers-reduced-motion: reduce) {
  .overlay .card { transition: none; }
  .best-pill.show { animation: none; }
}

/* ---------- menus: rank, missions, dojo, toasts ---------- */
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cta.play-main { width: 100%; margin-bottom: 12px; }
.mode-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 3px; margin: 4px 0 12px; border: 1.5px solid var(--ink-faint); border-radius: 12px; background: rgba(255, 255, 255, 0.5); }
.mode-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 50px; padding: 6px 2px; border: 0; border-radius: 9px; background: none; font: 800 12px/1.1 var(--ui); color: var(--ink-dim); cursor: pointer; }
.mode-chip .ico { width: 17px; height: 17px; }
.mode-chip:hover { color: var(--ink); }
.mode-chip { transition: transform 0.15s, box-shadow 0.15s; }
/* the picked mode is a little sticker on the page: inked edge, drop shadow, a highlighter swipe under its name */
.mode-chip.on { position: relative; z-index: 1; background: #fffdf6; color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 3px 0 var(--ink); transform: rotate(-2deg); }
.mode-chip.on .ico { color: var(--pen); }
.mode-chip.on .mc-name { background: linear-gradient(transparent 50%, var(--hi) 50%, var(--hi) 92%, transparent 92%); padding: 0 3px; }
.mode-chip.locked { opacity: 0.55; }
/* a small yellow pill on Brawl until the first fight */
.mode-chip { position: relative; }
.mc-new { position: absolute; top: -8px; right: -3px; z-index: 2; display: inline-flex; align-items: center; justify-content: center; height: 12px; padding: 0 4px; border-radius: 999px; background: #f2c94c; color: var(--ink); font: 800 7.5px/1 var(--ui); letter-spacing: 0.05em; text-transform: uppercase; box-shadow: 0 1px 0 rgba(43, 37, 32, 0.25); pointer-events: none; }
.mc-new[hidden] { display: none; }
.menu-row { gap: 8px; }
.menu-row .cta { flex: 1; }
/* the game-over card's main buttons stay pinned to its bottom edge while the rest scrolls behind them */
.over-go { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; padding: 10px 0 2px; background: var(--paper-2); box-shadow: 0 6px 0 22px var(--paper-2); }
.bo-hint { flex-basis: 100%; margin: 0 0 2px; text-align: center; font: 700 12.5px/1.3 var(--ui); color: var(--ink-dim); }
.bo-hint[hidden] { display: none; }
.over-go::before { content: ''; position: absolute; left: -22px; right: -22px; bottom: 100%; height: 26px; background: linear-gradient(to bottom, transparent, var(--paper-2)); pointer-events: none; }
#ov-over .btn-row { margin-top: 2px; }
/* game over: the side trips in one row of small tiles, icon over name, above the pinned Run again */
.over-tools { gap: 8px; flex-wrap: nowrap; margin-bottom: 18px; }
.over-tools .cta.small { flex: 1 1 0; min-width: 0; height: auto; min-height: 54px; flex-direction: column; gap: 4px; padding: 8px 4px; font-size: 12.5px; line-height: 1.1; }
.over-tools .cta.small[hidden] { display: none; }
.over-tools:has(#btn-board:not([hidden])) .cta.small, .over-tools:has(#btn-bo-board:not([hidden])) .cta.small { font-size: 11.5px; padding: 8px 2px; }
.over-tools .cta.small span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cta.ghost { background: var(--paper-2); color: var(--ink); min-width: 0; }
.cta.ghost .ico { color: var(--ink); }

.rank { display: none; align-items: center; gap: 10px; margin: 0 auto 14px; width: max-content; max-width: 100%; }
.rank.show { display: flex; }
button.rank { padding: 4px 8px; border: 0; border-radius: 12px; background: none; font: inherit; color: inherit; cursor: pointer; }
button.rank:hover { background: rgba(43, 37, 32, 0.05); }
.rank-info { color: var(--ink-dim); display: flex; }
.rank-info .ico { width: 16px; height: 16px; }
.belts-lead, .belts-foot { font-size: 14px; color: var(--ink-dim); margin: 0 0 12px; }
.belts-foot { margin: 12px 0 14px; font-size: 13px; }
.belt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; text-align: left; }
.belt-list li { display: flex; align-items: center; gap: 12px; padding: 5px 10px; border-radius: 10px; }
.belt-list li.here { background: rgba(242, 201, 76, 0.25); outline: 2px solid #f2c94c; }
.belt-list li.got { opacity: 0.55; }
.belt-list .belt { flex: none; transform: scale(0.8); }
.bl-name { flex: 1; display: flex; flex-direction: column; font: 800 14px/1.15 var(--ui); }
.bl-name small { font-size: 11px; font-weight: 700; color: var(--ink-dim); }
.bl-pay { display: flex; align-items: center; gap: 3px; font: 800 13px/1 var(--ui); color: #8a5a10; }
.bl-pay .ico { width: 14px; height: 14px; color: #c98a14; }
.bl-here { font: 800 11px/1 var(--ui); color: var(--ink); background: #f2c94c; padding: 4px 7px; border-radius: 6px; }
body.at-menu .hud-top .score, body.at-menu .combo, body.at-menu .ink-hud, body.at-menu #btn-restart, body.at-menu #btn-pause { visibility: hidden; }
#ov-start .card.tight { padding-top: 20px; padding-bottom: 14px; }
#ov-start .card.tight .mode-row { margin: 2px 0 10px; }
#ov-start .card.tight .mode-chip { min-height: 44px; }
#ov-start .card.tight .cp-track { margin-bottom: 4px; }
#ov-start .card.tight .cpt-rail { padding: 16px 16px 24px; }
#ov-start .card.tighter .cp-note, #ov-start .card.tighter .cpt-lab { display: none; }
#ov-start .card.tighter .cpt-rail { padding: 14px 16px 14px; }
#ov-start .card.tighter .cp-track { margin-bottom: 2px; }
#ov-start .card.tighter .missions { margin-bottom: 6px; }
#ov-start .card.tighter .gift-line { margin-bottom: 6px; }
/* the last squeeze for small phones in long languages: less side padding (fewer wrapped lines), smaller type */
#ov-start .card.tighter { padding-left: 16px; padding-right: 16px; padding-top: 14px; }
#ov-start .card.tighter h1 { font-size: 42px; }
#ov-start .card.tighter .tag { font-size: 19px; margin: 0 0 6px; }
#ov-start .card.tighter .rank { margin-bottom: 4px; }
#ov-start .card.tighter .rank-name { font-size: 19px; }
#ov-start .card.tighter .missions { gap: 4px; }
#ov-start .card.tighter .mission { padding: 3px 8px; gap: 8px; grid-template-columns: 22px 1fr auto; }
#ov-start .card.tighter .mission .m-ico { width: 22px; height: 22px; }
#ov-start .card.tighter .mission .m-text { font-size: 12.5px; line-height: 1.15; }
#ov-start .card.tighter .mission > span:nth-child(2) { line-height: 1.15; }
#ov-start .card.tighter .gift-line { font-size: 12px; }
#ov-start .card.tighter .mode-chip { min-height: 40px; font-size: 11px; gap: 2px; }
#ov-start .card.tighter .mode-chip .ico { width: 15px; height: 15px; }
#ov-start .card.tighter .mode-note { margin-bottom: 8px; font-size: 12px; }
#ov-start .card.tighter .play-main { margin-bottom: 8px; }
#ov-start .card.tight .mode-row { margin-bottom: 8px; }
#ov-start .card.tight .play-main { margin-bottom: 10px; }
#ov-start .card.tight h1 { font-size: 52px; }
#ov-start .card.tight .tag { margin: 2px 0 10px; font-size: 22px; }
#ov-start .card.tight .rank { margin-bottom: 8px; }
#ov-start .card.tight .missions { gap: 5px; margin-bottom: 10px; }
#ov-start .card.tight .mission { padding: 5px 10px; }
#ov-start .card.tight .sub { margin-top: 8px; }
.belt { width: 30px; height: 12px; border-radius: 3px; border: 2px solid var(--ink); position: relative; }
.belt::after { content: ""; position: absolute; left: 50%; top: -5px; width: 6px; height: 18px; transform: translateX(-50%) rotate(12deg); background: inherit; border: 2px solid var(--ink); border-radius: 2px; }
.rank-text { text-align: left; }
.rank-name { font-family: var(--hand); font-weight: 700; font-size: 22px; line-height: 1; }
.rank-bar { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; color: var(--ink-dim); }
.rank-bar .ico { width: 13px; height: 13px; fill: var(--gold); stroke: #9a6a10; }
.rank-track { width: 90px; height: 5px; border-radius: 5px; background: var(--ink-faint); overflow: hidden; }
.rank-track i { display: block; height: 100%; background: var(--gold); }

.missions { display: grid; gap: 8px; margin: 0 0 18px; text-align: left; }
.missions:empty { display: none; }
.missions h3 { margin: 0 0 2px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; }
.missions h3 .ico { width: 14px; height: 14px; }
.missions h3 small { font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink-dim); opacity: 0.8; }
.mission { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1.5px solid var(--ink-faint); border-radius: 10px; background: rgba(255, 255, 255, 0.45); }
.mission .m-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--ink-faint); color: var(--ink-dim); }
.mission .m-ico .ico { width: 14px; height: 14px; }
.mission.done { border-color: rgba(95, 160, 90, 0.5); background: rgba(150, 200, 130, 0.14); }
.mission.done .m-ico { background: #5b9a4f; border-color: #5b9a4f; color: #fff; }
.mission .m-text { font-size: 13px; font-weight: 700; line-height: 1.25; }
.mission .m-prog { margin-top: 4px; height: 4px; border-radius: 4px; background: var(--ink-faint); overflow: hidden; }
.mission .m-prog i { display: block; height: 100%; background: var(--pen); }
.mission .m-row { display: flex; align-items: center; gap: 8px; }
.mission .m-row .m-prog { flex: 1; }
.mission .m-count { margin-top: 4px; font-size: 11px; font-weight: 800; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.next-up { display: grid; gap: 6px; margin: 0 0 14px; text-align: left; }
.next-up h3 { margin: 0 0 2px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; }
.next-up h3 .ico { width: 14px; height: 14px; }
.nx { display: grid; grid-template-columns: 26px 1fr 64px; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border: 1.5px solid var(--ink-faint); border-radius: 10px; background: rgba(255, 255, 255, 0.45); font: inherit; color: inherit; text-align: left; }
button.nx { cursor: pointer; }
button.nx:hover { border-color: var(--pen); }
.nx .nx-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--ink-faint); color: var(--pen); }
.nx .nx-ico .ico { width: 14px; height: 14px; }
.nx .nx-t { font-size: 13px; font-weight: 700; line-height: 1.25; }
.nx .nx-t b { font-weight: 800; color: var(--pen); }
.nx .nx-bar { height: 6px; border-radius: 6px; background: var(--ink-faint); overflow: hidden; }
.nx .nx-bar i { display: block; height: 100%; background: var(--pen); border-radius: 6px; }
.nx.hot { border-color: var(--gold, #d9a520); background: rgba(242, 201, 76, 0.22); }
.nx.hot .nx-ico { color: #8a6a10; border-color: rgba(217, 165, 32, 0.6); }
.nx.hot .nx-bar i { background: #d9a520; animation: nx-glow 1.4s ease-in-out infinite; }
@keyframes nx-glow { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .nx.hot .nx-bar i { animation: none; } }
.mission.done .m-prog i { background: #5b9a4f; }
.mission .m-reward { display: flex; align-items: center; gap: 4px; font: 800 12px/1 var(--ui); color: #8a5a10; }
.mission .m-reward .ico { width: 13px; height: 13px; color: #c98a14; }
.missions.compact .mission { padding: 6px 9px; }
.missions.compact .m-text { font-size: 12px; }

.dojo { width: min(560px, 100%); }
.dojo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dojo-head h2 { margin: 0; }
.dojo-sub { margin: 6px 0 16px; text-align: left; font-size: 13px; color: var(--ink-dim); }
.coin-pill.big { font-size: 18px; padding: 6px 14px 6px 10px; }
.coin-pill.big .ico { width: 18px; height: 18px; }
.upgrades { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 18px; text-align: left; }
.upgrade { display: grid; grid-template-columns: 40px 1fr; gap: 4px 12px; padding: 12px; border: 2px solid var(--ink); border-radius: 12px 6px 14px 8px; background: #fff; box-shadow: 2px 3px 0 rgba(43, 37, 32, 0.1); }
.upgrade .u-ico { grid-row: span 2; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(45, 93, 168, 0.1); color: var(--pen); }
.upgrade .u-ico .ico { width: 20px; height: 20px; }
.upgrade .u-name { font-weight: 800; font-size: 15px; }
.upgrade .u-desc { font-size: 12px; color: var(--ink-dim); line-height: 1.35; }
.upgrade .u-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.pips { display: flex; gap: 4px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: var(--ink-faint); }
.pips i.on { background: var(--pen); }
.buy { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 9px; background: #f2c94c; font: 800 13px/1 var(--ui); color: var(--ink); cursor: pointer; box-shadow: 2px 2px 0 var(--ink); }
.buy .ico { width: 14px; height: 14px; }
.buy:disabled { background: var(--paper); color: var(--ink-dim); box-shadow: none; cursor: default; opacity: 0.8; }
.buy.maxed { background: rgba(150, 200, 130, 0.3); }
.buy.armed { background: var(--ink); color: #f2c94c; animation: armPulse 0.9s ease-in-out infinite; }
.w-item.armed { outline: 3px solid #f2c94c; outline-offset: -3px; }
.w-price.confirm { color: var(--ink); font-size: 10px; text-align: center; }
@keyframes armPulse { 50% { transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .buy.armed { animation: none; } }
.buy:not(:disabled):active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.upgrade.bought { animation: pop 0.35s ease-out; }

.toasts { position: absolute; left: 50%; top: calc(80px + env(safe-area-inset-top)); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; z-index: 5; }
.toast { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper-2); box-shadow: 3px 4px 0 rgba(43, 37, 32, 0.15); font: 700 14px/1.2 var(--ui); animation: toastIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1), toastOut 0.4s 2.6s forwards; }
.toast .t-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #5b9a4f; color: #fff; flex: none; }
.toast.rankup .t-ico { background: var(--gold); }
.toast .t-ico .ico { width: 15px; height: 15px; }
.toast small { display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim); }
.toast .t-reward { display: flex; align-items: center; gap: 4px; color: #8a5a10; font-weight: 800; }
.toast .t-reward .ico { width: 14px; height: 14px; color: #c98a14; }
@keyframes toastIn { from { transform: translateY(-14px) scale(0.9); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }
@media (max-width: 560px) { .toasts { top: calc(140px + env(safe-area-inset-top)); } }
@media (max-height: 460px) { .missions { gap: 5px; margin-bottom: 12px; } .mission { padding: 5px 8px; } .toasts { top: 70px; } }
#ov-over .card { width: min(390px, 100%); }
#ov-over .stats { display: grid; grid-template-columns: repeat(4, auto); justify-content: center; gap: 4px 20px !important; }
#ov-over .stats dd { font-size: 24px; }
/* laptops: replay and score on the left, goals and buttons on the right, so the goals are seen without scrolling */
@media (min-width: 900px) and (min-height: 501px) and (max-height: 1000px) {
  #ov-over .card { width: min(780px, 100%); display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: center; }
  /* two columns: the pinned Run again keeps its backing inside the right column, off the replay */
  #ov-over .over-go { box-shadow: 0 10px 0 0 var(--paper-2); }
  #ov-over .over-go::before { left: 0; right: 0; }
  #ov-over .over-b { align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
}
@media (max-height: 460px) {
  #ov-start h1 { font-size: 40px; margin-bottom: 6px; }
  #ov-start .tag { margin: 0 0 8px; font-size: 20px; }
  .rank { margin-bottom: 8px; }
  .rank-name { font-size: 19px; }
  .mission { padding: 4px 8px; gap: 8px; grid-template-columns: 22px 1fr auto; }
  .mission .m-ico { width: 22px; height: 22px; }
  .mission .m-text { font-size: 12px; }
  #ov-start .keys { display: none; }
  .dojo { width: min(760px, 100%); padding: 16px 18px 14px; }
  .dojo-sub { display: none; }
  .dojo-head h2 { font-size: 30px; }
  .upgrades { grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 12px; }
  .upgrade { padding: 8px; grid-template-columns: 30px 1fr; gap: 2px 8px; }
  .upgrade .u-ico { width: 30px; height: 30px; }
  .upgrade .u-ico .ico { width: 16px; height: 16px; }
  .upgrade .u-name { font-size: 13px; }
  .upgrade .u-desc { font-size: 11px; }
  .upgrade .u-foot { margin-top: 4px; }
  .buy { height: 28px; padding: 0 9px; font-size: 12px; }
  #ov-over .missions { display: none; }
}

/* ---------- ink picker ---------- */
.inks { display: flex; gap: 6px; padding-right: 12px; margin-right: 2px; border-right: 1.5px solid var(--ink-faint); pointer-events: auto; }
.inks:empty, .inks.solo { display: none; }
.ink-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 2px solid transparent; background: var(--ink-color); color: #fff; cursor: pointer; opacity: 0.55; transition: transform 0.15s, opacity 0.15s, border-color 0.15s; }
.ink-btn .ico { width: 18px; height: 18px; }
.ink-btn[aria-checked="true"] { opacity: 1; border-color: var(--ink); transform: scale(1.08); box-shadow: 2px 2px 0 rgba(43, 37, 32, 0.25); }
.ink-btn kbd { position: absolute; right: -3px; bottom: -3px; width: 15px; height: 15px; border-radius: 50%; background: var(--paper-2); border: 1.5px solid var(--ink); color: var(--ink); font: 800 9px/12px var(--ui); text-align: center; }
@media (hover: none) { .ink-btn kbd { display: none; } }
@media (max-height: 460px) { .ink-btn { width: 34px; height: 34px; } }
.upgrade .u-desc b { color: var(--ink); }
.upgrade .u-when { display: block; margin-top: 4px; color: var(--ink); }
@media (min-height: 461px) {
  .dojo { width: min(780px, 100%); }
  .upgrades { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ---------- boss health ---------- */
.bossbar { position: absolute; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%) translateY(-8px); display: flex; align-items: center; gap: 10px; padding: 6px 12px; border: 2px solid var(--ink); border-radius: 10px; background: rgba(251, 247, 238, 0.9); font: 800 12px/1 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; }
.bossbar.show { opacity: 1; transform: translateX(-50%); }
.bossbar b { display: block; width: 150px; height: 10px; border-radius: 5px; background: var(--ink-faint); overflow: hidden; border: 1.5px solid var(--ink); }
.bossbar i { display: block; height: 100%; width: 100%; background: var(--red); transition: width 0.3s; }
/* one notch per hit, so a tougher boss shows a longer row of pieces */
.bossbar b { position: relative; --seg: 3; }
.bossbar b::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(to right, transparent 0 calc(100% / var(--seg) - 1.5px), var(--ink) calc(100% / var(--seg) - 1.5px) calc(100% / var(--seg))); pointer-events: none; }
@media (max-width: 560px) { .bossbar { top: calc(132px + env(safe-area-inset-top)); } }

/* ---------- dojo tabs + wardrobe ---------- */
.dojo-head { flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; padding: 3px; border: 1.5px solid var(--ink-faint); border-radius: 10px; margin-right: auto; margin-left: 14px; }
.tab { height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; font: 800 13px/1 var(--ui); color: var(--ink-dim); cursor: pointer; }
.tab.on { background: var(--ink); color: var(--paper-2); }
.wardrobe { display: grid; gap: 14px; margin-bottom: 18px; text-align: left; }
.wardrobe[hidden], .upgrades[hidden] { display: none; }
.w-cat h3 { margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.w-items { display: flex; flex-wrap: wrap; gap: 8px; }
.w-item { display: grid; justify-items: center; gap: 5px; width: 84px; padding: 9px 6px 8px; border: 2px solid var(--ink-faint); border-radius: 12px; background: #fff; cursor: pointer; font: 700 11px/1.2 var(--ui); color: var(--ink); transition: transform 0.12s, border-color 0.12s; }
.w-item:hover { transform: translateY(-2px); }
.w-item.eq { border-color: var(--ink); box-shadow: 2px 3px 0 rgba(43, 37, 32, 0.15); }
.w-item.locked { color: var(--ink-dim); }
.w-item.poor { opacity: 0.55; }
.w-item.shake { animation: shake 0.3s; }
.w-swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink); position: relative; overflow: hidden; }
.w-price { display: flex; align-items: center; gap: 3px; font: 800 11px/1 var(--ui); color: #8a5a10; }
.w-price .ico { width: 12px; height: 12px; color: #c98a14; }
.w-tag { font: 800 10px/1 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: #3f8a46; }
@media (max-height: 460px) { .w-item { width: 72px; padding: 6px 4px; } .w-swatch { width: 30px; height: 30px; } .wardrobe { gap: 8px; } }

/* ---------- phone comfort: fewer, smaller overlays ---------- */
.icon-btn[hidden] { display: none; }
/* install: a quiet button on the start card, and the iPhone how-to card */
.install-btn { display: inline-flex; align-items: center; gap: 10px; margin: 10px auto 0; padding: 7px 14px 7px 10px; border: 2px dashed var(--ink); border-radius: 12px; background: transparent; color: var(--ink); font: inherit; font-weight: 800; font-size: 15px; text-align: left; cursor: pointer; }
.install-btn[hidden] { display: none; }
.install-btn .inst-short { display: none; }
.install-btn .ico { width: 22px; height: 22px; color: var(--pen, #2d5da8); flex: none; }
.install-btn small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-dim); }
.install-btn:hover { background: rgba(43, 37, 32, 0.05); }
.install-btn.nudge { animation: installNudge 1.2s ease-in-out 3; }
@keyframes installNudge { 50% { transform: scale(1.06); background: rgba(231, 169, 58, 0.25); } }
.install-card { text-align: center; }
.install-icon { display: block; width: 84px; height: 84px; margin: 4px auto 6px; border-radius: 24%; box-shadow: 0 0 0 3px var(--ink), 4px 5px 0 3px rgba(43, 37, 32, 0.16); }
.install-steps { list-style: none; margin: 12px 0 16px; padding: 0; text-align: left; display: grid; gap: 10px; }
.install-steps li { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.toasts.in-run { left: auto; right: max(16px, env(safe-area-inset-right)); top: calc(62px + env(safe-area-inset-top)); transform: none; justify-items: end; }
.toasts.in-run .toast { padding: 6px 10px; gap: 8px; font-size: 12px; border-width: 1.5px; box-shadow: 2px 2px 0 rgba(43, 37, 32, 0.12); animation: toastIn 0.3s cubic-bezier(0.2, 1.4, 0.4, 1), toastOut 0.35s 1.9s forwards; }
.toasts.in-run .toast .t-ico { width: 20px; height: 20px; }
.toasts.in-run .toast small { font-size: 9px; }
@media (max-width: 460px) { .actions { gap: 5px; } .icon-btn { width: 36px; height: 36px; } }
@media (max-height: 460px) { .icon-btn { width: 36px; height: 36px; } .actions { gap: 6px; } .combo { padding: 3px 10px 5px; } .combo-x { font-size: 26px; } }

/* ---------- pre-run card: missions and checkpoints ---------- */
.cps { margin: 0 0 16px; text-align: left; }
.cps h3 { margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; }
.cps h3 .ico { width: 14px; height: 14px; }
.cp-list { display: flex; flex-wrap: wrap; gap: 6px; }
.cp {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 6px 11px; border: 1.5px solid var(--ink-dim); border-radius: 10px;
  background: var(--paper-2); color: var(--ink); font: 800 14px/1.1 var(--ui); cursor: pointer;
}
.cp small { font: 600 11px/1.1 var(--ui); color: var(--ink-dim); }
.cp.on { border-color: var(--pen); background: var(--pen); color: #fff; box-shadow: 2px 2px 0 var(--ink); }
.cp.on small { color: rgba(255, 255, 255, 0.85); }
.cp-note { margin: 2px 0 0; font-size: 12px; color: var(--ink-dim); min-height: 1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-track { margin: -2px 0 18px; }
.cp-track[hidden] { display: none; }
.cpt-head { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; color: var(--ink-dim); }
.cpt-head .ico { width: 14px; height: 14px; }
.cpt-k { font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; }
.cpt-val { margin-left: auto; display: flex; align-items: baseline; gap: 6px; color: var(--ink); }
.cpt-val b { font: 800 14px/1 var(--ui); }
.cpt-val span { font: 700 12px/1 var(--ui); color: var(--pen); }
.cpt-rail { padding: 18px 16px 26px; cursor: pointer; touch-action: none; outline: none; -webkit-user-select: none; user-select: none; }
.cpt-rail:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; border-radius: 10px; }
.cpt-in { position: relative; height: 4px; }
.cpt-line, .cpt-fill { position: absolute; left: 0; top: 0; height: 4px; border-radius: 4px; }
.cpt-line { right: 0; background: var(--ink-faint); }
.cpt-fill { background: var(--pen); transition: width 0.12s; }
.cpt-tick { position: absolute; top: 2px; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--paper-2); border: 2px solid var(--ink-dim); }
.cpt-tick.past { border-color: var(--pen); background: var(--pen); }
.cpt-lab { position: absolute; top: 12px; transform: translateX(-4px); font: 700 10px/1 var(--ui); color: var(--ink-dim); white-space: nowrap; }
.cpt-lab.end { transform: translateX(calc(-100% + 4px)); }
.cpt-knob { position: absolute; top: 2px; width: 26px; height: 14px; margin: -7px 0 0 -13px; border-radius: 7px; background: #fffdf6; border: 2px solid var(--ink); box-shadow: 1.5px 1.5px 0 var(--ink); transition: left 0.12s; }
.cpt-rail.drag .cpt-knob { transform: scale(1.15); transition: none; }
.cpt-rail.drag .cpt-fill { transition: none; }
.cp-note:empty { display: none; }
.cta.resume { width: 100%; margin: 0 0 12px; height: auto; min-height: 52px; padding: 8px 20px; background: #2f9a6a; }
.cta.resume span { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.cta.resume small { font: 600 12px/1 var(--ui); opacity: 0.9; }
.cta.resume[hidden] { display: none; }
.icon-btn.zoom-pct { width: auto; min-width: 42px; padding: 0 7px; font: 800 13px/1 var(--ui); letter-spacing: -0.02em; }
@media (max-width: 460px), (max-height: 460px) { .icon-btn.zoom-pct { min-width: 36px; padding: 0 5px; font-size: 12px; } }


/* ---------- game over: replay of the last moments ---------- */
.over-a { position: relative; }
.replay { position: relative; margin: 0 auto 10px; width: 100%; aspect-ratio: 16 / 10; border: 2px solid var(--ink); border-radius: 10px 14px 8px 12px; overflow: hidden; background: var(--paper); box-shadow: 2px 3px 0 rgba(43, 37, 32, 0.14); }
.replay[hidden] { display: none; }
.replay canvas { display: block; width: 100%; height: 100%; }
.replay-tag { position: absolute; left: 8px; top: 7px; display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 6px; background: rgba(251, 247, 238, 0.85); font: 800 10px/1 var(--ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink); }
.replay-tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: rec-blink 1s steps(2) infinite; }
@keyframes rec-blink { 50% { opacity: 0.2; } }
.replay-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(43, 37, 32, 0.12); }
.replay-bar i { display: block; height: 100%; width: 0; background: var(--red); }
@media (max-height: 500px) and (min-width: 600px) {
  #ov-over .card { width: min(680px, 100%); display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: center; padding: 16px 20px; }
  #ov-over .over-go { box-shadow: 0 10px 0 0 var(--paper-2); }
  #ov-over .over-go::before { left: 0; right: 0; }
  #ov-over .replay { margin-bottom: 6px; }
  #ov-over .big { font-size: 60px; }
  #ov-over .stats { grid-template-columns: repeat(2, auto); margin: 0 0 10px; }
}

/* Brawl is played sideways, so its results sit in two columns: the score on the left, the buttons on the right */
@media (max-height: 500px) and (min-width: 600px) {
  #ov-blade .card { width: min(720px, 100%); display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; align-items: center; padding: 16px 20px; }
  /* with a replay: the replay and what happened on the left, the score and the buttons on the right */
  #ov-blade .replay { grid-area: 1 / 1 / 4 / 2; margin: 0; align-self: center; }
  #ov-blade .cause { grid-area: 4 / 1; margin: 6px 0 0; }
  #ov-blade .over-scoreline { grid-area: 1 / 2; }
  #ov-blade .big { font-size: 52px; }
  #ov-blade .stats { grid-area: 2 / 2; margin: 0; }
  #ov-blade .over-tools { grid-area: 3 / 2; margin: 6px 0 0; }
  #ov-blade .over-go { grid-area: 4 / 2; margin: 0; box-shadow: none; }
  #ov-blade .over-go::before { display: none; }
}

/* ---------- mode switch: endless or today's daily course ---------- */

/* ---------- keep going: a paid revive on the score card ---------- */
.cta.revive { background: #2f9a6a; }
.cta.revive[hidden] { display: none; }
/* while a CrazyGames ad loads or plays, nothing on the page can be pressed */
body.ad-busy .overlay, body.ad-busy #app { pointer-events: none; }
.rv-cost { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); font: 800 14px/1 var(--ui); }
.rv-cost .ico { width: 14px; height: 14px; }

/* on short landscape screens the badge sits beside the score, so nothing runs off the card */
@media (max-height: 500px) and (min-width: 600px) {
  #ov-over .over-scoreline { display: flex; align-items: center; justify-content: center; gap: 14px; }
  #ov-over .over-side { display: grid; justify-items: start; gap: 6px; }
  #ov-over .over-side .big-label { margin: 0; }
  #ov-over .best-pill { margin: 0; }
}

/* ---------- splash: the name written in by the pen, then tap to start ---------- */
.overlay.splash { background: rgba(243, 236, 221, 0.78); cursor: pointer; }
.splash-in { text-align: center; padding: 16px; }
.splash-title { position: relative; display: inline-block; margin: 0; font-family: var(--hand); font-weight: 700; font-size: clamp(64px, 14vw, 132px); line-height: 1; color: var(--ink); }
/* extra room on the right for the leaning d, so the pen and the reveal finish together */
.splash-title span { display: inline-block; padding: 0 0.2em 0 0.06em; clip-path: inset(-20% 100% -20% -15%); animation: splash-write 1.1s 0.25s cubic-bezier(0.55, 0.1, 0.35, 1) forwards; }
.splash-title .nib { position: absolute; top: 58%; left: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--pen); box-shadow: 0 0 0 3px rgba(45, 93, 168, 0.18); opacity: 0; animation: splash-nib 1.1s 0.25s cubic-bezier(0.55, 0.1, 0.35, 1) forwards; }
.splash-line { display: block; width: min(78%, 420px); height: auto; margin: -2px auto 10px; overflow: visible; }
.splash-line path { fill: none; stroke: var(--pen); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 320; stroke-dashoffset: 320; animation: splash-line 0.55s 1.25s ease-out forwards; }
.splash-tag { opacity: 0; animation: splash-fade 0.5s 1.6s ease-out forwards; }
/* a long translation wraps into two even lines, each with its own highlighter stroke */
.splash-tag { display: block; max-width: 30ch; margin-left: auto; margin-right: auto; padding: 0; background: none; line-height: 1.3; text-wrap: balance; }
.splash-tag span { padding: 0 6px; background: linear-gradient(transparent 55%, var(--hi) 55%, var(--hi) 90%, transparent 90%); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.splash-tap { margin: 22px 0 0; font: 800 13px/1 var(--ui); letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-dim); opacity: 0; animation: splash-fade 0.4s 1.9s ease-out forwards, splash-pulse 1.6s 2.3s ease-in-out infinite; }
/* short screens (the website's small game frame, phones held sideways): everything closer together */
@media (max-height: 420px) {
  .splash-in { padding: 8px; }
  .splash-title { font-size: clamp(40px, min(14vw, 24vh), 96px); }
  .splash-line { margin: -4px auto 4px; width: min(70%, 360px); }
  .splash-tag { font-size: 18px; margin: 0 auto; }
  .splash-tap { margin-top: 10px; font-size: 11px; }
}
/* a first visit: two ways in, running or fighting, instead of "tap to start" */
.splash-pick { display: flex; justify-content: center; gap: 14px; width: min(100%, 360px); margin: 22px auto 0; opacity: 0; animation: splash-fade 0.4s 1.9s ease-out forwards; }
.splash-pick[hidden] { display: none; }
.overlay.splash.picking { cursor: default; }
/* with the buttons in, the middle takes the screen's width rather than growing past it */
.overlay.splash.picking .splash-in { width: 100%; min-width: 0; }
.sp-btn { display: grid; justify-items: center; gap: 2px; width: calc(50% - 7px); padding: 12px 10px 13px; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper-2); box-shadow: 2px 3px 0 var(--ink); color: var(--ink); cursor: pointer; font: inherit; transition: transform 0.1s, box-shadow 0.1s; }
.sp-btn:active { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); }
.sp-btn .ico { width: 30px; height: 30px; margin-bottom: 2px; }
.sp-run .ico { color: var(--pen); }
.sp-fight .ico { color: var(--red); }
/* the same yellow sticker as on the Brawl chip, on the card's top corner */
.sp-btn { position: relative; }
.sp-new { position: absolute; top: -10px; right: -6px; display: inline-flex; align-items: center; justify-content: center; height: 19px; padding: 0 8px; border-radius: 999px; background: #f2c94c; color: var(--ink); font: 800 10.5px/1 var(--ui); letter-spacing: 0.05em; text-transform: uppercase; box-shadow: 0 1px 0 rgba(43, 37, 32, 0.25); transform: rotate(4deg); pointer-events: none; }
.sp-btn b { font: 700 32px/1 var(--hand); }
.sp-btn small { font: 700 12.5px/1.25 var(--ui); color: var(--ink-dim); text-wrap: balance; }
@media (max-height: 420px) {
  .splash-pick { margin-top: 10px; gap: 10px; }
  .splash-pick { width: min(100%, 320px); }
  .sp-btn { padding: 8px 8px 9px; }
  .sp-btn .ico { width: 24px; height: 24px; }
  .sp-btn b { font-size: 26px; }
  .sp-btn small { font-size: 11.5px; }
}
@keyframes splash-write { to { clip-path: inset(-20% 0 -20% -15%); } }
@keyframes splash-nib { 0% { left: 0; opacity: 1; } 92% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
@keyframes splash-line { to { stroke-dashoffset: 0; } }
@keyframes splash-fade { to { opacity: 1; } }
@keyframes splash-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .splash-title span { animation: none; clip-path: none; }
  .splash-title .nib { display: none; }
  .splash-line path { animation: none; stroke-dashoffset: 0; }
  .splash-tag, .splash-tap, .splash-pick { animation: none; opacity: 1; }
}

/* ---------- settings ---------- */
.card.settings { width: min(440px, 100%); text-align: left; }
.card.settings h2 { text-align: center; margin-bottom: 12px; }
.set-list { display: grid; gap: 4px; margin: 0 0 14px; }
.set-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 2px; border-bottom: 1px dashed rgba(43, 37, 32, 0.14); }
.set-row[hidden] { display: none; }
.set-label { display: inline-flex; align-items: center; gap: 8px; flex: 1; font: 800 14px/1.2 var(--ui); color: var(--ink); }
.set-label .ico { width: 18px; height: 18px; color: var(--ink-dim); }
.set-row input[type="range"] { flex: 1.3; min-width: 0; accent-color: var(--pen); height: 28px; }
.set-row output { width: 32px; text-align: right; font: 800 13px/1 var(--ui); color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.seg { display: flex; gap: 3px; padding: 3px; border: 1.5px solid var(--ink-dim); border-radius: 10px; background: var(--paper-2); }
.seg button { min-width: 50px; height: 32px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-dim); font: 800 13px/1 var(--ui); cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--paper-2); }
.switch { position: relative; width: 50px; height: 30px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); cursor: pointer; transition: background 0.15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform 0.18s; }
.switch[aria-checked="true"] { background: var(--pen); }
.switch[aria-checked="true"] i { transform: translateX(20px); background: #fff; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0 0 14px; }
.cta.small { height: 40px; min-width: 0; padding: 0 14px; font-size: 14px; gap: 7px; box-shadow: 2px 3px 0 var(--ink); }
.cta.small .ico { width: 16px; height: 16px; }
.cta.danger, .cta.danger .ico { color: var(--red); }
.cta.danger.armed { background: var(--red); color: #fff; }
.cta.danger.armed .ico { color: #fff; }
.set-actions .done { order: 3; flex-basis: 100%; max-width: 240px; height: 48px; font-size: 17px; }
@media (max-height: 500px) and (min-width: 600px) {
  .card.settings { width: min(640px, 100%); }
  .set-list { grid-template-columns: 1fr 1fr; column-gap: 22px; }
}

/* the top bar sits above every card, so cards start below it */
.overlay:not(.splash) { padding-top: calc(60px + env(safe-area-inset-top)); }
.overlay:not(.splash) .card { max-height: calc(100dvh - 76px - env(safe-area-inset-top)); }
@media (max-height: 500px) {
  .overlay:not(.splash) { padding-top: 58px; padding-bottom: 8px; }
  .overlay:not(.splash) .card { max-height: calc(100dvh - 66px); }
}

@media (max-height: 500px) {
  .card.settings { padding: 12px 20px 14px; }
  .card.settings h2 { font-size: 28px; margin-bottom: 4px; }
  .set-row { min-height: 40px; padding: 2px; }
  .set-list { margin-bottom: 10px; }
  .set-actions { margin: 0; }
  .set-actions .done { flex-basis: auto; order: 0; max-width: none; height: 40px; min-width: 110px; font-size: 15px; }
}

/* ---------- a retry skips the card: missions flash up at the top instead ---------- */
.mission-strip { position: absolute; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, -8px); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: max-content; max-width: calc(100% - 32px); pointer-events: none; opacity: 0; z-index: 4; }
.mission-strip.show { animation: strip-in 3.6s ease forwards; }
.mission-strip .ms { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--paper-2); font: 700 12px/1.1 var(--ui); color: var(--ink); box-shadow: 2px 2px 0 rgba(43, 37, 32, 0.14); }
.mission-strip .ms .ico { width: 14px; height: 14px; color: var(--ink-dim); }
@keyframes strip-in { 0% { opacity: 0; transform: translate(-50%, -8px); } 10%, 82% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -4px); } }
.link-btn { display: block; margin: 10px auto 0; padding: 4px 8px; border: 0; background: none; font: 700 13px/1.2 var(--ui); color: var(--ink-dim); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
/* phones held sideways: the top middle is free at the start of a run (the combo and boss bar come later), so the
   reminders go there, between the score and the buttons, instead of over the ink bar */
@media (max-height: 500px) { .mission-strip { top: calc(10px + env(safe-area-inset-top)); bottom: auto; max-width: min(46vw, 460px); } .mission-strip .ms { font-size: 11px; padding: 4px 8px; } }

/* ---------- stats and badges ---------- */
.card.stats-card { width: min(620px, 100%); text-align: left; }
.card.stats-card h2 { text-align: center; margin-bottom: 12px; }
.st-h { margin: 16px 0 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); display: flex; gap: 8px; }
.st-h span { color: var(--ink); }
.st-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.st-tile { display: grid; justify-items: center; gap: 2px; padding: 10px 6px; border: 1.5px solid rgba(43, 37, 32, 0.16); border-radius: 12px; background: #fff; text-align: center; }
.st-tile .ico { width: 18px; height: 18px; color: var(--ink-dim); }
.st-tile b { font-family: var(--hand); font-size: 26px; line-height: 1; }
.st-tile span { font: 700 11px/1.2 var(--ui); color: var(--ink-dim); }
.st-bosses { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.st-boss { display: grid; justify-items: center; gap: 3px; padding: 8px 4px; border: 1.5px dashed rgba(43, 37, 32, 0.25); border-radius: 12px; text-align: center; color: var(--ink-dim); }
.st-boss .ico { width: 20px; height: 20px; }
.st-boss b { font: 800 12px/1.15 var(--ui); color: var(--ink); }
.st-boss span { font: 600 11px/1 var(--ui); }
.st-boss.won { border-style: solid; border-color: #e7a93a; background: rgba(231, 169, 58, 0.12); }
.st-boss.won .ico { color: #c98a1e; }
.st-deaths { display: grid; gap: 6px; }
.st-death { display: grid; grid-template-columns: 150px 1fr 34px; align-items: center; gap: 8px; font: 700 13px/1.2 var(--ui); }
.st-death i { display: block; height: 10px; border-radius: 5px; background: var(--red); opacity: 0.75; }
.st-death b { text-align: right; font-variant-numeric: tabular-nums; }
.st-empty { margin: 0; font: 600 13px/1.4 var(--ui); color: var(--ink-dim); }
.st-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; margin-bottom: 16px; }
.st-badge { display: grid; justify-items: center; gap: 3px; padding: 10px 6px; border: 1.5px solid rgba(43, 37, 32, 0.14); border-radius: 12px; text-align: center; color: var(--ink-dim); background: rgba(43, 37, 32, 0.03); }
.st-badge .ico { width: 22px; height: 22px; }
.st-badge b { font: 800 12px/1.15 var(--ui); }
.st-badge span { font: 600 10.5px/1.25 var(--ui); }
.st-badge.got { color: var(--ink); background: #fff; border-color: #e7a93a; box-shadow: 2px 2px 0 rgba(231, 169, 58, 0.5); }
.st-badge.got .ico { color: #c98a1e; }
.card.stats-card > .cta { display: flex; margin: 0 auto; }
.badge-lock { color: var(--ink-dim); }
@media (max-width: 560px) {
  .st-tiles { grid-template-columns: repeat(2, 1fr); }
  .st-bosses { grid-template-columns: repeat(3, 1fr); }
  .st-death { grid-template-columns: 110px 1fr 30px; font-size: 12px; }
}

/* ---------- highlight clip button, pinned on the replay ---------- */
.clip-btn { position: absolute; right: 8px; top: 7px; display: inline-flex; align-items: center; gap: 6px; max-width: 70%; padding: 6px 10px; overflow: hidden; border: 1.5px solid var(--ink); border-radius: 8px; background: #fbf7ee; font: 800 12px/1 var(--ui); color: var(--ink); cursor: pointer; box-shadow: 2px 2px 0 rgba(43, 37, 32, 0.25); }
.clip-btn[hidden] { display: none; }
.clip-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-btn .ico { width: 14px; height: 14px; flex: none; color: var(--red); }
.clip-btn i { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--red); }
.clip-btn:disabled { opacity: 0.8; cursor: progress; }

/* ---------- a friend's challenge, on the start card ---------- */
.challenge { margin: 0 0 14px; padding: 12px 14px; border: 2px dashed var(--red); border-radius: 12px; background: rgba(196, 67, 47, 0.06); text-align: center; }
.challenge[hidden] { display: none; }
.challenge p { margin: 0 0 10px; font: 700 14px/1.35 var(--ui); }
.challenge .cta { background: var(--red); }

/* ---------- level mode ---------- */
.card.levels-card { width: min(620px, 100%); }
.lv-sub { display: flex; align-items: center; justify-content: center; gap: 6px; margin: -6px 0 12px; font: 800 13px/1 var(--ui); color: var(--ink-dim); }
.lv-sub .ico { width: 16px; height: 16px; color: #e7a93a; fill: #e7a93a; }
.lv-world { margin: 0 0 12px; text-align: left; }
.lv-world h3 { margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.lv-row { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.lv-tile { display: grid; justify-items: center; gap: 4px; padding: 8px 2px 6px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; cursor: pointer; box-shadow: 2px 2px 0 rgba(43, 37, 32, 0.2); }
.lv-tile b { font: 700 22px/1 var(--hand); color: var(--ink); }
.lv-tile.boss { background: rgba(196, 67, 47, 0.08); border-color: var(--red); }
.lv-tile.locked { border-color: rgba(43, 37, 32, 0.2); box-shadow: none; background: rgba(43, 37, 32, 0.04); cursor: default; }
.lv-tile.locked .ico { width: 16px; height: 16px; color: var(--ink-dim); }
.lv-mini { display: flex; gap: 2px; }
.lv-mini i { width: 7px; height: 7px; border-radius: 50%; background: rgba(43, 37, 32, 0.15); }
.lv-mini i.on { background: #e7a93a; }
.card.levels-card > .cta { display: flex; margin: 6px auto 0; }
.lvl-name { margin: -4px 0 10px; font: 700 15px/1.3 var(--ui); color: var(--ink-dim); }
.lv-stars { display: flex; justify-content: center; gap: 10px; margin: 0 0 12px; }
.lv-star .ico { width: 40px; height: 40px; color: rgba(43, 37, 32, 0.2); fill: rgba(43, 37, 32, 0.08); }
.lv-star.on .ico { color: #c98a1e; fill: #f2c94c; }
.lv-star.on { animation: star-pop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes star-pop { from { transform: scale(0.3) rotate(-30deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.lv-goals { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; text-align: left; }
.lv-goals li { display: flex; align-items: center; gap: 8px; font: 700 13px/1.3 var(--ui); color: var(--ink-dim); }
.lv-goals li .ico { width: 16px; height: 16px; flex: none; }
.lv-goals li.ok { color: var(--ink); }
.lv-goals li.ok .ico { color: #2f9a6a; }
@media (max-width: 560px) { .lv-row { grid-template-columns: repeat(5, 1fr); } }
@media (prefers-reduced-motion: reduce) { .lv-star.on { animation: none; } }

.set-select { min-width: 150px; height: 36px; padding: 0 10px; border: 1.5px solid var(--ink-dim); border-radius: 10px; background: var(--paper-2); font: 800 14px/1 var(--ui); color: var(--ink); cursor: pointer; }
/* Japanese: the hand-lettering font has no kana or kanji, so use a soft system face */
html[lang="ja"] { --hand: "Caveat", "Hiragino Maru Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif; }
html[lang="zh"] { --hand: "Caveat", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
html[lang="ko"] { --hand: "Caveat", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }

/* best moment or last seconds, on the replay */
.replay-tabs { position: absolute; left: 8px; top: 7px; display: flex; gap: 3px; padding: 3px; border-radius: 9px; background: rgba(251, 247, 238, 0.9); max-width: 58%; }
.replay-tabs[hidden] { display: none; }
.replay-tabs button { display: inline-flex; align-items: center; gap: 4px; max-width: 150px; padding: 4px 8px; border: 0; border-radius: 6px; background: transparent; font: 800 11px/1 var(--ui); color: var(--ink-dim); cursor: pointer; white-space: nowrap; overflow: hidden; }
.replay-tabs button span { overflow: hidden; text-overflow: ellipsis; }
.replay-tabs button .ico { width: 12px; height: 12px; flex: none; color: #c98a1e; }
.replay-tabs button.on { background: var(--ink); color: var(--paper-2); }
.replay-tag[hidden] { display: none; }

/* short screens (phones sideways): install sits as a small tag in the start card's corner, always in view,
   and the how-to card goes two columns so the steps and Got it fit without scrolling */
@media (max-height: 500px) {
  #ov-start .card .install-btn { position: absolute; top: 10px; left: 12px; margin: 0; padding: 4px 10px 4px 7px; gap: 6px; font-size: 13px; border-width: 1.5px; border-radius: 9px; }
  #ov-start .card .install-btn .inst-long { display: none; }
  #ov-start .card .install-btn .inst-short { display: inline; }
  #ov-start .card .install-btn .ico { width: 17px; height: 17px; }
}
/* short, wide screens (phones on their side): who you are on the left, the ways to play on the right */
@media (max-height: 500px) and (min-width: 600px) {
  #ov-start .card { width: min(780px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 26px; align-items: center; padding: 16px 22px 14px; }
  #ov-start .start-go .sub { margin-top: 8px; font-size: 19px; }
  #ov-start .mode-row { margin: 0 0 10px; }
  #ov-start .card.tight h1 { font-size: 40px; }
  #ov-start .card.tight .tag { margin-bottom: 6px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .card.install-card { width: min(640px, 100%); display: grid; grid-template-columns: 200px 1fr; column-gap: 22px; align-items: center; padding: 16px 22px; }
  .install-card .install-icon { grid-column: 1; grid-row: 1; width: 72px; height: 72px; margin: 0 auto; align-self: end; }
  .install-card h2 { grid-column: 1; grid-row: 2; font-size: 26px; line-height: 1.1; margin: 10px 0 0; align-self: start; }
  .install-card .install-steps { grid-column: 2; grid-row: 1 / 3; margin: 0 0 12px; align-self: end; }
  .install-card .install-steps li { font-size: 14px; }
  .install-card #btn-install-done { grid-column: 2; grid-row: 3; margin-top: 0; }
}

/* ---------- daily leaderboard ---------- */
.card.board-card { width: min(420px, 100%); }
.board-sub { margin: -4px 0 10px; font-size: 13px; font-weight: 700; color: var(--ink-dim); }
.board-form { margin: 0 0 8px; padding: 10px 12px; border: 2px dashed var(--ink); border-radius: 12px; }
.board-yours { margin: 0 0 8px; font-weight: 700; }
.board-yours b { font: 700 26px/1 var(--hand); }
.board-row { display: flex; gap: 8px; }
.board-row input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font: 700 16px var(--ui); color: var(--ink); }
.board-row .cta { height: 44px; padding: 0 14px; white-space: nowrap; }
.board-msg { min-height: 1.2em; margin: 0 0 6px; font-size: 14px; font-weight: 800; }
.board-msg.bad { color: var(--red); }
.board-list { list-style: none; margin: 0 0 12px; padding: 0; text-align: left; max-height: min(46vh, 440px); overflow-y: auto; overscroll-behavior: contain; }
.board-list li { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px dashed rgba(43, 37, 32, 0.2); font-weight: 700; }
.board-list li .rk { font: 700 22px/1 var(--hand); color: var(--ink-dim); text-align: center; }
.board-list li:nth-child(-n+3) .rk { color: var(--red); }
.board-list li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li .sc { font: 700 22px/1 var(--hand); }
.board-list li.me { background: rgba(231, 169, 58, 0.25); border-radius: 8px; }
.board-list .empty { display: block; text-align: center; color: var(--ink-dim); border: 0; }
@media (max-height: 500px) {
  .card.board-card { padding: 14px 18px; }
  .board-card h2 { font-size: 28px; margin-bottom: 4px; }
  .board-list li { padding: 4px 8px; }
  /* the list scrolls inside the card, so Back always stays in view */
  .board-list { max-height: calc(100dvh - 260px); min-height: 90px; margin-bottom: 8px; }
  .board-card #btn-board-back { height: 40px; }
}
/* phones sideways: two columns, so the form and Back stay in view and the list scrolls beside them */
@media (max-height: 500px) and (min-width: 600px) {
  .card.board-card { width: min(780px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; align-items: start; }
  .board-card > h2, .board-card > .board-sub, .board-card > .board-form, .board-card > .board-msg, .board-card > #btn-board-back { grid-column: 1; }
  .board-card > .tape { grid-column: 1 / -1; }
  .board-card > .board-list { grid-column: 2; grid-row: 1 / span 6; max-height: calc(100dvh - 100px); margin: 0; }
  .board-card .board-row { flex-direction: column; }
  .board-card .board-row input, .board-card .board-row .cta { width: 100%; height: 40px; min-height: 40px; flex: none; }
}

/* the way back to the start card (Levels, Stats) from the score card and the run card */
.over-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin: 10px 0 0; }
.over-links .link-btn { margin: 0; }
.ready-menu { display: block; margin: 10px auto 0; }

/* ---------- daily gift ---------- */
.cta.gift-btn { width: 100%; margin: 0 0 12px; height: auto; min-height: 52px; padding: 8px 20px; background: #d9a520; color: #2b2520; animation: gift-pulse 1.6s ease-in-out infinite; }
.cta.gift-btn[hidden] { display: none; }
.cta.gift-btn > span { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.cta.gift-btn small { font-size: 12px; font-weight: 700; opacity: 0.8; }
@keyframes gift-pulse { 50% { transform: scale(1.03); } }
.gift-line { display: flex; align-items: center; justify-content: center; gap: 6px; margin: -2px 0 12px; font-size: 13px; font-weight: 700; color: var(--ink-dim); cursor: pointer; }
.gift-line[hidden] { display: none; }
.gift-line .ico { width: 15px; height: 15px; color: #b8862a; }
.card.gift h2 { margin-bottom: 12px; }
.gift-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 0 0 14px; }
.gd { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border: 1.5px solid var(--ink-faint); border-radius: 9px; background: rgba(255, 255, 255, 0.45); font-size: 11px; }
.gd .gd-day { font-size: 9px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-dim); white-space: nowrap; }
.gd .ico { width: 16px; height: 16px; color: #b8862a; }
.gd b { font-weight: 800; font-size: 12px; }
.gd.done { background: rgba(47, 154, 106, 0.12); border-color: rgba(47, 154, 106, 0.45); }
.gd.done .ico { color: #2f9a6a; }
.gd.now { border-color: #d9a520; background: rgba(242, 201, 76, 0.3); box-shadow: 0 0 0 2px rgba(217, 165, 32, 0.35); }
.gd.d7 .ico { width: 18px; height: 18px; }
.gdl-note { font-size: 11px; font-weight: 700; color: var(--ink-dim); }
.gift-chest { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 4px auto 12px; padding: 0; border: 0; background: none; cursor: pointer; font: 800 16px/1 var(--ui); color: var(--ink); }
.gift-chest[hidden] { display: none; }
.gift-box { width: 92px; height: 92px; display: grid; place-items: center; border: 2.5px solid var(--ink); border-radius: 18px; background: #f2c94c; box-shadow: 4px 5px 0 rgba(43, 37, 32, 0.18); animation: gift-wiggle 2.2s ease-in-out infinite; }
.gift-box .ico { width: 52px; height: 52px; color: var(--ink); }
@keyframes gift-wiggle { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-7deg); } 82% { transform: rotate(6deg); } 88% { transform: rotate(-4deg); } 94% { transform: rotate(2deg); } }
.gift-got { display: grid; justify-items: center; gap: 4px; margin: 0 0 10px; }
.gift-got[hidden] { display: none; }
.gg-coins { display: inline-flex; align-items: center; gap: 6px; font: 700 44px/1 var(--hand); color: #9a6a10; }
.gg-coins .ico { width: 30px; height: 30px; }
.gg-item { font-size: 14px; font-weight: 700; }
.gg-item b { color: var(--pen); }
.card.gift.opened .gift-got { animation: gift-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes gift-pop { from { transform: scale(0.4); opacity: 0; } }
.gift-next { margin: 0 0 4px; font-weight: 800; font-size: 14px; }
.gift-next:empty { display: none; }
.gift-rule { margin: 0 0 14px; font-size: 12px; color: var(--ink-dim); }
.gift-deal { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; margin: 0 0 14px; padding: 9px 10px; border: 1.5px dashed rgba(217, 165, 32, 0.7); border-radius: 10px; background: rgba(242, 201, 76, 0.14); text-align: left; }
.gift-deal[hidden] { display: none; }
.gdl-ico { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #f2c94c; }
.gdl-ico .ico { width: 16px; height: 16px; }
.gdl-t { display: grid; gap: 1px; font-size: 13px; }
.gdl-k { font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.gdl-p { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: #9a6a10; }
.gdl-p s { color: var(--ink-dim); font-weight: 600; }
.gdl-p .ico { width: 12px; height: 12px; }
.cta.small { height: 36px; padding: 0 14px; font-size: 14px; }
.w-item { position: relative; }
.w-price.deal s { margin-right: 3px; color: var(--ink-dim); font-weight: 600; }
.w-ribbon { position: absolute; top: -7px; right: -6px; padding: 2px 6px; border-radius: 6px; background: #d9a520; color: #2b2520; font: 800 9px/1.3 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; transform: rotate(6deg); }
.w-item.on-deal { border-color: #d9a520; }
@media (prefers-reduced-motion: reduce) { .cta.gift-btn, .gift-box { animation: none; } }
.gg-cat { color: var(--ink-dim); font-weight: 600; }

/* ---------- modes: boss rush and master ---------- */
.mode-note { margin: -4px 0 12px; font-size: 13px; line-height: 1.35; color: var(--ink-dim); text-wrap: balance; }
.mode-note .link-btn { display: inline; margin: 0 0 0 4px; padding: 0; font-size: 13px; white-space: nowrap; }
.mode-note[hidden] { display: none; }
.rush-splits { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 6px 0 4px; }
.rush-splits[hidden] { display: none; }
.rs { display: grid; gap: 1px; padding: 4px 2px; border: 1.5px solid var(--ink-faint); border-radius: 8px; font-size: 10px; line-height: 1.15; }
.rs b { font-weight: 800; }
.rs i { font-style: normal; font-weight: 700; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.rs.won { border-color: rgba(47, 154, 106, 0.5); background: rgba(47, 154, 106, 0.1); }
.rs.won i { color: #2f9a6a; }
.rs.lost { border-color: rgba(196, 67, 47, 0.45); }
.rs.lost i { color: var(--red); }

/* ---------- a boss's entrance: its name and title sweep in over a dimmed screen ---------- */
.boss-intro { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(20, 16, 12, 0.08), rgba(20, 16, 12, 0.42)); }
.boss-intro.show { animation: bi-fade 2.3s ease forwards; }
.bi-in { position: relative; display: grid; justify-items: center; gap: 2px; transform: translateY(-12%); }
.bi-sub { font: 800 clamp(11px, 1.6vw, 15px)/1 var(--ui); letter-spacing: 0.28em; text-transform: uppercase; color: #fbf8f0; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); }
.bi-title { font: 700 clamp(46px, 8vw, 96px)/1.05 var(--hand); color: #fbf8f0; text-shadow: 0 3px 14px rgba(0, 0, 0, 0.45); }
.bi-stroke { display: block; width: 110%; height: 10px; margin-top: -4px; border-radius: 6px; background: var(--red); transform-origin: left center; }
.boss-intro.show .bi-title { animation: bi-in 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.boss-intro.show .bi-sub { animation: bi-in 0.55s 0.15s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.boss-intro.show .bi-stroke { animation: bi-stroke 0.45s 0.3s ease-out both; }
@keyframes bi-fade { 0% { opacity: 0; } 12% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bi-in { from { transform: translateX(-40px) scale(0.92); opacity: 0; } }
@keyframes bi-stroke { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .boss-intro.show .bi-title, .boss-intro.show .bi-sub, .boss-intro.show .bi-stroke { animation: none; } }

/* dark worlds (the caves): the score reads light on the cave roof */
body.dim-world #dist, body.dim-world .score-sub { color: #eef4f4; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }

.set-sub { display: block; font-size: 11px; font-weight: 600; color: var(--ink-dim); letter-spacing: 0; text-transform: none; margin-top: 1px; }

/* game over: the one-time offer of Relaxed pace to someone who keeps falling early */
.relax-offer { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; margin: 0 0 12px; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 12px; background: #eef5e6; text-align: left; }
.relax-offer[hidden] { display: none; }
.ro-ico { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #6aa55a; color: #fff; }
.ro-ico .ico { width: 17px; height: 17px; }
.ro-t { display: flex; flex-direction: column; gap: 2px; font: 800 14px/1.2 var(--ui); }
.ro-t small { font: 600 12px/1.3 var(--ui); color: var(--ink-dim); }
.ro-b { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.ro-b .link-btn { margin: 0; }
.ro-b .cta.small { height: 34px; }

/* ---------- Blade mode ---------- */
.blade-hud { display: none; position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); align-items: center; gap: 14px; padding: 6px 14px; border-radius: 14px; background: rgba(251, 247, 238, 0.78); border: 1.5px solid var(--ink-faint); pointer-events: none; }
body.blade-on .blade-hud { display: flex; }
body.blade-on .ink-hud, body.blade-on #coin-pill, body.blade-on #inks { display: none; }
body.at-menu .blade-hud { visibility: hidden; }
.bh-hearts { display: flex; gap: 4px; }
.bh-hearts .ico { width: 24px; height: 24px; fill: none; stroke: var(--red, #c4432f); stroke-width: 2; opacity: 0.4; transition: transform 0.2s; }
.bh-hearts .ico.full { fill: var(--red, #c4432f); opacity: 1; }
.blade-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 2px 0 12px; }
.blade-pick[hidden] { display: none; }
.weapon-chip { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 7px; border: 1.5px solid var(--ink-faint); border-radius: 10px; background: rgba(255, 255, 255, 0.5); font: 800 12px/1.1 var(--ui); color: var(--ink-dim); cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.weapon-chip canvas { width: 64px; height: 36px; }
.weapon-chip:hover { color: var(--ink); }
.weapon-chip.on { background: #fffdf6; color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 3px 0 var(--ink); transform: rotate(-2deg); }
.weapon-chip.on .wc-name { background: linear-gradient(transparent 50%, var(--hi) 50%, var(--hi) 92%, transparent 92%); padding: 0 3px; }
#ov-blade .blade-pick { margin: 10px 0 4px; }
@media (max-width: 420px) { .weapon-chip canvas { width: 52px; height: 29px; } .mode-chip { font-size: 11px; } }

.bh-hearts { display: flex; align-items: center; }
.bh-bar { position: relative; display: block; width: clamp(110px, 22vw, 190px); height: 14px; border: 2px solid var(--ink); border-radius: 8px; background: rgba(43, 37, 32, 0.08); overflow: hidden; }
.bh-bar i { position: absolute; inset: 0; transform-origin: left center; }
.bh-lag { background: var(--hi); transition: transform 0.5s 0.25s ease-out; }
.bh-fill { background: #2f9a6a; transition: transform 0.12s ease-out, background 0.2s; }
.bh-hearts.low .bh-fill { background: var(--red); }

.moves .mv-h { margin: 6px 0 8px; font: 800 12px/1 var(--ui); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim); text-align: left; }
.move-card { grid-template-columns: 116px 1fr; }
.move-card .mv-cv { grid-row: span 2; width: 116px; height: 87px; border-radius: 8px; background: rgba(243, 236, 221, 0.9); border: 1.5px solid var(--ink-faint); }
@media (max-height: 500px) { .move-card { grid-template-columns: 72px 1fr; } .move-card .mv-cv { width: 72px; height: 54px; } }

.bh-ult { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ink); background: linear-gradient(to top, rgba(196, 67, 47, 0.85) calc(var(--p, 0) * 100%), #fffdf6 0); color: var(--ink); pointer-events: auto; cursor: pointer; display: grid; place-items: center; padding: 0; }
.bh-ult .ico { width: 20px; height: 20px; opacity: 0.55; }
.bh-ult.ready { background: var(--red); color: #fff; animation: ultGlow 1.2s ease-in-out infinite; }
.bh-ult.ready .ico { opacity: 1; fill: #fff; }
@keyframes ultGlow { 50% { box-shadow: 0 0 0 5px rgba(196, 67, 47, 0.25); } }

/* the smallest phones in the longest languages: drop the Your best line (it's on the game-over card too) */
#ov-start .card.tightest .sub { display: none; }

/* ---------- cloud save ---------- */
.cloud-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; width: min(380px, 100%); text-align: left; overflow: hidden; }
.cloud-card .board-row input { width: 100%; }
.cloud-card .board-row .cta { flex: none; }
.cloud-card h2 { margin: 0; }
.cloud-sub { margin: 0; color: var(--ink-dim); font-size: 14px; line-height: 1.45; }
.cloud-k { margin: 0 0 4px; font: 800 11px/1 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); }
.cloud-have { padding: 10px 12px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; }
.cloud-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cloud-code { font: 800 24px/1.1 ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.04em; color: var(--ink); white-space: nowrap; }
.cloud-note { margin: 6px 0 0; font-size: 12px; color: var(--ink-dim); }
.cloud-restore { margin: 0; padding: 10px 12px; border: 2px dashed var(--ink); border-radius: 12px; }
.cloud-restore input { text-transform: uppercase; letter-spacing: 0.08em; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.cta.confirm { background: var(--red); border-color: var(--ink); color: #fff; }
#btn-cloud-back { justify-self: center; }
#btn-cloud-copy { white-space: nowrap; flex: none; }

/* the daily gift's "See it": today's item glows for a moment once the Wardrobe has scrolled to it */
.w-item.spot { animation: spot 1.6s ease-out 2; }
@keyframes spot { 0% { box-shadow: 0 0 0 0 rgba(242, 201, 76, 0.95); } 70% { box-shadow: 0 0 0 12px rgba(242, 201, 76, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 201, 76, 0); } }
