/* 見た目はぽかぽんシリーズ共通の作法:
   丸ゴシック(Zen Maru Gothic)、砂色の地、パネル、pill、常時表示フッター。 */

:root {
  --sand: #f6e7c9;
  --sand-deep: #e9d3ac;
  --bark: #5b4636;
  --bark-soft: #7d6450;
  --leaf: #6f9a5c;
  --leaf-deep: #4f7742;
  --sky: #7fb8d9;
  --berry: #d1685e;
  --pink: #e0879c;
  --pink-deep: #c25f78;
  --cream: #fffaf0;
  --font-rounded: "Zen Maru Gothic", -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
html { touch-action: manipulation; }   /* iPhoneで連打してもズームさせない */

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-rounded);
  background: var(--sand);
  color: var(--bark);
  -webkit-user-select: none;
  user-select: none;
}

.hidden { display: none !important; }
.dim { color: var(--bark-soft); font-weight: 400; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* 走者の頭上の名前 */
.labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.runner-label {
  position: absolute; transform: translate(-50%, -100%);
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
  background: rgba(255, 250, 240, .92); border: 2px solid var(--sand-deep); color: var(--bark);
  box-shadow: 0 2px 0 rgba(91, 70, 54, .12);
}
.runner-label.me { border-color: var(--pink-deep); background: #fdeef1; color: var(--pink-deep); }
.runner-label .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }

/* ── 音 ─────────────────────────────────────────── */
.sound-controls {
  position: fixed; top: 12px; right: max(12px, env(safe-area-inset-right) + 10px);
  z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.mute-btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 0; line-height: 1;
  width: 40px; height: 40px; font-size: 17px;
  background: var(--cream); border: 2px solid var(--sand-deep); border-radius: 999px; cursor: pointer;
}
.settings-btn { width: 32px; height: 32px; font-size: 14px; }
.sound-panel {
  padding: 12px 14px; background: var(--cream); border: 2px solid var(--sand-deep); border-radius: 14px;
  box-shadow: 0 6px 18px rgba(91, 70, 54, .14);
}
.sound-row { display: flex; align-items: center; gap: 8px; }
.sound-row + .sound-row { margin-top: 6px; }
.sound-mute-btn {
  width: 30px; height: 30px; font-size: 14px; padding: 0; line-height: 1;
  background: var(--sand); border: 2px solid var(--sand-deep); border-radius: 50%; cursor: pointer;
}
.sound-row-label { font-size: 12px; font-weight: 700; color: var(--bark-soft); width: 46px; flex-shrink: 0; white-space: nowrap; }
.sound-volume { width: 92px; min-width: 0; accent-color: var(--pink); }

/* ── ボタン ─────────────────────────────────────── */
button { font-family: inherit; }
.primary-button {
  font-size: 17px; font-weight: 700; padding: 13px 28px; border: none; border-radius: 999px;
  background: var(--pink); color: var(--cream); box-shadow: 0 3px 0 var(--pink-deep); cursor: pointer;
}
.primary-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--pink-deep); }
.primary-button:disabled { opacity: .45; cursor: default; transform: none; }
.secondary-button {
  font-size: 14px; padding: 9px 16px; border: 2px solid var(--sand-deep); border-radius: 999px;
  background: var(--cream); color: var(--bark); cursor: pointer;
}
.secondary-button:active { background: var(--sand-deep); }
.secondary-button:disabled { opacity: .45; cursor: default; }
.button-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; width: 100%; }

/* ── レース中 ───────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  /* 右上の🔇(40px)+ミニマップのぶん、右だけ余白を広げる */
  padding: 10px max(180px, calc(env(safe-area-inset-right) + 176px)) 0 12px;
  pointer-events: none;
}
.hud { width: 100%; max-width: 520px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--cream); border: 2px solid var(--sand-deep); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; white-space: nowrap; max-width: 42vw; overflow: hidden; text-overflow: ellipsis;
}
.pill strong { font-variant-numeric: tabular-nums; font-weight: 700; }
.pill-points { border-color: var(--pink); }
.pill-points strong { color: var(--pink-deep); }
.pill-rank strong { font-size: 17px; color: var(--pink-deep); min-width: 1.2em; text-align: right; }
#pill-gear.dash { border-color: var(--berry); color: var(--berry); }
#pill-gear.walk { border-color: var(--leaf-deep); color: var(--leaf-deep); }
#pill-gear.exhausted { border-color: var(--berry); background: #fde3df; color: var(--berry); }

