/* 旅先ルーレットの見た目。
   ここから「旅先ルーレット（段1 で新しく書いた分）」の見出しまでは、trade-lab の骨組み
   （web/ma-cross-lab.html の <style>）を写し、トレード固有の部品と外のフォントを削り、
   字体を端末の物に、下のタブの文字を13px にした（設計書 8.4）。
   段2 で、下のタブの列の数をタブの数に合わせる形にした（段2 は2つ、段5 で4つ）。
   色は変数だけを使い、明るい表示と暗い表示の両方を持つ。 */
:root {
  color-scheme: light;
  --ground: #FFFFFF; --sunk: #F2F4F8; --raised: #FFFFFF; --stage: #E7EBF1;
  --line: #DCE2EB; --line-soft: #EAEEF4;
  --ink: #0E1520; --ink-2: #4C5866; --ink-3: #69758A;
  --gold: #8A5E12; --gold-line: #B07C1C; --gold-wash: rgba(176, 124, 28, .10);
  --indigo: #1F4C79; --indigo-line: #2E6BA8; --indigo-wash: rgba(46, 107, 168, .10);
  --beni: #97241D;
  --focus: #2E6BA8; --bar: rgba(255, 255, 255, .94); --scrim: rgba(10, 14, 20, .40);
  --behind: rgba(10, 14, 20, .10);
  --shadow-sheet: 0 -10px 40px rgba(10, 14, 20, .18);
  --shadow-frame: 0 30px 80px -30px rgba(10, 14, 20, .45);
  --ease: cubic-bezier(.32, .72, 0, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0C1016; --sunk: #151B24; --raised: #151B24; --stage: #06080C;
    --line: #2A323E; --line-soft: #212832;
    --ink: #F0F3F7; --ink-2: #AAB4C2; --ink-3: #8B96A6;
    --gold: #E3B05C; --gold-line: #BD8424; --gold-wash: rgba(189, 132, 36, .14);
    --indigo: #86B4E0; --indigo-line: #4A8FDB; --indigo-wash: rgba(74, 143, 219, .14);
    --beni: #F0897E;
    --focus: #86B4E0; --bar: rgba(12, 16, 22, .94); --scrim: rgba(0, 0, 0, .58);
    --behind: rgba(0, 0, 0, .35);
    --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, .6);
    --shadow-frame: 0 30px 80px -30px rgba(0, 0, 0, .9);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0C1016; --sunk: #151B24; --raised: #151B24; --stage: #06080C;
  --line: #2A323E; --line-soft: #212832;
  --ink: #F0F3F7; --ink-2: #AAB4C2; --ink-3: #8B96A6;
  --gold: #E3B05C; --gold-line: #BD8424; --gold-wash: rgba(189, 132, 36, .14);
  --indigo: #86B4E0; --indigo-line: #4A8FDB; --indigo-wash: rgba(74, 143, 219, .14);
  --beni: #F0897E;
  --focus: #86B4E0; --bar: rgba(12, 16, 22, .94); --scrim: rgba(0, 0, 0, .58);
  --behind: rgba(0, 0, 0, .35);
  --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, .6);
  --shadow-frame: 0 30px 80px -30px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--stage); color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* ── 枠：スマホでは全画面、広い画面では端末の形で中央に ── */
.stage { height: 100dvh; display: grid; place-items: center; }
.app {
  position: relative; width: 100%; height: 100dvh; overflow: hidden;
  background: var(--ground); display: flex; flex-direction: column;
}
@media (min-width: 720px) and (min-height: 700px) {
  .stage { padding-inline: 16px; }
  .app {
    width: 400px; height: min(860px, calc(100dvh - 48px));
    border-radius: 34px; border: 1px solid var(--line); box-shadow: var(--shadow-frame);
  }
}
.viewport { position: relative; flex: 1; overflow: hidden; }

