/* Tokyo Life — station-concourse UI.
   Layout: a departure board across the top (clock, today's timetable, wallet), the rail map
   in the middle, platform-sign panels either side; on phones one panel at a time with a tab
   bar. The page mood follows the clock: body[data-phase] (rush, last train, no trains) and
   body[data-sky] (dawn, day, dusk, night). */
:root {
  --bg: #e7eae3;
  --panel: #fbfcf8;
  --panel-2: #eff2eb;
  --ink: #17201b;
  --muted: #59675f;
  --rule: #d1d8cd;
  --accent: #2a7a2e;
  --accent-ink: #ffffff;
  --accent-soft: #e1efd8;
  --good: #2a7a2e;
  --warn: #9a5b00;
  --bad: #bf3329;
  --good-fill: #3f9a42;
  --warn-fill: #e0a21a;
  --bad-fill: #d9443a;
  --stamp-ink: #c4302b;
  --focus: #1b74d1;
  --board: #121513;
  --board-2: #1d221f;
  --board-ink: #e8ebe5;
  --board-muted: #9aa69f;
  --board-rule: #2c332f;
  --led: #ffb21e;
  --led-dim: #6e5418;
  --neon: #ff4fa3;
  --neon-2: #39d5ff;
  --night: #6f5bd6;
  --map-land: #f6f7f2;
  --map-water: #cde1eb;
  --map-park: #d4e6c4;
  --map-hill: #b5cda2;
  --map-night: #0b1a3a;
  --casing: #ffffff;
  --scrim: rgba(12, 18, 15, 0.55);
  --shadow: 0 1px 0 rgba(20, 30, 25, 0.05), 0 10px 28px -16px rgba(20, 30, 25, 0.4);
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  --font-led: "DotGothic16", "Zen Kaku Gothic New", ui-monospace, monospace;
  --r: 12px;
  --tap: 44px;
  --tabbar-h: 60px;
  --actionbar-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f0d; --panel: #131a16; --panel-2: #1a221e; --ink: #e3e9e4; --muted: #97a59d; --rule: #26312b;
    --accent: #8fd14f; --accent-ink: #0b0f0d; --accent-soft: #1d3116; --good: #8fd14f; --warn: #f0b13c; --bad: #ff7b6f;
    --good-fill: #7cc449; --warn-fill: #f0b13c; --bad-fill: #ff6b5e;
    --stamp-ink: #ff7b6f; --focus: #6fb2ff; --board: #060807; --board-2: #131714; --led-dim: #4c3a0f;
    --map-land: #111814; --map-water: #0f2534; --map-park: #163020; --map-hill: #1f3b27; --map-night: #000512; --casing: #0b0f0d;
    --scrim: rgba(0, 0, 0, 0.65); --shadow: 0 10px 28px -16px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f0d; --panel: #131a16; --panel-2: #1a221e; --ink: #e3e9e4; --muted: #97a59d; --rule: #26312b;
  --accent: #8fd14f; --accent-ink: #0b0f0d; --accent-soft: #1d3116; --good: #8fd14f; --warn: #f0b13c; --bad: #ff7b6f;
  --good-fill: #7cc449; --warn-fill: #f0b13c; --bad-fill: #ff6b5e;
  --stamp-ink: #ff7b6f; --focus: #6fb2ff; --board: #060807; --board-2: #131714; --led-dim: #4c3a0f;
  --map-land: #111814; --map-water: #0f2534; --map-park: #163020; --map-hill: #1f3b27; --map-night: #000512; --casing: #0b0f0d;
  --scrim: rgba(0, 0, 0, 0.65); --shadow: 0 10px 28px -16px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 1.2s;
}
/* The light theme cools a touch after dark and warms at dusk; dark mode stays put. */
:root:not([data-theme="dark"]) body[data-sky="night"] { --bg: #e2e5e6; }
:root:not([data-theme="dark"]) body[data-sky="dusk"] { --bg: #ece8e0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-sky="night"], :root:not([data-theme="light"]) body[data-sky="dusk"] { --bg: #0b0f0d; }
}
:lang(ja) body, body:lang(ja) { line-height: 1.6; }
[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.quiet { color: var(--muted); }
.small { font-size: 12.5px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.led { font-family: var(--font-led); color: var(--led); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }

/* ── Buttons, pills, cards ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--rule);
  background: var(--panel); color: var(--ink); font-weight: 700; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-lg { padding: 14px 22px; font-size: 17px; border-radius: 12px; flex-direction: column; gap: 2px; }
.btn-lg small { font-weight: 500; font-size: 12.5px; opacity: 0.85; }
.icon-btn { border: 0; background: transparent; color: inherit; font-size: 20px; line-height: 1; min-width: var(--tap); min-height: var(--tap); padding: 6px 10px; border-radius: 10px; cursor: pointer; }
.icon-btn:hover { background: rgba(127, 127, 127, 0.15); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--rule); font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.pill-quiet { color: var(--muted); }
.pill-home { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 6px; margin-bottom: 10px; }
.card p { margin: 0; }
.card-alert { border-color: var(--bad); }
.card-title { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Game shell ─────────────────────────────────────────────────────── */
#game { display: flex; flex-direction: column; height: 100%; }
.layout {
  flex: 1; min-height: 0; display: grid; gap: 12px;
  grid-template-columns: 300px minmax(0, 1fr) minmax(370px, 430px);
  padding: 12px 16px;
}
.panel { min-width: 0; min-height: 0; overflow: auto; }
#mePanel, #herePanel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
#herePanel { padding: 0 14px 14px; container-type: inline-size; }
#mapPanel { display: flex; flex-direction: column; gap: 10px; }
#needsStrip { display: none; }
#tabbar { display: none; }
body.is-lang-swap #game, body.is-lang-swap #screen, body.is-lang-swap .phone-device { animation: lang-fade 0.26s ease-out; }
@keyframes lang-fade { from { opacity: 0.35; } }

/* ── Top bar: the departure board ───────────────────────────────────── */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px 8px; background: var(--board); color: var(--board-ink);
  border-bottom: 3px solid #80c241; transition: border-color 0.6s;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-kanji { font-weight: 900; font-size: 26px; letter-spacing: 0.04em; color: #fff; }
.brand-name { font-weight: 700; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--board-muted); }
.clock { display: flex; align-items: baseline; gap: 10px; padding: 4px 12px; background: #000; border-radius: 8px; box-shadow: inset 0 0 0 1px #1f2421; }
.clock .led-time { font-size: 30px; line-height: 1; text-shadow: 0 0 10px rgba(255, 178, 30, 0.35); }
.clock .led-date { font-size: 15px; }
.clock .led-day { font-size: 13px; color: var(--led-dim); }
body[data-paused="0"] .colon { animation: colon 1s steps(2, start) infinite; }
@keyframes colon { 50% { opacity: 0.25; } }
.clk-wx { font-size: 20px; }
.phase-wrap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.phase {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--board-2); color: var(--board-muted); white-space: nowrap; transition: background 0.4s, color 0.4s;
}
.topbar[data-phase="rushAM"] .phase, .topbar[data-phase="rushPM"] .phase { background: var(--led); color: #1a1405; }
.topbar[data-phase="lastTrain"] .phase { background: #ff6b5e; color: #1a0503; }
.topbar[data-phase="noTrains"] .phase, .topbar[data-phase="night"] .phase { background: var(--night); color: #fff; }
.topbar[data-phase="evening"] .phase { background: #e8875b; color: #1d0c03; }
.topbar[data-phase="rushAM"], .topbar[data-phase="rushPM"] { border-bottom-color: var(--led); }
.topbar[data-phase="lastTrain"] { border-bottom-color: #ff6b5e; }
.topbar[data-phase="noTrains"], .topbar[data-phase="night"] { border-bottom-color: var(--night); }
.lt-chip {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--led-dim); color: var(--led); font-family: var(--font-led); letter-spacing: 0.04em;
}
.lt-chip[data-tone="warn"] { background: var(--led); color: #1a1405; border-color: var(--led); }
.lt-chip[data-tone="bad"] { background: #ff6b5e; color: #1a0503; border-color: #ff6b5e; animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0.55; } }
.speed { display: flex; gap: 4px; }
.spd {
  min-width: 42px; min-height: 36px; padding: 6px 8px; border: 1px solid var(--board-rule); border-radius: 8px;
  background: var(--board-2); color: var(--board-muted); font-size: 12px; letter-spacing: -0.12em; cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.08s;
}
.spd:active { transform: scale(0.94); }
.spd.is-on { background: #000; color: var(--led); border-color: var(--led-dim); box-shadow: 0 0 0 1px var(--led-dim), 0 0 12px -4px var(--led); }
.wallet { display: flex; flex-direction: column; line-height: 1.15; font-variant-numeric: tabular-nums; margin-left: auto; text-align: right; }
.wallet-yen { font-weight: 900; font-size: 19px; }
.wallet-ic { font-size: 12.5px; color: var(--board-muted); }
.wallet-ic b { font-weight: 700; border: 1px solid currentColor; border-radius: 4px; padding: 0 3px; font-size: 10.5px; margin-right: 2px; }
.rent-chip { font-size: 12px; font-weight: 700; color: var(--board-muted); white-space: nowrap; }
.rent-chip[data-tone="warn"] { color: var(--led); }
.rent-chip[data-tone="bad"] { color: #ff8a7e; }
.phone-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 7px 12px; border-radius: 10px;
  background: var(--board-2); border: 1px solid #39413c; color: var(--board-ink); font-weight: 700; cursor: pointer;
}
.phone-btn:hover { border-color: var(--led-dim); }

/* Today's timetable: phases of the day as a strip, with a "now" marker. */
.dayline { flex: 1 1 440px; display: flex; align-items: center; gap: 12px; min-width: 0; }
.dl-track { position: relative; flex: 1; height: 10px; border-radius: 99px; background: var(--board-2); overflow: visible; }
.dl-seg { position: absolute; top: 0; bottom: 0; display: block; opacity: 0.85; }
.dl-seg:first-child { border-radius: 99px 0 0 99px; }
.dl-seg:nth-last-child(5) { border-radius: 0 99px 99px 0; }
.dl-noTrains { background: #33296b; }
.dl-lastTrain { background: #ff6b5e; }
.dl-morning { background: #f2d48a; }
.dl-day { background: #7cc7e8; }
.dl-evening { background: #e8875b; }
.dl-night { background: var(--night); }
.dl-rushAM, .dl-rushPM { background: repeating-linear-gradient(-45deg, var(--led) 0 5px, #e09200 5px 9px); }
.dl-tick { position: absolute; top: 12px; transform: translateX(-50%); font-family: var(--font-led); font-size: 10px; color: var(--board-muted); line-height: 1; pointer-events: none; }
.dl-now { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 2px var(--board), 0 0 10px #fff; transition: left 0.3s linear; }
.dl-next { font-family: var(--font-led); font-size: 12.5px; color: var(--led); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dayline { padding-bottom: 8px; }

/* ── Language switch: segmented control with a sliding thumb ────────── */
.lang-switch { display: inline-flex; align-items: center; gap: 6px; width: fit-content; justify-self: start; padding: 3px 3px 3px 9px; border-radius: 999px; border: 1px solid var(--rule); background: var(--panel); }
.ls-globe { width: 16px; height: 16px; flex: none; opacity: 0.75; }
.ls-track { position: relative; display: grid; grid-template-columns: 1fr 1fr; }
.ls-thumb { grid-area: 1 / 1; border-radius: 999px; background: var(--ink); transition: transform 0.24s cubic-bezier(0.3, 0.7, 0.2, 1); }
.lang-switch[data-lang="ja"] .ls-thumb { transform: translateX(100%); }
.ls-track button {
  grid-row: 1; position: relative; z-index: 1; border: 0; background: none; cursor: pointer;
  min-width: 54px; min-height: 32px; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--muted);
  transition: color 0.2s;
}
.ls-track button:first-of-type { grid-column: 1; }
.ls-track button:last-of-type { grid-column: 2; }
.ls-track button.is-on { color: var(--bg); }
.ls-track button:not(.is-on):hover { color: var(--ink); }
.ls-board { background: var(--board-2); border-color: #39413c; color: var(--board-muted); }
.ls-board .ls-thumb { background: var(--board-ink); }
.ls-board .ls-track button { color: var(--board-muted); }
.ls-board .ls-track button.is-on { color: var(--board); }
.ls-board .ls-track button:not(.is-on):hover { color: var(--board-ink); }

/* ── Needs ──────────────────────────────────────────────────────────── */
.needs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.need { display: grid; grid-template-columns: 22px 74px minmax(0, 1fr) 46px; align-items: center; column-gap: 8px; font-size: 13.5px; border-radius: 8px; }
.need-ic { text-align: center; font-size: 16px; }
.need-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.need-trend { font-size: 8px; margin-left: 3px; letter-spacing: -1px; vertical-align: 1px; }
.need-trend.is-good { color: var(--good); }
.need-trend.is-bad { color: var(--bad); }
.need-bar {
  position: relative; height: 12px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--rule); overflow: hidden;
}
.need-bar::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), color-mix(in srgb, var(--ink) 12%, transparent) calc(25% - 1px) 25%);
}
.need-bar i {
  display: block; height: 100%; border-radius: inherit; transition: width 0.4s linear, background-color 0.4s;
  background: linear-gradient(180deg, color-mix(in srgb, #fff 22%, var(--good-fill)), var(--good-fill));
}
.need-warn .need-bar i { background: linear-gradient(180deg, color-mix(in srgb, #fff 22%, var(--warn-fill)), var(--warn-fill)); }
.need-bad .need-bar i { background: linear-gradient(180deg, color-mix(in srgb, #fff 22%, var(--bad-fill)), var(--bad-fill)); }
.need-bad .need-name { color: var(--bad); font-weight: 700; }
.need-bad .need-bar { animation: need-alarm 1.6s ease-in-out infinite; }
@keyframes need-alarm { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad-fill) 35%, transparent); } }
.need-eta { grid-column: 3 / 5; font-size: 11.5px; color: var(--warn); margin-top: 1px; }
.need-bad .need-eta { color: var(--bad); font-weight: 700; }
.need.is-bump-good { animation: bump-good 1.4s ease-out; }
.need.is-bump-bad { animation: bump-bad 1.4s ease-out; }
@keyframes bump-good { from { background: color-mix(in srgb, var(--good-fill) 30%, transparent); } }
@keyframes bump-bad { from { background: color-mix(in srgb, var(--bad-fill) 30%, transparent); } }
.need-hint { margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; font-size: 13px; line-height: 1.45; background: var(--panel-2); border-left: 4px solid var(--rule); }
.need-hint.tone-good { border-left-color: var(--good-fill); color: var(--muted); }
.need-hint.tone-warn { border-left-color: var(--warn-fill); }
.need-hint.tone-bad { border-left-color: var(--bad-fill); background: color-mix(in srgb, var(--bad-fill) 10%, var(--panel)); font-weight: 500; }

/* Compact strip (tablet/phone): icon + bar per need; the whole strip opens "Me". */
.strip-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.needs-compact { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.needs-compact .need { grid-template-columns: 18px minmax(0, 1fr); column-gap: 4px; font-size: 13px; padding: 2px 0; }
.needs-compact .need-ic { font-size: 14px; }
.needs-compact .need-bar { height: 8px; }
.needs-compact .need-bar::after { display: none; }
.needs-compact .need-val { display: none; }
.needs-compact .need-bad .need-ic { animation: blink 1.2s steps(2, start) infinite; }
#needsStrip .need-hint { margin: 8px 0 0; padding: 5px 9px; font-size: 12.5px; }

/* ── Me panel & agenda ──────────────────────────────────────────────── */
.me-card { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 32px; background: var(--accent-soft); border: 2px solid var(--accent); }
.me-id { display: grid; gap: 4px; }
.me-id strong { font-size: 18px; }
.mood { font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; width: fit-content; border: 1px solid currentColor; }
.mood-great, .mood-ok { color: var(--good); }
.mood-meh { color: var(--warn); }
.mood-bad { color: var(--bad); }
.me-block { margin: 14px 0; padding: 10px 0; border-block: 1px solid var(--rule); display: grid; gap: 6px; }
.me-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.me-row > span { color: var(--muted); }
.me-row > b { text-align: right; font-weight: 700; }
.me-h { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
:lang(ja) .me-h, :lang(ja) .app-h, :lang(ja) .cat summary { letter-spacing: 0.04em; }
.me-card + .me-h { margin-top: 4px; }
.agenda { margin-top: 6px; }
.ag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ag-row {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid transparent; border-left: 4px solid var(--rule);
  font-size: 13px; text-align: left; line-height: 1.35;
}
button.ag-row { cursor: pointer; min-height: var(--tap); }
button.ag-row:hover { border-color: var(--accent); }
.ag-ic { text-align: center; }
.ag-text { display: grid; min-width: 0; }
.ag-text small { color: var(--muted); font-size: 11.5px; }
.ag-go { color: var(--muted); font-weight: 700; }
.ag-row.tone-warn { border-left-color: var(--warn-fill); }
.ag-row.tone-warn small { color: var(--warn); font-weight: 700; }
.ag-row.tone-bad { border-left-color: var(--bad-fill); color: var(--bad); font-weight: 700; }
.ag-row.tone-good { border-left-color: var(--good-fill); }
.ag-row.tone-pick { border-left-color: var(--led); background: color-mix(in srgb, var(--led) 12%, var(--panel)); }
.skills { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.skills li { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13.5px; }
.skills small { color: var(--muted); }
.pips { display: inline-flex; gap: 2px; }
.pips i { width: 9px; height: 9px; border-radius: 2px; background: var(--panel-2); border: 1px solid var(--rule); }
.pips i.on { background: var(--accent); border-color: var(--accent); }
.pips i.part { background: linear-gradient(to right, var(--accent) calc(var(--f) * 100%), var(--panel-2) 0); }
.bag { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Map ────────────────────────────────────────────────────────────── */
#mapWrap { background: var(--map-land); border: 1px solid var(--rule); border-radius: var(--r); overflow: auto; box-shadow: var(--shadow); }
.map-svg { display: block; width: 100%; height: auto; }
.m-land { fill: var(--map-land); }
.m-water, .m-moat { fill: var(--map-water); }
.m-river { fill: none; stroke: var(--map-water); stroke-width: 16; stroke-linecap: round; }
.m-park { fill: var(--map-park); }
.m-hill { fill: var(--map-hill); }
.m-night { fill: var(--map-night); pointer-events: none; transition: fill-opacity 1s; }
.m-rain { stroke: var(--muted); stroke-width: 1.4; opacity: 0.35; }
.m-rainfill { pointer-events: none; }
.m-water-label { fill: var(--muted); font-size: 15px; font-style: italic; letter-spacing: 0.1em; opacity: 0.8; }
.m-casing { fill: none; stroke: var(--casing); stroke-width: 12; stroke-linejoin: round; stroke-linecap: round; }
.m-line { fill: none; stroke-width: 6; stroke-linejoin: round; stroke-linecap: round; }
.m-line-down { stroke-dasharray: 10 8; opacity: 0.45; }
.m-mover-bg { fill: var(--panel); stroke: var(--ink); stroke-width: 2; }
.stn { cursor: pointer; }
.stn-hit { fill: transparent; }
.stn:hover .stn-hit, .stn.is-selected .stn-hit { fill: var(--accent); fill-opacity: 0.16; }
.stn:focus-visible { outline: none; }
.stn:focus-visible .stn-hit { stroke: var(--focus); stroke-width: 3; }
.stn-dot { fill: var(--panel); stroke: var(--ink); stroke-width: 3; }
.stn.is-stamped .stn-dot { fill: var(--led); }
.stn-home, .stn-work { fill: var(--panel); }
.stn.is-here .stn-dot { stroke: var(--accent); stroke-width: 5; }
.stn.is-here circle.stn-dot { fill: var(--accent); }
.stn-pulse { fill: none; stroke: var(--accent); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { from { transform: scale(0.8); opacity: 0.9; } to { transform: scale(1.9); opacity: 0; } }
.stn-label, .stn-alt { paint-order: stroke; stroke: var(--map-land); stroke-width: 5px; stroke-linejoin: round; pointer-events: none; }
.stn-label { font-size: 20px; font-weight: 700; fill: var(--ink); }
.stn-alt { font-size: 15px; font-weight: 500; fill: var(--muted); }
.stn.is-here .stn-label { fill: var(--accent); }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); padding: 0 4px; }
.lg-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--ink); }
.lg-here { background: var(--accent); border-color: var(--accent); }
.lg-stamp { background: var(--led); }
.map-alert { background: var(--board); color: var(--led); font-family: var(--font-led); font-size: 14px; border-radius: 8px; padding: 6px 10px; margin: 0 0 6px; }

/* ── Departure board (travel) ───────────────────────────────────────── */
.board-hint { color: var(--muted); margin: 0; padding: 4px; }
.board { background: var(--board); color: var(--board-ink); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.board-head { display: flex; align-items: center; gap: 12px; }
.board-title { display: grid; flex: 1; min-width: 0; }
.board-title strong { font-size: 22px; font-weight: 900; line-height: 1.1; }
.board-title small { color: var(--board-muted); }
.code-badge { font-family: var(--font-led); color: var(--led); background: #000; border: 1px solid var(--led-dim); border-radius: 6px; padding: 4px 8px; font-size: 15px; letter-spacing: 0.08em; }
.board-flavor { margin: 0; color: var(--board-muted); font-size: 13.5px; }
.board-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 17px; }
.board-meta .pill { background: var(--board-2); border-color: #333b36; color: var(--board-ink); }
.board-rows { display: grid; gap: 6px; }
.board-row {
  display: grid; grid-template-columns: 64px 72px 78px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; min-height: 52px; padding: 10px 12px; border: 1px solid #2a312d; border-radius: 10px; background: var(--board-2);
  color: var(--board-ink); text-align: left; cursor: pointer; transition: border-color 0.15s, transform 0.08s;
}
.board-row:hover:not(:disabled) { border-color: var(--led); }
.board-row:active:not(:disabled) { transform: scale(0.985); }
.board-row:disabled { cursor: not-allowed; }
.board-row:disabled .led { color: var(--led-dim); }
.board-row .led { font-size: 16px; }
.led-mode { white-space: nowrap; }
.board-detail { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; min-width: 0; }
.board-notes { font-size: 12.5px; color: var(--board-muted); }
.board-row:disabled .board-notes { color: #ffb4a6; }
.board-go { font-weight: 700; color: var(--led); white-space: nowrap; }
.board-row:disabled .board-go { visibility: hidden; }
.board-note { margin: 0; font-size: 13px; color: var(--board-muted); }
.icon-btn[data-cmd="select"] { color: var(--board-muted); }
.line-chip { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.07); border-left: 4px solid var(--line); white-space: nowrap; }

/* ── Here: sky, station sign, notes ─────────────────────────────────── */
.sky {
  position: relative; height: 84px; margin: 0 -14px; overflow: hidden; border-radius: var(--r) var(--r) 0 0;
  background: linear-gradient(180deg, #7fc3ef, #bfe2f7 70%, #e6f3fb); --bld: #a2b6c6; --win: #ffd36a; --win-o: 0;
  transition: background 1.2s;
}
.sky-dawn { background: linear-gradient(180deg, #f6b89a, #fbe0c2 60%, #d6e7f3); --bld: #a395a6; --win-o: 0.35; }
.sky-day { --win-o: 0; }
.sky-dusk { background: linear-gradient(180deg, #3e3a7a, #c4637a 55%, #f4a261); --bld: #2c2540; --win-o: 0.75; }
.sky-night { background: linear-gradient(180deg, #050a1f, #101a40 60%, #2a1f55); --bld: #0a0e1c; --win-o: 0.95; }
.skyline { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 62px; }
.skyline .bld { fill: var(--bld); transition: fill 1.2s; }
.skyline .win { fill: var(--win); opacity: var(--win-o); transition: opacity 1.2s; }
.skyline .beacon { fill: #ff3b3b; opacity: var(--win-o); }
.sky-night .skyline .beacon { animation: blink 2s steps(2, start) infinite; }
.skyline .ridge { fill: color-mix(in srgb, var(--bld) 70%, #2f5a35); }
.skyline .ridge-far { fill: color-mix(in srgb, var(--bld) 55%, #8fb5a0); opacity: 0.8; }
.sky-orb { position: absolute; width: 18px; height: 18px; border-radius: 50%; transform: translate(-50%, 50%); }
.sky-orb.is-sun { background: radial-gradient(circle, #fff6c8, #ffd25e 60%, #ffb21e); box-shadow: 0 0 22px 6px rgba(255, 210, 94, 0.55); }
.sky-dusk .sky-orb.is-sun, .sky-dawn .sky-orb.is-sun { background: radial-gradient(circle, #ffe0b0, #ff8c4a); box-shadow: 0 0 26px 8px rgba(255, 130, 70, 0.5); }
.sky-orb.is-moon { width: 14px; height: 14px; background: #f3efd8; box-shadow: 0 0 14px 3px rgba(243, 239, 216, 0.35), inset -4px -2px 0 #d8d2b0; }
.sky-stars {
  position: absolute; inset: 0; opacity: 0.8;
  background-image: radial-gradient(1px 1px at 12% 22%, #fff, transparent), radial-gradient(1px 1px at 33% 12%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 58% 28%, #fff, transparent), radial-gradient(1px 1px at 77% 10%, #fff, transparent),
    radial-gradient(1px 1px at 88% 34%, #fff, transparent), radial-gradient(1px 1px at 45% 40%, #cfd8ff, transparent);
}
.sky.wx-rain::after, .sky.wx-snow::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.sky.wx-rain::after { background: repeating-linear-gradient(105deg, transparent 0 7px, rgba(255, 255, 255, 0.32) 7px 8px); animation: rain 0.6s linear infinite; background-size: 40px 40px; }
.sky.wx-snow::after { background-image: radial-gradient(1.6px 1.6px at 10% 20%, #fff, transparent), radial-gradient(1.6px 1.6px at 40% 60%, #fff, transparent), radial-gradient(1.6px 1.6px at 70% 30%, #fff, transparent), radial-gradient(1.6px 1.6px at 90% 70%, #fff, transparent); animation: snow 3s linear infinite; background-size: 120px 84px; }
.sky.wx-cloudy { filter: saturate(0.6) brightness(0.95); }
@keyframes rain { to { background-position: -12px 40px; } }
@keyframes snow { to { background-position: 10px 84px; } }
/* A train crosses the skyline: often at rush hour, rarely late, never after the last one. */
.sky-train {
  position: absolute; bottom: 3px; left: 0; width: 64px; height: 7px; border-radius: 3px;
  background: linear-gradient(90deg, #e9eef0 0 92%, transparent 92%), #e9eef0;
  box-shadow: inset 0 -2px 0 var(--line), 0 0 0 1px rgba(0, 0, 0, 0.25);
  animation: sky-train 9s linear infinite; animation-delay: -3s;
}
.sky-night .sky-train, .sky-dusk .sky-train { background: #ffe9a8; box-shadow: inset 0 -2px 0 var(--line), 0 0 10px rgba(255, 220, 140, 0.6); }
.sky[data-phase="rushAM"] .sky-train, .sky[data-phase="rushPM"] .sky-train { animation-duration: 3.6s; }
.sky[data-phase="lastTrain"] .sky-train { animation-duration: 12s; }
.sky[data-phase="noTrains"] .sky-train { display: none; }
body[data-paused="1"] .sky-train, body[data-paused="1"] .sky.wx-rain::after, body[data-paused="1"] .sky.wx-snow::after { animation-play-state: paused; }
@keyframes sky-train { from { transform: translateX(-80px); } to { transform: translateX(calc(100cqw + 40px)); } }

.sign { position: sticky; top: 0; z-index: 2; margin: -24px 0 0; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; box-shadow: 0 8px 20px -14px rgba(0, 0, 0, 0.45); transition: box-shadow 0.6s, border-color 0.6s; }
body[data-phase="lastTrain"] .sign, body[data-phase="noTrains"] .sign {
  border-color: color-mix(in srgb, var(--neon) 55%, var(--rule));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 35%, transparent), 0 0 24px -6px var(--neon), 0 8px 20px -14px rgba(0, 0, 0, 0.45);
}
.sign-body { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 14px 4px; }
.sign-names { display: grid; min-width: 0; }
.sign-name { font-size: 32px; font-weight: 900; margin: 0; letter-spacing: 0.02em; }
.sign-alt { color: var(--muted); font-size: 14px; letter-spacing: 0.06em; }
.sign-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.sign-stripe { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; padding: 0 14px 10px; }
.sign-stripe::before { content: ""; position: absolute; left: 0; right: 0; top: 13px; height: 8px; background: var(--line); }
.sign-code { position: relative; z-index: 1; background: var(--panel); border: 3px solid var(--line); border-radius: 8px; padding: 1px 10px; font-weight: 900; font-size: 14px; letter-spacing: 0.08em; }
.sign-prev, .sign-next { padding-top: 24px; font-size: 13px; color: var(--muted); font-weight: 500; }
.sign-next { text-align: right; }
.flavor { color: var(--muted); font-size: 14px; margin: 12px 2px 6px; max-width: 60ch; }
.ambient { color: var(--muted); font-size: 13px; font-style: italic; margin: 0 2px 12px; max-width: 60ch; }
.ambient span { font-style: normal; color: var(--led); margin-right: 4px; }
:lang(ja) .ambient { font-style: normal; }
.empty-state { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 16px; }

.phase-note { margin: 0 0 12px; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.45; display: flex; gap: 8px; align-items: flex-start; }
.pn-rush { background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--led) 22%, var(--panel)) 0 10px, color-mix(in srgb, var(--led) 12%, var(--panel)) 10px 20px); border: 1px solid color-mix(in srgb, var(--led) 60%, var(--rule)); }
.pn-late { background: color-mix(in srgb, var(--neon) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--neon) 45%, var(--rule)); }
.pn-dead { background: var(--board); color: var(--board-ink); border: 1px solid var(--night); }
.pn-dawn { background: color-mix(in srgb, #f6b89a 22%, var(--panel)); border: 1px solid color-mix(in srgb, #f6b89a 60%, var(--rule)); }

/* Today's pick */
.pick-away {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%;
  min-height: var(--tap); margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; cursor: pointer; text-align: left;
  border: 1px dashed var(--led); background: color-mix(in srgb, var(--led) 9%, var(--panel)); font-size: 13.5px;
}
.pick-away:hover { border-style: solid; }
.pick-star { color: var(--led); font-size: 18px; }
.pick-go { font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.pick-hero { margin: 0 0 14px; }
.pick-label { margin: 0 0 6px; font-weight: 900; font-size: 13px; color: #b07400; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pick-label { color: var(--led); } }
:root[data-theme="dark"] .pick-label { color: var(--led); }

/* Section jump chips */
.jump {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: none;
  -webkit-mask: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.jump::-webkit-scrollbar { display: none; }
.jump-chip {
  display: inline-flex; align-items: center; gap: 5px; flex: none; min-height: 34px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--panel-2); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.jump-chip b { font-size: 11px; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--panel); border: 1px solid var(--rule); text-align: center; }
.jump-chip:hover { border-color: var(--accent); }

/* ── Activity groups and rows ───────────────────────────────────────── */
.cat { border-top: 1px solid var(--rule); scroll-margin-top: 150px; }
.cat summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; min-height: var(--tap);
  padding: 8px 2px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
.cat summary::-webkit-details-marker { display: none; }
.cat summary::after { content: "▾"; margin-left: auto; transition: transform 0.15s; }
.cat:not([open]) summary::after { transform: rotate(-90deg); }
.cat-ic { font-size: 15px; letter-spacing: 0; }
.cat-count { font-variant-numeric: tabular-nums; border: 1px solid var(--rule); border-radius: 999px; padding: 0 7px; font-size: 11.5px; letter-spacing: 0; }
.cat-rows { display: grid; gap: 8px; padding-bottom: 12px; }
.cat-work .act-row:not(.is-off) { border-color: var(--accent); }
.act-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 56px;
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--rule); background: var(--panel); cursor: pointer; transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.act-row:hover:not(.is-off) { border-color: var(--accent); background: var(--accent-soft); }
.act-row:active:not(.is-off) { transform: scale(0.985); }
.act-row.is-off, .act-row[aria-disabled="true"] { cursor: default; background: var(--panel-2); }
.act-row.is-off .act-icon, .act-row.is-off .pc-stamp { filter: grayscale(1); opacity: 0.55; }
.act-row.is-off .act-name, .act-row.is-off .pc-name, .act-row.is-off .act-cost { color: var(--muted); }
.act-row.is-shake { animation: shake 0.32s; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.act-icon { font-size: 24px; text-align: center; }
.act-main { display: grid; gap: 3px; min-width: 0; }
.act-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.act-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12px; color: var(--muted); align-items: center; }
.meta-dur, .meta-end, .meta-earn, .fx { font-variant-numeric: tabular-nums; white-space: nowrap; }
.meta-end { color: var(--muted); }
.meta-end::before { content: "→ "; opacity: 0.6; }
:lang(ja) .meta-end::before { content: ""; }
.meta-earn { color: var(--good); font-weight: 700; }
.fx-up { color: var(--good); }
.fx-down { color: var(--bad); }
.tag { border: 1px solid var(--rule); border-radius: 999px; padding: 0 7px; font-size: 11px; white-space: nowrap; }
.tag-stamp { border-color: var(--stamp-ink); color: var(--stamp-ink); font-weight: 700; }
.tag-done { color: var(--good); border-color: var(--good); }
.tag-half { background: var(--stamp-ink); color: #fff; border-color: var(--stamp-ink); font-weight: 700; }
.tag-warn { color: var(--warn); border-color: var(--warn); }
.tag-pick { background: var(--led); border-color: var(--led); color: #1a1405; font-weight: 700; }
.tag-col { border-style: dashed; letter-spacing: 0.05em; }
.tag-night { border-color: var(--night); color: var(--night); }
:root[data-theme="dark"] .tag-night { color: #b2a5ff; border-color: #8f7cf0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag-night { color: #b2a5ff; border-color: #8f7cf0; } }
.row-why { font-size: 12.5px; color: var(--warn); font-weight: 500; }
.act-cost { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Sights as postcards */
.postcard {
  position: relative; overflow: hidden; grid-template-columns: 54px minmax(0, 1fr) auto; align-items: start; padding: 12px 12px 12px 12px;
  background:
    linear-gradient(90deg, transparent calc(100% - 66px), color-mix(in srgb, var(--rule) 60%, transparent) calc(100% - 66px) calc(100% - 65px), transparent calc(100% - 65px)),
    var(--panel);
}
.postcard::after {
  content: ""; position: absolute; top: 9px; right: 10px; width: 46px; height: 16px; pointer-events: none; opacity: 0.55;
  background: repeating-linear-gradient(0deg, transparent 0 3px, color-mix(in srgb, var(--muted) 45%, transparent) 3px 4px);
  -webkit-mask: radial-gradient(circle at 0 50%, transparent 7px, #000 7.5px); mask: radial-gradient(circle at 0 50%, transparent 7px, #000 7.5px);
}
.pc-stamp {
  width: 50px; height: 50px; display: grid; place-items: center; font-size: 26px; border-radius: 8px; transform: rotate(-3deg);
  background: var(--panel-2); border: 2px dotted color-mix(in srgb, var(--muted) 55%, transparent);
}
.pc-body { display: grid; gap: 4px; min-width: 0; }
.pc-name { font-weight: 900; font-size: 15.5px; line-height: 1.3; }
.pc-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.pc-tags:empty { display: none; }
.pc-status { font-size: 12px; color: var(--good); font-weight: 500; }
.pc-status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.pc-status.is-closed { color: var(--warn); }
.pc-side { display: grid; justify-items: end; gap: 6px; padding-top: 20px; min-width: 52px; }
.pc-visited { font-size: 11px; font-weight: 900; color: var(--stamp-ink); border: 2px solid var(--stamp-ink); border-radius: 6px; padding: 0 5px; transform: rotate(-6deg); white-space: nowrap; }
.postcard.is-visited .pc-stamp { border-style: solid; border-color: var(--stamp-ink); }
.postcard.is-pick { border-color: var(--led); box-shadow: inset 0 0 0 1px var(--led); }
.postcard.is-hero { padding: 14px; border-width: 2px; background: linear-gradient(135deg, color-mix(in srgb, var(--led) 14%, var(--panel)), var(--panel) 60%); }
.postcard.is-hero .pc-stamp { width: 62px; height: 62px; font-size: 32px; }
.postcard.is-hero .pc-name { font-size: 18px; }
.postcard.is-hero { grid-template-columns: 66px minmax(0, 1fr) auto; }
@container (min-width: 560px) {
  .cat-sights .cat-rows, .cat-season .cat-rows { grid-template-columns: 1fr 1fr; }
}

/* ── Action bar ─────────────────────────────────────────────────────── */
#actionBar { background: var(--board); color: var(--board-ink); border-top: 1px solid #2a312d; }
.ab { display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: var(--actionbar-h); }
.ab-icon { font-size: 26px; width: 34px; text-align: center; }
.ab-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.ab-top { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.ab-label { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ab-until { font-family: var(--font-led); color: var(--board-muted); font-size: 12.5px; white-space: nowrap; margin-left: auto; }
.ab-lines { display: inline-flex; gap: 3px; flex: none; }
.ab-lines i { width: 16px; height: 6px; border-radius: 2px; background: var(--line); align-self: center; }
.ab-idle .ab-label { font-weight: 500; color: var(--board-muted); white-space: normal; }
.ab-progress { height: 8px; background: var(--board-2); border-radius: 99px; overflow: hidden; box-shadow: inset 0 0 0 1px #262c28; }
.ab-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--led-dim), var(--led)); transition: width 0.3s linear; }
.ab-travel .ab-progress i { background: repeating-linear-gradient(90deg, var(--led) 0 14px, #e09200 14px 18px); }
.ab-sleep .ab-progress i { background: linear-gradient(90deg, #3b2f7a, var(--night)); }
.ab-left { font-family: var(--font-led); color: var(--led); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ab .btn { min-height: var(--tap); background: var(--board-2); color: var(--board-ink); border-color: #39413c; }
.ab .btn-primary { background: var(--led); color: #1a1405; border-color: var(--led); }
.ab-skip { gap: 6px; }
.ab-skip-time { color: inherit; font-size: 13px; opacity: 0.8; }

/* ── Phone ──────────────────────────────────────────────────────────── */
#phone { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--scrim); padding: 16px; }
#phone.is-opening { animation: fade-in 0.15s ease-out; }
#phone.is-opening .phone-device { animation: phone-up 0.22s cubic-bezier(0.3, 0.7, 0.2, 1); }
@keyframes fade-in { from { opacity: 0; } }
.phone-device {
  width: min(400px, 100%); height: min(780px, 100%); display: flex; flex-direction: column;
  background: var(--bg); border: 10px solid #0d0f0e; border-radius: 36px; overflow: hidden; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}
@keyframes phone-up { from { transform: translateY(24px); opacity: 0.6; } }
.phone-status { display: flex; justify-content: space-between; padding: 8px 18px 4px; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.phone-carrier { color: var(--muted); letter-spacing: 0.1em; }
.phone-home { flex: 1; overflow: auto; padding: 18px; display: grid; align-content: start; gap: 18px; }
.phone-date { font-size: 28px; font-weight: 900; text-align: center; padding: 10px 0; }
.app-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 8px; }
.app-icon { display: grid; justify-items: center; gap: 6px; background: none; border: 0; cursor: pointer; font-size: 12px; font-weight: 500; padding: 4px; border-radius: 12px; transition: transform 0.08s; }
.app-icon:hover { background: rgba(127, 127, 127, 0.12); }
.app-icon:active { transform: scale(0.94); }
.app-glyph { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; background: var(--panel); border: 1px solid var(--rule); box-shadow: var(--shadow); }
.app-head { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--rule); }
.app-head h2 { margin: 0; font-size: 18px; }
.app-body { flex: 1; overflow: auto; padding: 14px; }
.app-h { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.app-h:first-child { margin-top: 0; }
.phone-close { border: 0; border-top: 1px solid var(--rule); background: var(--panel); min-height: 52px; padding: 12px; font-weight: 700; cursor: pointer; }
.job-pay { font-weight: 900; font-size: 18px; }
.job-foot, .home-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.home-card.is-mine { border-color: var(--accent); }
.line-card { grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; }
.line-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: var(--accent-soft); }
.line-main { display: grid; gap: 2px; min-width: 0; font-size: 13px; }
.rel-bar { height: 5px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.rel-bar i { display: block; height: 100%; background: #06c755; }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.stamp {
  aspect-ratio: 1; max-width: 100%; border: 2px dashed var(--rule); border-radius: 50%;
  display: grid; place-items: center; align-content: center; text-align: center; padding: 6px; gap: 0;
}
.stamp.is-got { border: 3px solid var(--stamp-ink); color: var(--stamp-ink); transform: rotate(-7deg); }
.stamp-ink { font-size: 22px; min-height: 26px; }
.stamp-code { font-family: var(--font-led); font-size: 12px; }
.stamp-name { font-size: 10px; line-height: 1.2; color: var(--muted); }
.stamp.is-got .stamp-name { color: var(--stamp-ink); }
.album, .goals, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.album li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 0 8px; font-size: 13.5px; }
.album li .quiet { grid-column: 2; }
.goals li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 10px; background: var(--panel); opacity: 0.6; }
.goals li.is-done { opacity: 1; border-color: var(--accent); }
.goal-ic { font-size: 20px; text-align: center; }
.log li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; font-size: 13px; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .log-day { display: block; font-weight: 700; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; margin-top: 8px; }
.log-good span { color: var(--good); }
.log-warn span { color: var(--warn); }
.log-bad span { color: var(--bad); }
select, textarea.code, .field input { width: 100%; min-height: 40px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--rule); background: var(--panel); }
textarea.code { font-family: ui-monospace, monospace; font-size: 11.5px; resize: vertical; word-break: break-all; }
.app-status .agenda { margin-bottom: 4px; }

/* Collections (Stamps app) */
.col-card, .guide-group { padding: 0; display: block; }
.col-card summary { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.col-card summary::-webkit-details-marker { display: none; }
.col-icon { font-size: 22px; text-align: center; }
.col-main { display: grid; gap: 1px; min-width: 0; }
.col-count { font-family: var(--font-led); font-size: 15px; color: var(--muted); }
.col-card.is-done { border-color: var(--accent); }
.col-card.is-done .col-count { color: var(--good); font-weight: 700; }
.col-perk { font-size: 12.5px; padding: 0 12px 6px; }
.col-items { list-style: none; margin: 0; padding: 0 12px 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.col-items li.is-done { color: var(--good); }

/* Guide app */
.pick-card { border: 2px solid var(--led); background: color-mix(in srgb, var(--led) 10%, var(--panel)); display: grid; gap: 4px; margin-bottom: 10px; }
.guide-group summary { display: flex; align-items: baseline; gap: 8px; min-height: var(--tap); padding: 10px 12px; cursor: pointer; list-style: none; }
.guide-group summary::-webkit-details-marker { display: none; }
.guide-meta { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-family: var(--font-led); }
.guide-rows { list-style: none; margin: 0; padding: 0 12px 10px; display: grid; gap: 6px; }
.guide-rows li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: start; gap: 8px; font-size: 13.5px; }
.guide-rows li.is-done { opacity: 0.6; }
.guide-name { display: grid; min-width: 0; }
.guide-cols { font-size: 12px; letter-spacing: 1px; white-space: nowrap; }
.guide-cost { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ── Modal, toasts, floaters, big moments ───────────────────────────── */
#modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--scrim); padding: 16px; }
#modal.is-opening { animation: fade-in 0.15s ease-out; }
#modal.is-opening .modal-card { animation: phone-up 0.22s cubic-bezier(0.3, 0.7, 0.2, 1); }
.modal-card { width: min(440px, 100%); background: var(--panel); border-radius: 16px; padding: 24px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6); display: grid; gap: 10px; text-align: center; }
.modal-card h2 { margin: 0; font-size: 22px; }
.modal-card p { margin: 0; }
.event-icon { font-size: 44px; }
.event-choices { display: grid; gap: 8px; margin-top: 8px; }
.event-choices .btn { min-height: var(--tap); }
.ending-kanji { font-size: 64px !important; font-weight: 900; line-height: 1; color: var(--stamp-ink); }
.ending-score { display: grid; gap: 4px; background: var(--board); color: var(--board-ink); border-radius: 10px; padding: 12px; }
.ending-score .led { font-size: 22px; }

#toasts { position: fixed; right: 16px; bottom: calc(var(--actionbar-h) + 16px); z-index: 70; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); pointer-events: none; }
.toast {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start;
  background: var(--board); color: var(--board-ink); border-left: 4px solid var(--led); border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; line-height: 1.45; box-shadow: 0 12px 24px -12px rgba(0, 0, 0, 0.6); animation: toast-in 0.22s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.toast-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--board-2); font-size: 14px; font-weight: 900; }
.toast-body { display: grid; gap: 2px; min-width: 0; }
.toast-body b { font-weight: 700; }
.toast-chips { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12.5px; font-weight: 700; margin-top: 2px; }
.toast-chips .fx { padding: 1px 7px; border-radius: 99px; background: var(--board-2); }
.toast-chips .fx-up { color: #9be37a; }
.toast-chips .fx-down { color: #ff9a8e; }
.toast-good { border-left-color: #80c241; }
.toast-good .toast-ic { color: #80c241; }
.toast-warn { border-left-color: var(--led); }
.toast-warn .toast-ic { color: var(--led); }
.toast-bad { border-left-color: #ff6b5e; }
.toast-bad .toast-ic { color: #ff6b5e; }
.toast-info { border-left-color: var(--board-muted); }
.toast-result { border-left-color: var(--neon-2); }
.toast.is-out { opacity: 0; transform: translateX(12px); transition: opacity 0.3s, transform 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes toast-drop { from { opacity: 0; transform: translateY(-10px) scale(0.98); } }

#fxLayer { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.floater {
  position: fixed; transform: translate(-50%, 0); font-weight: 900; font-size: 14px; font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: 99px; white-space: nowrap; animation: float-up 1.4s ease-out forwards;
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.5);
}
.floater.is-good { background: #2f7d32; color: #fff; }
.floater.is-bad { background: #b8322a; color: #fff; }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 4px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 34px); } }

.celebrate {
  position: fixed; left: 50%; top: 136px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px;
  padding: 12px 18px 12px 12px; border-radius: 18px; background: var(--board); color: var(--board-ink);
  box-shadow: 0 24px 50px -18px rgba(0, 0, 0, 0.7); animation: cel-in 0.45s cubic-bezier(0.2, 1.4, 0.3, 1) both; width: max-content; max-width: calc(100vw - 32px);
}
.celebrate.is-out { opacity: 0; transform: translate(-50%, -10px); transition: opacity 0.35s, transform 0.35s; }
@keyframes cel-in { from { opacity: 0; transform: translate(-50%, -14px) scale(0.92); } }
.cel-text { display: grid; gap: 2px; min-width: 0; }
.cel-text b { font-size: 17px; font-weight: 900; }
.cel-text span { color: var(--board-muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cel-stamp {
  width: 72px; height: 72px; flex: none; border-radius: 50%; display: grid; place-items: center; align-content: center;
  border: 4px double #ff5a4f; color: #ff5a4f; transform: rotate(-9deg); animation: thunk 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
  background: radial-gradient(circle, rgba(255, 90, 79, 0.12), transparent 70%);
}
.cel-code { font-family: var(--font-led); font-size: 17px; letter-spacing: 0.08em; line-height: 1; }
.cel-ic { font-weight: 900; font-size: 18px; line-height: 1.1; }
@keyframes thunk { from { transform: rotate(-30deg) scale(2.1); opacity: 0; filter: blur(2px); } 60% { opacity: 1; filter: none; } }
.cel-badge { width: 52px; height: 52px; flex: none; border-radius: 14px; display: grid; place-items: center; font-size: 28px; background: var(--board-2); animation: thunk 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.cel--collection .cel-badge { background: linear-gradient(135deg, #ffd25e, #ff9f1c); }
.cel--pick .cel-badge { color: var(--led); font-size: 30px; }
.cel--collection, .cel--promoted { border: 1px solid var(--led-dim); }

/* ── Full-screen screens: home, character creation ─────────────────── */
#screen {
  position: fixed; inset: 0; z-index: 30; overflow: auto; padding: 24px 16px 48px;
  background:
    linear-gradient(var(--rule) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, var(--rule) 1px, transparent 1px) 0 0 / 56px 56px,
    var(--bg);
}

.how { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.how li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; }
.how-ic { font-size: 20px; line-height: 1.2; text-align: center; }
.how b { display: block; font-size: 15px; }
.how li > span:last-child > span { display: block; font-size: 13.5px; color: color-mix(in srgb, var(--board-ink) 82%, var(--board)); line-height: 1.5; }
.about p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: color-mix(in srgb, var(--board-ink) 86%, var(--board)); }
.about .about-v { font-family: var(--font-led); color: var(--led); font-size: 18px; }
.set-row { display: grid; grid-template-columns: minmax(7em, auto) minmax(0, 1fr); align-items: center; gap: 10px 14px; padding: 8px 0; }
.set-row + .set-row { border-top: 1px solid var(--rule); }
.set-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.seg-pick { gap: 6px; }
.seg-pick .btn { min-height: 38px; padding: 6px 14px; }
.seg-pick .btn.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (max-width: 480px) { .set-row { grid-template-columns: minmax(0, 1fr); gap: 6px; } }

/* ── Home screen: Tokyo between dusk and night ──────────────────────────
   Layers, back to front: sky, far city (Fuji, Shinjuku, Tochō), Tokyo Tower, near city with
   two signs, a scrim for the text, the train, the viaduct with its stops, the page content.
   The scene is always dusk whatever the theme: it is a poster, not a panel. */
#screen.is-home { padding: 0; overflow-x: hidden; background: #0e1230; }
.home {
  --h-ink: #f4f2ff; --h-soft: #dcd9f5; --h-muted: #b4b0d8; --h-line: #2e3568;
  --h-panel: #10143a; --h-panel-2: #171d48; --h-green: #80c241; --h-green-ink: #0f2208;
  --h-landmark: #ff7b27; --h-amber: #ffb86b;
  position: relative; min-height: 100%; min-height: max(100dvh, 600px); overflow: hidden;
  color: var(--h-ink); isolation: isolate;
}
.home-scene { position: absolute; inset: 0; z-index: 0; }
.home.is-intro .home-scene { animation: home-fade 0.8s ease-out both; }
.home-sky {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #0d1130 0%, #181b48 30%, #2e265d 50%, #5e376f 63%, #b2647f 73%, #ea957a 81%, #f6c182 88%, #f6c182 100%);
}
.home-far, .home-near, .home-tower { position: absolute; left: 0; right: 0; bottom: 0; }
.home-far { width: 100%; height: 44vh; }
.home-far .fuji { fill: #3a3574; }
.home-far .fuji-snow { fill: #9590c9; opacity: 0.5; }
.home-far .far-bld { fill: #252a5c; }
.home-tower { left: auto; right: 7vw; bottom: 54px; height: min(84vh, 880px); aspect-ratio: 340 / 612; }
.home-tower svg { display: block; width: 100%; height: 100%; }
.home.is-intro .home-tower svg { animation: home-tower-on 1.6s ease-out 0.2s both; }
.home-near { width: 100%; height: 31vh; }
.home-near .near-bld { fill: #10142d; }
.home-near .w-warm { fill: #ffd28a; opacity: 0.72; }
.home-near .w-cool { fill: #bfe1ff; opacity: 0.42; }
.home-near .sign text { font-family: var(--font-body); }
.home-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(9, 11, 32, 0.74) 0%, rgba(9, 11, 32, 0.5) 32%, rgba(9, 11, 32, 0) 58%);
}
.home-train { position: absolute; left: 0; bottom: 76px; width: min(720px, 92vw); z-index: 1; transform: translateX(-100%); animation: home-train 26s linear 1.6s infinite; }
.home-train svg { display: block; width: 100%; height: auto; }
@keyframes home-fade { from { opacity: 0; } }
@keyframes home-tower-on { from { filter: brightness(0.3) saturate(0.25); } }
@keyframes home-train { 0% { transform: translateX(-100%); } 50%, 100% { transform: translateX(100vw); } }

.home-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) clamp(16px, 4vw, 44px) 0;
}
.home-clock { margin: 0; font-size: 13px; font-weight: 700; color: var(--h-muted); }
.home-clock-time { margin-left: 4px; font-family: var(--font-led); font-size: 18px; color: var(--h-amber); }
.home .lang-switch { box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.6); }

.home-hero { position: relative; z-index: 2; padding: calc(56px + 7vh) clamp(20px, 7vw, 120px) 104px; max-width: 46rem; }
.home-title { margin: 0; display: flex; align-items: flex-start; gap: clamp(10px, 1.4vw, 20px); }
.home-title-ja {
  display: flex; flex-direction: column; align-items: center; gap: 0.32em; padding-top: 0.45em;
  font-size: clamp(14px, 1.5vw, 21px); font-weight: 700; line-height: 1; color: var(--h-amber);
}
.home-title-ja > span { display: block; }
.home-title-ja .v-rot { transform: rotate(90deg); }
.home-title-en {
  font-size: clamp(60px, min(10.5vw, 17vh), 156px); font-weight: 900; line-height: 0.84; letter-spacing: -0.035em;
  color: var(--h-ink); text-shadow: 0 4px 40px rgba(8, 10, 34, 0.55);
}
.home-tag { margin: clamp(18px, 3.2vh, 32px) 0 0; font-size: clamp(18px, min(1.85vw, 3.3vh), 26px); font-weight: 500; line-height: 1.32; color: var(--h-soft); }
.home-tag span { display: block; }
.home-cta { margin-top: clamp(20px, 3.6vh, 36px); display: flex; flex-wrap: wrap; gap: 12px; }
.home-play {
  display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  min-height: 64px; padding: 12px 34px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--h-green); color: var(--h-green-ink); font: inherit; font-size: 20px; font-weight: 800; text-align: left;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 14px 34px -14px rgba(128, 194, 65, 0.75);
  transition: background-color 0.15s, transform 0.1s;
}
.home-play small { font-size: 13px; font-weight: 600; opacity: 0.82; }
.home-play:hover { background: #91d455; }
.home-play:active { transform: translateY(1px); }
.home-second {
  min-height: 64px; padding: 0 24px; border-radius: 16px; cursor: pointer; font: inherit; font-size: 17px; font-weight: 700;
  border: 1.5px solid rgba(244, 242, 255, 0.42); background: rgba(14, 18, 48, 0.4); color: var(--h-ink);
}
.home-second:hover { border-color: var(--h-ink); }
.home-free { margin: 14px 0 0; font-size: 14px; color: var(--h-muted); }
.home-more ul { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 22px; }
.home-link {
  min-height: 44px; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; font-size: 15px; font-weight: 600;
  color: var(--h-soft); text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 6px; text-decoration-thickness: 2px;
}
.home-link:hover, .home-link[aria-expanded="true"] { color: var(--h-ink); text-decoration-color: var(--h-green); }
.home :is(.home-play, .home-second, .home-link, .home-close, .home-save, .home-lang-opt):focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* The viaduct: its rail is the route line, the stops sit on it like a line map. */
.home-viaduct {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; height: 72px;
  background: linear-gradient(#0b0e24, #06081a); border-top: 4px solid var(--h-green);
}
.home-route { list-style: none; margin: 0; padding: 0 clamp(16px, 7vw, 120px); display: flex; justify-content: space-between; position: relative; top: -12px; }
.home-route li { display: grid; justify-items: center; gap: 3px; min-width: 0; text-align: center; }
.home-stop { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--h-green); }
.home-route .is-last .home-stop { border-color: var(--h-landmark); }
.home-stop-name { font-size: 14px; font-weight: 700; color: var(--h-ink); white-space: nowrap; }
.home-route .is-last .home-stop-name { color: var(--h-amber); }
.home-stop-alt { font-size: 11.5px; color: var(--h-muted); white-space: nowrap; }

/* Dialogs over the scene: language choice, saves, how to play, settings, about. */
.home-dialog-wrap {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(6, 8, 24, 0.58); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.home-dialog {
  width: min(600px, 100%); max-height: min(82vh, 760px); overflow: auto; padding: 20px 22px 22px;
  background: var(--h-panel); color: var(--h-ink); border: 1px solid var(--h-line); border-radius: 20px;
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.75); animation: home-dialog-in 0.22s ease-out;
}
@keyframes home-dialog-in { from { opacity: 0; transform: translateY(8px); } }
.home-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.home-dialog-head h2 { margin: 0; font-size: 20px; }
.home-close {
  min-height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 700;
  border: 1px solid #3a4277; background: var(--h-panel-2); color: var(--h-ink);
}
.home-close:hover { border-color: var(--h-green); }
.home-dialog .how li > span:last-child > span { color: var(--h-muted); }
.home-dialog .about p { color: var(--h-soft); }
.home-dialog .about-v { font-family: var(--font-led); color: var(--h-amber); font-size: 18px; }
.home-dialog .set-row + .set-row { border-top-color: var(--h-line); }
.home-dialog .set-label { color: var(--h-muted); }
.home-dialog .seg-pick .btn:not(.is-on) { background: var(--h-panel-2); border-color: #3a4277; color: var(--h-ink); }
.home-dialog .seg-pick .btn.is-on { background: var(--h-green); border-color: var(--h-green); color: var(--h-green-ink); }
.home-saves { display: grid; gap: 8px; }
.home-save {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 52px; padding: 10px 12px;
  border: 1px solid var(--h-line); border-radius: 12px; background: var(--h-panel-2); color: var(--h-ink);
  text-align: left; cursor: pointer; font: inherit; font-size: 14px; line-height: 1.4;
}
.home-save small { color: var(--h-muted); }
button.home-save:hover:not(:disabled) { border-color: var(--h-green); }
.home-save:disabled { opacity: 0.55; cursor: not-allowed; }
.home-save.is-empty { display: block; background: transparent; border-style: dashed; color: var(--h-muted); cursor: default; }
.home-dialog-note { margin: 12px 0 0; font-size: 13px; color: var(--h-muted); }

/* First launch: the scene, then one question. Both languages are always shown. */
.home-lang { text-align: center; padding: 30px 26px 26px; width: min(560px, 100%); }
.home-lang-title { margin: 0; display: grid; gap: 4px; font-size: clamp(32px, 6vw, 46px); font-weight: 900; line-height: 1; }
.home-lang-title span[lang="ja"] { font-size: 0.42em; font-weight: 700; color: var(--h-amber); letter-spacing: 0.2em; }
.home-lang-ask { margin: 18px 0 18px; display: grid; gap: 2px; font-size: 17px; font-weight: 700; }
.home-lang-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.home-lang-opt {
  display: grid; justify-items: center; gap: 4px; padding: 24px 12px; border-radius: 16px; cursor: pointer; font: inherit;
  border: 2px solid var(--h-line); background: var(--h-panel-2); color: var(--h-ink);
}
.home-lang-opt b { font-size: clamp(24px, 5vw, 30px); font-weight: 900; }
.home-lang-opt small { font-size: 13px; color: var(--h-muted); }
.home-lang-opt:hover, .home-lang-opt.is-suggested { border-color: var(--h-green); }
.home-lang-note { margin: 18px 0 0; display: grid; gap: 2px; font-size: 12.5px; color: var(--h-muted); }

@media (max-width: 760px) {
  .home-far { height: 38vh; }
  .home-near { height: 25vh; }
  .home-tower { right: -16vw; bottom: 50px; height: 58vh; }
  .home-scrim { background: linear-gradient(180deg, rgba(9, 11, 32, 0.62) 0%, rgba(9, 11, 32, 0.38) 50%, rgba(9, 11, 32, 0.1) 75%); }
  .home-hero { padding: 84px 20px 112px; }
  .home-title-en { font-size: clamp(60px, 20vw, 104px); }
  .home-title-ja { font-size: 13px; }
  .home-tag { font-size: 19px; }
  .home-cta { flex-direction: column; align-items: stretch; }
  .home-play { align-items: center; text-align: center; width: 100%; }
  .home-second { min-height: 54px; }
  .home-more ul { gap: 0 18px; }
  .home-link { font-size: 14.5px; }
  .home-viaduct { height: 64px; }
  .home-route { padding: 0 10px; top: -9px; }
  .home-stop { width: 14px; height: 14px; border-width: 3px; }
  .home-stop-name { font-size: 12px; }
  .home-stop-alt { font-size: 10px; }
  .home-train { bottom: 67px; width: 520px; }
}
@media (min-width: 761px) and (max-height: 820px) {
  .home-hero { padding-top: 60px; padding-bottom: 96px; }
  .home-title-en { font-size: clamp(60px, min(10.5vw, 15vh), 140px); }
  .home-tower { height: 88vh; }
}
@media (max-width: 760px) and (max-height: 720px) {
  .home-hero { padding-top: 70px; padding-bottom: 100px; }
  .home-title-en { font-size: clamp(56px, min(18vw, 11vh), 92px); }
  .home-tag { margin-top: 14px; font-size: 17px; }
  .home-cta { margin-top: 18px; }
  .home-play { min-height: 56px; }
  .home-free { margin-top: 10px; font-size: 13px; }
  .home-more ul { margin-top: 8px; gap: 0 14px; }
  .home-link { min-height: 40px; font-size: 14px; }
}


.create { max-width: 820px; margin: 0 auto; display: grid; gap: 18px; background: var(--panel); border: 1px solid var(--rule); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.create h1 { margin: 0; font-size: 30px; font-weight: 900; }
.create-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.field { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > label, .field > legend { font-weight: 700; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 0; margin-bottom: 8px; }
.avatars { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-opt { position: relative; }
.avatar-opt input, .choice input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-opt span { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; border: 2px solid var(--rule); background: var(--panel-2); cursor: pointer; }
.avatar-opt.is-on span { border-color: var(--accent); background: var(--accent-soft); }
.avatar-opt:focus-within span, .choice:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.choices-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.choice { position: relative; display: grid; align-content: start; gap: 4px; padding: 12px 14px; border: 2px solid var(--rule); border-radius: 12px; background: var(--panel); cursor: pointer; }
.choice.is-on { border-color: var(--accent); background: var(--accent-soft); }
.choice-title { font-weight: 700; }
.choice-desc { font-size: 13.5px; color: var(--muted); }
.choice-extra { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.create-go { justify-self: start; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1099px) and (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(360px, 410px); }
  #mePanel { display: none; }
  #needsStrip { display: block; padding: 8px 16px 0; }
}
@media (max-width: 899px) {
  :root { --actionbar-h: 64px; }
  #game { display: block; height: auto; padding-bottom: calc(var(--tabbar-h) + var(--actionbar-h) + 16px + env(safe-area-inset-bottom, 0px)); }
  /* Header wraps into rows: identity + wallet, controls + language, then the hour and today's timetable. */
  .topbar { gap: 8px 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; }
  .brand { order: 1; }
  .clock { order: 2; }
  .wallet { order: 3; margin-left: auto; }
  .speed { order: 4; }
  .lang-switch { order: 5; margin-left: auto; }
  .phase-wrap { order: 6; }
  .dayline { order: 7; flex: 1 1 150px; padding-bottom: 0; }
  .brand-name, .phone-btn { display: none; }
  .clock .led-time { font-size: 24px; }
  .clock .led-day { display: none; }
  .dl-tick { display: none; }
  #needsStrip { display: block; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding: 8px 16px; border-bottom: 1px solid var(--rule); }
  .layout { display: block; padding: 12px 16px; }
  .panel, #mePanel, #mapPanel, #herePanel { display: none; overflow: visible; }
  body[data-view="me"] #mePanel, body[data-view="here"] #herePanel { display: block; }
  body[data-view="map"] #mapPanel { display: flex; }
  .sign { position: relative; }
  .cat { scroll-margin-top: 64px; }
  #mapWrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .map-svg { min-width: 680px; }
  /* The departure board slides up as a sheet over the map. */
  body[data-view="map"] #travelBoard:has(.board) {
    position: fixed; left: 8px; right: 8px; z-index: 25; max-height: 62vh; overflow: auto; border-radius: 16px;
    bottom: calc(var(--tabbar-h) + var(--actionbar-h) + 8px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -12px 40px -8px rgba(0, 0, 0, 0.55); animation: sheet-up 0.22s cubic-bezier(0.3, 0.7, 0.2, 1);
  }
  body[data-view="map"] #travelBoard .board { border-radius: 16px; }
  body[data-view="map"] #travelBoard .board::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: #3a423d; margin: -6px auto 2px; }
  #actionBar { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); z-index: 20; box-shadow: 0 -8px 20px -12px rgba(0, 0, 0, 0.5); }
  .ab { min-height: var(--actionbar-h); padding: 8px 12px 8px 16px; gap: 10px; }
  .ab-left { display: none; }
  .ab-stop { padding: 8px 10px; }
  #tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--panel); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #tabbar button { position: relative; display: grid; justify-items: center; align-content: center; gap: 1px; min-height: var(--tabbar-h); padding: 6px 4px; border: 0; background: none; font-size: 11.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
  #tabbar button span { font-size: 20px; line-height: 1.1; transition: transform 0.15s; }
  #tabbar button.is-on { color: var(--accent); }
  #tabbar button.is-on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  #tabbar button.is-on span { transform: translateY(-1px) scale(1.08); }
  #tabbar button:active span { transform: scale(0.9); }
  /* On phones, messages drop in from the top so they never cover the action bar or the board. */
  #toasts { top: calc(8px + env(safe-area-inset-top, 0px)); bottom: auto; left: 12px; right: 12px; width: auto; align-content: start; }
  .toast { animation-name: toast-drop; }
  .toast.is-out { transform: translateY(-10px); }
  .celebrate { top: 42%; }
  .board-row { grid-template-columns: auto auto auto 1fr; }
  .board-detail { grid-column: 1 / -1; }
  .board-go { grid-column: 4; grid-row: 1; justify-self: end; }
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0.4; } }
@media (max-width: 560px) {
  #phone { padding: 0; }
  .phone-device { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .brand-kanji { font-size: 22px; }
  .clock { padding: 3px 9px; gap: 6px; }
  .clock .led-date { display: none; }
  .clk-wx { font-size: 17px; }
  .speed .spd { min-width: 40px; padding: 6px 4px; }
  .lt-chip, .phase { font-size: 11px; padding: 2px 8px; }
  .ls-globe { display: none; }
  .lang-switch { padding: 3px; }
  .ls-track button { min-width: 44px; padding: 4px 9px; }
  .wallet-yen { font-size: 17px; }
  .create { padding: 16px; }
  .sign-name { font-size: 28px; }
  .sky { height: 72px; }
  .ab-skip-txt { display: none; }
  .ab-until { display: none; }
  .dl-next { display: none; }
}
@media (pointer: coarse) {
  .spd { min-height: 40px; }
  .ls-track button { min-height: 36px; }
  .act-row { min-height: 60px; }
  .jump-chip { min-height: 38px; }
  .tag { padding: 1px 8px; }
}
/* ── Day counter, holidays, autosave chip ───────────────────────────── */
.day-badge {
  align-self: center; font-family: var(--font-led); font-size: 13px; letter-spacing: 0.06em; white-space: nowrap;
  padding: 2px 8px; border-radius: 6px; background: var(--led); color: #1a1405; line-height: 1.3;
}
.clock[data-dow="6"] .led-date { color: #7cc0ff; }
.clock[data-dow="0"] .led-date, .clock[data-hol="1"] .led-date { color: #ff8a7e; }
.hol-chip { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: #3a1d1b; color: #ffb4a6; border: 1px solid #6b2a24; }
.save-chip { font-size: 11.5px; color: var(--board-muted); white-space: nowrap; padding: 2px 6px; border-radius: 6px; }
.save-chip.is-flash { animation: saved 1.6s ease-out; }
@keyframes saved { 0% { color: #9be37a; background: rgba(128, 194, 65, 0.22); } 100% { background: transparent; } }

/* The morning card */
.day-card {
  position: fixed; left: 50%; top: 120px; transform: translateX(-50%); z-index: 81; pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; gap: 14px; padding: 12px 18px 12px 12px; width: max-content; max-width: calc(100vw - 32px);
  border: 1px solid var(--led-dim); border-radius: 18px; background: var(--board); color: var(--board-ink); text-align: left;
  box-shadow: 0 24px 50px -18px rgba(0, 0, 0, 0.7); animation: cel-in 0.45s cubic-bezier(0.2, 1.4, 0.3, 1) both; font: inherit;
}
.day-card.is-out { opacity: 0; transform: translate(-50%, -10px); transition: opacity 0.35s, transform 0.35s; }
.dc-badge { flex: none; font-family: var(--font-led); font-size: 22px; letter-spacing: 0.06em; color: var(--led); background: #000; border: 1px solid var(--led-dim); border-radius: 10px; padding: 8px 12px; text-shadow: 0 0 10px rgba(255, 178, 30, 0.4); }
.dc-main { display: grid; gap: 2px; min-width: 0; }
.dc-main b { font-size: 17px; font-weight: 900; }
.dc-main span { color: var(--board-muted); font-size: 13.5px; }
.dc-main .dc-y { color: var(--board-ink); font-size: 12.5px; font-family: var(--font-led); }

/* ── Conversations & relationships ──────────────────────────────────── */
#sheet { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; background: var(--scrim); padding: 16px; }
#sheet.is-opening { animation: fade-in 0.15s ease-out; }
#sheet.is-opening .sheet-card { animation: phone-up 0.22s cubic-bezier(0.3, 0.7, 0.2, 1); }
.sheet-card { width: min(480px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border-radius: 18px; padding: 16px; display: grid; gap: 10px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6); }
.sheet-card p { margin: 0; }
.sheet-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.sheet-title h2 { margin: 0; font-size: 18px; }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.topic {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 6px; min-height: 52px; padding: 8px 10px;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--panel-2); cursor: pointer; text-align: left; font-weight: 700; font-size: 13.5px;
  transition: border-color 0.12s, transform 0.08s, background 0.12s;
}
.topic:hover { border-color: var(--accent); }
.topic:active { transform: scale(0.97); }
.topic-ic { font-size: 20px; text-align: center; }
.topic-name { min-width: 0; line-height: 1.25; hyphens: auto; overflow-wrap: break-word; }
.topic-mark { font-size: 13px; color: var(--muted); }
.topic.is-like { border-color: #ff6f9c; background: color-mix(in srgb, #ff6f9c 12%, var(--panel)); }
.topic.is-like .topic-mark { color: #e0336c; }
.topic.is-dislike { opacity: 0.7; }
.topic.is-dislike .topic-mark { color: var(--bad); }
.topic.is-last { border-style: dashed; }
.rel-meter { position: relative; display: block; height: 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--rule); overflow: hidden; }
.rel-meter i { display: block; height: 100%; background: linear-gradient(90deg, #ffb3c8, #ff5c8a); border-radius: inherit; }
.rel-meter b { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--panel); opacity: 0.9; }

/* Wallet (家計簿): this week's money by category */
.wl { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.wl-row { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13px; }
.wl-row > span:first-child { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-row > b { font-variant-numeric: tabular-nums; }
.wl-bar { display: block; height: 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--rule); overflow: hidden; }
.wl-bar i { display: block; height: 100%; border-radius: inherit; }
.wl-in .wl-bar i { background: var(--good); }
.wl-out .wl-bar i { background: var(--warn-fill, #e8a33d); }
.wl-in > b { color: var(--good); }
.wl-total { border-top: 1px solid var(--rule); padding-top: 8px; }
.rel-tag { border-color: #ffb3c8; color: #c2185b; }
.rel-tag.t0 { border-color: var(--rule); color: var(--muted); }
.rel-tag.t3, .rel-pill.t3 { background: #ff5c8a; border-color: #ff5c8a; color: #fff; }
.rel-pill.t2 { border-color: #ff8fb1; color: #c2185b; }
:root[data-theme="dark"] .rel-tag, :root[data-theme="dark"] .rel-pill.t2 { color: #ff9fbd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rel-tag, :root:not([data-theme="light"]) .rel-pill.t2 { color: #ff9fbd; } }
.line-card { align-items: start; }
.line-main { gap: 4px; }
.line-meter { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-top: 2px; }
.line-likes { display: flex; flex-wrap: wrap; gap: 4px; }
.topic-pill.is-like { border-color: #ff8fb1; }
.topic-pill.is-dislike { opacity: 0.7; }
.line-perk { font-size: 12.5px; color: var(--muted); }
.line-perk.is-on { color: #b07400; font-weight: 700; }
.line-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.line-card > .line-avatar { margin-top: 2px; }

/* ── Saves ──────────────────────────────────────────────────────────── */
.save-card.is-mine { border-color: var(--accent); }
.save-card.is-empty { opacity: 0.75; }
.save-sum { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 13.5px; line-height: 1.4; }
.save-av { font-size: 26px; text-align: center; }

/* Event cards: what kind of moment this is */
.ev-cat { justify-self: center; font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
:lang(ja) .ev-cat { letter-spacing: 0.04em; }
.ev-daily .ev-cat { background: var(--accent-soft); color: var(--good); }
.ev-tourist .ev-cat { background: color-mix(in srgb, var(--led) 22%, var(--panel)); color: #8a5a00; }
.ev-work .ev-cat { background: color-mix(in srgb, #1b74d1 15%, var(--panel)); color: #1b5fa8; }
.ev-social .ev-cat { background: color-mix(in srgb, #ff5c8a 15%, var(--panel)); color: #c2185b; }
:root[data-theme="dark"] .ev-tourist .ev-cat { color: var(--led); }
:root[data-theme="dark"] .ev-work .ev-cat { color: #8cc4ff; }
:root[data-theme="dark"] .ev-social .ev-cat { color: #ff9fbd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ev-tourist .ev-cat { color: var(--led); } :root:not([data-theme="light"]) .ev-work .ev-cat { color: #8cc4ff; } :root:not([data-theme="light"]) .ev-social .ev-cat { color: #ff9fbd; } }

@media (max-width: 899px) {
  #sheet { place-items: end stretch; padding: 0; }
  .sheet-card { width: 100%; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); max-height: 82vh; }
  #sheet.is-opening .sheet-card { animation-name: sheet-up; }
  .day-card { top: 42%; }
}
@media (max-width: 560px) {
  .save-chip { display: none; }
  .hol-chip { font-size: 11px; padding: 2px 8px; }
  .day-badge { font-size: 12px; padding: 2px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .sky-train { display: none; }
}

/* The morning card steps aside while the phone, a conversation or an event card is open. */
body:has(#phone:not([hidden])) .day-card, body:has(#sheet:not([hidden])) .day-card, body:has(#modal:not([hidden])) .day-card { display: none; }

/* Reduced motion: follows the system setting, or Settings → Animation → Reduced. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important;
}
/* With reduced motion the train waits at the platform instead of crossing. */
@media (prefers-reduced-motion: reduce) { .home-train { animation: none; transform: translateX(6vw); } }
:root[data-motion="reduce"] .home-train { animation: none; transform: translateX(6vw); }
