/* 見本（docs/mock/index.html・G6.1 承認）から移した値。色・余白・角丸・文字はここの値だけを使う。
   文字: Bahnschrift は Windows に入っている細身の書体。スマホには無いので、配布できる細身の書体へ差し替える余地を残す。 */
:root {
  --c-bg: #f5f1e8;
  --c-surface: #fffaf0;
  --c-text: #1d1a14;
  --c-muted: #6b6455;
  --c-accent: #ffc928;
  --c-danger: #d2381f;
  --c-done: #2e8a5c;
  --c-brown: #6b3a12;
  --c-line: #1d1a14;
  --s-1: .25rem; --s-2: .5rem; --s-3: 1rem; --s-4: 1.5rem; --s-5: 2.5rem; --s-6: 4rem;
  --r-0: 0; --r-1: .375rem; --r-2: 999px;
  --f-display: "Bahnschrift Condensed", "Bahnschrift", "DIN Condensed", "Yu Gothic UI", sans-serif;
  --f-body: "BIZ UDPGothic", "Yu Gothic UI", "Hiragino Sans", "Meiryo", sans-serif;
  --fs-1: .8125rem; --fs-2: 1rem; --fs-3: 1.5rem; --fs-4: 3rem;
  --e-1: 0 .125rem 0 var(--c-line);
  --e-2: 0 .375rem 0 var(--c-line);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--c-bg); color: var(--c-text); font-family: var(--f-body); overflow: hidden; }
button { font: inherit; color: inherit; }
.is-hidden { display: none !important; }