.layer { position: absolute; inset: 0; background: var(--ground); will-change: transform; }
.layer[hidden] { display: none; }
.layer::after {
  content: ""; position: absolute; inset: 0; background: var(--behind);
  opacity: 0; pointer-events: none; transition: opacity 360ms var(--ease);
}
.scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.layer.root .scroll { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.layer.pushed .scroll { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

.layer.pushed { transform: translateX(100%); transition: transform 360ms var(--ease); box-shadow: -12px 0 30px rgba(10, 14, 20, .10); }
.layer.pushed.in { transform: translateX(0); }
.layer.behind { transform: translateX(-24%); transition: transform 360ms var(--ease); }
.layer.root:not(.behind) { transition: transform 360ms var(--ease); }
.layer.behind::after { opacity: 1; }
.layer.enter { animation: tab-in 180ms ease-out; }
@keyframes tab-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── 上のバー ── */
.bar {
  position: sticky; top: 0; z-index: 5; background: var(--bar);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line-soft);
  display: grid; grid-template-columns: 88px 1fr 88px; align-items: center;
  min-height: 52px; padding: 0 8px; padding-top: env(safe-area-inset-top);
}
.bar .bar-title { font-size: 16px; font-weight: 700; margin: 0; text-align: center; line-height: 1.3; }
.bar-back {
  justify-self: start; border: 0; background: none; color: var(--indigo); font-size: 16px; font-weight: 500;
  padding: 10px 8px; min-height: 44px; cursor: pointer; touch-action: manipulation;
}
.bar-back:active { opacity: .5; }
.bar-large { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 14px 18px 10px; padding-top: calc(14px + env(safe-area-inset-top)); }
.bar-large .bar-title { font-size: 28px; text-align: left; letter-spacing: .01em; }
.bar-eyebrow { margin: 0; font-size: 13px; font-weight: 500; color: var(--ink-3); }

.content { padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 20px; }

/* ── 押したときの反応 ── */
.tap { cursor: pointer; touch-action: manipulation; transition: transform 120ms ease, background-color 120ms ease; }
.tap:active { transform: scale(.985); background: var(--sunk); }

/* ── 大きな数字 ── */
.hero { background: var(--sunk); border-radius: 18px; padding: 22px 18px 20px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.hero-label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.hero-value { font-size: clamp(44px, 14vw, 56px); font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.hero.small .hero-value { font-size: 38px; }
.hero-say { font-size: 14px; color: var(--ink-2); }

/* ── 行のリスト ── */
.group { display: flex; flex-direction: column; gap: 8px; }
.group-title { margin: 0 4px; font-size: 13px; font-weight: 700; color: var(--ink-3); letter-spacing: .02em; }
.list, .form-card { background: var(--raised); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 14px 13px 16px; min-height: 56px; border: 0; background: var(--raised);
  border-bottom: 1px solid var(--line-soft);
}
.list > .row:last-child, .row.in-card { border-bottom: 0; }
.row.in-card { border-top: 1px solid var(--line-soft); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 16px; font-weight: 500; line-height: 1.45; }
.row-sub { font-size: 13px; color: var(--ink-3); line-height: 1.5; }
.row-value { font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; white-space: nowrap; }
.chev { color: var(--ink-3); font-size: 22px; line-height: 1; margin-left: 2px; }

.caution { margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.75; padding: 2px 4px; }
.caution b { color: var(--ink); font-weight: 700; margin-right: 4px; }
.hint { margin: -8px 4px 0; font-size: 13px; color: var(--ink-3); line-height: 1.6; }
.placeholder { text-align: center; color: var(--ink-2); padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.placeholder p { margin: 0; font-size: 15px; }
.notice { border: 1px solid var(--line); border-left: 4px solid var(--beni); border-radius: 14px; background: var(--raised); padding: 14px 16px; font-size: 14px; line-height: 1.75; overflow-wrap: anywhere; }
.notice b { display: block; color: var(--beni); margin-bottom: 4px; }
.notice span { display: block; color: var(--ink-2); font-size: 13px; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 50px; padding: 12px 18px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--raised); font-size: 16px; font-weight: 700;
  cursor: pointer; touch-action: manipulation; position: relative;
}
.placeholder .btn { width: auto; min-width: 180px; }
.btn:active { transform: scale(.98); background: var(--sunk); }
.btn-primary { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.btn-primary:active { background: var(--ink-2); }

/* ── 条件 ── */
.form-card { display: flex; flex-direction: column; }
.field { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.form-card > .field:last-of-type { border-bottom: 0; }
.field-label { font-size: 14px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--raised); border-radius: 999px; padding: 8px 16px; min-height: 42px; font-size: 14px; font-weight: 500; cursor: pointer; touch-action: manipulation; }
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--indigo-wash); border-color: var(--indigo-line); color: var(--indigo); font-weight: 700; }
.help { margin: 0; font-size: 13px; color: var(--ink-3); }

.actions { display: flex; flex-direction: column; gap: 10px; }

/* ── 下のタブ ── */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--bar); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line-soft); padding-bottom: env(safe-area-inset-bottom);
  transition: transform 360ms var(--ease);
}
.app.has-stack .tabbar { transform: translateY(110%); }
.tab { position: relative; border: 0; background: none; color: var(--ink-3); font-size: 13px; font-weight: 500; padding: 8px 2px 9px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; touch-action: manipulation; }
.tab svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 160ms ease; }
.tab:active svg { transform: scale(.88); }
.tab[aria-selected="true"] { color: var(--indigo); font-weight: 700; }

