/* Door to Desk */
:root {
  --ground: #EDF0F2;
  --card: #FFFFFF;
  --ink: #16202B;
  --ink-2: #2C3742;
  --muted: #4A5663;
  --line: #E1E6EB;
  --track: #C9D2DB;
  --bar: #2B4C7E;
  --neg: #A3361A;
  --pos: #2F6B4F;
  --accent: #B8461E;
  --accent-soft: #F08A5D;
  --dark: #16202B;
  --dark-2: #1F2C3A;
  --sans: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--bar); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
}

/* 上の帯 */
.topbar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.clock:focus { outline: none; }
.clock { font-family: var(--mono); font-size: 15px; font-weight: 600; letter-spacing: .04em; }
.where { font-size: 13px; color: var(--muted); flex: 1; text-align: right; }
.lang { border: 1px solid var(--track); background: var(--card); border-radius: 16px; padding: 6px 12px; font-size: 12px; min-height: 32px; }

.screen { flex: 1; display: flex; flex-direction: column; gap: 20px; padding-top: 8px; animation: in .35s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }
.spacer { flex: 1; }

.heading { display: flex; flex-direction: column; gap: 6px; }
.kicker { margin: 0; font-size: 14px; color: var(--muted); }
h1 { margin: 0; font-size: 28px; line-height: 1.3; font-weight: 700; outline: none; }
.lead { margin: 0; font-size: 14px; line-height: 1.7; }
.muted { color: var(--muted); }
.small { font-size: 12px; margin: 0; }

.card { background: var(--card); border-radius: 16px; padding: 18px; }
.section-label { margin: 0 0 10px; font-size: 12px; color: var(--muted); letter-spacing: .08em; }
.section-label.strong { font-size: 14px; color: var(--ink); font-weight: 700; letter-spacing: 0; }

