/* A manga page. Everything sits in コマ (panels): white, ruled in thick sumi ink, with white
   gutters between them. Grey is never a flat fill but screentone (halftone dots). Motion is drawn
   with speed lines and 集中線 (focus lines); sound is lettered over the art (ピンポーン！ ブッブー
   プシュー). Colour is spot colour only: each 系統's own, the bus's green stripe, the amber LED,
   and one red for emphasis. The bus itself (destination sign, stop poles, the stop button,
   numbered tickets) stays, drawn into the panels. */
:root {
  color-scheme: light;
  --paper: #fffefa;
  --ground: #ece8dc;
  --ink: #111111;
  --ink-soft: #4a4d55;
  --rule: #b9b4a6;
  --accent: #e0312b;
  --signal: #ffcf26;
  --ok: #17693c;
  --ok-soft: #e6f2e8;
  --warn: #9a5c00;

  --bus-green: #23874a;
  --bus-lime: #a9c934;
  --board: #17181d;
  --board-edge: #2c2e36;
  --led: #ffb52e;
  --led-soft: #ffd27a;
  --lamp: #d23f97;

  --line: 3px;
  --gutter-w: 10px;

  --font-body: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  --font-display: "Dela Gothic One", "BIZ UDPGothic", "PingFang TC", sans-serif;
  --font-sfx: "Reggae One", "Dela Gothic One", "PingFang TC", sans-serif;
  --font-led: "DotGothic16", "BIZ UDPGothic", "PingFang TC", monospace;

  /* screentone at three densities, in screen pixels */
  --tone-ink: rgb(17 17 17 / 0.32);
  --tone: radial-gradient(circle, var(--tone-ink) 0 0.95px, transparent 1.35px) 0 0 / 5px 5px,
    radial-gradient(circle, var(--tone-ink) 0 0.95px, transparent 1.35px) 2.5px 2.5px / 5px 5px;
  --tone-light: radial-gradient(circle, rgb(17 17 17 / 0.18) 0 0.8px, transparent 1.15px) 0 0 / 4px 4px;
  --tone-dark: radial-gradient(circle, var(--ink) 0 1.45px, transparent 1.9px) 0 0 / 5px 5px,
    radial-gradient(circle, var(--ink) 0 1.45px, transparent 1.9px) 2.5px 2.5px / 5px 5px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--tone-light), var(--ground);
  color: var(--ink);
  font: 400 1rem/1.65 var(--font-body);
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-underline-offset: 0.18em; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 6px var(--signal); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the page and its panels ---------- */
.page {
  max-width: 1440px; margin: 0 auto; padding: var(--gutter-w);
  display: flex; flex-direction: column; gap: var(--gutter-w); min-height: 100dvh;
}
.koma {
  position: relative;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  box-shadow: 0 0 0 var(--gutter-w) var(--paper) inset, 0 0 0 calc(var(--gutter-w) + var(--line)) transparent inset;
}
.koma { box-shadow: none; }

