/* momonaku — Tokyo Lines
 * Visual language: railway wayfinding. Off-white ground, charcoal text,
 * thick route strokes, station dots, rectangular information panels.
 * No operator logos, no official map artwork, no signage reproduction.
 *
 * Route colors are injected inline from the registry in lines.js and are
 * never redefined here. Nothing in this file may tint, lighten or darken a
 * route color — states use opacity, outline, border, surround, scale, shadow.
 */

:root {
  --ground:        #FAF9F6;
  --panel:         #FFFFFF;
  --ink:           #1C1C1E;
  --ink-2:         #5A5A5F;
  --ink-3:         #68686D;   /* AA on the patterned ground: 4.5:1 at 4.51 */
  --infra:         #DCDCD6;   /* subtle gray infrastructure lines */
  --infra-2:       #EDEDE8;
  --miss:          #B0B0AE;   /* neutral gray for a missed branch */
  --focus:         #1C1C1E;

  --r-panel: 14px;
  --r-pill:  999px;

  --gap:   14px;
  --pad:   18px;
  --shell: 560px;

  --t-fast: 140ms;
  --t-mid:  260ms;
  --ease:   cubic-bezier(.2, .7, .3, 1);

  color-scheme: light;
}

* { box-sizing: border-box; }

/* Several blocks below set an explicit `display`, which would otherwise beat
   the UA's [hidden] rule. Screen switching relies on this. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  /* Abstract route-network texture: original artwork, tiled seamlessly, kept
     a whisper above the ground color so it never competes with content.
     Panels sit on top in solid white, so text contrast is untouched. */
  background-color: var(--ground);
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><g fill='none' stroke='%23EAE8DE' stroke-width='4.5' stroke-linecap='round' stroke-linejoin='round'><path d='M-10 34H30L58 62H102L130 34H170'/><path d='M-10 126H22L50 98H94L122 126H170'/><path d='M126-10V26L150 50V110L126 134V170'/></g><g fill='%23FAF9F6' stroke='%23EAE8DE' stroke-width='3'><circle cx='58' cy='62' r='4'/><circle cx='102' cy='62' r='4'/><circle cx='50' cy='98' r='4'/><circle cx='94' cy='98' r='4'/></g></svg>");
  background-repeat: repeat;
  background-size: 230px 230px;
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, "Hiragino Kaku Gothic ProN",
               "Yu Gothic", Arial, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  z-index: 10;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.app {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------------- top bar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 0 10px;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* station-code-style chip */
.brand-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  flex: none;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: lowercase;
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.qcount {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  width: 44px; height: 44px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--infra);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink-3);
  font-size: 17px;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}
.icon-btn[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }
.icon-btn svg { display: block; width: 20px; height: 20px; }
.icon-btn .sound-waves { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.icon-btn .sound-slash { opacity: 1; transition: opacity var(--t-fast) var(--ease); }
.icon-btn[aria-pressed="true"] .sound-waves { opacity: 1; }
.icon-btn[aria-pressed="true"] .sound-slash { opacity: 0; }

/* ---------------- progress: a route stroke of station dots ---------------- */

.progress {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  margin: 2px 4px 16px;
}
.progress::before {
  content: "";
  position: absolute;
  left: 5px; right: 5px; top: 50%;
  height: 3px;
  margin-top: -1.5px;
  background: var(--infra);
  border-radius: 2px;
}
.progress-dot {
  position: relative;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--infra);
  box-shadow: 0 0 0 3px var(--ground);
  transition: transform var(--t-mid) var(--ease);
}
.progress-dot.is-current {
  width: 14px; height: 14px;
  border: 3px solid var(--ink);
  background: var(--panel);
}
.progress-dot.is-hit  { background: var(--ink); }
.progress-dot.is-miss { background: var(--panel); border: 2.5px solid var(--miss); }

/* ---------------- shared blocks ---------------- */

