* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  background: #181c24;
  color: #fff;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

#app,
.screen {
  position: fixed;
  inset: 0;
}

/* ---- ガレージ ---- */

.garage {
  display: flex;
  flex-direction: column;
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.018) 0 14px, rgba(255, 255, 255, 0) 14px 28px),
    radial-gradient(circle at 50% 26%, #2c3752, #1a2032 58%, #12161f 100%);
}

.garage header {
  padding: calc(12px + env(safe-area-inset-top)) 16px 2px;
  text-align: center;
}

.garage h1 {
  font-size: 25px;
  font-style: italic;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(#ffe9a3, #f7b733 70%, #d98b1e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5));
}

.garage .sub {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 5px;
  color: #6d7994;
}

/* 財布(貯めたコイン)。ショップの支払いに使う */
.wallet-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.wallet {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 14px;
  font-weight: 900;
  color: #ffd94d;
  font-variant-numeric: tabular-nums;
}

.wallet i,
.price i,
.result .wallet i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a0, #f5c518 60%, #d99b12);
  border: 1.5px solid #a8720b;
  flex: 0 0 auto;
}

.preview {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
}

.preview canvas {
  position: absolute;
  inset: 0;
}

/* 向きの切り替え。**canvas は inset:0 で全面を覆うので、上に重ねないと押せない**
   (置いただけだと canvas に当たりを取られる) */