/* ---------- title panel: the bus speeding in ---------- */
.koma-title {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 18px;
  padding: 10px 18px 10px 0; overflow: hidden;
}
.title-art {
  position: relative; align-self: stretch; display: grid; place-items: center;
  padding: 8px 34px 8px 20px;
  /* a slanted inner panel with speed lines behind the bus */
  background: repeating-linear-gradient(0deg, transparent 0 7px, rgb(17 17 17 / 0.85) 7px 8px, transparent 8px 13px, rgb(17 17 17 / 0.45) 13px 13.6px), var(--paper);
  clip-path: polygon(0 0, 100% 0, calc(100% - 26px) 100%, 0 100%);
  border-right: 0;
}
.title-art::after { /* the diagonal panel rule */
  content: ""; position: absolute; top: 0; bottom: 0; right: 12px; width: var(--line);
  background: var(--ink); transform: skewX(-13deg); transform-origin: top;
}
.bus-art { width: 172px; height: auto; position: relative; z-index: 1; background: transparent; }
.art-sfx {
  position: absolute; right: 30px; top: 2px; z-index: 2;
  font: 400 1.2rem/1 var(--font-sfx); color: var(--paper);
  -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
  transform: rotate(-9deg);
}
.title-text { min-width: 0; padding: 6px 0; }
.kicker {
  display: inline-block; margin: 0 0 4px; padding: 1px 10px;
  background: var(--ink); color: var(--paper);
  font: 700 0.72rem/1.6 var(--font-body); letter-spacing: 0.18em;
}
.koma-title h1 {
  margin: 0; font: 400 clamp(1.35rem, 3.2vw, 2.3rem)/1.2 var(--font-display); letter-spacing: 0.01em;
  text-shadow: 3px 3px 0 var(--signal);
}
.tagline { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.92rem; }
.corner { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; align-self: start; padding-top: 4px; }
.langs { display: flex; gap: 4px; }
/* お知らせ: a small inked tab, with a red NEW stamp until the newest entry is seen */
.news {
  position: relative; padding: 1px 10px; border: 2px solid var(--ink); background: var(--tone-light), var(--paper);
  font-size: 0.82rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.news:hover { background: var(--signal); }
/* ← ゲームに戻る: on every page but the game, at the top where the eye starts */
.back {
  padding: 3px 12px; border: var(--line) solid var(--ink); background: var(--ink); color: var(--paper);
  font-size: 0.88rem; font-weight: 700; text-decoration: none; white-space: nowrap; box-shadow: 3px 3px 0 var(--accent);
  transition: transform 0.08s, box-shadow 0.08s;
}
.back:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--accent); }
.back:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--accent); }
.news-new {
  display: inline-block; margin-left: 6px; padding: 0 5px; background: var(--accent); color: var(--paper);
  font: 400 0.68rem/1.45 var(--font-display); letter-spacing: 0.04em; transform: rotate(-6deg);
}
.news .news-new { animation: blink-new 2.4s ease-in-out infinite; }
@keyframes blink-new { 0%, 70%, 100% { transform: rotate(-6deg) scale(1); } 80% { transform: rotate(-10deg) scale(1.18); } }
.langs a {
  white-space: nowrap; padding: 2px 10px; border: 2px solid var(--ink); text-decoration: none;
  font-size: 0.85rem; font-weight: 700; background: var(--paper);
}
.langs a[aria-current="true"] { background: var(--ink); color: var(--paper); }