.stamina-panel {
  display: flex; align-items: center; gap: 8px; width: min(360px, 90vw);
  background: var(--cream); border: 2px solid var(--sand-deep); border-radius: 999px; padding: 4px 12px; font-size: 12px;
}
.stamina-label { font-weight: 700; color: var(--bark-soft); white-space: nowrap; }
.stamina-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--sand-deep); overflow: hidden; }
.stamina-bar > i { display: block; height: 100%; width: 100%; background: var(--leaf); transition: width .08s linear; }
.stamina-panel.low .stamina-bar > i { background: var(--berry); }
.stamina-panel.pad .stamina-bar > i { background: #3ec26b; }
.stamina-num { font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; font-weight: 700; }

.minimap-wrap {
  /* 🔇(12〜52px)と⚙️(58〜90px)の下に置く */
  position: fixed; top: 98px; right: max(12px, env(safe-area-inset-right) + 10px); z-index: 20;
  background: rgba(255, 250, 240, .9); border: 2px solid var(--sand-deep); border-radius: 12px; padding: 4px;
  pointer-events: none;
}
.minimap-wrap canvas { display: block; width: 150px; height: 110px; }
.minimap-caption { margin: 2px 0 0; font-size: 10px; text-align: center; color: var(--bark-soft); line-height: 1.4; }
.minimap-caption .legend { display: block; font-size: 9px; }
.minimap-caption i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: -1px; margin: 0 1px 0 3px; }
.minimap-caption .lg-pad { background: #3ec26b; }
.minimap-caption .lg-rock { background: #9a948a; border: 1px solid #3b2f26; border-radius: 2px; transform: rotate(45deg); width: 6px; height: 6px; }
.minimap-caption .lg-hill { background: linear-gradient(90deg, #d9b98a, #784e28); border-radius: 2px; width: 14px; }

/* ダッシュ中の風。ふちから中心へ向かう線が流れる(中心は透明なので走者は見える) */
.wind {
  position: fixed; inset: 0; z-index: 18; pointer-events: none; opacity: 0; transition: opacity .25s;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0) 0 22px, rgba(255,255,255,.55) 22px 24px, rgba(255,255,255,0) 24px 60px);
  -webkit-mask: radial-gradient(ellipse at center, transparent 38%, #000 85%);
  mask: radial-gradient(ellipse at center, transparent 38%, #000 85%);
  transform: perspective(300px) rotateX(70deg) scale(2.6);
  transform-origin: 50% 50%;
  animation: wind-flow .28s linear infinite;
}
.wind::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0) 0 30px, rgba(255,255,255,.35) 30px 32px, rgba(255,255,255,0) 32px 80px);
  animation: wind-flow-v .32s linear infinite;
}
.wind.on { opacity: 1; }
@keyframes wind-flow { to { background-position: -60px 0; } }
@keyframes wind-flow-v { to { background-position: 0 80px; } }

.countdown {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 25;
  font-size: min(28vw, 140px); font-weight: 900; color: var(--cream); pointer-events: none;
  text-shadow: 0 6px 0 var(--pink-deep), 0 0 30px rgba(0, 0, 0, .25);
}
.race-banner {
  position: fixed; top: 34%; left: 50%; transform: translate(-50%, -6px); z-index: 25;
  background: var(--cream); border: 2px solid var(--sand-deep); border-radius: 14px; padding: 8px 18px;
  font-size: 16px; font-weight: 700; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.race-banner.show { opacity: 1; transform: translate(-50%, 0); }

.bottombar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 74px; z-index: 20;
  width: min(520px, 94vw); display: flex; flex-direction: column; gap: 6px;
}
.touch-row { display: flex; gap: 8px; justify-content: center; }
.touch-btn {
  flex: 1 1 0; height: 62px; border-radius: 16px; border: 2px solid var(--sand-deep);
  background: rgba(255, 250, 240, .92); font-size: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent;
}
.touch-btn small { font-size: 11px; font-weight: 700; color: var(--bark-soft); }
.touch-btn.steer { flex: 0 0 70px; }
.touch-btn.dash { border-color: var(--berry); }
.touch-btn.run { border-color: var(--leaf-deep); }
.touch-btn.on { background: var(--pink); border-color: var(--pink-deep); color: var(--cream); }
.touch-btn.on small { color: var(--cream); }
.action-row { display: flex; gap: 6px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.speed-pill { font-size: 13px; }
.speed-pill strong { min-width: 2.6em; text-align: right; }
.speed-pill.dash { border-color: var(--berry); color: var(--berry); }
.key-hint { font-size: 11px; color: var(--bark-soft); background: rgba(255, 250, 240, .8); border-radius: 999px; padding: 3px 10px; }
.quit-button { color: var(--bark-soft); }
@media (hover: none) { .key-hint { display: none; } }

/* ── スマホの仮想スティック(タッチ端末だけ) ─────────── */
.touch-controls { display: none; }
@media (hover: none) {
  .touch-controls { display: block; position: fixed; inset: 0; z-index: 15; pointer-events: none; }
  .touch-zone { position: absolute; left: 0; top: 120px; bottom: 150px; width: 55%; pointer-events: auto; touch-action: none; }
  .touch-stick {
    position: absolute; left: 90px; bottom: 210px; width: 122px; height: 122px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .5); background: rgba(0, 0, 0, .22);
    transform: translate(-50%, 50%); opacity: .5; transition: opacity .15s;
  }
  .touch-stick.active { opacity: 1; background: rgba(0, 0, 0, .32); border-color: rgba(255, 255, 255, .8); transition: none; }
  .touch-stick-knob {
    position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%;
    background: rgba(255, 255, 255, .65); border: 2px solid rgba(255, 255, 255, .9); transform: translate(-50%, -50%);
  }
  .touch-zone-label {
    position: absolute; left: 90px; bottom: 138px; transform: translateX(-50%);
    color: #fff; font-size: 11px; font-weight: 700; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); white-space: nowrap;
  }
  .touch-dash {
    position: absolute; right: 18px; bottom: 160px; width: 92px; height: 92px; border-radius: 50%;
    pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent;
    border: 3px solid rgba(255, 255, 255, .7); background: rgba(209, 104, 94, .6); color: #fff;
    font-family: inherit; font-size: 28px; font-weight: 800; line-height: 1.1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  }
  .touch-dash small { font-size: 11px; }
  .touch-jump {
    position: absolute; right: 122px; bottom: 172px; width: 72px; height: 72px; border-radius: 50%;
    pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent;
    border: 3px solid rgba(255, 255, 255, .7); background: rgba(111, 154, 92, .65); color: #fff;
    font-family: inherit; font-size: 22px; font-weight: 800; line-height: 1.1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  }
  .touch-jump small { font-size: 10px; }
  .touch-jump:active { transform: scale(.94); }
  .touch-dash.on { background: rgba(209, 104, 94, .95); transform: scale(.94); }
}

/* ── 画面 ───────────────────────────────────────── */
.screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 16px 14px 84px; overflow-y: auto;
  background: rgba(246, 231, 201, .96);
}
.screen.peek { background: rgba(246, 231, 201, .28); align-items: flex-end; }
.panel {
  width: min(460px, 92vw); margin: auto 0;
  background: var(--cream); border: 3px solid var(--sand-deep); border-radius: 22px; padding: 20px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  box-shadow: 0 6px 0 rgba(91, 70, 54, .12);
}
.panel.wide { width: min(560px, 94vw); }
.panel.bottom { margin: 0 0 6px; padding: 14px 14px; gap: 10px; }
.hero-emoji { font-size: 44px; line-height: 1; }
.title { font-size: 24px; margin: 0; }
.lead { margin: 0; font-size: 14px; line-height: 1.8; color: var(--bark-soft); }
.note { font-size: 12px; color: var(--bark-soft); margin: 0; min-height: 1.2em; }
.note.bad { color: var(--berry); font-weight: 700; }
.note.good { color: var(--leaf-deep); font-weight: 700; }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; font-size: 12px; }
.rules-link, .link-row .home-link, .share-button {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px;
  border: 2px solid var(--sand-deep); border-radius: 999px; background: var(--cream); color: var(--leaf-deep);
  font-size: 12px; font-weight: 700; font-family: inherit; text-decoration: none; cursor: pointer;
}
.rules-link:hover, .link-row .home-link:hover, .share-button:hover { border-color: var(--pink); background: #fdeef1; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--bark-soft); width: 100%; }
.field input {
  font: inherit; font-size: 16px; padding: 10px 14px; border: 2px solid var(--sand-deep); border-radius: 14px;
  background: var(--sand); color: var(--bark); text-align: center;
}
.field-label { font-size: 12px; color: var(--bark-soft); margin: 0; }

.pill-choices { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.pill-choices button {
  font-family: inherit; font-size: 14px; padding: 8px 16px; border: 2px solid var(--sand-deep); border-radius: 999px;
  background: var(--cream); color: var(--bark); cursor: pointer;
}
.pill-choices button.on { background: var(--leaf); border-color: var(--leaf-deep); color: var(--cream); font-weight: 700; }
.pill-choices.small button { padding: 6px 14px; font-size: 12px; }

.mode-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 4px 0; }
.mode-option {
  border: 2px solid var(--sand-deep); border-radius: 14px; background: var(--cream); padding: 12px 6px;
  cursor: pointer; text-align: center; font-family: inherit; color: inherit;
}
.mode-option .mode-name { display: block; font-size: 14px; font-weight: 800; }
.mode-option .mode-sub { display: block; font-size: 10.5px; color: var(--bark-soft); margin-top: 4px; line-height: 1.4; }
.mode-option.active { border-color: var(--pink-deep); background: #fdeef1; box-shadow: 0 0 8px rgba(194, 95, 120, .35); }

/* キャラクター選択 */
.char-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.char-btn {
  border: 2px solid var(--sand-deep); border-radius: 12px; background: var(--cream); padding: 8px 4px;
  font-family: inherit; font-size: 11.5px; font-weight: 700; color: var(--bark); cursor: pointer; line-height: 1.3;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.char-btn .swatch { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .12); }
.char-btn .trait { font-size: 9.5px; font-weight: 500; color: var(--bark-soft); line-height: 1.25; }
.char-btn.active { border-color: var(--pink-deep); background: #fdeef1; }
.char-btn:disabled { opacity: .6; cursor: progress; }
@media (max-width: 380px) { .char-grid { grid-template-columns: repeat(3, 1fr); } }

/* コース選択 */
.course-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.course-card {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 2px solid var(--sand-deep); border-radius: 14px; background: var(--cream); padding: 8px 10px;
  font-family: inherit; color: inherit; cursor: pointer;
}
.course-card:hover { background: #fdeef1; border-color: var(--pink); }
.course-card canvas { width: 72px; height: 50px; flex-shrink: 0; background: var(--sand); border-radius: 8px; }
.course-card .course-text { flex: 1; min-width: 0; }
.course-card .course-name { display: block; font-size: 14px; font-weight: 800; }
.course-card .course-sub { display: block; font-size: 11px; color: var(--bark-soft); }
.course-card .course-no { font-size: 20px; font-weight: 900; color: var(--pink-deep); width: 1.4em; text-align: center; flex-shrink: 0; }
.course-card .course-del {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--sand-deep);
  background: var(--cream); cursor: pointer; font-size: 13px;
}
.course-heading { font-size: 12px; font-weight: 700; color: var(--bark-soft); margin: 6px 0 0; text-align: left; width: 100%; }

/* エディタ */
.editor-canvas {
  width: 100%; max-width: 520px; aspect-ratio: 6 / 5; height: auto;
  background: #eef7e6; border: 2px solid var(--sand-deep); border-radius: 14px; touch-action: none; cursor: crosshair;
}

/* ランキング */
.ranking-title { font-size: 14px; margin: 4px 0 2px; font-weight: 700; }
.ranking-groups { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.ranking-group { background: var(--sand); border: 2px solid var(--sand-deep); border-radius: 14px; padding: 10px 12px 4px; }
.ranking-group-title { font-size: 13px; font-weight: 800; color: var(--pink-deep); margin: 0 0 4px; }
.ranking-note { font-size: 12px; color: var(--bark-soft); margin: 0 0 4px; line-height: 1.5; }
.ranking-list { list-style: none; margin: 10px 0 0; padding: 0; text-align: left; font-size: 14px; max-height: 30vh; overflow-y: auto; }
.ranking-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--sand-deep); }
.ranking-list li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-list li .val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranking-list li.me { background: #fdeef1; border-radius: 10px; font-weight: 700; }
.ranking-list li.empty { justify-content: center; color: var(--bark-soft); border: none; }
.ranking-list.loading { opacity: .45; transition: opacity .15s; }
.ranking-list.compact { max-height: 24vh; font-size: 13px; }
.result-table { width: 100%; margin-top: 0; }
.result-table .swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; border: 1px solid rgba(0, 0, 0, .15); }
.result-place { font-size: 15px; margin: 0; }
.result-points { font-size: 16px; margin: 0; }
.result-points strong { font-size: 30px; color: var(--leaf-deep); }
.countdown-num { margin: 0; font-size: 16px; }
.countdown-num strong { font-size: 44px; color: var(--pink-deep); font-variant-numeric: tabular-nums; }
.match-list { width: 100%; max-height: 30vh; }
.mode-choice-button { display: flex; flex-direction: column; gap: 3px; align-items: center; width: 100%; }
.mode-choice-sub { font-size: 12px; font-weight: 400; opacity: .9; }
.result-place strong { font-size: 40px; color: var(--pink-deep); }

/* よみこみ */
.loading-panel { gap: 10px; }
.loading-title { margin: 0; font-size: 15px; }
.loading-bar { width: min(260px, 70vw); height: 12px; border-radius: 999px; background: var(--sand-deep); overflow: hidden; }
.loading-bar-fill { height: 100%; width: 0; background: var(--pink); transition: width .2s; }
.loading-percent { margin: 0; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--bark-soft); }
.loading-error { margin: 0; font-size: 13px; color: var(--berry); display: flex; flex-direction: column; gap: 8px; align-items: center; }

/* 確認モーダル */
.overlay { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(60, 45, 35, .45); }
.modal-card { background: var(--cream); border: 3px solid var(--sand-deep); border-radius: 18px; padding: 20px 18px; width: min(360px, 90vw); text-align: center; }
.modal-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; }
.modal-buttons { display: flex; flex-direction: column; gap: 8px; }

