:root { --cream: #f6f1e2; --green: #1f3a2a; --orange: #f08a24; --yellow: #ffd23f; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; background: #8fc1e6; color: #fff; font-family: ui-rounded, "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
button { font: inherit; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
p, h1 { margin: 0; }

#hud-top { position: fixed; top: env(safe-area-inset-top); left: 0; right: 0; height: 48px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 8px;
  background: linear-gradient(rgba(10, 30, 20, 0.45), rgba(10, 30, 20, 0)); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); pointer-events: none; font-weight: 700; }
#hud-stage { white-space: nowrap; }
#hud-time { display: flex; flex-direction: column; align-items: center; font-variant-numeric: tabular-nums; }
#hud-time-num { font-size: 24px; line-height: 1.1; }
/* 残り時間は濃い下地に載せ、どの時刻の空の上でも同じ濃さで読めるようにする */
#hud-time { padding: 1px 6px 4px;border-radius: 12px; background: rgba(10, 24, 18, 0.68); }
#hud-time-num { text-shadow: none; }
/* 最後の10秒と暮れた後は、下地の色を替える（空の色に頼らない）。脈は hud.js が1秒に1回 */
#hud-time.is-last { background: #a8300c; box-shadow: 0 0 0 2px var(--yellow); }
#hud-time.is-last #hud-time-num { color: var(--yellow); font-size: 29px; }
#hud-time.is-out { background: #6e1408; box-shadow: 0 0 0 2px #fff; }
#hud-time.is-out #hud-time-num { color: #fff; font-size: 29px; }
#hud-time-bar { width: 108px; height: 4px; background: rgba(255, 255, 255, 0.35); border-radius: 2px; overflow: hidden; }
#hud-time-bar i, #memo-bar i { display: block; height: 100%; background: #fff; transform-origin: left; }
#hud-time.is-last #hud-time-bar i { background: var(--yellow); }
#hud-right { justify-self: end; pointer-events: auto; display: flex; gap: 4px; }
#hud-time { transform-origin: center top; }
#btn-mute { width: 44px; height: 44px; padding: 10px; border: 0; border-radius: 12px; background: rgba(10, 30, 20, 0.35); color: #fff; }
#btn-mute svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
#btn-mute .cross, #btn-mute[aria-pressed="true"] .wave { display: none; }
#btn-mute[aria-pressed="true"] .cross { display: inline; }
#btn-lang { white-space: nowrap; min-width: 44px;height: 44px; padding: 0 8px; border: 0; border-radius: 12px; background: rgba(10, 30, 20, 0.35); color: #fff; font-size: 14px; font-weight: 700; }

#map-key { position: fixed; left: 0; top: 0; display: flex; gap: 14px; padding: 2px 10px; border-radius: 10px; background: rgba(20, 40, 28, 0.82); font-size: 13px; line-height: 18px; font-weight: 700; white-space: nowrap; pointer-events: none; }
#map-key > span { display: inline-flex; align-items: center; gap: 5px; }
#map-key svg { width: 16px; height: 16px; }
#memo-hint { font-size: 12px; line-height: 16px; font-weight: 700; text-align: right; }
#dot { position: fixed; left: 50%; top: 42%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: rgba(255, 255, 255, 0.4); pointer-events: none; }

.ready-head { position: fixed; top: calc(52px + env(safe-area-inset-top)); left: 56px; right: 56px; text-align: center; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85); pointer-events: none; }
.ready-head::before { content: ""; position: absolute; z-index: -1; inset: -6px -18px; border-radius: 50%; background: radial-gradient(closest-side, rgba(10, 30, 20, 0.7), rgba(10, 30, 20, 0.55) 65%, rgba(10, 30, 20, 0)); }
.ready-head { max-width: 360px; margin: 0 auto; }
.ready-head h1 { font-size: 24px; }
.ready-head p { font-size: 14px; }
.ready-foot { position: fixed; left: 0; right: 0; bottom: calc(40px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 10px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85); }
#ready-record { margin: -6px 16px 0; font-size: 14px; text-align: center; text-wrap: balance; }
.btn-primary { width: 240px; min-height: 64px; border: 0; border-radius: 20px; background: var(--orange); color: #fff; font-size: 22px; font-weight: 800; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }
.btn-second { min-width: 200px; min-height: 48px; border: 0; border-radius: 16px; background: var(--cream); color: var(--green); font-weight: 700; }

#bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 8px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#bottom button { pointer-events: auto; }
#memo { width: 344px; max-width: 100%; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9); }
#memo-bar { height: 6px; background: rgba(255, 255, 255, 0.35); border-radius: 3px; overflow: hidden; }
.memo-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; font-size: 14px; font-weight: 700; }
.memo-row b { font-size: 36px; font-variant-numeric: tabular-nums; }
#btn-ready { min-height: 48px; padding: 0 14px; border: 0; border-radius: 16px; background: var(--cream); color: var(--green); font-weight: 800; white-space: nowrap; }
#btn-ready:disabled { opacity: 0.5; }