/* ---------- the spread: map panel and play panel ---------- */
.spread {
  flex: 1; display: grid; gap: var(--gutter-w);
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  min-height: 560px;
}
.koma-map { min-height: 340px; overflow: hidden; background: var(--tone), #eae5d6; --tone-ink: rgb(17 17 17 / 0.16); }
.map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.koma-play { padding: 16px 18px 22px; overflow: auto; }
.sheet { flex: 1; display: flex; flex-direction: column; gap: var(--gutter-w); }

/* ナレーション: the rectangular caption box of a manga */
.narration {
  margin: 12px 0; padding: 6px 12px;
  background: var(--paper); border: 2px solid var(--ink);
  font-size: 0.9rem; font-weight: 700;
}
.narration.off { border-style: dashed; color: var(--ink-soft); font-weight: 400; }
.caption { position: absolute; top: 10px; left: 10px; margin: 0; max-width: calc(100% - 20px); z-index: 2; box-shadow: 4px 4px 0 var(--ink); }

/* 吹き出し: the speech bubble */
.bubble {
  position: relative; margin: 10px 4px 24px; padding: 12px 18px;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 26px;
  font-weight: 700; line-height: 1.55;
}
.bubble::before, .bubble::after {
  content: ""; position: absolute; left: 34px; width: 0; height: 0; border-style: solid;
}
.bubble::before { bottom: -19px; border-width: 19px 6px 0 14px; border-color: var(--ink) transparent transparent transparent; }
.bubble::after { bottom: -13px; left: 37px; border-width: 14px 3px 0 9px; border-color: var(--paper) transparent transparent transparent; }
.prompt { margin-top: 16px; }

/* ---------- map ---------- */
.net-casing { fill: none; stroke: #8f8a7d; stroke-width: 4.2; stroke-linejoin: round; stroke-linecap: round; }
.net { fill: none; stroke: #fffefa; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.glow { fill: none; stroke-width: 22; stroke-linejoin: round; stroke-linecap: round; opacity: 0.9; }
.line { fill: none; stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.line.casing { stroke: var(--ink); stroke-width: 9; }
.line.other { stroke-width: 3.5; stroke-dasharray: 6 5; opacity: 0.85; }
.stop { fill: var(--paper); stroke: var(--ink); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.pole-foot { fill: rgb(17 17 17 / 0.35); }
.pole-post { stroke: var(--ink); stroke-linecap: round; }
.pole .pole-sign { fill: var(--paper); stroke: var(--ink); }
.pole.hidden .pole-sign { fill: var(--signal); }
.pole.got .pole-sign { fill: var(--ok); stroke: var(--paper); }
.pole.shown .pole-sign { fill: var(--paper); stroke: var(--bus-green); }
.qmark { font-family: var(--font-display); fill: var(--ink); pointer-events: none; }
.lbl { font-family: var(--font-body); font-weight: 700; fill: var(--ink); stroke: var(--paper); paint-order: stroke; stroke-linejoin: round; }
.lbl.got { fill: var(--ok); }

/* ---------- chapters (tabs) ---------- */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.tabs button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 6px 8px 8px; border: var(--line) solid var(--ink); background: var(--paper); color: var(--ink);
  font: 700 0.9rem/1.25 var(--font-body); text-align: left; cursor: pointer;
}
.tabs button small { padding: 0 6px; background: var(--ink); color: var(--paper); font-size: 0.66rem; letter-spacing: 0.08em; }
.tabs button:hover { background: var(--tone-light), var(--paper); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); box-shadow: 4px 4px 0 var(--accent); }
.tabs button[aria-selected="true"] small { background: var(--signal); color: var(--ink); }

/* ---------- small text ---------- */
.best, .note, .meta, .progress, .left, .daily-no { color: var(--ink-soft); font-size: 0.88rem; }
.progress { margin: 10px 0 8px; font: 400 0.95rem/1 var(--font-display); color: var(--ink); }
.start-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }

/* ---------- buttons: inked, with a hard offset shadow ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 18px; border: var(--line) solid var(--ink); border-radius: 0;
  background: var(--paper); color: var(--ink); font: 700 1rem/1.2 var(--font-body);
  text-decoration: none; cursor: pointer; box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--ink); color: var(--paper); box-shadow: 4px 4px 0 var(--accent); }
.btn.primary:hover { box-shadow: 5px 5px 0 var(--accent); }
.btn.big { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; padding: 10px 34px; }
.btn.ghost { box-shadow: 3px 3px 0 var(--rule); border-color: var(--ink-soft); font-weight: 400; }
.view > .btn { margin-top: 12px; }
.view > .btn + .btn { margin-left: 8px; }

/* 系統 badge: the coloured route plate */
.badge {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 2px 10px; border-radius: 5px;
  background: var(--c, var(--ink)); color: var(--t, var(--paper));
  font: 700 1rem/1.4 var(--font-body); white-space: nowrap;
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.25);
}
.badge small { font-size: 0.72em; opacity: 0.85; }
.badge.big { font-size: 1.9rem; line-height: 1.2; padding: 6px 14px; border-radius: 8px; height: 100%; align-items: center; }
.badge.big small { font-size: 0.42em; }
.badge.blank { background: var(--board-edge); color: var(--led); font-family: var(--font-led); text-shadow: 0 0 8px rgb(255 168 28 / 0.7); }

/* ---------- 方向幕: the destination sign, inked into its own panel ---------- */
.q-head { position: relative; margin: 4px 8px 8px 0; }
.q-head::before { content: ""; position: absolute; inset: 8px -8px -8px 8px; background: var(--tone-dark); }
.dest {
  position: relative; display: flex; align-items: stretch; gap: 6px;
  padding: 6px; background: var(--board); border: var(--line) solid var(--ink);
}
.dest-plate { display: flex; flex-shrink: 0; }
.dest-plate.flip { animation: flip 0.45s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes flip { from { transform: rotateX(90deg); } to { transform: none; } }
.led {
  position: relative; flex: 1; min-width: 0; min-height: 58px; overflow: hidden;
  display: flex; align-items: center; padding: 6px 12px; background: #0b0c0e;
}
.led::after { /* the dot matrix: light shows only through a lattice of holes */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle, transparent 0 1.1px, rgb(11 12 14 / 0.92) 1.5px) 0 0 / 3px 3px;
}
.led-text {
  display: inline-block; white-space: nowrap;
  font: 400 1.6rem/1.25 var(--font-led); color: var(--led);
  text-shadow: 0 0 1px #ffd27a, 0 0 6px rgb(255 168 28 / 0.9), 0 0 16px rgb(255 140 0 / 0.4);
}
.led-text.roll { animation: roll 8s linear infinite alternate; }
@keyframes roll { 0%, 18% { transform: none; } 82%, 100% { transform: translateX(var(--roll)); } }
.led .ends-line { display: block; margin: 0; font: inherit; }
.led .ends-line .arrow { margin: 0 0.35em; color: var(--led-soft); }
.led .ends-line .loop { margin-left: 0.4em; padding: 0 0.4em; border: 1px solid var(--led); font-size: 0.75em; }
.led .via { display: block; font-size: 0.68em; color: var(--led-soft); }
.led-unknown { letter-spacing: 0.08em; }

/* ---------- バス停: answer slots as bus-stop poles ---------- */
.slots { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0; margin: 0 0 12px; }
.slots:has(> :only-child) { grid-template-columns: 1fr; }
.slot { display: flex; flex-direction: column; align-items: center; }
.slot .pole-sign {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); border: 4px solid var(--bus-green); outline: 2px solid var(--ink);
  color: var(--bus-green); font: 700 0.62rem/1 var(--font-body); letter-spacing: 0.04em;
  position: relative; z-index: 1; margin-bottom: -4px;
}
.slot .pole-board {
  width: 100%; min-height: 48px; padding: 6px 8px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--paper); border: var(--line) solid var(--ink);
  font-weight: 700; color: var(--ink-soft); line-height: 1.3; overflow-wrap: anywhere;
  box-shadow: 4px 4px 0 0 rgb(17 17 17 / 0.85);
}
.slot .pole-post { width: 8px; height: 18px; background: var(--tone-dark), #c9c9c9; border: 2px solid var(--ink); border-top: 0; }
.slot.got .pole-sign { background: var(--bus-green); color: var(--paper); }
.slot.got .pole-board { color: var(--ok); background: var(--ok-soft); animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: scale(0.9) rotate(-2deg); } to { transform: none; } }