.game { position: fixed; inset: 0; overflow: hidden; background: #a9dcf2; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.game__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- 走行中の表示 ---- */
.hud { position: absolute; inset: 0; pointer-events: none; }

.course { position: absolute; left: var(--s-3); top: var(--s-3); background: var(--c-surface); border: .125rem solid var(--c-line);
  border-left: .5rem solid var(--c-accent); padding: var(--s-1) var(--s-3) var(--s-1) var(--s-2); box-shadow: var(--e-1); max-width: 14rem; }
.course__no { font-family: var(--f-display); font-size: var(--fs-1); letter-spacing: .12em; color: var(--c-muted); }
.course__name { font-size: var(--fs-2); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.clock { position: absolute; left: 50%; top: var(--s-2); transform: translateX(-50%); text-align: center; width: min(calc(100vw - 36rem), 24rem); }
.clock__time { font-family: var(--f-display); font-size: var(--fs-4); line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--c-surface); -webkit-text-stroke: .375rem var(--c-line); paint-order: stroke fill; letter-spacing: .02em; }
.track { position: relative; height: .75rem; margin-top: var(--s-2); background: var(--c-surface); border: .125rem solid var(--c-line); border-radius: var(--r-2); }
.track__fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c-accent); border-radius: var(--r-2); }
.track__dot { position: absolute; top: 50%; width: 1rem; height: 1rem; margin: -.5rem 0 0 -.5rem; border: .125rem solid var(--c-line); border-radius: var(--r-2); }
.track__dot--me { background: #1c3a9a; }
.track__dot--croc { background: #2f6b1a; border-radius: var(--r-1); }
.track__goal { position: absolute; right: -.25rem; top: 50%; transform: translate(100%, -50%); font-family: var(--f-display); font-size: var(--fs-1);
  background: var(--c-line); color: var(--c-surface); padding: 0 var(--s-1); border-radius: var(--r-1); }
.clock__remain { margin-top: var(--s-1); font-family: var(--f-display); font-size: var(--fs-2); font-weight: 700; color: var(--c-surface);
  -webkit-text-stroke: .25rem var(--c-line); paint-order: stroke fill; font-variant-numeric: tabular-nums; }

.mirror { position: absolute; right: var(--s-3); top: var(--s-3); width: 15rem; }
.mirror__glass { height: 7rem; border: .375rem solid var(--c-line); border-radius: var(--r-1); box-shadow: var(--e-2); }
.mirror.is-near .mirror__glass { border-color: var(--c-danger); }
.mirror__label { display: flex; justify-content: space-between; align-items: baseline; margin-top: var(--s-2); padding: 0 var(--s-2);
  background: var(--c-surface); border: .125rem solid var(--c-line); font-weight: 700; font-size: var(--fs-1); }
.mirror__dist { font-family: var(--f-display); font-size: var(--fs-3); font-variant-numeric: tabular-nums; }
.mirror.is-near .mirror__dist { color: var(--c-danger); }

.meter { position: absolute; left: var(--s-3); bottom: var(--s-3); width: 11.5rem; background: var(--c-surface); border: .125rem solid var(--c-line);
  border-radius: var(--r-1); padding: var(--s-2) var(--s-2) var(--s-1); box-shadow: var(--e-2); }
.meter__svg { display: block; width: 100%; height: auto; }
.meter__row { display: flex; justify-content: space-between; align-items: baseline; }
.meter__label { font-weight: 700; font-size: var(--fs-2); }
.meter__value { font-family: var(--f-display); font-size: var(--fs-3); font-weight: 700; font-variant-numeric: tabular-nums; }
.meter.is-over .meter__value { color: var(--c-danger); }

.koshi { position: absolute; right: var(--s-3); bottom: var(--s-3); width: 9rem; text-align: center; pointer-events: auto; }
.koshi__btn { position: relative; width: 9rem; height: 9rem; border-radius: var(--r-2); border: .25rem solid var(--c-line); background: var(--c-surface);
  box-shadow: var(--e-2); cursor: pointer; display: grid; place-items: center; padding: 0; touch-action: manipulation; }
.koshi__btn[disabled] { cursor: default; color: var(--c-muted); }
.koshi__btn:focus-visible { outline: .25rem solid var(--c-done); outline-offset: .25rem; }
.koshi__btn:not([disabled]):hover { transform: translateY(.125rem); box-shadow: var(--e-1); }
.koshi__ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.koshi__word { position: relative; font-weight: 700; font-size: var(--fs-3); line-height: 1.1; }
.koshi__sub { display: block; font-size: var(--fs-1); font-weight: 400; }
.koshi.is-full .koshi__btn { background: var(--c-accent); }
.koshi.is-standing .koshi__btn { background: var(--c-done); color: var(--c-surface); }

.keys { position: absolute; left: 13.5rem; bottom: 5.5rem; max-width: calc(100vw - 25rem); font-size: var(--fs-1); background: var(--c-surface);
  border: .125rem solid var(--c-line); border-radius: var(--r-2); padding: var(--s-1) var(--s-3); }
.pad { display: none; touch-action: none; user-select: none; -webkit-user-select: none; }

.toast { position: absolute; left: 50%; top: 9.5rem; transform: translateX(-50%); max-width: min(80vw, 30rem); background: var(--c-brown); color: var(--c-surface);
  border: .125rem solid var(--c-line); padding: var(--s-2) var(--s-3); font-weight: 700; text-align: center; box-shadow: var(--e-1); }
.toast.is-empty { display: none; }

/* ---- 重ねる画面（結果・捕獲・コース選択） ---- */
.sheet { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--s-3); background: rgba(245, 241, 232, .78); overflow: auto; touch-action: manipulation; }
.card { width: min(100%, 34rem); background: var(--c-surface); border: .25rem solid var(--c-line); border-radius: var(--r-1); box-shadow: var(--e-2); padding: var(--s-4); }
.card__kicker { font-family: var(--f-display); letter-spacing: .14em; font-size: var(--fs-2); color: var(--c-muted); }
.card__title { margin: var(--s-1) 0 var(--s-3); font-size: var(--fs-3); line-height: 1.3; border-left: .5rem solid var(--c-accent); padding-left: var(--s-3); }
.card__title--bad { border-left-color: var(--c-danger); }
.result { display: grid; grid-template-columns: auto 1fr; gap: var(--s-3); align-items: center; margin-bottom: var(--s-4); }
.result__rank { width: 6.5rem; height: 6.5rem; display: grid; place-items: center; font-family: var(--f-display); font-size: 5rem; font-weight: 700; line-height: 1;
  border: .25rem solid var(--c-line); background: var(--c-done); color: var(--c-surface); }
.result__rank--lost { background: var(--c-brown); }
.result__rank--bad { background: var(--c-danger); }
.result__list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: var(--s-1) var(--s-3); }
.result__list dt { color: var(--c-muted); font-size: var(--fs-1); align-self: center; }
.result__list dd { margin: 0; font-family: var(--f-display); font-size: var(--fs-3); font-weight: 700; font-variant-numeric: tabular-nums; }
.result__note { font-family: var(--f-body); font-size: var(--fs-1); font-weight: 400; color: var(--c-muted); margin-left: var(--s-2); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.btn { border: .125rem solid var(--c-line); background: var(--c-surface); border-radius: var(--r-1); padding: var(--s-2) var(--s-3); font-weight: 700; cursor: pointer; min-height: 2.75rem; }
.btn:hover { background: var(--c-bg); }
.btn:focus-visible { outline: .25rem solid var(--c-done); outline-offset: .125rem; }
.btn[disabled] { color: var(--c-muted); border-style: dashed; cursor: default; }
.btn--main { background: var(--c-accent); box-shadow: var(--e-1); flex: 1 1 12rem; font-size: var(--fs-2); }
.btn--main:hover { background: var(--c-accent); transform: translateY(.125rem); box-shadow: none; }

.select { width: min(100%, 52rem); }
.select__head { text-align: center; margin-bottom: var(--s-4); }
.select__series { font-family: var(--f-display); letter-spacing: .2em; font-size: var(--fs-2); }
.select__title { margin: 0; font-size: var(--fs-4); line-height: 1.1; font-weight: 700; }
.select__lead { margin: var(--s-2) 0 0; color: var(--c-muted); text-wrap: balance; }
.select__list { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); list-style: none; margin: 0; padding: 0; }
.select__tools { display: flex; justify-content: center; gap: var(--s-2); margin-top: var(--s-4); }
.stage { background: var(--c-surface); border: .25rem solid var(--c-line); border-radius: var(--r-1); box-shadow: var(--e-2); padding: var(--s-3); display: grid; gap: var(--s-2); }
.stage.is-locked { box-shadow: none; border-style: dashed; color: var(--c-muted); }
.stage__no { font-family: var(--f-display); letter-spacing: .12em; font-size: var(--fs-1); }
.stage__name { font-size: var(--fs-3); font-weight: 700; margin: 0; }
.stage__foe { font-size: var(--fs-1); margin: 0; min-height: 2.5em; }
.stage__best { font-family: var(--f-display); font-size: var(--fs-2); font-variant-numeric: tabular-nums; border-top: .125rem solid var(--c-line); padding-top: var(--s-2); }