/* ── 常時表示フッター ─────────────────────────── */
.site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--sand-deep); color: var(--bark); text-align: center; font-size: 11px; line-height: 1.7;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--bark); }
.version-link { font-size: 10px; text-decoration: none; border-bottom: 1px dotted currentColor; font-weight: 700; }
.version-link:hover { color: var(--pink-deep); }

/* ── 法務モーダル ─────────────────────────────── */
.legal-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.legal-modal-backdrop { position: absolute; inset: 0; background: rgba(60, 45, 35, .55); }
.legal-modal-body {
  position: relative; width: min(720px, 94vw); height: min(80vh, 720px);
  background: var(--cream); border-radius: 18px; overflow: hidden; box-shadow: 0 10px 40px rgba(60, 45, 35, .35);
}
.legal-modal-body iframe { width: 100%; height: 100%; border: none; }
.legal-modal-close {
  position: absolute; top: 8px; right: 10px; z-index: 1; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--sand-deep); background: var(--cream); color: var(--bark); font-size: 15px; cursor: pointer;
}

@media (max-height: 620px) {
  .title { font-size: 20px; }
  .touch-btn { height: 50px; font-size: 20px; }
}
@media (max-width: 600px) {
  .topbar { padding-right: max(170px, calc(env(safe-area-inset-right) + 166px)); }
  .hud { justify-content: flex-start; }
  .stamina-panel { width: 100%; }
}