/* ---------- the answer row and the stop button ---------- */
.answer-row { display: flex; gap: 10px; align-items: stretch; }
.answer-row input {
  flex: 1; min-width: 0; min-height: 54px; padding: 8px 12px; border: var(--line) solid var(--ink); border-radius: 0;
  font: 400 1rem/1.3 var(--font-body); background: #fff; color: var(--ink);
}
.stop-btn {
  flex-shrink: 0; min-width: 98px; padding: 5px 10px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: var(--line) solid var(--ink); border-radius: 18px;
  background: radial-gradient(circle at 50% 30%, #fff3b0, var(--signal) 70%);
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink); font: 700 1rem/1.1 var(--font-body); cursor: pointer;
}
.stop-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.lamp { padding: 1px 8px; border-radius: 999px; border: 1.5px solid var(--ink); background: #5c3a52; color: #d1b3c6; font-size: 0.66rem; letter-spacing: 0.06em; white-space: nowrap; }
.lamp.lit { animation: lamp 1.6s ease-out; }
@keyframes lamp {
  0%, 70% { background: var(--lamp); color: #fff; box-shadow: 0 0 12px var(--lamp); }
  100% { background: #5c3a52; color: #d1b3c6; box-shadow: none; }
}

/* ---------- 整理券: misses left ---------- */
.left-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; }
.tickets { display: flex; gap: 4px; }
.ticket {
  width: 30px; height: 40px; padding-top: 3px; display: flex; flex-direction: column; align-items: center;
  background: var(--tone-light), #fffbe8; border: 2px solid var(--ink); border-radius: 2px 2px 6px 6px;
  font-size: 0.7rem; line-height: 1.1; transition: transform 0.3s, opacity 0.3s;
}
.ticket small { font-size: 0.45rem; color: var(--ink-soft); white-space: nowrap; }
.ticket b { font-size: 1rem; margin-top: 2px; }
.ticket.used { opacity: 0.2; transform: translateY(5px) rotate(-12deg); }
.left { margin: 0; }

.log { list-style: none; padding: 0; margin: 6px 0 14px; font-size: 0.92rem; }
.log li { padding: 5px 0 5px 10px; border-bottom: 2px dotted var(--rule); border-left: 4px solid transparent; }
.g-end { color: var(--ok); font-weight: 700; border-left-color: var(--ok) !important; }
.g-on-route { color: var(--warn); border-left-color: var(--signal) !important; }
.g-elsewhere, .g-miss { color: var(--accent); border-left-color: var(--accent) !important; }
.g-again { color: var(--ink-soft); }

.alt { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.9rem; }
.points { display: inline-block; margin: 16px 0 4px; font: 400 2rem/1 var(--font-sfx); -webkit-text-stroke: 1px var(--ink); transform: rotate(-4deg); }
.p2 { color: var(--ok); }
.p1 { color: var(--warn); }
.p0 { color: var(--accent); }

/* ---------- 終点→系統 options ---------- */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 6px 6px 16px 0; }
.option {
  min-height: 62px; border: var(--line) solid var(--ink); background: var(--paper);
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 6px;
  box-shadow: 5px 5px 0 0 rgb(17 17 17 / 0.9);
}
.option:hover:not(:disabled) { background: var(--tone-light), #fff6d6; transform: translate(-1px, -1px); }
.option .badge { font-size: 1.2rem; }
.option.right { background: var(--ok-soft); box-shadow: 5px 5px 0 var(--ok); outline: 3px solid var(--ok); }
.option.wrong { background: var(--tone-light), #fbe1df; box-shadow: 5px 5px 0 var(--accent); outline: 3px solid var(--accent); }
.option:disabled { cursor: default; }
.ok, .ng { font: 400 1.15rem/1.3 var(--font-display); margin: 0 0 10px; }
.ok { color: var(--ok); }
.ng { color: var(--accent); }

/* ---------- results: 集中線 around the score ---------- */
.result-head {
  display: inline-block; margin: 4px 0 4px; padding: 2px 14px;
  background: var(--ink); color: var(--paper); font: 400 1.05rem/1.4 var(--font-display);
  transform: rotate(-2deg);
}
.burst {
  position: relative; display: grid; place-items: center; padding: 34px 8px; margin: 4px 0 8px;
  border: var(--line) solid var(--ink); overflow: hidden;
  background: var(--paper);
}
.burst::before {
  content: ""; position: absolute; inset: -40%;
  background: repeating-conic-gradient(from 0deg, var(--ink) 0deg 0.9deg, transparent 0.9deg 5.2deg);
  -webkit-mask-image: radial-gradient(circle, transparent 0 26%, #000 58%);
  mask-image: radial-gradient(circle, transparent 0 26%, #000 58%);
}
.result .score {
  position: relative; margin: 0; padding: 6px 18px;
  background: var(--paper); border: var(--line) solid var(--ink);
  font: 400 clamp(1.8rem, 5vw, 2.4rem)/1.2 var(--font-display);
  box-shadow: 5px 5px 0 var(--accent);
}
/* the round as inked boxes: filled right, toned one end, slashed wrong */
.marks { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.mark { width: 22px; height: 22px; border: 3px solid var(--ink); background: var(--paper); }
.mark.full { background: var(--ink); }
.mark.half { background: var(--tone-dark), var(--paper); }
.mark.none { background: linear-gradient(135deg, transparent 0 calc(50% - 2px), var(--accent) calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px)), var(--paper); }
.new-best { color: var(--accent); font: 400 1.1rem/1.4 var(--font-display); }
.recap { list-style: none; padding: 0; margin: 12px 0; font-size: 0.92rem; }
.recap li { padding: 6px 0; border-bottom: 2px dotted var(--rule); }
.recap .pts { font-weight: 700; }
.sys-note { display: block; margin-left: 2px; color: var(--ink-soft); font-size: 0.8rem; }
.share { margin: 18px 0; padding: 12px 14px 14px; border: var(--line) solid var(--ink); background: var(--tone-light), var(--paper); }
.share-lead { display: inline-block; margin: -26px 0 10px -4px; padding: 2px 12px; background: var(--ink); color: var(--paper); font: 400 0.95rem/1.4 var(--font-display); }
.share-row { display: flex; gap: 10px; flex-wrap: wrap; }
.share-row .btn { min-height: 42px; padding: 6px 14px; font-size: 0.92rem; }
.share .status { display: block; margin-top: 8px; color: var(--ok); font-size: 0.88rem; overflow-wrap: anywhere; }
.share .status:empty { display: none; }

/* 称号: the player's title, stamped */
.rank-title { margin: 10px 0; }
.rank-title b {
  display: inline-block; margin-right: 8px; padding: 2px 12px; transform: rotate(-2deg);
  background: var(--accent); color: var(--paper); font: 400 1.15rem/1.4 var(--font-display);
  box-shadow: 3px 3px 0 var(--ink);
}
.rank-title span { font-size: 0.9rem; color: var(--ink-soft); }
.versus { border-width: 3px; font-size: 1rem; background: var(--signal); }

/* 果たし状: a friend's challenge, as a folded letter */
.challenge {
  position: relative; margin: 6px 0 14px; padding: 10px 16px 12px;
  border: var(--line) solid var(--ink); background: repeating-linear-gradient(90deg, transparent 0 46px, rgb(17 17 17 / 0.07) 46px 47px), #fffaf0;
  box-shadow: 5px 5px 0 var(--accent);
}
.challenge p { margin: 0; font-weight: 700; }
.challenge-head { display: inline-block; margin: 0 0 4px !important; padding: 0 10px; background: var(--ink); color: var(--paper); font: 400 1rem/1.5 var(--font-display) !important; }

/* ---------- 擬音: sound effects lettered over the page ---------- */
.sfx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.sfx {
  position: absolute; white-space: nowrap;
  font: 400 2.3rem/1 var(--font-sfx); color: var(--paper);
  -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill;
  transform: rotate(var(--tilt)) scale(1);
  animation: sfx 1.2s cubic-bezier(0.2, 1.5, 0.4, 1) forwards;
}
.sfx-good { color: var(--signal); }
.sfx-bad { color: #7cc4ff; }
.sfx-near { color: #ff9f1c; font-size: 1.9rem; }
.sfx-door { color: var(--paper); font-size: 2rem; }
.sfx-boom { color: var(--accent); font-size: 3.1rem; }
@keyframes sfx {
  0% { opacity: 0; transform: rotate(var(--tilt)) scale(0.4); }
  18% { opacity: 1; transform: rotate(var(--tilt)) scale(1.12); }
  30% { transform: rotate(var(--tilt)) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--tilt)) translateY(-18px) scale(1); }
}

/* ---------- footer panel ---------- */
.koma-foot { padding: 10px 16px 12px; background: var(--tone-light), var(--paper); }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 10px; margin-bottom: 6px; }
.foot-links a {
  padding: 3px 12px; border: 2px solid var(--ink); background: var(--paper);
  font-weight: 700; font-size: 0.88rem; text-decoration: none;
}
.foot-links a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.foot-links a.sister { border-color: var(--bus-green); }
.credit { margin: 4px 0 0; color: var(--ink-soft); font-size: 0.78rem; }

/* ---------- stats page ---------- */
.sheet > .view > .bubble { max-width: 760px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: var(--gutter-w); }
.stat-koma { padding: 0 16px 16px; }
.stat-koma.wide { grid-column: 1 / -1; }
.koma-label {
  display: inline-block; margin: -3px 0 10px -19px; padding: 4px 14px;
  background: var(--ink); color: var(--paper); font: 400 1rem/1.4 var(--font-display);
}
.stat-koma h3 { margin: 12px 0 6px; font-size: 0.92rem; }
.big-number { margin: 0; font: 400 2rem/1.2 var(--font-display); }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: 0 0 2px; border-bottom: var(--line) solid var(--ink); }
.hist-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 2px; }
.hist-bar { width: 100%; height: var(--h); min-height: 2px; background: var(--tone-dark), var(--paper); border: 2px solid var(--ink); border-bottom: 0; }
.hist-col small { font-size: 0.68rem; color: var(--ink-soft); }
.rank { margin: 0; padding-left: 1.6em; font-size: 0.9rem; }
.rank li { padding: 4px 0; border-bottom: 2px dotted var(--rule); }
.rank-ends { margin: 0 6px; }
.rank-n { color: var(--ink-soft); font-size: 0.82rem; white-space: nowrap; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px 24px; }
.empty { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- contact page ---------- */
.koma-form { padding: 18px 22px 24px; }
.koma-form .view { max-width: 720px; }
.feedback { display: flex; flex-direction: column; gap: 6px; }
.feedback label { font-weight: 700; margin-top: 10px; }
.feedback textarea, .feedback input[type="email"] {
  width: 100%; padding: 10px 12px; border: var(--line) solid var(--ink); border-radius: 0;
  font: 400 1rem/1.5 var(--font-body); background: #fff; color: var(--ink);
}
.kinds { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.kinds legend { font-weight: 700; margin-bottom: 6px; }
.kind { display: inline-flex; margin: 0 !important; }
.kind input { position: absolute; opacity: 0; }
.kind span { padding: 6px 14px; border: 2px solid var(--ink); background: var(--paper); cursor: pointer; font-weight: 700; }
.kind input:checked + span { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--accent); }
.kind input:focus-visible + span { outline: 3px solid var(--ink); box-shadow: 0 0 0 6px var(--signal); }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.privacy { color: var(--ink-soft); font-size: 0.82rem; margin: 10px 0; }
.feedback .btn { align-self: flex-start; }
.form-status:empty { display: none; }
.form-status.ok { border-color: var(--ok); color: var(--ok); }

/* ---------- manga motion: lettering, stamps and slams ---------- */
/* Title panel: the bus drives in on its speed lines, the sound pops, the title is stamped.
   Only on the first page of a visit (src/boot.js sets .intro); later pages arrive still. */
.intro .bus-art { animation: drive-in 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.15) both; }
.intro .title-art .speed { animation: speed 0.7s ease-out both; }
.intro .art-sfx { animation: art-pop 0.5s 0.55s cubic-bezier(0.3, 1.8, 0.5, 1) both; }
.intro .koma-title h1 { animation: stamp 0.45s 0.15s cubic-bezier(0.25, 1.6, 0.5, 1) both; }
.intro .kicker { animation: slide-in 0.35s ease-out both; }

/* Moving between pages: a quick cross-fade where the browser can, instead of a blank frame.
   The panels are not pinned by name: their heights differ between pages, and a pinned panel
   would be stretched on the way. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.16s; }
@keyframes drive-in { from { transform: translateX(-120%) skewX(-8deg); } 70% { transform: translateX(4%) skewX(3deg); } to { transform: none; } }
@keyframes speed { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes art-pop { from { opacity: 0; transform: rotate(-9deg) scale(0.2); } to { opacity: 1; transform: rotate(-9deg) scale(1); } }
@keyframes stamp { from { opacity: 0; transform: scale(1.7) rotate(-4deg); } 60% { opacity: 1; } to { transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

/* 吹き出し: the balloon pops from its tail, then the line is lettered in character by character. */
.bubble { animation: balloon 0.32s cubic-bezier(0.3, 1.5, 0.5, 1) both; transform-origin: 40px 100%; }
@keyframes balloon { from { opacity: 0; transform: scale(0.6) rotate(-2deg); } to { opacity: 1; transform: none; } }
.bubble.typing { cursor: pointer; }
.bubble.typing .ch { opacity: 0; animation: ink-in 0.12s var(--d) ease-out forwards; }
.bubble.typed .ch { opacity: 1; animation: none; }
@keyframes ink-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ナレーション boxes slide in from the panel edge. */
.view .narration { animation: slide-in 0.3s ease-out both; }

/* 擬音: focus lines burst behind the letters; a wrong answer shakes, a combo slams. */
.sfx-text { position: relative; display: inline-block; }
.sfx::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 9em; height: 9em; margin: -4.5em 0 0 -4.5em; z-index: -1;
  background: repeating-conic-gradient(from 3deg, var(--ink) 0deg 1.4deg, transparent 1.4deg 9deg);
  -webkit-mask-image: radial-gradient(circle, transparent 0 24%, #000 30%, transparent 62%);
  mask-image: radial-gradient(circle, transparent 0 24%, #000 30%, transparent 62%);
  opacity: 0; animation: lines 0.6s ease-out forwards;
}
.sfx-door::before, .sfx-near::before { display: none; }
@keyframes lines { 0% { opacity: 0; transform: scale(0.4); } 25% { opacity: 0.85; } 100% { opacity: 0; transform: scale(1.25); } }
.sfx-bad .sfx-text { animation: shake 0.42s 0.1s linear; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px) rotate(-3deg); } 40% { transform: translateX(6px) rotate(3deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.sfx-combo { color: var(--signal); font-size: 1.6rem; -webkit-text-stroke-width: 6px; animation-duration: 1.4s; }
.sfx-combo .sfx-text { padding: 2px 10px; background: var(--accent); -webkit-text-stroke: 0; color: var(--paper); box-shadow: 4px 4px 0 var(--ink); }
.sfx-combo::before { display: none; }

/* 結果発表: the label slams down, the focus lines rush in, the score is stamped and tallies up. */
.result .result-head { animation: slam 0.35s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.result .burst::before { animation: rush 0.6s ease-out both; }
.result .score { animation: stamp 0.45s 0.2s cubic-bezier(0.25, 1.6, 0.5, 1) both; }
.result .score.counting { color: var(--accent); }
.result .rank-title b { animation: hanko 0.4s 0.75s cubic-bezier(0.3, 1.7, 0.5, 1) both; }
.result .new-best { animation: stamp 0.4s 0.9s cubic-bezier(0.25, 1.6, 0.5, 1) both; }
.result .mark { animation: pop 0.25s calc(0.35s + var(--i, 0) * 40ms) both; }
@keyframes slam { from { opacity: 0; transform: translateY(-30px) rotate(-8deg) scale(1.3); } to { opacity: 1; transform: rotate(-2deg); } }
@keyframes rush { from { opacity: 0; transform: scale(1.6) rotate(-10deg); } to { opacity: 1; transform: none; } }
@keyframes hanko { from { opacity: 0; transform: rotate(-14deg) scale(2.2); } to { opacity: 1; transform: rotate(-2deg); } }

/* ---------- about page ---------- */
.koma-info { padding: 18px 22px 24px; }
.koma-info .view { max-width: 980px; }
.info-koma { padding: 0 18px 14px; margin: 18px 0 0; }
.info-koma .koma-label { margin-left: -21px; }
.part-n { margin-right: 10px; padding-right: 10px; border-right: 2px solid var(--paper); font-size: 0.85rem; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 var(--gutter-w); }
.info-koma p { margin: 8px 0; }
.links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.operator { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 10px 0; font-size: 0.92rem; }
.operator dt { font-weight: 700; }
.operator dd { margin: 0; }
.updates { background: var(--tone-light), var(--paper); }
.update-list { list-style: none; margin: 0; padding: 0; }
.update { padding: 10px 0 12px; border-bottom: 2px dotted var(--rule); }
.update:last-child { border-bottom: 0; }
.update h3 { margin: 2px 0 4px; font-size: 1rem; }
.update p { margin: 0; font-size: 0.92rem; }
.update-date { color: var(--ink-soft); font: 400 0.85rem/1.4 var(--font-display) !important; }
.update:target { background: #fff6d6; outline: 3px solid var(--signal); outline-offset: 4px; }

/* ---------- wishlist page ---------- */
.wish-top { margin: 4px 0 0; }
.wish-status { display: inline-block; }
.wish-list { list-style: none; margin: 0; padding: 0; }
.wish-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 14px; align-items: center;
  padding: 12px 0; border-bottom: 2px dotted var(--rule);
}
.wish-item:last-child { border-bottom: 0; }
.wish-rank { width: 34px; height: 34px; display: grid; place-items: center; border: var(--line) solid var(--ink); font: 400 1.05rem/1 var(--font-display); }
.wish-item.top .wish-rank { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--accent); }
.wish-name { margin: 0; font-size: 1rem; }
.wish-note { margin: 2px 0 0 !important; color: var(--ink-soft); font-size: 0.86rem; }
.wish-act { display: flex; align-items: baseline; gap: 4px; }
.wish-count { min-width: 2ch; text-align: right; font: 400 1.5rem/1 var(--font-display); }
.wish-count.bump { animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); color: var(--accent); }
.wish-act small { margin-right: 8px; color: var(--ink-soft); font-size: 0.78rem; }
.wish-vote { min-height: 40px; padding: 6px 14px; font-size: 0.92rem; }
.wish-vote[aria-pressed="true"] { background: var(--ink); color: var(--paper); box-shadow: 4px 4px 0 var(--accent); }
.wish-vote:disabled { opacity: 0.5; cursor: default; }
.wish-error { grid-column: 2 / -1; margin: 0; color: var(--accent); font-size: 0.86rem; }
.wish-nudge { margin: 4px 0 14px; font-weight: 700; }
.wish-nudge a { text-decoration-thickness: 2px; }
@media (max-width: 560px) {
  .wish-item { grid-template-columns: auto minmax(0, 1fr); }
  .wish-act { grid-column: 2; }
}

/* ---------- phones ---------- */
@media (max-width: 860px) {
  .spread { grid-template-columns: 1fr; min-height: 0; }
  .koma-map { height: 42vh; min-height: 250px; }
  .koma-title { grid-template-columns: auto minmax(0, 1fr); padding-right: 12px; }
  .corner { grid-column: 1 / -1; justify-self: stretch; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; padding: 0 0 6px; order: -1; }
  .corner .back { margin-right: auto; }
  .bus-art { width: 104px; }
  .title-art { padding: 6px 26px 6px 10px; }
  .art-sfx { font-size: 0.9rem; right: 20px; }
}
@media (max-width: 480px) {
  :root { --gutter-w: 7px; }
  .koma-play { padding: 12px 12px 18px; }
  .tabs button { font-size: 0.8rem; padding: 5px 6px 7px; }
  .badge.big { font-size: 1.55rem; }
  .led-text { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .led-text.roll { animation: none; white-space: normal; }
  .dest-plate.flip, .slot.got .pole-board, .lamp.lit { animation: none; }
  .lamp.lit { background: var(--lamp); color: #fff; }
  .sfx { animation: none; }
  .intro .bus-art, .intro .title-art .speed, .intro .art-sfx, .intro .koma-title h1, .intro .kicker, .bubble, .bubble.typing .ch, .view .narration,
  .sfx::before, .sfx-bad .sfx-text, .result .result-head, .result .burst::before, .result .score, .result .rank-title b,
  .result .new-best, .result .mark, .wish-count.bump, .news .news-new { animation: none; }
  .bubble.typing .ch { opacity: 1; }
  .sfx::before { display: none; }
  .btn, .option, .back { transition: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