/* ---- タイトルメニュー（決定台帳 #13） ---- */
.title { position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; justify-items: center; padding: var(--s-5) var(--s-3) var(--s-5);
  background: linear-gradient(rgba(245, 241, 232, .1), rgba(245, 241, 232, .55)); touch-action: manipulation; overflow: auto; }
.title__logo { align-self: center; text-align: center; }
.title__series { display: inline-block; font-weight: 700; font-size: var(--fs-3); background: var(--c-accent); border: .25rem solid var(--c-line); padding: 0 var(--s-3); box-shadow: var(--e-1); }
.title__name { margin: var(--s-3) 0 0; font-size: clamp(3.5rem, 13vw, 8rem); line-height: 1; font-weight: 700; letter-spacing: .04em; color: var(--c-surface);
  -webkit-text-stroke: .75rem var(--c-line); paint-order: stroke fill; }
.title__lead { margin: var(--s-4) 0 0; font-size: var(--fs-2); font-weight: 700; color: var(--c-surface); -webkit-text-stroke: .25rem var(--c-line); paint-order: stroke fill; text-wrap: balance; }
.title__menu { display: grid; gap: var(--s-2); width: min(100%, 18rem); }
.title__item { width: 100%; font-size: var(--fs-2); box-shadow: var(--e-1); }
.title__item.btn--main { font-size: var(--fs-3); min-height: 3.5rem; box-shadow: var(--e-2); }

/* ---- あそびかた ---- */
.how { width: 100%; border-collapse: collapse; margin-bottom: var(--s-3); font-size: var(--fs-1); }
.how th, .how td { border-bottom: .0625rem solid var(--c-line); padding: var(--s-1) var(--s-2); text-align: left; }
.how thead th { color: var(--c-muted); font-weight: 400; }
.how tbody th { font-weight: 700; white-space: nowrap; }
.how__notes { margin: 0 0 var(--s-4); padding-left: 1.25rem; font-size: var(--fs-1); line-height: 1.7; }

/* ---- 導入 ---- */
.intro { position: absolute; inset: 0; cursor: pointer; touch-action: manipulation; }
.intro__skip { position: absolute; right: var(--s-3); top: var(--s-3); box-shadow: var(--e-1); }
.intro__caption { position: absolute; left: 50%; bottom: var(--s-4); transform: translateX(-50%); width: min(92%, 40rem); background: var(--c-surface);
  border: .25rem solid var(--c-line); border-left: .75rem solid var(--c-accent); border-radius: var(--r-1); box-shadow: var(--e-2); padding: var(--s-3) var(--s-4); }