/* 人物 */
.who { display: flex; gap: 14px; align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 28px; background: #DCE3EA; color: var(--bar); display: grid; place-items: center; flex-shrink: 0; }
.name { font-size: 20px; font-weight: 700; }
.who .muted { font-size: 14px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 16px 0 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; }
.note { margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.7; color: var(--ink-2); }

/* ステータス */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--card); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.stat-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.stat-label { font-size: 13px; color: var(--muted); }
.meter { position: relative; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter .gain { position: absolute; top: 0; bottom: 0; background: #3FA372; animation: gain 1.6s ease .3s both; }
@keyframes gain { from { opacity: 0; } to { opacity: 1; } }
.meter > div { height: 100%; background: var(--bar); border-radius: 3px; transition: width .5s ease; }
.delta { font-size: 12px; font-weight: 700; }
.delta.down { color: var(--neg); }
.delta.up { color: var(--pos); }
.num { font-family: var(--mono); font-size: 16px; font-weight: 600; }
.num.neg { color: var(--neg); }

/* ボタン */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; border-radius: 28px; border: 0; font-size: 17px; font-weight: 700; text-decoration: none; padding: 0 20px; width: 100%; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.dark { background: var(--dark); color: #fff; }
.btn.ghost { background: var(--card); color: var(--ink); min-height: 48px; font-size: 15px; }
.btn.sub { background: var(--card); color: var(--ink); min-height: 48px; font-size: 15px; font-weight: 500; }
.btn.ghost-dark { background: transparent; border: 1.5px solid var(--ink); min-height: 52px; font-size: 16px; }
.link { align-self: center; background: none; border: 0; text-decoration: underline; color: var(--bar); font-size: 14px; padding: 12px; min-height: 44px; }
.pill { font-size: 12px; font-weight: 700; color: #fff; background: var(--accent); padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.pill.big { font-size: 15px; padding: 6px 16px; border-radius: 16px; }
.pill.ok { background: var(--pos); }
.flash { margin: 0; font-size: 14px; color: var(--pos); font-weight: 700; }
.snoozed { display: flex; flex-direction: column; gap: 10px; animation: in .35s ease both; }
.meter > div { transition: width .8s ease; }
@media (prefers-reduced-motion: reduce) { .meter > div { transition: none; } }

/* 手段 */
.modes { display: flex; flex-direction: column; gap: 12px; }
.mode { display: flex; flex-direction: column; gap: 12px; text-align: left; background: var(--card); border: 2px solid var(--card); border-radius: 16px; padding: 16px 18px; transition: border-color .15s; }
.mode:hover, .mode.usual { border-color: var(--accent); }
.mode-head { display: flex; align-items: center; gap: 12px; }
.mode-icon { display: grid; place-items: center; }
.mode-name { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.mode-name strong { font-size: 17px; }
.mode-name .muted { font-size: 13px; }
.mode-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-size: 14px; font-weight: 700; }
.mode-facts small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.warn { font-size: 12px; color: var(--neg); }

/* 移動中 */
.route { padding: 18px 16px 14px; }
.track { position: relative; height: 4px; background: var(--track); border-radius: 2px; margin: 5px 7px 0; }
.track .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 2px; transition: width .6s ease; }
.stops { list-style: none; margin: -9px 0 0; padding: 0; display: flex; justify-content: space-between; }
.stops li { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.stops li:first-child { align-items: flex-start; }
.stops li:last-child { align-items: flex-end; }
.stops .dot { width: 14px; height: 14px; border-radius: 7px; background: var(--card); border: 2px solid var(--track); }
.stops .done .dot { background: var(--accent); border-color: var(--accent); }
.stops .here .dot { border: 3px solid var(--accent); }
.stops .here { color: var(--ink); font-weight: 700; }
.stop { white-space: nowrap; }

.crowd { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.crowd-grid { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 5px; }
.crowd-grid span { aspect-ratio: 1; border-radius: 50%; background: var(--line); }
.crowd-grid span.on { background: #7D8A97; }
.crowd-grid span.me { background: var(--accent); }
.seat-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.seat-grid span { height: 20px; border-radius: 5px 5px 3px 3px; background: #7D8A97; }
.seat-grid span.me { background: var(--accent); }

.feed { display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.line { margin: 0; font-size: 15px; line-height: 1.8; color: var(--muted); }
.line.latest { color: var(--ink); font-size: 16px; }
.line.event { color: var(--ink); }
.alert { background: var(--dark); color: #fff; border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.alert-head { display: flex; align-items: center; gap: 8px; color: #F2B544; font-size: 13px; font-weight: 700; letter-spacing: .06em; }
.alert p { margin: 0; font-size: 16px; line-height: 1.6; font-weight: 700; }
.alert .source { display: flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 400; color: #C9D2DB; }

.question { background: var(--card); border-radius: 16px; padding: 16px 18px; border: 2px solid var(--accent); }
.question p { margin: 0; font-size: 16px; line-height: 1.7; font-weight: 700; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--card); border: 0; border-radius: 14px; padding: 14px 16px; min-height: 64px; }
.choice > span { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.choice strong { font-size: 16px; }
.choice .muted { font-size: 13px; }

/* 到着 */
.arrival { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 0 4px; }
.big-time { font-family: var(--mono); font-size: 72px; font-weight: 600; line-height: 1; outline: none; }
.facts4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.facts4 small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.facts4 .num { font-size: 20px; }
.story { margin: 0; font-size: 17px; line-height: 1.8; font-weight: 700; }

/* ふり返り */
.sharecard { margin: 0; border-radius: 14px; overflow: hidden; background: var(--dark); aspect-ratio: 1200 / 630; }
.sharecard img { display: block; width: 100%; height: 100%; }
.share-actions { display: flex; flex-direction: column; gap: 10px; }
.row2 { display: flex; gap: 10px; }
.row2 .btn { flex: 1; }
.lifetime { margin: 0; font-size: 14px; line-height: 1.8; color: var(--ink-2); }
.cmp { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.cmp:first-of-type { margin-top: 0; }
.cmp-head { display: flex; justify-content: space-between; font-size: 13px; }
.cmp.locked .cmp-head { color: var(--muted); }
.cmp-play { font-size: 13px; font-weight: 700; color: var(--bar); }
.cmp-bar.empty { background: var(--line); }
.cmp-bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.cmp-bar > div { height: 100%; background: var(--accent); border-radius: 5px; }
.cmp.locked .cmp-bar { background: repeating-linear-gradient(135deg, var(--line) 0 6px, #F4F6F8 6px 12px); }
.fineprint { margin: 0; font-size: 11px; color: var(--muted); text-align: center; }
.load-error { margin: 40vh 0 0; text-align: center; font-size: 14px; line-height: 1.8; color: var(--muted); }

/* 目覚めた場所 */
#app[data-screen="reveal"] { max-width: none; padding: 0; background: var(--dark); }
body:has(#app[data-screen="reveal"]) { background: var(--dark); }
.reveal { min-height: 100vh; min-height: 100dvh; width: 100%; color: #fff; display: flex; flex-direction: column; padding: 20px 24px calc(28px + env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto; box-sizing: border-box; }
.reveal-top { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.reveal-brand { font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: .22em; }
.lang.dark { background: transparent; color: #fff; border-color: #3A4654; }
.reveal-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.reveal-kicker { margin: 0 0 18px; font-size: 15px; color: #A9B6C3; }
.reveal-country { margin: 0; font-size: 20px; font-weight: 700; color: var(--city); letter-spacing: .04em; }
.reveal-city { margin: 0; font-size: 56px; line-height: 1.1; font-weight: 700; word-break: keep-all; overflow-wrap: anywhere; }
.reveal.spinning .reveal-city { color: #6B7987; }
.reveal.done .reveal-city { animation: land .5s ease both; }
@keyframes land { 0% { transform: scale(.94); opacity: .4; } 100% { transform: none; opacity: 1; } }
.reveal-meta { display: flex; gap: 28px; margin-top: 28px; padding-top: 20px; border-top: 1px solid #3A4654; opacity: 0; transition: opacity .4s ease .2s; }
.reveal.done .reveal-meta { opacity: 1; }
.reveal-meta > span { display: flex; flex-direction: column; gap: 4px; font-size: 18px; font-weight: 700; }
.reveal-meta small { font-size: 12px; color: #A9B6C3; font-weight: 400; }
.reveal-meta .num { font-size: 22px; }
.reveal-btn { background: var(--city); color: var(--dark); opacity: 0; pointer-events: none; transition: opacity .4s ease .4s; }
.reveal.done .reveal-btn { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .reveal.done .reveal-city { animation: none; } .reveal-meta, .reveal-btn { transition: none; } }

/* 人物紹介の上の国バッジ */
.city-badge { margin: 0; display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; font-size: 14px; font-weight: 700; color: var(--ink); background: var(--card); padding: 6px 14px 6px 10px; border-radius: 16px; }
.city-badge .dot { width: 10px; height: 10px; border-radius: 5px; background: var(--accent-soft); }