/* ── シート・トースト ── */
.scrim { position: absolute; inset: 0; z-index: 30; background: var(--scrim); opacity: 0; transition: opacity 300ms var(--ease); }
.scrim.open { opacity: 1; }
.scrim[hidden], .sheet[hidden] { display: none; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 80%;
  background: var(--ground); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform 320ms var(--ease);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.sheet.open { transform: translateY(0); }
.sheet-grab { padding: 10px 16px 6px; touch-action: none; cursor: grab; }
.sheet-grab::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-title { margin: 0; font-size: 17px; font-weight: 700; text-align: center; }
.sheet-body { overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.sheet-option { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--raised); padding: 12px 16px; min-height: 64px; }
.sheet-option .row-title { font-size: 18px; font-weight: 600; }
.sheet-option.is-current { border-color: var(--indigo-line); background: var(--indigo-wash); }
.check { width: 20px; color: var(--indigo); font-size: 18px; font-weight: 700; text-align: center; }

.toast {
  position: absolute; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: calc(100% - 32px); transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--ground); border-radius: 999px; padding: 10px 18px;
  font-size: 14px; font-weight: 500; text-align: center; transition: opacity 200ms ease, transform 260ms var(--ease);
}
.app.has-stack .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ── 旅先ルーレット（ここから下は段1 で新しく書いた分） ── */

/* 候補の数（大きな数字の下の1行）。本文なので16px */
.count-say { margin: 0; font-size: 16px; color: var(--ink-2); }
.hero p { margin: 0; }

/* [回す]は高さ56px・幅いっぱい（設計書 5.3） */
.btn-spin { min-height: 56px; font-size: 18px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:active { transform: none; }

/* スロット: 高さ1行の窓の中で、名前を並べた帯が縦に動く。
   帯の高さが「名前の数 × 1行」になるよう、行の高さは --reel-row の1か所で決める */
.slot { --reel-row: 56px; display: flex; flex-direction: column; gap: 10px; }
.reel { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 12px; }
.reel-label { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.reel-window {
  height: var(--reel-row); overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: var(--sunk);
}
.reel-band { list-style: none; margin: 0; padding: 0; will-change: transform; }
.reel-item {
  height: var(--reel-row); line-height: var(--reel-row); padding: 0 14px; text-align: center;
  font-size: 26px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 結果のカード */
/* 結果の枠は aria-live。空の間も隠さない（display: none にすると、中身が入っても読み上げないことがある） */
.result { display: flex; flex-direction: column; gap: 12px; }
.result-card { background: var(--raised); border: 1px solid var(--gold-line); border-radius: 18px; overflow: hidden; }
.result-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line-soft); }
.result-pref { margin: 0; font-size: 14px; font-weight: 700; color: var(--gold); }
.result-name {
  margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px;
  font-size: 30px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere;
}
.result-kana { font-size: 16px; font-weight: 500; color: var(--ink-2); }
.result-link { color: var(--indigo); text-decoration: none; }
.result-link .row-title { flex: 1; min-width: 0; }
.result-links > .result-link:last-child { border-bottom: 0; }

/* ── ここから下は段2 で新しく書いた分 ── */

/* hidden 属性は、display を書いた部品（.btn・.tabbar など）でも必ず隠す */
[hidden] { display: none !important; }

/* 出発地が無い間の案内のカード */
.guide-card {
  display: flex; flex-direction: column; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--line); border-left: 4px solid var(--indigo-line); border-radius: 14px;
  background: var(--raised);
}
.guide-text { margin: 0; font-size: 16px; line-height: 1.7; }