.intro__step { font-family: var(--f-display); letter-spacing: .14em; font-size: var(--fs-1); color: var(--c-muted); }
.intro__text { margin: var(--s-1) 0 0; font-size: var(--fs-3); font-weight: 700; line-height: 1.5; text-wrap: balance; }

/* ---- 見本に無かった部品（実装で足した分。要件 §12.5 に記録） ---- */
.hud__pause { position: absolute; left: var(--s-3); top: 4.5rem; pointer-events: auto; min-height: 2.25rem; padding: var(--s-1) var(--s-2); font-size: var(--fs-1); box-shadow: var(--e-1); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--c-bg); font-weight: 700; text-align: center; padding: var(--s-4); }
.loading.is-error { color: var(--c-danger); }

/* ---- 速さの表示（レースの仕組みにした時に足した。要件 §16） ---- */
.speed { position: absolute; left: 13.5rem; bottom: var(--s-3); background: var(--c-surface); border: .125rem solid var(--c-line); border-radius: var(--r-1);
  padding: var(--s-1) var(--s-3); box-shadow: var(--e-1); display: flex; align-items: baseline; gap: var(--s-1); }
.speed__value { font-family: var(--f-display); font-size: var(--fs-4); line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.speed__unit { font-family: var(--f-display); font-size: var(--fs-1); color: var(--c-muted); }
.speed.is-off .speed__value { color: var(--c-danger); }

/* ---- スマホ幅: 左下にハンドル、右下にアクセル・ブレーキ・ジャンプ・立つ（決定台帳 #10） ---- */
@media (max-width: 43.75rem) {
  :root { --fs-4: 2.25rem; --pad: 4.5rem; }
  .course { max-width: 7.5rem; padding-right: var(--s-2); }
  .clock { top: 4.25rem; width: calc(100% - 13rem); left: var(--s-3); transform: none; text-align: left; }
  .mirror { width: 8.5rem; }
  .mirror__glass { height: 4.5rem; }
  .mirror__dist { font-size: var(--fs-2); }
  .meter { width: 6.5rem; left: var(--s-3); bottom: auto; top: 10.5rem; padding: var(--s-1) var(--s-2); }
  .meter__label { font-size: var(--fs-1); }
  .meter__value { font-size: var(--fs-2); }
  .speed { left: var(--s-3); bottom: calc(var(--pad) + var(--s-4)); padding: 0 var(--s-2); }
  .speed__value { font-size: var(--fs-3); }
  .koshi { right: var(--s-3); bottom: calc(var(--pad) + var(--s-4)); width: var(--pad); }
  .koshi__btn { width: var(--pad); height: var(--pad); }
  .koshi__word { font-size: var(--fs-2); }
  .koshi__sub { display: none; }
  .keys { display: none; }
  .pad { display: grid; place-items: center; position: absolute; bottom: var(--s-3); width: var(--pad); height: var(--pad); border: .25rem solid var(--c-line);
    border-radius: var(--r-1); background: var(--c-surface); box-shadow: var(--e-2); font-size: var(--fs-1); font-weight: 700; pointer-events: auto; }
  .pad.is-down { transform: translateY(.25rem); box-shadow: var(--e-1); }
  .pad--left { left: var(--s-3); font-size: var(--fs-3); }
  .pad--right { left: calc(var(--s-3) + var(--pad) + var(--s-2)); font-size: var(--fs-3); }
  .pad--accel { right: var(--s-3); background: var(--c-accent); }
  .pad--brake { right: calc(var(--s-3) + var(--pad) + var(--s-2)); }
  .pad--jump { right: calc(var(--s-3) + var(--pad) + var(--s-2)); bottom: calc(var(--pad) + var(--s-4)); border-radius: var(--r-2); }
  .toast { top: 16.5rem; }
  .hud__pause { top: 7.6rem; left: auto; right: var(--s-3); }
  .select__list { grid-template-columns: 1fr; }
  .select__title { font-size: var(--fs-3); }
  .result { grid-template-columns: 1fr; }
  .card { padding: var(--s-3); }
  .intro__text { font-size: var(--fs-2); }
}

@media (prefers-reduced-motion: reduce) {
  .btn--main:hover { transform: none; }
  .koshi__btn:not([disabled]):hover { transform: none; }
}