main { flex: 1 0 auto; }

.screen { animation: panel-in var(--t-mid) var(--ease) both; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--infra);
  border-radius: var(--r-panel);
  padding: var(--pad);
}

.panel-title {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.panel-note { margin: 0 0 12px; font-size: 13px; color: var(--ink-3); }

.cta {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 15px 20px;
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
}
.cta:active { transform: scale(.985); }
.cta-ghost { background: var(--panel); color: var(--ink); }
.cta-next { margin-top: 4px; }

:where(button, input, a, summary):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ---------------- landing ---------------- */

/* abstract route strokes in authentic line colors, set inline by game.js */
.rail-art {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 4px 0 22px;
}
.rail-stroke {
  height: 10px;
  border-radius: var(--r-pill);
  transform-origin: left center;
  animation: stroke-grow 620ms var(--ease) both;
}
@keyframes stroke-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 7.6vw, 34px);
  line-height: 1.14;
  letter-spacing: -.02em;
  font-weight: 700;
  text-wrap: balance;
}

.lede {
  margin: 0 0 22px;
  font-size: 16px;
  color: var(--ink-2);
  max-width: 34ch;
}

.stay-panel { margin-bottom: 20px; }

.stay-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.stay-chip {
  min-height: 44px;
  padding: 10px 15px;
  border: 1.5px solid var(--infra);
  border-radius: var(--r-pill);
  background: var(--panel);
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}
.stay-chip[aria-pressed="true"] {
  border-color: var(--ink);
  border-width: 2px;
  color: var(--ink);
}

.fineprint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: .02em;
}

.challenge-banner {
  display: block;
  border: 2px solid var(--ink);
  border-radius: var(--r-panel);
  padding: 14px 16px;
  margin: 0 0 22px;
  background: var(--panel);
}
.challenge-kicker {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.challenge-headline { display: block; font-size: 21px; letter-spacing: -.01em; }
.challenge-sub { display: block; font-size: 14px; color: var(--ink-2); margin-top: 3px; }

/* ---------------- game ---------------- */

.q-panel { margin-bottom: var(--gap); }

.q-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.q-type { text-align: right; }

.q-prompt {
  margin: 0;
  font-size: clamp(19px, 5.2vw, 23px);
  line-height: 1.25;
  letter-spacing: -.01em;
  font-weight: 700;
  text-wrap: balance;
}

.stimulus { margin-top: 16px; }

/* the big color strip for color -> line questions */
.swatch-hero {
  height: 92px;
  border-radius: 10px;
  animation: stroke-grow 480ms var(--ease) both;
}

/* station-code-style chip for symbol questions */
.symbol-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px; height: 84px;
  margin: 4px auto 0;
  border-radius: 50%;
  border: 5px solid var(--ink);
  background: var(--panel);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .02em;
}

.options {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
.options.is-swatches { grid-template-columns: 1fr 1fr; }

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  border: 1.5px solid var(--infra);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              opacity var(--t-mid) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.option:active:not(:disabled) { transform: scale(.99); }
.option:disabled { cursor: default; }

/* the colored bullet is the route color, untouched */
.option-bullet {
  flex: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}

/* neutral until reveal — see buildLineOption(hideColor) */
.option-bullet.is-blank {
  background: var(--panel);
  box-shadow: inset 0 0 0 2px var(--infra);
}

.option-body { min-width: 0; }
.option-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.005em;
}
.option-operator {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 1px;
}

/* swatch answers: a large route-color block, no name until resolved */
.option-swatch {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
  min-height: 118px;
}
.option-swatch .swatch-fill { flex: 1 1 auto; min-height: 82px; }
.option-swatch .swatch-foot {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-top: 1px solid var(--infra);
  background: var(--panel);
}
.option-swatch.is-revealed .swatch-foot { color: var(--ink); }

