:root {
  --bg: #f4f6fb; --card: #fff; --ink: #1d2433; --sub: #5c6578; --line: #dde2ec;
  --brand: #10306b; --accent: #f39700; --blue: #2f7de1; --red: #e0463c; --yellow: #f2c230; --ok: #1a9b55;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; line-height: 1.7; -webkit-text-size-adjust: 100%; }
a { color: #1f5fbf; }
.site-header { background: var(--brand); padding: 8px 16px; }
.logo { color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo small { font-weight: 500; font-size: 12px; opacity: .8; }
.logo .mark { background: var(--accent); color: #fff; border-radius: 8px; width: 28px; height: 28px; display: inline-grid; place-items: center; font-size: 16px; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; }
h1 { font-size: 22px; line-height: 1.4; margin: 8px 0; }
h2 { font-size: 18px; }
.lead { color: var(--sub); }
.step { font-weight: 700; margin: 20px 0 8px; }
.small { font-size: 12px; color: var(--sub); }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 10px 16px; font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.big { display: block; width: 100%; padding: 14px; font-size: 17px; margin: 16px 0; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .4; cursor: default; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 8px; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit; color: var(--ink); }
.seg button small { display: block; font-size: 11px; color: var(--sub); font-weight: 500; }
.seg button.on { border-color: var(--accent); background: #fff6e8; }
.slots { display: grid; gap: 8px; }
.slot { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.slot input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 16px; font-family: inherit; }
.slot button { width: 64px; border: 0; border-radius: 8px; padding: 8px 0; font-weight: 700; cursor: pointer; font-family: inherit; }
.slot.you button { background: var(--accent); color: #fff; }
.slot.cpu button { background: #dfe6f3; color: var(--brand); }
.slot.off { opacity: .5; }
.slot.off button { background: #eee; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 4px; flex: none; }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff6e8; border: 1px solid #f5d39a; border-radius: 12px; padding: 12px; margin: 12px 0; }
.resume span { display: block; font-size: 12px; color: var(--sub); }
.howto { background: #fff; border-radius: 12px; padding: 4px 16px 8px; margin: 16px 0; border: 1px solid var(--line); }
.howto li { margin-bottom: 8px; }
.chip { display: inline-block; padding: 0 6px; border-radius: 6px; font-size: 12px; font-weight: 700; color: #fff; }
.chip.blue { background: var(--blue); } .chip.red { background: var(--red); } .chip.yellow { background: var(--yellow); color: #533; }
.ad-slot:empty { display: none; }
.site-footer { text-align: center; padding: 24px 16px 40px; font-size: 13px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }

/* ---------- ゲーム画面 ---------- */
body.in-game { overflow: hidden; }
body.in-game .site-header { display: none; }
.game { position: fixed; inset: 0; display: flex; flex-direction: column; background: #eef1f6; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--brand); color: #fff; padding-top: max(6px, env(safe-area-inset-top)); }
.when { font-size: 13px; white-space: nowrap; }
.when b { font-size: 18px; }
.when small { opacity: .7; }
.dest { flex: 1; min-width: 0; background: rgba(255,255,255,.12); border-radius: 8px; padding: 2px 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.dest small { font-weight: 500; margin-left: 6px; opacity: .85; }
.icon-btn { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 0 6px; }
.map-wrap { position: relative; flex: 1; min-height: 0; }
#map { width: 100%; height: 100%; display: block; touch-action: none; background: #f8f9fb; user-select: none; -webkit-user-select: none; }
.map-tools { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.map-tools button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.92); font-size: 18px; font-weight: 700; cursor: pointer; color: var(--brand); }
.walk { stroke: #aab; stroke-width: 3; stroke-dasharray: 3 4; }
.node { cursor: pointer; }
.node .dot { fill: #fff; stroke: #333; stroke-width: 2.5; }
.node.blue .dot { fill: var(--blue); stroke: #1b4f96; }
.node.red .dot { fill: var(--red); stroke: #8c241d; }
.node.yellow .dot { fill: var(--yellow); stroke: #a17d0b; }
.node .label { font-size: 12px; text-anchor: middle; fill: #222; paint-order: stroke; stroke: #fff; stroke-width: 3.5px; stroke-linejoin: round; font-weight: 700; pointer-events: none; }
.node.prop .label { font-size: 13px; }
#map.far .node:not(.major):not(.cand):not(.is-dest) .label { display: none; }
#map.far .node.major .label { font-size: 22px; stroke-width: 5px; }
#map.very-far .node .label { display: none; }
#map.very-far .node.is-dest .label, #map.very-far .node.cand .label { display: block; font-size: 30px; }
.node.cand .dot { stroke: #ff7a00; stroke-width: 5; animation: pulse 0.9s ease-in-out infinite alternate; }
.node.cand .label { fill: #c24f00; }
@keyframes pulse { from { r: 9; } to { r: 14; } }
.destmark circle { fill: none; stroke: #ff3b30; stroke-width: 4; stroke-dasharray: 6 4; }
.flagtxt { font-size: 22px; pointer-events: none; }
.token { pointer-events: none; transition: transform .15s; }
.token circle { stroke: #fff; stroke-width: 3; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.token text { fill: #fff; font-size: 12px; font-weight: 800; text-anchor: middle; }
.token.active circle { stroke: #ffde59; stroke-width: 4; }
.token .ghost { font-size: 18px; }
.panel { background: #fff; border-top: 1px solid var(--line); padding: 8px 8px max(10px, env(safe-area-inset-bottom)); max-height: 52vh; overflow-y: auto; }
.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 6px; }
.pl { border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 8px; padding: 3px 8px; font-size: 12px; line-height: 1.45; cursor: pointer; }
.pl.on { background: #fff8e6; border-color: #f5c66b; border-left-color: var(--c); }
.pl .dot { background: var(--c); }
.pl-name { font-weight: 700; display: flex; align-items: center; }
.pl-name small { margin-left: auto; color: var(--sub); }
.pl-money { font-size: 15px; font-weight: 800; }
.pl-money.neg { color: var(--red); }
.pl-sub { color: var(--sub); font-size: 11px; }
.action { margin-top: 8px; }
.msg { margin: 4px 0 8px; }
.action .btn.big { margin: 6px 0; }
.cards, .cands { display: flex; flex-wrap: wrap; gap: 6px; }
.card-btn, .cand-btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 10px; font-weight: 700; font-family: inherit; font-size: 14px; cursor: pointer; text-align: left; color: var(--ink); }
.card-btn small, .cand-btn small { display: block; font-weight: 500; font-size: 11px; color: var(--sub); }
.card-btn { background: #fffbe6; border-color: #f0d77a; }
.cand-btn { border-left: 5px solid #ccc; }
.cand-btn.blue { border-left-color: var(--blue); } .cand-btn.red { border-left-color: var(--red); } .cand-btn.yellow { border-left-color: var(--yellow); } .cand-btn.prop { border-left-color: #333; }
.dice { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 54px; line-height: 1; padding: 6px 0; }
.dice b { font-size: 34px; margin-left: 8px; color: var(--accent); }
.dice.rolling span { animation: shake .12s infinite alternate; }
@keyframes shake { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }

/* ---------- ダイアログ ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,20,40,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.sheet { background: #fff; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 16px; } }
.sheet h2 { margin: 0 0 8px; }
.m-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.props { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.props th, .props td { border-bottom: 1px solid var(--line); padding: 5px 4px; text-align: left; }
.props th { font-size: 11px; color: var(--sub); font-weight: 500; }
.st-lines .ln { display: inline-block; color: #fff; font-weight: 800; font-size: 12px; border-radius: 50%; width: 22px; height: 22px; text-align: center; line-height: 22px; margin: 0 2px 0 6px; }
.st-riders small { color: var(--sub); font-size: 11px; }
.big-num { font-size: 18px; text-align: center; }
.big-num b { color: var(--accent); font-size: 24px; }
.plus { color: var(--ok); } .minus { color: var(--red); }

/* ---------- 結果 ---------- */
.r-head { color: var(--sub); margin: 8px 0 0; }
.ranking { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.ranking li { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 10px; padding: 8px 12px; display: grid; grid-template-columns: auto 1fr auto; gap: 0 10px; align-items: baseline; }
.ranking .rk { font-weight: 800; }
.ranking .nm { font-weight: 700; }
.ranking .am { font-weight: 800; font-size: 17px; }
.ranking small { grid-column: 1 / -1; color: var(--sub); font-size: 12px; }
.ranking li:first-child { background: #fff8e6; }
.share { display: flex; gap: 8px; flex-wrap: wrap; }
.sh { flex: 1; text-align: center; padding: 10px; border-radius: 10px; font-weight: 700; text-decoration: none; color: #fff; border: 0; font-size: 14px; font-family: inherit; cursor: pointer; }
.sh.x { background: #111; } .sh.line { background: #06c755; } .sh.copy { background: #6b7385; }
.sub { margin-top: 24px; }
.best { padding-left: 0; list-style: none; }
.best li { margin-bottom: 6px; }

/* サイコロのあと：進む駅をえらぶ間 */
.hint { position: absolute; left: 8px; right: 54px; top: 8px; z-index: 2; background: #ff7a00; color: #fff; font-weight: 800; border-radius: 12px; padding: 8px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.25); pointer-events: none; animation: hintIn .3s ease-out; line-height: 1.4; }
.hint b { font-size: 22px; }
.hint span { display: inline-block; }
@keyframes hintIn { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.game.choosing .players { display: none; }
.game.choosing .action { margin-top: 0; }
.cand-btn { min-height: 44px; }
.msg small { color: var(--sub); }

/* とても狭い画面 */
@media (max-width: 360px) { .logo small { display: none; } }
.wrap { overflow-wrap: anywhere; }

/* 駅のできごと */
.spot { display: inline-block; font-size: 13px; font-weight: 700; color: #6a4b00; background: #fff4d6; border-radius: 6px; padding: 1px 8px; margin-bottom: 4px; }
.spot small { font-weight: 500; color: var(--sub); }

/* 説明ページ */
.doc h2 { font-size: 18px; margin-top: 28px; padding-left: 8px; border-left: 4px solid var(--accent); }
.doc li { margin-bottom: 6px; }