#pad { display: grid; grid-template-columns: 96px 128px 96px; grid-template-areas: "left forward right" ". back ."; column-gap: 12px; row-gap: 10px; justify-content: center; }
#btn-left { grid-area: left; } #btn-forward { grid-area: forward; } #btn-right { grid-area: right; }
#btn-back { grid-area: back; justify-self: center; width: 160px; height: 44px; flex-direction: row; gap: 6px; }
.walk { position: relative; height: 96px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 3px solid transparent; border-radius: 20px;
  background: rgba(246, 241, 226, 0.78); color: var(--green); font-size: 14px; font-weight: 800; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35); }
.walk svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
#btn-back svg { width: 28px; height: 28px; }
.walk span { pointer-events: none; }
.walk .key { display: none; font-size: 11px; opacity: 0.7; }
.walk.is-down { transform: translateY(2px); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35); border-color: var(--orange); }
#pad.is-dim .walk { opacity: 0.35; }
#btn-forward.is-blocked { background: rgba(246, 241, 226, 0.3); color: rgba(31, 58, 42, 0.5); box-shadow: none; }
#btn-forward.shake { animation: shake-wall 0.32s; }
@keyframes shake-wall { 20% { translate: -8px 0; } 45% { translate: 7px 0; } 70% { translate: -4px 0; } 85% { translate: 2px 0; } }
.walk.is-queued::after { content: ""; position: absolute; top: 8px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); }
#walk-hint { padding: 6px 14px; border-radius: 12px; background: rgba(20, 40, 28, 0.88); font-size: 15px; font-weight: 700; text-align: center; animation: bounce 0.5s; }
.bonus-chip { position: fixed; left: 0; top: 0; padding: 4px 12px; border-radius: 14px; background: var(--orange); font-size: 18px; font-weight: 800; white-space: nowrap; pointer-events: none; z-index: 6; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4); }
.memo-row b { display: inline-block; }
.walk.shake { animation: shake 0.25s; }
.walk.bounce { animation: bounce 0.35s; }
@keyframes shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
@keyframes bounce { 40% { translate: 0 -8px; } }
@media (max-height: 700px) { .walk { height: 84px; } #pad { grid-template-columns: 96px 128px 96px; } }
/* 高さの低い横向き: 後ろを右の外側へ置いて1段にする */
@media (max-height: 499px) {
  .walk { height: 72px; }
  #pad { grid-template-columns: 96px 128px 96px 96px; grid-template-areas: "left forward right back"; }
  #btn-back { width: 96px; height: 72px; flex-direction: column; gap: 0; font-size: 12px; }
  .memo-row { min-height: 44px; }
}
@media (max-height: 499px) and (orientation: landscape) {
  #memo { position: fixed; right: 8px; top: 64px; width: 180px; }
  .memo-row { flex-direction: column; }
  .ready-head { left: 8px; right: auto; width: 216px; top: 40%; }
  .ready-head h1 { font-size: 22px; }
  .ready-foot { left: auto; right: 8px; width: 216px; bottom: 30%; }
  .ready-foot .btn-primary { width: 200px; }
}
@media (hover: hover) and (min-width: 700px) and (min-height: 500px) { #pad { grid-template-columns: 100px 136px 100px; } .walk { height: 80px; } .walk .key { display: block; } .walk svg { width: 32px; height: 32px; } #btn-back svg { width: 24px; height: 24px; } }

#banner { position: fixed; top: 24%; left: 12px; right: 12px; text-align: center; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9); }
#banner-main { font-size: 30px; font-weight: 800; }
#banner-sub { font-size: 16px; font-weight: 700; }
/* 暮れた瞬間の帯は、暗い庭でも明るい庭でも同じ見え方の下地に載せる */
#banner.is-dusk:not(.is-top) #banner-main { display: inline-block; padding: 6px 18px; border-radius: 16px; background: #6e1408; box-shadow: 0 0 0 2px var(--yellow); }
/* 上空の絵がある間は、迷路の上の空き（上の帯と迷路の間）に小さく出す */
#banner.is-top { top: calc(54px + env(safe-area-inset-top)); left: 56px; right: 56px; line-height: 1.3; }
#banner.is-top #banner-main { font-size: 19px; }
#banner.is-top #banner-sub { font-size: 14px; color: var(--yellow); }
#toast { position: fixed; bottom: var(--toast-bottom, 8px); left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 12px; background: rgba(20, 40, 28, 0.88); font-size: 15px; font-weight: 700; text-align: center; overflow-wrap: anywhere; pointer-events: none; z-index: 5; }
#toast.is-line { padding: 1px 10px; border-radius: 8px; font-size: 13px; line-height: 18px; white-space: nowrap; }
#result { position: fixed; left: 0; right: 0; bottom: 0; max-height: 55%; overflow-y: auto; touch-action: pan-y; }
#result.is-measuring { visibility: hidden; }
.cover { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; padding: 24px; text-align: center; font-weight: 700; z-index: 10; }
#paused { background: rgba(12, 28, 20, 0.7); }
#loading, #nowebgl { background: #5f9fd8; }
@media (max-height: 499px) and (orientation: landscape) {
  #result { left: auto; right: 0; width: min(360px, 46%); max-height: calc(100% - 48px - env(safe-area-inset-top)); }
}
@media (max-height: 499px) and (orientation: landscape) { #dot { top: 33%; } }
@media (max-height: 499px) and (orientation: landscape) {
  #banner.is-top { top: 30%; left: 8px; right: auto; width: 184px; }
  #toast { left: 8px; bottom: 100px; transform: none; width: 184px; }
  #toast.is-line { white-space: normal; }
}

/* ---- 対戦（js/app/race/） ---- */
#btn-race { min-height: 44px; padding: 0 20px; border: 2px solid rgba(255, 255, 255, 0.75); border-radius: 22px; background: rgba(12, 32, 22, 0.55); color: #fff; font-size: 15px; font-weight: 700; }
body.race-screen #ready-panel, body.race-screen #map-key, body.race-screen #bottom, body.race-screen #banner,
body.race-screen #hud-stage, body.race-screen #hud-time, body.race-screen #result, body.race-play #ready-panel { display: none !important; }
body.race-screen #hud-top { z-index: 7; }
body.race-screen #hud-right { grid-column: 3; }
#toast { z-index: 8; }

/* 入口、部屋に入る、待合、断り。後ろの庭は暗くして、操作だけを読ませる */
body.race-screen #race-stage { position: fixed; inset: 0; z-index: 4; display: flex; justify-content: center; background: rgba(14, 34, 24, 0.94); }
.race-sheet { width: 100%; max-width: 420px; height: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 10px; overflow-y: auto; touch-action: pan-y;
  padding: calc(56px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); text-align: center; }
.race-sheet > * { flex: none; }
.race-sheet.is-center { justify-content: center; gap: 18px; }
.race-sheet h2 { margin: 0; padding: 0 44px; font-size: 22px; }
.race-sheet p { margin: 0; }
.race-lead { font-size: 14px; font-weight: 700; text-wrap: balance; }
.race-error { font-size: 18px; font-weight: 800; line-height: 1.5; text-wrap: balance; }
.race-small { font-size: 12px; font-weight: 700; opacity: 0.9; }
.race-label { font-size: 14px; font-weight: 800; }
.race-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; text-align: left; }
#race input { min-width: 0; height: 48px; padding: 0 12px; border: 2px solid transparent; border-radius: 14px; background: var(--cream); color: var(--green); font: inherit; font-size: 18px; font-weight: 700;
  user-select: text; -webkit-user-select: text; touch-action: manipulation; }
#race input:focus { outline: none; border-color: var(--orange); }
#race .race-code-input { flex: 1 1 0; text-align: center; font-size: 26px; letter-spacing: 0.35em; text-transform: uppercase; }
.race-btn { min-height: 48px; padding: 6px 16px; border: 0; border-radius: 16px; background: var(--cream); color: var(--green); font-size: 16px; font-weight: 800; line-height: 1.25; touch-action: manipulation; }
.race-sheet button, #race-result button, .race-panel button { touch-action: manipulation; }
.race-btn.is-main { min-height: 56px; background: var(--orange); color: #fff; font-size: 20px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); }
.race-btn.is-quiet { min-height: 44px; background: transparent; border: 2px solid rgba(255, 255, 255, 0.6); color: #fff; font-size: 14px; }
.race-btn:disabled { opacity: 0.45; }
.race-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px; background: rgba(255, 255, 255, 0.1); }
.race-row { display: flex; gap: 8px; align-items: stretch; justify-content: center; }
.race-row > .race-btn { flex: 1 1 0; min-width: 0; }
.race-row > #race-join { flex: 0 0 96px; }

.race-sheet.is-lobby { overflow: hidden; gap: 6px; padding-left: 0; padding-right: 0; }
.race-sheet > .race-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; display: flex; flex-direction: column; gap: 8px; padding: 0 16px; }
.race-scroll > * { flex: none; }
.race-codebox { display: flex; flex-direction: column; gap: 4px; }
.race-sheet .race-code { font-size: 44px; font-weight: 900; line-height: 1.1; letter-spacing: 0.18em; padding-left: 0.18em; color: var(--yellow); user-select: text; -webkit-user-select: text; }
#race-link-note:empty { display: none; }
.race-url { display: block; margin-top: 4px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; -webkit-touch-callout: default; }
.race-players { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0; padding: 0; list-style: none; }
.race-players li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 5px; min-width: 0; min-height: 34px; padding: 3px 8px; border-radius: 10px; background: var(--cream); color: var(--green); font-size: 14px; text-align: left; }
.race-players b { min-width: 0; overflow-wrap: anywhere; unicode-bidi: isolate; white-space: pre-wrap; }
.race-players li.is-away { opacity: 0.5; }
.race-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #1d2a17; }
.race-tag { padding: 0 5px; border-radius: 6px; background: #d8d0b4; font-size: 10px; font-weight: 800; white-space: nowrap; }
.race-tag.is-you { background: var(--green); color: #fff; }
.race-away { font-size: 10px; font-weight: 700; }
.race-choice { display: flex; flex-direction: column; gap: 4px; }
.race-seg { display: flex; gap: 6px; }
.race-seg button { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 3px solid transparent; border-radius: 12px; background: rgba(246, 241, 226, 0.25); color: #fff; font-size: 15px; font-weight: 800; line-height: 1.2; }
.race-seg button[aria-pressed="true"] { background: var(--cream); color: var(--green); border-color: var(--orange); }
.race-seg button:disabled { opacity: 0.5; }
.race-seg small { font-size: 11px; font-weight: 700; }
.race-setting { font-size: 15px; font-weight: 800; }
/* 広さが4つ以上の時は、3つずつの2段 */
.race-choice.is-sizes > .race-seg { display: grid; grid-template-columns: repeat(3, 1fr); }
/* 巨大と最大の、上から見る間の「全体」へ戻るボタンと、寄り方の一言。下の札や帯のすぐ上に置く */
#race-whole { position: fixed; z-index: 5; right: 8px; bottom: var(--map-bottom, 8px); min-width: 72px; min-height: 44px; padding: 4px 14px; border: 2px solid var(--green); border-radius: 14px; background: var(--cream); color: var(--green); font-size: 15px; font-weight: 800; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); touch-action: manipulation; }
#race-mapnote { position: fixed; z-index: 3; left: 8px; right: 96px; bottom: var(--map-bottom, 8px); display: flex; justify-content: center; pointer-events: none; }
/* 開始の時刻までは幕で覆う（庭を立てる最初のコマは重く、早く立った人だけが迷路を長く見ないようにする） */
#race-preparing { position: fixed; z-index: 6; inset: 0; margin: 0; padding: 0 24px; display: flex; align-items: center; justify-content: center; text-align: center; background: #143022; font-size: 18px; font-weight: 800; }
#race-preparing[hidden] { display: none; }
body.race-play:has(#race-preparing:not([hidden])) #hud-top { z-index: 7; }
.race-box-title { font-size: 13px; font-weight: 800; text-align: center; color: var(--yellow); }
.race-late { margin: 0; padding: 7px 10px; border-radius: 12px; background: var(--yellow); color: #1d2a17; font-size: 15px; font-weight: 800; line-height: 1.35; text-wrap: balance; }
.race-late[hidden] { display: none; }
.race-panel > .race-late { flex: none; }
/* PC の幅の、広い設定の面の結果: 札を右に置く（幅は play.js の SIDE_CARD_PX と合わせる） */
body.race-side #race-result { left: auto; right: 8px; bottom: 8px; width: 380px; }
body.race-side #race-result .result-card.rr-card { max-height: calc(100vh - 68px); max-height: calc(100dvh - 68px); border-radius: 20px; }
body.race-side #race-whole { right: 400px; }
body.race-side #race-mapnote { right: 504px; }
/* 上の帯の文の上から指を置いても、下の絵が動くようにする */
body.race-play #banner { pointer-events: none; }
/* 寄っている間は地図が画面いっぱいになるので、まだ使えない歩くボタンを隠し（そこもなぞれる）、文には下地を敷く */
body.map-zoomed #pad { visibility: hidden; }
body.map-zoomed #banner, body.map-zoomed #memo { padding: 4px 10px; border-radius: 14px; background: rgba(14, 34, 24, 0.82); }
@media (max-height: 499px) and (orientation: landscape) {
  #race-whole { right: auto; left: 8px; bottom: 8px; }
  #race-mapnote { left: 96px; right: min(368px, 48%); bottom: 8px; }
}
.race-foot { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 0 16px; }
.race-wait { font-size: 15px; font-weight: 800; }

/* 遊びの間: 上の1行、出るボタン、着いた後の札、面の結果 */
#race-note { position: fixed; z-index: 3; top: calc(52px + env(safe-area-inset-top)); left: 56px; right: 76px; margin: 0; padding: 4px 8px; border-radius: 10px; background: rgba(20, 40, 28, 0.82); font-size: 13px; font-weight: 700; text-align: center; overflow-wrap: anywhere; pointer-events: none; }
#race-out { position: fixed; z-index: 3; top: calc(52px + env(safe-area-inset-top)); right: 8px; min-width: 60px; max-width: 108px; min-height: 40px; padding: 2px 8px; border: 0; border-radius: 12px; background: rgba(10, 30, 20, 0.5); color: #fff; font-size: 12px; font-weight: 700; line-height: 1.25; touch-action: manipulation; }
body.race-play #banner.is-top { left: 76px; right: 76px; }
.race-panel { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; max-width: 480px; max-height: 46%; margin: 0 auto; display: flex; flex-direction: column; gap: 4px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: rgba(18, 40, 28, 0.95); text-align: center; box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3); }
.race-panel p { margin: 0; }
.race-wait-title { font-size: 19px; font-weight: 800; text-wrap: balance; }
.race-wait-sub { font-size: 13px; font-weight: 700; white-space: pre-line; }
.race-wait-count { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--yellow); }
/* 上から見ている間の一覧（ux C の部品）。迷路は札の上に収め、札が伸びすぎる時は一覧だけが縦に動く */
.race-roster { flex: 0 1 auto; min-height: 36px; overflow-y: auto; touch-action: pan-y; }
.race-panel > * { flex: none; }
.race-panel > .race-roster { flex-shrink: 1; }
.race-panel.is-overhead { gap: 3px; padding-top: 8px; }
.race-panel.is-overhead .race-wait-title { font-size: 16px; line-height: 1.3; }
.race-panel.is-overhead .race-wait-count { font-size: 13px; }
.race-panel.is-overhead .race-btn.is-quiet { min-height: 40px; }
/* 走る・観戦するの切り替え */
.race-seg.race-roles button { min-height: 44px; }
.race-role-box { display: flex; flex-direction: column; gap: 3px; }
.race-role-hint { line-height: 1.35; text-wrap: balance; }
#race-result .race-roles button { min-height: 38px; background: rgba(31, 58, 42, 0.12); color: var(--green); }
#race-result .race-roles button[aria-pressed="true"] { background: var(--green); color: #fff; }
.race-field-error { align-self: stretch; padding: 6px 8px; border-radius: 10px; background: #8a1c0e; color: #fff; font-size: 14px; font-weight: 800; }
.race-players li.is-watcher { background: #d9e2d6; }
.race-players li.is-wide { grid-column: 1 / -1; }
/* 低い画面（360×640）の結果の札: 順位の行が3人分はスクロールなしで見えるように、札を少し高くし、下のボタンの段を詰める。
   最後の札は、役の切り替えが1行、その下に「部屋を出る」「1人で遊ぶ」「もう1回」を1行に並べる */
@media (max-height: 700px) and (orientation: portrait) {
  #race-result .result-card.rr-card { max-height: 64vh; max-height: 64dvh; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  #race-result .race-result-foot { gap: 3px; margin-top: 4px; }
  #race-result .race-result-foot.is-final { display: grid; grid-template-columns: 1fr 1fr 1.3fr; column-gap: 6px; }
  .race-result-foot.is-final > .race-roles, .race-result-foot.is-final > p { grid-column: 1 / -1; grid-row: auto; }
  .race-result-foot.is-final > .race-row { display: contents; }
  .race-result-foot.is-final #race-again { grid-column: 3; order: 3; }
  .race-result-foot.is-final > .race-row > .race-btn { order: 2; }
  .race-result-foot.is-final > p { order: 1; line-height: 1.3; }
  #race-result .race-result-foot.is-final .race-btn { min-height: 44px; font-size: 13px; padding: 2px 4px; }
  #race-result .race-result-foot.is-final #race-again { font-size: 16px; }
  #race-result .race-roles button { min-height: 34px; }
}
.race-tag.is-watch { background: var(--green); color: #fff; }
#race-result { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; }
.race-result-foot { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.race-result-foot p { margin: 0; }
.race-next { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
#race-result .race-btn.is-main { min-height: 48px; font-size: 18px; }
#race-result .race-btn.is-quiet { min-height: 40px; border-color: rgba(31, 58, 42, 0.45); color: var(--green); }
#race-reconnect { position: fixed; z-index: 9; left: 50%; top: 40%; transform: translate(-50%, -50%); margin: 0; padding: 10px 18px; border-radius: 14px; background: #6e1408; box-shadow: 0 0 0 2px var(--yellow); font-size: 15px; font-weight: 800; white-space: nowrap; pointer-events: none; }
@media (max-height: 700px) { .race-sheet { gap: 8px; } .race-sheet .race-code { font-size: 36px; } .race-players li { min-height: 28px; font-size: 13px; } .race-btn.is-main { min-height: 50px; font-size: 18px; } }
@media (max-height: 499px) and (orientation: landscape) {
  .race-panel, #race-result { left: auto; right: 0; width: min(360px, 46%); max-height: calc(100% - 48px); }
}
/* 入口と待合の知らせは、下の押す所に重ねないで、上の帯の空いた左側に出す */
body.race-screen #toast { top: calc(4px + env(safe-area-inset-top)); bottom: auto; left: 8px; transform: none; max-width: calc(100% - 124px); padding: 4px 10px; font-size: 13px; line-height: 18px; text-align: left; }
/* 下に札がある間（結果、上から見ている間）の知らせは、札のボタンに重ねないで上に出す */
body.race-play:has(#race-result, .race-panel) #toast { top: calc(52px + env(safe-area-inset-top)); bottom: auto; }
/* 面の間は「部屋を出る」と「次の面へ」を横に並べ、順位の一覧の高さを残す */
.race-result-foot .race-row > #race-next { flex: 1.6 1 0; }
/* 低い画面の待合は、8人いても部屋主の設定がスクロールなしで届くように詰める */
@media (max-height: 700px) {
  .race-sheet.is-lobby { padding-top: calc(50px + env(safe-area-inset-top)); padding-bottom: 8px; }
  .race-sheet.is-lobby .race-scroll { gap: 5px; }
  .race-codebox { gap: 2px; }
  .race-sheet .race-code { font-size: 30px; }
  .race-codebox .race-btn { min-height: 40px; }
  .race-players li { flex-wrap: nowrap; }
  .race-players b { flex: 0 1 auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .race-choice { flex-direction: row; align-items: center; gap: 6px; }
  .race-choice > .race-label { flex: 0 0 62px; font-size: 12px; text-align: left; }
  .race-choice > .race-seg { flex: 1 1 0; }
  .race-sheet .race-box { gap: 5px; padding: 6px; }
}
