/* =====================================================================
   作り込む文字の型（『超絶怒涛のGスイング！』で塾長OKが出た版）
   - 選ぶ文字（説明・内訳・ボタン）: --font-ui のまま。読みやすさ優先
   - 作り込む文字（数字・コンボ・ハンコ・掛け声・スコア）: .fx を付ける
   - タイトルロゴ: WARI RUN 専用（下の「WARI RUN のタイトルロゴ」）
   外部フォントは読み込まない。各OSの標準から一番太い書体を選ぶ。
   ゲームに合わせて変えてよいのは色（--ink / --gloss-*）と角度・厚みだけ。
   ===================================================================== */
:root {
  --ink: #2b2140; /* 縁と厚みの色。真っ黒より濃紺・濃紫が明るい画面になじむ */
  --font-ui: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  --font-num: "Futura-CondensedExtraBold", "Futura Condensed ExtraBold", "AvenirNextCondensed-Heavy", "Avenir Next Condensed", Impact, "Arial Black", sans-serif;
  --font-jp: "Hiragino Sans", "Hiragino Kaku Gothic StdN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  --font-fx: var(--font-num), var(--font-jp);
  /* 光沢：上半分に明るい帯、38→40%で境目をくっきり */
  --gloss-gold: linear-gradient(180deg, #fffde0 0%, #fff27a 38%, #ffc21a 40%, #ff8a1f 78%, #ff5a1f 100%);
  --gloss-pink: linear-gradient(180deg, #ffe3f4 0%, #ff8ad8 38%, #ff3c8a 40%, #c8176e 100%);
  --gloss-cyan: linear-gradient(180deg, #f0ffff 0%, #9ff3ff 38%, #3dc6ff 40%, #1a6fe0 100%);
  --gloss-white: linear-gradient(180deg, #ffffff 0%, #ffffff 40%, #dfe8ff 42%, #b6c6f0 100%);
}
html, body { font-family: var(--font-ui); }

/* ---------- 演出の文字 ---------- */
.fx {
  font-family: var(--font-fx);
  font-weight: 900;
  font-style: italic;
  color: transparent;
  /* 注意: background の一括指定は background-clip をリセットして四角く塗れる。必ず background-image */
  background-image: var(--gloss-gold);
  -webkit-background-clip: text;
  background-clip: text;
  /* 縁（4方向）＋右下へずらした厚み。transform と一緒に動くので重ねても軽い */
  filter: drop-shadow(2px 0 0 var(--ink)) drop-shadow(-2px 0 0 var(--ink)) drop-shadow(0 2px 0 var(--ink)) drop-shadow(0 -2px 0 var(--ink)) drop-shadow(2px 4px 0 var(--ink));
  padding: 0 0.12em; /* 斜体の右端が切れないように */
  white-space: nowrap;
}
.fx.jp { font-family: var(--font-jp); }          /* 日本語の掛け声 */
.fx.pink { background-image: var(--gloss-pink); } /* 最高評価・FEVER */
.fx.cyan { background-image: var(--gloss-cyan); } /* コンボ・ゴール */
.fx.white { background-image: var(--gloss-white); } /* 常時表示のスコア */
.fx.stamp { /* 画面中央のハンコ。必ず画面幅で上限を切る */
  font-size: clamp(34px, 11.5cqw, 92px);
  filter: drop-shadow(3px 0 0 var(--ink)) drop-shadow(-3px 0 0 var(--ink)) drop-shadow(0 3px 0 var(--ink)) drop-shadow(0 -3px 0 var(--ink)) drop-shadow(4px 7px 0 var(--ink)) drop-shadow(0 0 18px rgba(255, 220, 120, 0.6));
}

/* ---------- WARI RUN のタイトルロゴ（このゲーム専用） ----------
   「走って伸びた犬が、割り算の棒になる」。上に WARI、下に RUN、間を犬が走りぬけて WARI ÷ RUN の形にする。
   絵は index.html の中の SVG（オブジェクトエディターの logo001）。ここでは大きさ・傾き・動きだけを付ける。
   大きさは --tile（画面の高さごとに下の方で決めている）× --k。背の高い縦画面だけ --k を上げて大きく見せる。 */
#logo {
  --tile: clamp(40px, min(17cqw, 9dvh), 84px); --k: 2.5;
  position: relative; z-index: 1; margin: 0 0 14px; padding: 0; line-height: 0;
  height: calc(var(--tile) * var(--k)); aspect-ratio: 800 / 540; max-width: 96cqw;
  transform: rotate(-5deg);
}
@media (orientation: portrait) and (min-height: 600px) { #logo { --k: 3.4; } }
.wl { display: block; width: 100%; height: 100%; overflow: visible; }
#wl-wari { animation: wlTop 0.55s 0.28s cubic-bezier(0.2, 1.7, 0.4, 1) both; }
#wl-run { animation: wlBot 0.55s 0.28s cubic-bezier(0.2, 1.7, 0.4, 1) both; }
#wl-dog { transform-origin: 720px 266px; animation: wlDash 0.42s cubic-bezier(0.1, 0.9, 0.2, 1) both; }
.wl-leg, #wl-ear, #wl-tail { transform-box: fill-box; }
.wl-leg { animation: wlLeg 0.34s ease-in-out infinite alternate; }
.wl-b1 { transform-origin: 100% 70%; } .wl-b2 { transform-origin: 100% 10%; }
.wl-f1 { transform-origin: 0 20%; } .wl-f2 { transform-origin: 0 10%; }
.wl-b2, .wl-f1 { animation-delay: -0.17s; }
#wl-ear { transform-origin: 100% 45%; animation: wlEar 0.34s ease-in-out infinite alternate; }
#wl-tail { transform-origin: 75% 90%; animation: wlTail 0.17s ease-in-out infinite alternate; }
#wl-slot-hide-speed rect { animation: wlLine 0.5s linear infinite; }
#wl-slot-hide-speed rect:nth-child(2) { animation-delay: -0.18s; } #wl-slot-hide-speed rect:nth-child(3) { animation-delay: -0.33s; }
@keyframes wlTop { from { opacity: 0; transform: translateY(60px); } }
@keyframes wlBot { from { opacity: 0; transform: translateY(-60px); } }
@keyframes wlDash { from { transform: translateX(-820px) scaleX(1.5); } }
@keyframes wlLeg { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
@keyframes wlEar { from { transform: rotate(-6deg); } to { transform: rotate(8deg); } }
@keyframes wlTail { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
@keyframes wlLine { from { transform: translateX(26px); opacity: 1; } to { transform: translateX(-30px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .wl * { animation: none !important; }
}

/* =====================================================================
   WARI RUN 固有
   色の役割：世界＝夜明けの紫と淡い空 / 主役＝白い犬 / 操作・目標＝金 /
   危険＝赤 / 左右の幕＝青（左）と赤（右）で固定（正解の色ではない）
   ===================================================================== */
:root { --bg: #2a2250; --panel: #fffaf0; --gate-l: #2d9cff; --gate-r: #ff4d6d; --gold: #ffc21a; --danger: #ff4d6d; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; touch-action: manipulation; color: var(--ink); }
#app {
  position: relative; display: flex; flex-direction: column; height: 100dvh; max-width: 520px; margin: 0 auto;
  background: #b9e4ff; box-shadow: 0 0 0 100vmax var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
}
#stage { container-type: inline-size; position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---- HUD ---- */
#hud { position: absolute; inset: 0 0 auto 0; padding: 10px 14px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; pointer-events: none; }
#hud[hidden] { display: none; }
#score { font-size: clamp(34px, 10vw, 54px); line-height: 1; }
#hearts { display: flex; gap: 4px; }
#hearts svg { width: clamp(20px, 6vw, 28px); height: auto; filter: drop-shadow(0 2px 0 var(--ink)); transition: transform 0.15s; }
#hearts svg.lost { opacity: 0.25; filter: none; }
#hearts svg.hit { animation: heartHit 0.35s; }
@keyframes heartHit { 30% { transform: scale(1.5) rotate(-12deg); } }
#combo { font-size: clamp(22px, 6.5vw, 32px); }
#vol {
  position: absolute; right: 10px; top: 10px; z-index: 5; font: 800 13px var(--font-ui); color: var(--ink);
  background: var(--panel); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 12px; box-shadow: 0 3px 0 var(--ink);
}
#fxlayer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; left: 50%; transform: translate(-50%, 0); animation: popUp 0.9s ease-out forwards; will-change: transform, opacity; }
@keyframes popUp { 0% { transform: translate(-50%, 18px) scale(0.4); opacity: 0; } 12% { transform: translate(-50%, 0) scale(1.15); opacity: 1; } 24% { transform: translate(-50%, 0) scale(1); } 70% { transform: translate(-50%, -14px) scale(1); opacity: 1; } 100% { transform: translate(-50%, -34px) scale(1); opacity: 0; } }
.pop:not(.stamp) { font-size: clamp(28px, 9.5cqw, 46px); }
.pop.small { font-size: clamp(24px, 7.5cqw, 36px); }
/* ミスの理由。光沢文字ではなく、読みやすい白い札にする */
.pop.why { font: 900 clamp(15px, 4.6cqw, 22px) var(--font-jp); color: var(--ink); background: #fff; -webkit-background-clip: border-box; background-clip: border-box; filter: none; border: 3px solid var(--ink); border-radius: 999px; padding: 3px 14px; white-space: nowrap; box-shadow: 0 3px 0 var(--ink); animation-duration: 1.4s; }
/* 縦の低い画面（SE縦・360×640）は理由の札の下が最大で約10px切れる。「ミス！」「ちがう！」と札をいっしょに少し上げる（間はそのまま） */
@media (orientation: portrait) and (max-height: 700px) { .pop.jp, .pop.why { margin-top: -12px; } }
.flash { position: absolute; inset: 0; opacity: 0; animation: flash 0.28s ease-out; }
@keyframes flash { 0% { opacity: 0.45; } 100% { opacity: 0; } }
.shake { animation: shake 0.3s; }
@keyframes shake { 20% { transform: translate(-5px, 2px); } 40% { transform: translate(5px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }

/* ---- 操作（下の帯）：素数ボタンはプレイヤーの下・左右タップの上 ---- */
#controls { flex: 0 0 auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(180deg, #4a3d8f, #2a2250); border-top: 4px solid var(--ink); }
#row1 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; }
#prime {
  width: 100%; height: clamp(52px, 8.5dvh, 70px); font: italic 900 clamp(28px, 8.5vw, 40px) var(--font-fx); letter-spacing: 0.04em;
  color: var(--ink); background-image: var(--gloss-gold); border: 4px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink);
}
#prime:disabled { filter: grayscale(0.7) brightness(0.8); }
#prime:not(:disabled):active, #prime.armed { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
#prime.armed { background-image: var(--gloss-pink); color: #fff; }
#boost {
  position: relative; height: clamp(52px, 8.5dvh, 70px); border: 4px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink);
  background-image: var(--gloss-cyan); color: var(--ink); display: grid; align-content: center; justify-items: center; line-height: 1; padding: 0 4px; touch-action: none;
}
#boost span { font: italic 900 clamp(20px, 6vw, 28px) var(--font-fx); letter-spacing: 0.02em; }
#boost small { font: 800 clamp(10px, 2.9vw, 12px) var(--font-ui); margin-top: 3px; }
#boost:disabled { filter: grayscale(0.7) brightness(0.8); }
#boost.on { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); background-image: var(--gloss-pink); color: #fff; }
/* 横向きの低い画面はボタンの高さが下限の52pxになるのに文字は画面の幅で最大になり、下が切れる。文字を高さに合わせて小さくする */
@media (orientation: landscape) and (max-height: 500px) {
  #prime { font-size: 28px; }
  #boost span { font-size: 22px; line-height: 1; }
  #boost small { font-size: 10px; line-height: 1; margin-top: 1px; }
}
/* 縦の低い画面（SE縦など）もボタンが低く、ブーストの2行が上下に約1pxはみ出す。文字の大きさはそのままで行の高さだけ詰める */
@media (orientation: portrait) and (max-height: 700px) {
  #boost span { line-height: 1; }
  #boost small { line-height: 1; margin-top: 1px; }
}
/* ブースト中に走る5本の光の線（transform と opacity だけ動かす） */
#speedlines { position: absolute; inset: 0; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 0.18s; }
#speedlines.on { opacity: 1; }
#speedlines i {
  position: absolute; top: 14%; width: 7px; height: 38%; border-radius: 4px; transform-origin: 50% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 55%, rgba(120, 220, 255, 0.9)); box-shadow: 0 0 12px 2px rgba(150, 230, 255, 0.8);
  animation: streak 0.42s linear infinite; will-change: transform, opacity;
}
#speedlines i:nth-child(1) { left: 12%; --dx: -18vw; animation-delay: 0s; }
#speedlines i:nth-child(2) { left: 31%; --dx: -8vw; animation-delay: 0.17s; }
#speedlines i:nth-child(3) { left: 50%; --dx: 0vw; animation-delay: 0.08s; }
#speedlines i:nth-child(4) { left: 69%; --dx: 8vw; animation-delay: 0.3s; }
#speedlines i:nth-child(5) { left: 88%; --dx: 18vw; animation-delay: 0.23s; }
@keyframes streak { 0% { transform: translate(0, -20%) scaleY(0.4); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(var(--dx), 190%) scaleY(1.5); opacity: 0; } }
/* 左右は「ボタン」ではなく、画面下半分を左・右に分けたタッチ領域。どこを押しても左か右へ行く */
#controls { padding-bottom: 0; }
#lr { display: grid; grid-template-columns: 1fr 1fr; margin: 0 -12px; }
#lr button {
  position: relative; height: clamp(96px, 18dvh, 160px); padding: 0 0 env(safe-area-inset-bottom, 0px); border: 0; border-radius: 0; box-shadow: none;
  font: 900 clamp(54px, 17cqw, 84px) var(--font-ui); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink);
  background: linear-gradient(180deg, rgba(42, 34, 80, 0.2), var(--tint)); transition: background 0.1s;
}
#btnL { --tint: rgba(45, 156, 255, 0.62); }
#btnR { --tint: rgba(255, 77, 109, 0.62); }
#btnL::after { content: ""; position: absolute; right: 0; top: 14%; bottom: 14%; width: 2px; background: rgba(255, 255, 255, 0.28); }
#lr button.on { filter: brightness(1.25) saturate(1.1); }
#lr button:active { filter: brightness(1.4); }

/* ---- タイトル・結果 ---- */
.card-screen {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 16px clamp(16px, 6vw, 32px); text-align: center; background: rgba(42, 34, 80, 0.62); overflow: clip; /* 放射光のはみ出しを切る */
}
.card-screen[hidden] { display: none; }
#title { padding-top: 54px; /* 右上の音量ボタンとロゴが重ならないように */ }
#result { background: rgba(32, 25, 66, 0.86); }
/* 結果の左右の列。縦向きは列を作らず、そのまま上から並べる */
.r-col { display: contents; }
/* 横向きの低い画面（iPhone横など）は高さが足りないので、左に点と成績、右に「次は」の枠と「もう一回！」を並べる。
   iPad横・PC はゲームの列が縦長（幅約400px）で、2列にすると列が狭くなり「ジャンプ成功」が折れるので、縦向きと同じ1列にする */
@media (orientation: landscape) and (max-height: 500px) {
  #result { flex-direction: row; gap: clamp(12px, 3vw, 32px); }
  .r-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; flex: 1 1 0; min-width: 0; max-width: 420px; }
  #result .stats { grid-template-columns: 1fr 1fr; }
  #r-best { word-break: keep-all; } /* 列が狭いので、「自己ベスト更新！」と「（この端末の記録）」の間でだけ折る（「記／録」と折れないように） */
  #retry { white-space: nowrap; padding-inline: 22px; font-size: clamp(24px, 5.5vh, 32px); } /* 列の幅が狭いので2行に折れないようにする */
}
.how { position: relative; z-index: 2; list-style: none; margin: 0; padding: 12px 14px; width: 100%; max-width: 380px; background: var(--panel); border: 4px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); text-align: left; display: grid; gap: 8px; }
.how li { display: grid; grid-template-columns: 4.6em 1fr; gap: 8px; align-items: baseline; font-size: clamp(12px, 3.5vw, 16px); }
.how li span { text-wrap: balance; /* 折り返しても、最後の1文字だけが次の行に残らないように */ }
.how b.how-arrows { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 4px 6px; }
.how b.how-arrows svg { width: 1.05em; height: 1.05em; fill: #fff; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.how b { font-family: var(--font-jp); font-weight: 900; background: var(--ink); color: #fff; border-radius: 8px; padding: 2px 6px; text-align: center; }
.big-btn { position: relative; z-index: 2; font: italic 900 clamp(28px, 9vw, 40px) var(--font-fx); color: var(--ink); background-image: var(--gloss-gold); border: 4px solid var(--ink); border-radius: 22px; padding: 10px 34px; box-shadow: 0 7px 0 var(--ink); }
.big-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
#retry { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.best { position: relative; z-index: 2; margin: 0; color: #fff; font-weight: 800; font-size: clamp(13px, 3.8vw, 15px); text-shadow: 0 2px 0 var(--ink); }
.version { position: absolute; right: 10px; bottom: 6px; z-index: 2; margin: 0; color: rgba(255, 255, 255, 0.75); font-size: 12px; pointer-events: none; }
.err { margin: 0; max-width: 340px; padding: 10px 12px; background: #fff; border: 3px solid var(--danger); border-radius: 12px; font-size: 14px; font-weight: 700; }
#r-score { font-size: clamp(44px, 14vw, 76px); line-height: 1; }
#rank { animation: stampIn 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both; font-size: clamp(64px, 22vw, 120px); line-height: 1; } /* 行の高さを詰めて、まちがえた問題の分を空ける */
@keyframes stampIn { from { transform: scale(3) rotate(-14deg); opacity: 0; } }
.stats { list-style: none; margin: 0; padding: 10px 14px; width: 100%; max-width: 340px; background: var(--panel); border: 4px solid var(--ink); border-radius: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: clamp(13px, 3.8vw, 15px); text-align: left; }
.stats b { float: right; }
.hint { margin: 0; max-width: 340px; padding: 8px 12px; background: #fff3b8; border: 3px solid var(--ink); border-radius: 12px; font-size: clamp(13px, 3.8vw, 15px); font-weight: 700; }
.hint p { margin: 0; }
#r-hint::before { content: "ヒント "; font-weight: 900; color: #b25a00; }
/* 次に練習すること（いちばん多かったまちがいから）。枠のいちばん上に大きめに出す */
#r-next { margin-bottom: 6px; font-weight: 900; font-size: 1.12em; color: var(--ink); }
#r-next::before { content: "次は "; color: #c8193c; }
/* ランクの次の段までの点 */
.best.up { font-size: clamp(12px, 3.4vw, 14px); color: #ffe27a; }
.best.up[hidden] { display: none; }
/* その回にまちがえた問題（最大3つ）。ヒントと同じ枠の上に小さな札で並べる */
.miss { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 6px; }
.miss[hidden] { display: none; }
.miss::before { content: "まちがえた"; font-weight: 900; color: #c8193c; }
.miss li { padding: 1px 8px; background: #fff; border: 2px solid var(--ink); border-radius: 8px; font-weight: 900; white-space: nowrap; }

@media (max-height: 700px) {
  .card-screen { gap: 8px; padding-block: 10px; }
  .how { padding: 8px 12px; gap: 5px; }
  .how li { font-size: 12px; }
  .big-btn { padding: 6px 28px; font-size: 26px; }
  .stats { padding: 6px 12px; font-size: 12px; }
  .hint { font-size: 12px; padding: 6px 10px; }
  .miss { margin-bottom: 4px; gap: 3px 4px; }
  .miss li { padding: 0 6px; }
  #r-next { margin-bottom: 4px; }
  #result { gap: 6px; }
  #rank { font-size: 52px; }
  #r-score { font-size: 40px; }
}
@media (max-height: 620px) {
  #title { padding-top: 46px; }
  #logo { --tile: clamp(36px, min(17cqw, 8dvh), 84px); margin-bottom: 4px; }
  .how li span { font-size: 11px; } .how li { grid-template-columns: 4.2em 1fr; } }
/* ラボの「戻る入口」が出ている間は、上の予約領域のぶん結果画面の中身が下へ押される。高さ820px以下（PCの小さな窓など）で、ランクと点数を少し小さくして「もう一回」を画面内に収める */
@media (max-height: 820px) {
  html[data-oikaze-lab-return="visible"] #rank { font-size: 56px; }
  html[data-oikaze-lab-return="visible"] #r-score { font-size: 44px; }
}
/* ラボの「戻る入口」が出ている間は、上の予約領域のぶん中身が下へ押される。背の低い画面（iPhone SE など）で、ロゴを少し小さくして、自己ベストの行まで画面内に収める */
@media (max-height: 620px) {
  html[data-oikaze-lab-return="visible"] #logo { --tile: clamp(30px, min(15cqw, 6.6dvh), 84px); margin-bottom: 6px; }
  html[data-oikaze-lab-return="visible"] .card-screen { gap: 5px; padding-block: 6px; }
  html[data-oikaze-lab-return="visible"] #rank { font-size: 40px; }
  html[data-oikaze-lab-return="visible"] #r-score { font-size: 34px; }
}

/* 音ファイルのクレジット（素材を入れたときだけ表示）。タイトルの一番下に、小さく目立たなく並べる */
.credit { position: relative; z-index: 2; margin: -2px 0 0; text-align: center; font: 700 10px var(--font-ui); color: rgba(255, 255, 255, 0.72); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5); pointer-events: none; }
.credit[hidden] { display: none; }

/* PCの小さな窓など（高さ820px以下）：ラボの戻る入口が出ている間は、ロゴを少し小さくして、クレジットの行まで画面内に収める */
@media (max-height: 820px) {
  html[data-oikaze-lab-return="visible"] #logo { --tile: clamp(32px, min(17cqw, 7.4dvh), 84px); }
}
/* 新ロゴ(タイル)は旧ロゴより少し背が高い。ラボの「戻る入口」が出ている間、背の低い画面(〜700px)ではロゴを小さくし、サブタイトルを隠して、自己ベストまで画面内に収める */
@media (max-height: 700px) {
  html[data-oikaze-lab-return="visible"] #title { padding-top: 46px; }
  html[data-oikaze-lab-return="visible"] #logo { --tile: clamp(32px, min(15cqw, 7.4dvh), 84px); margin-bottom: 4px; }
}

/* --- main の版から引きつぐ詰め（タイトル・結果の間は押せない操作ボタンを隠す、低い画面で結果を詰める） --- */
/* 縦向きも、タイトル・結果の間は押せない操作ボタン（素数・ブースト・◀▶）を隠す（横向きの低い画面と同じ扱い） */
@media (orientation: portrait) {
  #app:has(#title:not([hidden])) #controls, #app:has(#result:not([hidden])) #controls { display: none; }
}
/* 横向きの低い画面（iPhone横など）は、タイトル・結果の間だけ下の操作ボタンを隠して高さを空ける */
@media (orientation: landscape) and (max-height: 500px) {
  #app:has(#title:not([hidden])) #controls, #app:has(#result:not([hidden])) #controls { display: none; }
  .card-screen { gap: 6px; }
  .stats, .hint { max-width: 480px; } /* 横幅を使って行数を減らす */
  .stats { grid-template-columns: repeat(4, 1fr); }
  /* ラボの戻るボタンの分だけ上が空くので、ロゴを少し小さくしてタイトルの「この端末の自己ベスト」を画面内に入れる */
  #title { padding-top: 40px; }
  #logo, html[data-oikaze-lab-return="visible"] #logo { --tile: clamp(26px, 6.4dvh, 40px); margin-bottom: 4px; }
}
/* iPad横・PC も結果の間は押せない操作ボタンを隠す。1列だと「次は」の一言の分、「もう一回！」が操作ボタンにかかるため */
@media (orientation: landscape) and (min-height: 501px) {
  #app:has(#result:not([hidden])) #controls { display: none; }
}
@media (max-height: 640px) { #result { gap: 4px; } #rank { font-size: 44px; } #r-score { font-size: 34px; } }
/* Android横（高さ360px）など、さらに低い横向きはロゴ下・説明・ボタンをもう一段詰める */
@media (orientation: landscape) and (max-height: 370px) {
  .how { padding-block: 5px; gap: 3px; }
  .big-btn { padding-block: 4px; }
  .hint { padding-block: 4px; }
  #r-next { margin-bottom: 2px; }
  #rank { font-size: 36px; }
  #r-score { font-size: 28px; }
}
/* iPad横・PC は画面の幅で決まる大きさだと結果の「もう一回！」が下の操作ボタンにかかるので、ランクと得点を小さくし、すき間を詰める */
@media (orientation: landscape) and (min-height: 701px) { #result { gap: 8px; } #rank { font-size: 64px; } #r-score { font-size: 48px; } }

@media (prefers-reduced-motion: reduce) {
  #speedlines i { animation: none !important; opacity: 0.8; transform: translateY(40%); }
  .pop { animation: none !important; transform: translate(-50%, 0); opacity: 1; }
  .flash, .shake, #retry, #hearts svg.hit, #rank { animation: none !important; }
}