/* 泊数のボタン: 4つを横に並べ、2行目に距離の目安（390px 幅で1つ約85px） */
.nights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.nights-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 56px; padding: 6px 2px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--raised); line-height: 1.3; cursor: pointer; touch-action: manipulation;
}
.nights-btn:active { transform: scale(.96); }
.nights-name { font-size: 16px; font-weight: 700; white-space: nowrap; }
.nights-range { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.nights-btn[aria-pressed="true"] { background: var(--indigo-wash); border-color: var(--indigo-line); color: var(--indigo); }
.nights-btn[aria-pressed="true"] .nights-range { color: var(--indigo); }
.nights-btn.is-locked { opacity: .45; }
.nights-btn:disabled { opacity: .7; cursor: default; }
.nights-btn:disabled:active { transform: none; }
.note { margin: 0 4px; font-size: 13px; color: var(--ink-2); line-height: 1.6; }

/* 候補が0のとき、[回す]の代わりに出す案内 */
.empty-card { display: flex; flex-direction: column; gap: 10px; }
.empty-title { margin: 0 4px; font-size: 18px; font-weight: 700; }
.relax-count { font-size: 16px; font-weight: 600; color: var(--indigo); }

/* 結果の方角と距離 */
.result-direction { margin: 6px 0 0; font-size: 16px; color: var(--ink-2); }

/* 設定の画面の説明 */
.group > .help { margin: 0 4px; line-height: 1.6; }

/* データについて（設定の重なる画面）。出典のリンクは1行ずつ、押せる高さ44px 以上 */
.about { display: flex; flex-direction: column; gap: 16px; }
.about-source {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--raised); border: 1px solid var(--line); border-radius: 16px;
}
.about-source p { margin: 0; padding: 14px 16px 10px; font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.about-link {
  display: flex; align-items: center; min-height: 48px; padding: 10px 16px;
  border-top: 1px solid var(--line-soft); color: var(--indigo); font-size: 14px; line-height: 1.5;
  overflow-wrap: anywhere;
}
.about-note { margin: 0 4px; font-size: 14px; line-height: 1.7; color: var(--ink-2); overflow-wrap: anywhere; }
.about-note b { color: var(--ink); }

/* トースト: 長い文は折り返す（幅は中身に合わせ、画面の幅 − 32px まで） */
.toast { width: max-content; border-radius: 16px; line-height: 1.6; }

/* ── ここから下は段3 で新しく書いた分 ── */

/* ルーレットの画面の「条件のまとめ」（押すと条件のシート） */
.cond-summary .row-title { font-weight: 600; overflow-wrap: anywhere; }
.cond-summary:disabled { opacity: .6; cursor: default; }
.cond-summary:disabled:active { transform: none; background: var(--raised); }

/* 条件のシート。選ぶボタンは押せる高さ44px 以上・本文16px（骨組みの .chip は 42px・14px） */
.cond-sheet { display: flex; flex-direction: column; gap: 16px; padding-bottom: 8px; }
.cond-sheet .chip { min-height: 44px; font-size: 16px; padding: 8px 18px; }
.cond-sheet .field .help { line-height: 1.6; }
.cond-count { margin: 0 4px; font-size: 18px; font-weight: 700; }

/* 候補の県（県名と候補の数。2列） */
.pref-counts {
  list-style: none; margin: 0; padding: 8px 14px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 16px;
}
.pref-item { display: flex; justify-content: space-between; gap: 8px; font-size: 16px; line-height: 1.9; }
.pref-name { min-width: 0; overflow-wrap: anywhere; }
.pref-count { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.pref-none { grid-column: 1 / -1; font-size: 16px; color: var(--ink-2); }

/* 結果の根拠の印（宿・冬）。一目で見る数なので本文と同じ16px */
.result-facts { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; }
.fact {
  padding: 4px 12px; border-radius: 12px; background: var(--gold-wash); color: var(--ink);
  font-size: 16px; line-height: 1.5; overflow-wrap: anywhere;
}

/* ── ここから下は段4 で新しく書いた分 ── */

/* 結果の駅の名前（行き方の手がかり。本文16px）と、その下の小さな注（13px） */
.result-stations { margin: 10px 0 0; font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.result-note { margin: 4px 0 0; font-size: 13px; line-height: 1.6; color: var(--ink-2); overflow-wrap: anywhere; }

/* ── ここから下は段5 で新しく書いた分 ── */

/* 結果の[行った]・[行きたい]（2つを横に並べる。押せる高さ44px 以上・本文16px）。
   印が付いている間（aria-pressed="true"）は色を変え、✓ を出す */
.result-marks {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.mark-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--raised); font-size: 16px; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.mark-btn:active { transform: scale(.97); }
.mark-btn[aria-pressed="true"] { background: var(--indigo-wash); border-color: var(--indigo-line); color: var(--indigo); }
.mark-btn[aria-pressed="false"] .mark-check { display: none; }

/* 空のときの文（当たりタブ・行った所タブ）。本文なので16px */
.empty-note { margin: 0 4px; font-size: 16px; line-height: 1.7; color: var(--ink-2); }

/* 行った所タブの「行った3 / 179」（都道府県の行の右） */
.visited-count { font-size: 16px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* その県の市町村の一覧の上の「行った3 / 179」 */
.visited-note { margin: 0 4px; font-size: 16px; font-weight: 700; }
.visited-row[aria-pressed="true"] { background: var(--indigo-wash); }

/* 設定の「最後に書き出した日」の日付（見出しの下の行） */
.row-detail { font-size: 16px; color: var(--ink-2); line-height: 1.5; }
