/* The answer console: station-name board, number roundels, stamp, input, per-line progress. */

/* ---------- station numbering roundel (Tokyo Metro / Toei style) ---------- */
.roundel {
  --c: var(--ink);
  display: inline-grid;
  place-content: center;
  justify-items: center;
  flex: none;
  width: 2.45rem;
  aspect-ratio: 1;
  border: 0.32rem solid var(--c);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-num);
  font-weight: 700;
  line-height: 0.82;
}
.roundel b { font-size: 0.76rem; }
.roundel i { font-style: normal; font-size: 0.96rem; letter-spacing: -0.02em; }
.roundel.sm { width: 1.85rem; border-width: 0.24rem; }
.roundel.sm b { font-size: 0.8rem; }
.roundel.xs { width: 1.55rem; border-width: 0.19rem; }
.roundel.xs b { font-size: 0.52rem; }
.roundel.xs i { font-size: 0.66rem; }
.roundel.blank { --c: var(--rail-off); color: var(--ink-soft); }

.roundel-btn {
  padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer;
  transition: transform 0.12s ease;
}
.roundel-btn:hover { transform: scale(1.06); }
.roundel-btn[aria-pressed="true"] .roundel { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }

/* ---------- 駅名標: the station-name board ---------- */
.board {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
  box-shadow: 0 1px 0 var(--rule), 0 10px 18px -14px rgb(29 34 51 / 0.45);
}

.board-head { display: flex; align-items: center; gap: 14px; min-height: 104px; padding: 14px 16px 12px; }
.board-roundels { display: flex; gap: 4px; flex: none; }

.board-names { flex: 1; min-width: 0; container-type: inline-size; }
.board.stamped .board-names { padding-right: 82px; }

/* Signs never wrap a station name; long ones are set smaller to fit the board. */
.board-ja {
  margin: 0;
  font: 700 min(2.5rem, calc(92cqi / var(--len, 3))) / 1.12 var(--font-station);
  letter-spacing: 0.06em;
  font-feature-settings: "palt";
  white-space: nowrap;
}
.board-sub { margin-left: 0.08em; font-size: 0.42em; letter-spacing: 0; vertical-align: 0.2em; }
.board-en { margin: 3px 0 0; font: 600 1rem/1.2 var(--font-num); color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-zh { margin: 1px 0 0; font-size: 0.8rem; color: var(--ink-soft); }
.board-note { margin: 4px 0 0; font-size: 0.88rem; line-height: 1.5; color: var(--ink-soft); }

.board-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 6px 12px;
  background: var(--c, var(--rail-off));
  color: var(--on-c, var(--ink));
  font: 700 1.17rem/1.2 var(--font-station); /* large text: 3:1 contrast suffices on line colours */
}
.stop { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.stop.next { margin-left: auto; }
.stop-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop.unknown .stop-name { letter-spacing: 0.1em; }
.arrow { flex: none; width: 0.6em; height: 0.72em; fill: currentColor; }

/* ---------- 駅スタンプ ---------- */
.stamp {
  --rot: -12deg;
  position: absolute;
  top: 6px;
  right: 8px;
  width: 88px;
  color: var(--stamp);
  opacity: 0.88;
  mix-blend-mode: multiply;
  transform: rotate(var(--rot));
  pointer-events: none;
  animation: stamp-in 0.34s var(--ease-stamp) both;
}
.stamp text { font-family: var(--font-station); font-weight: 700; stroke: none; }
.stamp .arc { letter-spacing: 1px; }
.stamp .date { font-family: var(--font-num); font-size: 9px; letter-spacing: 0.5px; }

@keyframes stamp-in {
  from { transform: scale(1.9) rotate(calc(var(--rot) - 22deg)); opacity: 0; }
  55% { opacity: 0.95; }
  to { transform: scale(1) rotate(var(--rot)); opacity: 0.88; }
}

/* ---------- answer field ---------- */
.answer { margin-top: 14px; }

.answer input {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  font: 700 1.25rem/1.2 var(--font-station);
}
:lang(zh) .answer input { font-family: var(--font-body); }
.answer input::placeholder { color: #676d7a; font: 400 1rem/1.2 var(--font-body); }
.answer input:focus { outline: none; box-shadow: 0 0 0 4px var(--signal); }
.answer input:disabled { background: var(--ground); border-color: var(--rule); }
.answer input.shake { animation: shake 0.28s ease; }

@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.hint { margin: 6px 0 0; font-size: 0.78rem; line-height: 1.5; color: var(--ink-soft); }

.feedback { min-height: 1.6em; margin: 4px 0 0; font-weight: 700; font-size: 0.95rem; line-height: 1.5; }
.feedback[data-kind="found"] { color: var(--ok); }
.feedback[data-kind="miss"] { color: var(--stamp); }
.feedback[data-kind="decoy"], .feedback[data-kind="dup"], .feedback[data-kind="close"] { color: var(--warn); }

/* ---------- score line ---------- */
.scoreline { display: flex; align-items: center; gap: 18px; margin-top: 2px; }
.scoreline p { margin: 0; }
.score { display: flex; align-items: baseline; white-space: nowrap; }
.count { font: 700 2.5rem/1 var(--font-num); font-variant-numeric: tabular-nums; }
.of { margin-left: 4px; color: var(--ink-soft); font-weight: 600; }
.clock { color: var(--ink-soft); font-size: 0.88rem; white-space: nowrap; }
.clock time { margin-left: 2px; font: 600 1.2rem var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink); }
.scoreline .btn { margin-left: auto; }

/* ---------- per-line progress ---------- */
.lines h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0 0 4px; font-size: 1rem; }
.lines h2 small { font-size: 0.76rem; font-weight: 400; color: var(--ink-soft); }
.line-group h3 {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0 4px; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
}
.line-group h3::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }

.linelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }

.line-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
  width: 100%;
  padding: 4px 8px;
  border: 0;
  border-radius: 2px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.line-row .roundel { grid-row: 1 / 3; }
.line-row:hover { background: var(--surface); }
.line-row[aria-pressed="true"] { background: var(--surface); box-shadow: inset 3px 0 0 var(--c); }
.line-name { font-weight: 700; font-size: 0.92rem; }
.line-count { font: 600 0.88rem var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* The unfilled part of a bar is screentone; the filled part is the line colour. */
.line-bar {
  grid-column: 2 / 4;
  height: 5px;
  overflow: hidden;
  background: radial-gradient(circle, rgb(29 34 51 / 0.32) 0 0.8px, transparent 1.2px) 0 50% / 4px 4px repeat-x;
}
.line-bar span {
  display: block; height: 100%; background: var(--c);
  transform-origin: left; transform: scaleX(calc(var(--p, 0) / 100));
  transition: transform 0.3s ease;
}

/* A finished line gets a small red 制覇 stamp next to its count. */
.line-row.done .line-count::after {
  content: "制覇";
  display: inline-block;
  margin-left: 6px;
  padding: 0 4px;
  border: 1.5px solid var(--stamp);
  border-radius: 2px;
  color: var(--stamp);
  font: 700 0.72rem/1.4 var(--font-station);
  transform: rotate(-8deg);
}
:lang(zh) .line-row.done .line-count::after { content: "制霸"; }
:lang(en) .line-row.done .line-count::after { content: "Done"; font-family: var(--font-num); }

@media (max-width: 360px) {
  .scoreline { flex-wrap: wrap; row-gap: 6px; }
}

@media (max-width: 420px) {
  .roundel { width: 2.1rem; border-width: 0.28rem; }
  .board-head { gap: 10px; padding: 12px; min-height: 92px; }
  .board.stamped .board-names { padding-right: 66px; }
  .board .stamp { width: 70px; }
  .board-band { font-size: 1.05rem; gap: 8px; padding: 6px 10px; }
  .count { font-size: 2.2rem; }
  .scoreline { gap: 12px; }
}