.view-btn {
  position: absolute;
  right: 10px;
  top: 8px;
  z-index: 2;
  min-height: 48px;   /* 下限は 44。**ちょうどにしない**(余裕を持たせる ← 規約 5章) */
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(10, 16, 27, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cfd8ea;
  font-size: 13px;
  font-weight: 800;
}

.view-btn[data-view='side'] {
  border-color: rgba(255, 217, 77, 0.6);
  color: #ffd94d;
}

.panel {
  background: linear-gradient(rgba(26, 32, 49, 0.96), rgba(17, 21, 33, 0.98));
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  padding-top: 12px;
}

.cats {
  display: flex;
  gap: 8px;
  padding: 0 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.cat-btn {
  overflow-wrap: anywhere;
  min-width: 58px;
  /* タッチの下限。44px はこのリポジトリの他ゲームの下限(60px)を割る */
  min-height: 60px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #262e42;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #b9c4da;
  font-weight: 700;
  font-size: 14px;
}

.cat-btn.active {
  background: linear-gradient(#ffe08a, #f0a92e);
  border-color: transparent;
  color: #3a2c07;
  box-shadow: 0 2px 8px rgba(245, 179, 46, 0.35);
}

/* **横スクロールにしない。** 1行に並べると、8色のうち後ろの4色が画面の外に出て
   一生さわれなくなる(2026-08-22 のプレイテストで実際に起きた)。
   格子で折り返せば、画面の外へ出る余地がそもそも無い。
   auto-fill なので、横長の画面では列が増えて1行に収まる。 */
.options {
  display: grid;
  /* 64px なら 320 幅でも4列に収まり、8色が2段で済む(72px だと3列=3段になって
     パネルが伸び、低い画面で「レースへ GO!」が画面の外へ出る) */
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  padding: 10px 14px 4px;
  justify-items: stretch;
}

.opt-btn {
  width: 100%;
  min-width: 0;
  /* 値札が**自分の段**を持つので、そのぶん背が要る(重ねると絵か名前のどちらかが隠れる) */
  height: 84px;
  border-radius: 14px;
  background: linear-gradient(#2b3450, #222941);
  border: 3px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #c3cde2;
}

.opt-btn.selected {
  border-color: #ffd94d;
  background: linear-gradient(#354064, #2a3350);
  box-shadow: 0 0 14px rgba(255, 217, 77, 0.35), 0 3px 0 rgba(0, 0, 0, 0.35);
}

/* 絵は「残った高さ」に収める。canvas は属性で寸法を持つので、CSS 側で頭打ちにする */
.opt-btn > canvas {
  max-height: 100%;
  height: auto;
}

.opt-btn .swatch {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.opt-label {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  /* **分割できない長い1語**(de の Renn-Reifen、pt の Todo terreno)が来ても
     箱の外へ出ないようにする。格子は minmax(64px, 1fr) なので列は広がらず、
     この1行が無いと字だけが箱からはみ出す(coding.md 4.5章) */
  overflow-wrap: anywhere;
}

.opt-note {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #7f8ba6;
  padding-top: 2px;
}

.opt-note.warn {
  color: #ffb14d;
}

/* まだ買っていないもの: 絵を沈めて値札を出す。押すと買う */
.opt-btn.locked {
  position: relative;
  border-color: rgba(255, 255, 255, 0.06);
}

/* **名前は沈めない。** 0.32 まで落としていたころ、買う前の品は
   「暗い塊 + 値段」にしか見えず、**ひらがなで付けた名前がいちばん要る場面で
   1文字も読めなかった**(対象者視点レビューの実測: 15品中 11品)。
   絵は「まだ持っていない」と分かる程度に沈めるだけにする。 */
.opt-btn.locked > canvas,
.opt-btn.locked > .swatch {
  opacity: 0.5;
}

.opt-btn.locked > .opt-label {
  opacity: 0.8;
}

.opt-btn .price {
  /* **絵にも名前にも重ねない。** まん中の下に置いていたころは名前が完全に隠れ
     (見えている幅 0.0px)、右上の角へ逃がしたら今度は**色玉を 62〜67% 覆った**
     (高さ 660px 以下では色玉が 26px に縮むのに、値札は 43px のままだったため)。
     **重ねる場所を動かすかぎり同じ事故が別の相手で再発する** ―― 段を1つ持たせる。 */
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.85);
  border: 1px solid rgba(255, 217, 77, 0.5);
  font-size: 10px;
  line-height: 1.3;
  font-weight: 900;
  color: #ffd94d;
  font-variant-numeric: tabular-nums;
}

/* 買えなかったことを、動きで返す(明るさ・不透明度は動かさない ← 点滅の規約) */
.opt-btn.shake {
  animation: shake 0.36s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  45% { transform: translateX(5px); }
  70% { transform: translateX(-3px); }
}

/* パーツの性能(スピード/かそく/ハンドル/タフさ)。選んだ結果がその場で動く */
.stats-row {
  display: grid;
  /* **minmax(0, 1fr)。** 素の 1fr は min-content を下回れないので、長い性能名が
     1つあるだけで4列ぜんぶが押し広がる(coding.md 4.5章) */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 0 14px 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  /* 4列の格子。**min-width: 0 が無いと、長い性能名(pt の Arranque)で列が広がって
     格子ごと画面の外へ出る**(1fr は min-content を下回れない) */
  min-width: 0;
}

.stat-name {
  font-size: 10px;
  font-weight: 800;
  color: #9aa7c2;
  text-align: center;
  overflow-wrap: anywhere;
}

.stat-bar {
  display: flex;
  gap: 2px;
}

.stat-bar i {
  width: 8px;
  height: 7px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
}

.stat-bar i.on {
  background: linear-gradient(#ffe08a, #f0a92e);
}

.stat[data-stat='tough'] .stat-bar i.on {
  background: linear-gradient(#a8e6ff, #38a5ef);
}

.go-row {
  display: flex;
  justify-content: center;
  padding: 4px 0 calc(14px + env(safe-area-inset-bottom));
}

.race-btn {
  min-height: 62px;
  padding: 12px 48px;
  border-radius: 999px;
  background: linear-gradient(#ffb054, #f0602a 82%);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 22px;
  font-style: italic;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  box-shadow: 0 6px 0 #9c3712, 0 10px 22px rgba(240, 96, 42, 0.35);
}

.race-btn span {
  display: inline-block;
}

/* 箱ではなく中身だけ縮める(当たり判定を縮めない ← 規約 1章) */
.race-btn:active span {
  transform: scale(0.94);
}

/* 低い画面(小さいスマホ・横向き)では、パネルの各段を詰める。
   **詰めないと下端の「レースへ GO!」が画面の外へ出る** ―― 実測: 320x568 で
   GO の下端が 579(画面 568)になり、押せなくなっていた */
@media (max-height: 660px) {
  .garage header {
    padding-top: calc(6px + env(safe-area-inset-top));
  }

  .garage h1 {
    font-size: 20px;
  }

  .garage .sub {
    display: none;
  }

  .opt-btn {
    height: 72px;
  }

  /* **絵と値札は同じ率で詰める。** 絵だけ縮めて値札を固定にすると、
     値札が絵を覆う(色玉 26px に対して値札 43px で 62〜67% 覆っていた) */
  .opt-btn > canvas {
    max-width: 40px;
    max-height: 38px;
  }

  .opt-btn .swatch {
    width: 26px;
    height: 26px;
  }

  .cat-btn {
    min-height: 52px;
    padding: 6px 10px;
  }

  .stats-row {
    padding-bottom: 4px;
  }

  .race-btn {
    min-height: 54px;
    padding: 8px 34px;
    font-size: 19px;
  }

  .go-row {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

/* ---- レース ---- */

.race {
  background: #3d9a47;
}

.race-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}

.hud-rank {
  background: rgba(10, 14, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 4px 12px 6px;
  font-size: 26px;
  font-weight: 900;
  color: #ffd94d;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  line-height: 1.1;
}

.hud-rank .num {
  font-size: 32px;
}

.hud-rank small {
  font-size: 13px;
  font-weight: 700;
  color: #dfe6f2;
}

.hud-rank .sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 800;
  color: #dfe6f2;
  text-shadow: none;
}

.hud-rank .coin {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #ffd94d;
}

.hud-rank .coin i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a0, #f5c518 60%, #d99b12);
  border: 1.5px solid #a8720b;
}

.hud-rank .coin b.max {
  color: #ffb14d;
}

.hud-rank .time {
  font-variant-numeric: tabular-nums;
  color: #9fe8ff;
}

.hud-progress {
  flex: 1;
  margin-top: 16px;
  height: 14px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.25);
  position: relative;
}

.hud-progress .bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(#8fdcff, #38a5ef);
}

.hud-progress .bar::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.hud-progress .flag {
  position: absolute;
  right: -6px;
  top: -18px;
  font-size: 17px;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.4));
}

.back-btn {
  pointer-events: auto;
  min-width: 60px;
  min-height: 48px;
  border-radius: 14px;
  background: rgba(10, 14, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.hud-speed {
  position: absolute;
  right: 14px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(10, 14, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 22px;
  font-style: italic;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.hud-speed small {
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  color: #b9c4da;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.count {
  font-size: 110px;
  font-style: italic;
  font-weight: 900;
  background: linear-gradient(#fff3c4, #ffd94d 55%, #f59f22);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.45));
  animation: pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes pop {
  from {
    transform: scale(0.3);
  }
  to {
    transform: scale(1);
  }
}

.count-hint {
  margin-top: 14px;
  max-width: calc(100% - 32px);
  text-align: center;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 14px;
  font-weight: 800;
  color: #dfe6f2;
}

/* 仕掛けの説明(カウントダウン中に、なぞり方の一言の下へ)。
   **色は肯定の水色**(「気をつけて」であって「しっぱい」ではない ← #434 の対象者視点レビュー) */
.count-gimmick {
  margin-top: 8px;
  font-size: 13px;
  color: #9fe8ff;
}

.result {
  pointer-events: auto;
  max-width: calc(100% - 24px);
  background: linear-gradient(rgba(20, 26, 41, 0.94), rgba(11, 15, 24, 0.96));
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  padding: 26px 40px 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
  animation: pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
  /* **板が画面より高くなることがある。** 1位 + 次のコース解放 の行が入ると
     高さ 375 の画面で 33〜49px はみ出し、「マップへ」「ガレージへ」が画面の外へ出ていた
     ―― いちばん嬉しい瞬間に、開いたばかりのコースへ行く導線だけが消える
     (対象者視点レビューの実測)。**中で送れるようにする。** */
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.result .trophy {
  font-size: 54px;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.result .rank-big {
  font-size: 68px;
  font-style: italic;
  font-weight: 900;
  line-height: 1;
  color: #ffd94d;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
}

.result .rank-2 {
  color: #ccd8e8;
}

.result .rank-3 {
  color: #e0a35c;
}

.result .rank-4 {
  color: #9fd6ff;
}

.result .rank-big small {
  font-size: 26px;
}

.result .msg {
  font-size: 21px;
  font-weight: 800;
}

.result .stats {
  font-size: 13px;
  font-weight: 700;
  color: #b9c4da;
}

.result .nomiss {
  color: #5fe08a;
}

/* もらったコインと、いま持っているコイン(ショップの動機づけ) */
.result .wallet {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 18px;
}

.result .wallet span {
  font-size: 12px;
  font-weight: 700;
  color: #b9c4da;
  margin-left: 4px;
}

/* タイムとベスト。**上達が見える**のがこの画面のいちばんの仕事 */
.result .time-big {
  font-size: 40px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #9fe8ff;
  line-height: 1;
}

.result .time-big small {
  font-size: 20px;
}

.result .best {
  font-size: 14px;
  font-weight: 800;
  color: #b9c4da;
  font-variant-numeric: tabular-nums;
}

.result .best.new {
  color: #ffd94d;
}

/* ゴール直後の1秒を埋める。**画面の上のほう**に出して自分の車を隠さない */
.goal-flash {
  position: absolute;
  top: 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 44px;
  font-style: italic;
  font-weight: 900;
  color: #ffd94d;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
  animation: pop 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.goal-flash span {
  font-size: 24px;
  font-style: normal;
  color: #9fe8ff;
  font-variant-numeric: tabular-nums;
}

.result button {
  min-height: 56px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
  padding: 10px 28px;
}

.result .again {
  background: linear-gradient(#ffb054, #f0602a 82%);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  box-shadow: 0 4px 0 #9c3712;
}

.result .to-garage {
  background: #2c3446;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: -5vh;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation: fall 2.4s ease-in forwards;
}

@keyframes fall {
  to {
    transform: translateY(115vh) rotate(720deg);
  }
}


/* ---- ワールドマップ ---- */
/* 絵(canvas)はただの背景。**的は比率で置いた DOM の札**なので、絵を描き替えても
   ずれないし、指で押しやすい大きさを保てる(ゆめいろサロンの まち と同じ考え方) */

.worldmap {
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 30%, #14324f, #0b1a2c 70%);
}

.worldmap header {
  padding: calc(10px + env(safe-area-inset-top)) 16px 4px;
  text-align: center;
}

.worldmap h1 {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffd94d;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.map-area {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  margin: 6px 10px 0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pins {
  position: absolute;
  inset: 0;
}

/* **札は小さく。** 大きいと地図の絵をふさいでしまう(それでも指の下限 44px は保つ) */
.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 66px;
  min-height: 46px;
  padding: 3px 6px 4px;
  border-radius: 11px;
  background: rgba(10, 16, 27, 0.74);
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: #fff;
}

.pin.here {
  border-color: #ffd94d;
  box-shadow: 0 0 14px rgba(255, 217, 77, 0.5), 0 4px 10px rgba(0, 0, 0, 0.45);
}

.pin.locked {
  background: rgba(12, 18, 30, 0.72);
  border-color: rgba(255, 255, 255, 0.1);
  color: #8f9bb3;
}

.pin-badge {
  font-size: 10px;
  line-height: 1;
  color: #ffd94d;
  letter-spacing: 1px;
}

.pin.locked .pin-badge {
  color: #8f9bb3;
}

.pin-name {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.pin-meta {
  font-size: 9px;
  font-weight: 700;
  color: #9fe8ff;
  font-variant-numeric: tabular-nums;
}

.pin.locked .pin-meta {
  color: #7f8ba6;
}

.pin-cup {
  position: absolute;
  top: -9px;
  right: -7px;
  font-size: 15px;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.5));
}

.pin-car {
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

/* ロックの札を押したときの手ごたえ。**`.opt-btn.shake` は使えない** ――
   あちらの keyframes は translateX だけなので、札の translate(-50%,-50%) を
   打ち消して半分ずれる(位置決めごと消える) */
.pin.shake {
  animation: pin-shake 0.36s ease;
}

@keyframes pin-shake {
  0%, 100% { transform: translate(-50%, -50%); }
  20% { transform: translate(-50%, -50%) translateX(-5px); }
  45% { transform: translate(-50%, -50%) translateX(5px); }
  70% { transform: translate(-50%, -50%) translateX(-3px); }
}

.map-note {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #9aa7c2;
  padding: 8px 14px 2px;
  min-height: 30px;
}

.map-note.warn {
  color: #ffb14d;
}

.map-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 2px 0 calc(12px + env(safe-area-inset-bottom));
}

.garage-btn {
  min-height: 56px;
  padding: 10px 20px;
  border-radius: 999px;
  background: #262e42;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cfd8ea;
  font-size: 15px;
  font-weight: 800;
}

.race-btn.map-go {
  min-height: 56px;
  padding: 10px 34px;
  font-size: 20px;
}

.result .unlocked {
  font-size: 15px;
  font-weight: 900;
  color: #5fe08a;
}

.result .hint {
  font-size: 12px;
  font-weight: 700;
  color: #9aa7c2;
}

.result-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.result-row button {
  flex: 1 1 0;
  min-height: 52px;
  padding: 10px 14px;
  font-size: 15px;
  background: #2c3446;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 999px;
  font-weight: 800;
}

@media (max-height: 660px) {
  .worldmap h1 {
    font-size: 17px;
  }

  /* 低い画面では結果の板が画面より高くなる。**実測: 812x375 で 564px(画面 375)**で、
     「もういちど」も「マップへ」も画面の外に出ていた(日本語でも同じ。多言語化で
     文が2行になる言語ではさらに伸びる)。段を詰めて収め、それでも足りないぶんは
     板の中で送れるようにする(ボタンに必ず手が届くことを最優先する) */
  .result {
    gap: 8px;
    padding: 14px 22px 16px;
    max-height: calc(100% - 12px);
    overflow-y: auto;
  }

  .result .trophy {
    font-size: 34px;
  }

  .result .rank-big {
    font-size: 44px;
  }

  .result .rank-big small {
    font-size: 18px;
  }

  .result .time-big {
    font-size: 30px;
  }

  .result .msg {
    font-size: 18px;
  }

  .result button {
    min-height: 48px;
  }

  .result-row button {
    min-height: 46px;
  }

  .goal-flash {
    font-size: 34px;
  }

  .map-note {
    padding-top: 4px;
    min-height: 22px;
  }

  .garage-btn,
  .race-btn.map-go {
    min-height: 50px;
  }
}

/* ---- ことば(表示言語) ---- */
/* ボタンは**財布と同じ行**に置く(見出しへ重ねると、長い見出しの言語で必ずぶつかる)。
   持ち主は js/core/lang-button.js の1か所。 */
.lang-btn {
  min-width: 60px;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #262e42;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #b9c4da;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* 箱ではなく**中身だけ**縮める(当たり判定を縮めない ← 規約 1章) */
.lang-btn:active svg {
  transform: scale(0.9);
}

.lang-btn svg {
  width: 26px;
  height: 26px;
  display: block;
}

/* 「おと」ボタン。ことばボタンと同じ形・同じ大きさにそろえる
   (逃げ道と設定が並ぶ場所なので、片方だけ小さいのはおかしい)。
   **押した手ごたえは中の絵だけを縮める** —— 箱を縮めると当たり判定ごと縮む(規約 1章)。 */
.sound-btn {
  min-width: 60px;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #262e42;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #b9c4da;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sound-btn svg {
  width: 26px;
  height: 26px;
  display: block;
}

.sound-btn:active svg {
  transform: scale(0.9);
}

/* 消しているあいだは**形(波が消える)と色の両方**で示す */
.sound-btn[data-muted='on'] {
  color: #7a8296;
}

.lang-menu {
  position: absolute;
  inset: 0;
  z-index: 90;
  background: rgba(6, 10, 18, 0.74);
  display: grid;
  place-items: center;
  padding: 14px;
}

.lang-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(rgba(26, 32, 49, 0.98), rgba(17, 21, 33, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}

.lang-item {
  position: relative;
  min-width: 0;
  min-height: 60px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #262e42;
  border: 3px solid transparent;
  color: #dfe6f2;
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

/* いま選ばれている印は**色だけでなく形(チェック)でも**出す */
.lang-item.on {
  border-color: #ffd94d;
  color: #ffd94d;
}

.lang-tick {
  margin-left: 6px;
}

/* 閉じるボタンは**言語カードと同じ大きさ**(逃げ道が的の中でいちばん小さいのはおかしい) */
.lang-close {
  color: #b9c4da;
  font-size: 22px;
}

/* ============================================================
   **ここから下に何も足さないこと。**
   動きをへらす設定は「止めたい規則より後ろ」に無いと効かない
   (特異性が同じなので後勝ちで負ける)。実際に2回踏んだ:
   1回目は media を前に置いてカウント/リザルトが止まらず、
   2回目は `.pin.shake` をこの下に書いて札の揺れが止まらなかった。
   新しい規則は**このブロックより上**に書く。
   ============================================================ */
/* 動きをへらす設定。**止める前に「反応まで消えないか」を確かめてある**(規約 3章):
   - カウント・リザルト・ゴールの拡大は、出す/出さないの情報を文字が持っているので止めてよい
   - 紙吹雪は**落ちる動きが本体**。止めると1点に固まって残るので、出さない
     (お祝いは 🏆 と順位とタイムが伝える)
   - 買えなかったときの揺れも止めてよい。理由は文字(「コインが N まい たりないよ」)が出る
   遊びの中身そのもの(レースの画面)は canvas で、止めると遊びが消えるので触らない */
/* ------------------------------------------------------------------ 横向き(低い画面)
   **つくった車が見えなくなる。** `.preview { flex: 1 1 0 }` は残りの高さをもらう作りなので、
   高さ 375 では **28px の帯**にしかならなかった(実測。車の描画幅は画面の 3.3%)——
   「じぶんで組んだ車で走る」がこのゲームの背骨なのに、組んだ結果が見えない。
   **横向きのときだけ2列にする**(左に車・右にパーツ)。縦向きは1列のまま。 */
@media (orientation: landscape) and (max-height: 520px) {
  .garage {
    display: grid;
    grid-template-columns: minmax(0, 44%) minmax(0, 56%);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 8px;
  }

  .garage header {
    grid-column: 1 / -1;
    padding-bottom: 0;
  }

  .preview {
    grid-column: 1;
    min-height: 0;
  }

  /* **送るのはパネル全体ではなく、選択肢の並びだけ。**
     パネルごと送れるようにして「コースへ すすむ」を貼り付けると、
     初期表示で**そのボタンが2段目の品に重なる**(押せる品が隠れる)。
     パネルを4段の格子にして、真ん中だけを送る形にすると重なりが消える。
     直す前は 667x375 で「いろ」「シール」「よこシール」を開くと
     ボタンが**画面の外**に出ていた(見えている高さ 0px。対象者視点レビューの実測)。 */
  .panel {
    grid-column: 2;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: 18px 0 0 0;
    padding-top: 6px;
  }

  .options {
    overflow-y: auto;
    min-height: 0;
    padding-bottom: 6px;
  }

  .go-row {
    padding: 4px 0 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .count,
  .result,
  .goal-flash {
    animation: none;
  }

  .confetti {
    display: none;
  }

  .opt-btn.shake,
  .pin.shake {
    animation: none;
  }
}