/* resolved states — surround only, never the route color itself */
.option.is-correct {
  border-color: var(--ink);
  border-width: 2.5px;
  box-shadow: 0 0 0 3px var(--infra-2);
}
.option.is-wrong { border-color: var(--miss); border-style: dashed; }
.option.is-dim { opacity: .38; }

.option-mark {
  margin-left: auto;
  flex: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-2);
}
.option-swatch .option-mark {
  position: absolute;
  top: 8px; right: 10px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--panel);
  border: 1.5px solid var(--infra);
  margin: 0;
}

.feedback {
  min-height: 24px;
  margin: 14px 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
}
.feedback.is-correct { color: var(--ink); }

/* ---------------- result ---------------- */

.result-card {
  background: var(--panel);
  border: 1px solid var(--infra);
  border-radius: var(--r-panel);
  padding: 24px var(--pad) 20px;
  text-align: center;
  margin-bottom: var(--gap);
}

.result-kicker {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.result-score {
  margin: 0;
  font-size: clamp(56px, 17vw, 76px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.result-outof { font-size: .38em; color: var(--ink-3); letter-spacing: -.01em; }

.result-rank {
  margin: 12px 0 0;
  font-size: clamp(21px, 6vw, 26px);
  font-weight: 700;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.result-flavor {
  margin: 8px auto 0;
  max-width: 32ch;
  font-size: 15px;
  color: var(--ink-2);
}

.minimap { margin: 22px 0 18px; }
.minimap svg { display: block; width: 100%; height: auto; }

/* route-map lettering: small, uppercase, tracked out */
.minimap .map-label {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;   /* uppercased in game.js, not by text-transform */
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--infra);
}
.result-stats div { text-align: center; }
.result-stats dt {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.result-stats dd {
  margin: 3px 0 0;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.versus {
  border: 2px solid var(--ink);
  border-radius: var(--r-panel);
  padding: 16px;
  text-align: center;
  margin-bottom: var(--gap);
  background: var(--panel);
}
.versus-line {
  margin: 0;
  font-size: clamp(22px, 6.4vw, 28px);
  font-weight: 700;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.versus-sub { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); }

.result-actions { display: grid; gap: 10px; margin-bottom: var(--gap); }

.share-panel { margin-bottom: var(--gap); }
.share-text {
  margin: 10px 0 16px;
  padding: 14px;
  background: var(--ground);
  border: 1px solid var(--infra);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.share-url-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.share-url {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--infra);
  border-radius: 10px;
  background: var(--ground);
  color: var(--ink-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.share-status { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); text-align: center; }

.review summary {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
  min-height: 24px;
}
.review[open] summary { margin-bottom: 12px; }
.review-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.review-list li {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.35;
}
.review-list .option-bullet { margin-top: 4px; }
.review-q { display: block; color: var(--ink-2); }
.review-a { display: block; font-weight: 700; margin-top: 2px; }
.review-empty { font-size: 14px; color: var(--ink-2); }

/* ---------------- footer ---------------- */

.site-footer {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--infra);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-3);
  text-align: center;
}
.site-footer p { margin: 0 0 6px; }
.footer-sub { opacity: .85; }

/* ---------------- responsive ---------------- */

@media (min-width: 600px) {
  .app { padding-left: 24px; padding-right: 24px; }
  .options.is-swatches { grid-template-columns: repeat(4, 1fr); }
  .result-actions { grid-template-columns: 1fr 1fr; }
  .minimap { margin-left: -8px; margin-right: -8px; }
}

/* 320px: keep everything inside the viewport */
@media (max-width: 359px) {
  :root { --pad: 14px; --gap: 11px; }
  .app { padding-left: 12px; padding-right: 12px; }
  .brand-name { letter-spacing: .08em; font-size: 14px; }
  .option { padding: 11px 12px; gap: 10px; }
  .option-name { font-size: 15px; }
  .stay-chip { padding: 10px 12px; font-size: 13px; }
}

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