/* =========================================================
 * オムライスシミュレーター（omurice） スタイル
 * ========================================================= */
:root {
  --font-jp: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  --font-num: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --c-text: #2b1d14;
  --c-dim: #7d6a5a;
  --c-accent: #e2502a;
  --c-accent-deep: #b4361a;
  --c-egg: #f7c444;
  --c-egg-deep: #e89a1c;
  --c-green: #49b85a;
  --c-red: #d64545;
  --c-orange: #f08c1e;
  --c-panel: rgba(255, 250, 241, 0.97);
  --c-line: rgba(43, 29, 20, 0.14);
  --c-glass: rgba(26, 18, 12, 0.62);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-jp);
  color: var(--c-text);
  background: #1c1510;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ===== レイアウト =====
   共通ヘッダー(--sgh-top)とフッター広告(--ad-space)のぶんだけ内側に収める */
#app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--sgh-top, 0px);
  bottom: var(--ad-space, 0px);
  display: flex;
  flex-direction: column;
}

/* ===== 上部バー =====
   タイトルだけの帯は縦幅を圧迫するので隠す（画面には出さず、スクリーンリーダー向けにだけ残す）。
   h1（ゲームタイトル）と、共通ヘッダーのメニューが click() で押す元ボタンは DOM に残す。
   position: absolute でフローから外れるので、#stage（flex: 1）が共通ヘッダーの直下から全部を使う */
#topbar {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

#logo {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #ffe9b0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

#topbar-buttons { display: flex; gap: 6px; flex: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); }

/* ===== ステージ ===== */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #1c1510;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

/* 周辺減光（写真らしい奥行き） */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 48%, transparent 58%, rgba(20, 10, 4, 0.38) 100%);
  z-index: 1;
}

/* ===== 工程・指示 ===== */
#hud {
  position: absolute;
  top: 8px;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

#step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
}

#step-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 220, 160, 0.16);
  color: #fff;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
#step-no {
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 800;
  color: #3a2408;
  background: linear-gradient(135deg, #ffe08a, var(--c-egg-deep));
}
#step-name { font-size: 14px; font-weight: 900; letter-spacing: 0.04em; }

#step-dots {
  display: flex;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
#step-dots li {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
#step-dots li.done { background: var(--c-egg); }
#step-dots li.now { background: #fff; transform: scale(1.3); box-shadow: 0 0 0 2px rgba(247, 196, 68, 0.7); }

#instr {
  margin: 0;
  max-width: min(560px, 100%);
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
  color: #fff;
  background: rgba(26, 18, 12, 0.5);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#instr:empty { display: none; }

/* ===== ゲージ ===== */
#meters {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(420px, 100%);
  padding: 7px 10px;
  border-radius: 12px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 220, 160, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.meter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.m-label { flex: none; width: 5.4em; white-space: nowrap; letter-spacing: -0.02em; color: rgba(255, 236, 205, 0.85); }
.m-bar {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.m-ideal {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(110, 230, 125, 0.24);
  box-shadow: inset 2px 0 0 rgba(150, 255, 160, 0.9), inset -2px 0 0 rgba(150, 255, 160, 0.9);
}
/* いちばん点が高くなる位置（緑の範囲の中の 1 点） */
.m-best {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #ffe24a;
  box-shadow: 0 0 4px rgba(255, 215, 40, 0.95);
}
.m-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  border-radius: 999px;
  background: linear-gradient(90deg, #ffe39a, var(--c-egg) 60%, var(--c-egg-deep));
  opacity: 0.9;
}
.m-fill.temp { background: linear-gradient(90deg, #6fb6ff, #ffd36a 45%, #ff8a3d 70%, #e8361d); background-size: calc(100% / var(--k, 1)) 100%; }
.m-fill.cool { background: linear-gradient(90deg, #d8b98a, #a8662a 60%, #5e2f10); }
.m-mark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}
.m-val { flex: none; width: 5.6em; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter.ok .m-val { color: #8ef09a; }
.meter.warn .m-val { color: #ff8a73; animation: warn 0.8s ease-in-out infinite; }
@keyframes warn { 50% { opacity: 0.45; } }

/* ===== 卵を振り下ろす強さ ===== */
#power {
  position: absolute;
  right: calc(16px + env(safe-area-inset-right, 0px));
  top: 50%;
  z-index: 11;
  width: 18px;
  height: 170px;
  margin-top: -60px;
  border-radius: 999px;
  background: rgba(26, 18, 12, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.25);
  overflow: visible;
  pointer-events: none;
}
#power .power-zone {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20%;
  height: 51%;
  background: rgba(96, 214, 110, 0.35);
  border-radius: 4px;
}
#power .power-zone::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16%;
  height: 50%;
  background: rgba(140, 255, 150, 0.45);
}
#power-fill {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  height: calc(100% - 6px);
  border-radius: 999px;
  transform-origin: 50% 100%;
  transform: scaleY(0);
  background: linear-gradient(0deg, #ffe39a, #ff9a3d 60%, #e8361d);
}
#power-txt {
  position: absolute;
  top: 100%;
  right: -6px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ===== トントンのリング ===== */
#tapring {
  position: absolute;
  left: 50%;
  top: 66%;
  z-index: 11;
  width: 0;
  height: 0;
  pointer-events: none;
}
.tap-target, #tap-outer {
  position: absolute;
  left: 0;
  top: 0;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.tap-target {
  border: 5px solid rgba(255, 255, 255, 0.9);
  background: rgba(247, 196, 68, 0.22);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 18px rgba(247, 196, 68, 0.5);
}
#tap-outer {
  border: 4px solid var(--c-egg);
  box-shadow: 0 0 10px rgba(247, 196, 68, 0.8);
  opacity: 0;
}
.tap-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* ===== 火加減・操作ボタン ===== */
#controls {
  position: absolute;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  bottom: 10px;
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}
#controls > * { pointer-events: auto; }
#controls:empty { display: none; }

#heat {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 220, 160, 0.14);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.heat-label { padding: 0 6px 0 4px; font-size: 11px; font-weight: 800; color: rgba(255, 236, 205, 0.85); white-space: nowrap; }
#heat button {
  min-width: 44px;
  height: 40px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: var(--font-jp);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}
#heat button.on {
  border-color: transparent;
  background: linear-gradient(135deg, #5aa3ff, #2459d6);
  box-shadow: 0 0 12px rgba(80, 140, 255, 0.6);
}
#heat button[data-heat="3"].on { background: linear-gradient(135deg, #ff9a3d, #e0401c); box-shadow: 0 0 12px rgba(255, 110, 40, 0.6); }
#heat button[data-heat="1"].on { background: linear-gradient(135deg, #7fc4ff, #3d7be0); }

#actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#actions:empty { display: none; }
.btn.act { min-height: 48px; padding: 10px 18px; font-size: 16px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); }
.btn.act.btn-sub { color: #fff; background: rgba(26, 18, 12, 0.66); border: 1px solid rgba(255, 230, 190, 0.28); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.btn.act:disabled { opacity: 0.42; cursor: default; filter: grayscale(0.5); box-shadow: none; }
.btn.act.btn-primary:not(:disabled) { animation: act-glow 1.6s ease-in-out infinite; }
@keyframes act-glow { 50% { box-shadow: 0 6px 22px rgba(240, 112, 46, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25); } }

/* ===== 文字の演出 ===== */
#floats {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 11;
  overflow: hidden;
}
.float {
  position: absolute;
  left: -200px;
  top: -200px;
  transform: translate(-50%, -50%);
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.9);
  opacity: 0;
}
.float.go { animation: float-up 1.1s ease-out forwards; }
.float.mid { color: #ffe27a; font-size: 19px; }
.float.big { color: #ffd04a; font-size: 24px; }
.float.bad { color: #ff9a85; font-size: 19px; }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.12); }
  30% { transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(0.95); }
}

.banner {
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 13;
  transform: translate(-50%, -50%);
  font-size: clamp(24px, 6.4vw, 46px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(120, 50, 10, 0.9), 0 6px 18px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0;
  animation: banner-pop 1.5s ease-out forwards;
}
.banner:empty { display: none; }
.banner.step { font-size: clamp(20px, 5.4vw, 36px); color: #ffe9b0; }
.banner.good { color: #b6ff9a; }
.banner.bad { color: #ffb39e; font-size: clamp(20px, 5vw, 34px); }
.banner.gold { color: #ffe27a; font-size: clamp(34px, 9vw, 64px); text-shadow: 0 3px 0 #8a5a10, 0 0 26px rgba(255, 200, 60, 0.8); }
@keyframes banner-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  22% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* ===== 画面オーバーレイ共通 ===== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

/* ===== 読み込み中 ===== */
#screen-loading { background: #1c1510; }
.loading-panel { text-align: center; color: #f5e6d3; font-size: 14px; }
.loading-egg {
  width: 46px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
  background: radial-gradient(circle at 38% 35%, #fff8ec, #e8d6bc 70%, #c9ad8a);
  animation: egg-wobble 1s ease-in-out infinite;
}
@keyframes egg-wobble { 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }

/* ===== タイトル画面（皿の見本が見えるように、下か右に寄せる） ===== */
#screen-title {
  align-items: flex-end;
  background: linear-gradient(180deg, rgba(20, 12, 6, 0) 30%, rgba(20, 12, 6, 0.55));
}
.title-panel {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: 18px 20px 16px;
  border-radius: 22px;
  text-align: center;
  color: #fff5e8;
  background: rgba(30, 20, 13, 0.78);
  border: 1px solid rgba(255, 220, 160, 0.16);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: panel-in 0.4s ease-out;
}
.title-en {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.42em;
  color: rgba(255, 214, 140, 0.75);
}
.title-ja { margin: 4px 0 2px; line-height: 1.05; }
.title-ja .t1 {
  display: block;
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--c-egg);
  text-shadow: 0 3px 0 #9a5a10, 0 0 0 #000, 0 8px 22px rgba(0, 0, 0, 0.55);
}
.title-ja .t2 {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 12px;
  border-radius: 8px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: #fff;
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  box-shadow: 0 3px 0 rgba(90, 20, 6, 0.6);
}
.title-catch {
  margin: 10px 0 4px;
  font-size: 16px;
  font-weight: 800;
  color: #ffe4a8;
}
.title-desc {
  margin: 0 auto 8px;
  max-width: 340px;
  font-size: 12.5px;
  line-height: 1.6;
  color: rgba(255, 240, 225, 0.82);
}
#title-best { margin: 4px 0 0; font-size: 14px; font-weight: 800; color: #fff; }
#title-total { margin: 2px 0 0; min-height: 1em; font-size: 12px; color: rgba(255, 230, 200, 0.7); }
.title-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.title-sub-buttons { display: flex; gap: 8px; }
.title-sub-buttons .btn { flex: 1; }

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-family: var(--font-jp);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1.25;
}
.btn small { font-size: 11px; font-weight: 700; opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  color: #fff;
  font-size: 19px;
  background: linear-gradient(135deg, #f0702e, #c63b16);
  box-shadow: 0 6px 18px rgba(198, 59, 22, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-sub {
  color: #fff1de;
  font-size: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 230, 190, 0.22);
}
.btn-sub:hover { background: rgba(255, 255, 255, 0.16); }

/* ===== 結果 ===== */
#screen-result {
  align-items: flex-end;
  background: linear-gradient(180deg, rgba(20, 12, 6, 0) 25%, rgba(20, 12, 6, 0.5));
}
.result-panel {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: 12px 14px 12px;
  border-radius: 20px;
  background: var(--c-panel);
  color: var(--c-text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  animation: panel-in 0.4s ease-out;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(18px) scale(0.97); } }
.result-top { display: flex; align-items: center; gap: 14px; }
.result-rank {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin: 0;
  border-radius: 18px;
  font-family: var(--font-num);
  font-size: 40px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #8a7a6a, #5d4c3d);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.result-rank.rank-S { background: linear-gradient(135deg, #ffd85a, #e08a10); text-shadow: 0 2px 0 #9a5a10; animation: rank-shine 1.6s ease-in-out infinite; }
.result-rank.rank-A { background: linear-gradient(135deg, #ff8a5a, #d63d1a); }
.result-rank.rank-B { background: linear-gradient(135deg, #6cc46e, #2f8a3c); }
.result-rank.rank-C { background: linear-gradient(135deg, #6aa8e8, #2f67b8); }
@keyframes rank-shine { 50% { box-shadow: 0 0 24px rgba(255, 200, 60, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.3); } }
.result-main { flex: 1; min-width: 0; text-align: left; }
.result-title { margin: 0; font-size: 17px; font-weight: 900; color: var(--c-accent-deep); }
.result-score-row { margin: 0; line-height: 1; }
#result-score {
  font-family: var(--font-num);
  font-size: 40px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.result-unit { margin-left: 4px; font-size: 16px; font-weight: 800; color: var(--c-dim); }
#result-new { margin: 6px 0 0; font-size: 14px; font-weight: 900; text-align: center; color: #d9821a; animation: warn 1s ease-in-out infinite; }
.result-advice { margin: 6px 0 0; padding: 5px 10px; border-radius: 10px; font-size: 12.5px; font-weight: 800; line-height: 1.45; color: #7a3a14; background: rgba(247, 196, 68, 0.2); text-align: left; }
.result-advice:empty { display: none; }
#result-rows { margin: 8px 0 10px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
#result-rows li { padding: 4px 8px 5px; border-radius: 10px; background: rgba(43, 29, 20, 0.05); }
.rr-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rr-name { font-size: 13px; font-weight: 900; }
.rr-pt { font-family: var(--font-num); font-size: 13px; font-weight: 800; color: var(--c-dim); }
.rr-bar { position: relative; height: 5px; margin: 3px 0 2px; border-radius: 999px; background: rgba(43, 29, 20, 0.1); overflow: hidden; }
.rr-bar i { position: absolute; inset: 0; transform-origin: 0 50%; border-radius: 999px; background: linear-gradient(90deg, #ffd36a, #f08c1e); }
.rr-bar i.hi { background: linear-gradient(90deg, #8be08e, #2f9a40); }
.rr-bar i.lo { background: linear-gradient(90deg, #ffb39e, #d64545); }
.rr-comment { margin: 0; font-size: 11.5px; font-weight: 700; line-height: 1.35; color: var(--c-dim); }
.result-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.result-buttons .btn-primary { flex: 1 1 100%; }
.result-buttons .btn-sub { flex: 1; color: var(--c-text); background: rgba(43, 29, 20, 0.07); border-color: var(--c-line); }

/* スマホ縦: 採点は2列にして、料理が見える高さを残す（工程ごとのひとことは隠し、いちばんの改善点だけ上に出す） */
@media (max-width: 560px) {
  #result-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 6px 0 8px; }
  #result-rows .rr-comment { display: none; }
  .rr-name { font-size: 12px; white-space: nowrap; letter-spacing: -0.02em; }
  .rr-pt { font-size: 11.5px; white-space: nowrap; }
  #result-rows li { padding: 4px 7px 5px; }
  #result-score { font-size: 36px; }
  .result-rank { width: 52px; height: 52px; font-size: 34px; }
  .result-buttons .btn { padding: 9px 12px; }
  .result-buttons .btn-primary { font-size: 17px; }
}

/* 横長の画面では、タイトルと結果を右側に寄せて、左に料理を見せる */
@media (min-width: 760px) and (min-aspect-ratio: 6/5) {
  #screen-title, #screen-result { align-items: center; justify-content: flex-end; padding-right: calc(24px + env(safe-area-inset-right, 0px)); background: linear-gradient(90deg, rgba(20, 12, 6, 0) 40%, rgba(20, 12, 6, 0.5)); }
  .title-panel, .result-panel { margin: auto 0; width: 400px; }
}

/* ===== 一時停止・エラー ===== */
#screen-paused, #gl-error { background: rgba(10, 7, 5, 0.6); }
#screen-paused { cursor: pointer; }
.paused-panel {
  padding: 22px 26px;
  border-radius: 16px;
  text-align: center;
  color: #fff;
  background: rgba(30, 20, 13, 0.88);
  border: 1px solid rgba(255, 220, 170, 0.15);
}
.paused-title { margin: 0 0 6px; font-size: 22px; font-weight: 900; }
.paused-hint { margin: 0; font-size: 13px; line-height: 1.6; color: rgba(255, 235, 210, 0.75); }

/* ===== 遊び方モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2147482800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + var(--sgh-top, 0px));
  padding-bottom: calc(16px + var(--ad-space, 0px));
  background: rgba(8, 6, 4, 0.66);
}
.modal-box {
  width: min(500px, 100%);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 16px;
  border-radius: 16px;
  background: var(--c-panel);
  color: var(--c-text);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  -webkit-user-select: text;
  user-select: text;
}
.modal-title { margin: 0 0 10px; font-size: 19px; text-align: center; }
.howto { margin: 0 0 14px; padding-left: 1.4em; font-size: 13.5px; line-height: 1.7; }
.howto li { margin-bottom: 6px; }
.howto b { color: var(--c-accent-deep); }
.modal-box .btn { width: 100%; }

/* ===== フッター ===== */
#footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(255, 240, 225, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 40;
  display: none;
}
#footer a { color: #ffd04a; pointer-events: auto; }
body.on-title #footer { display: block; }
body.on-title #screen-title { padding-bottom: 46px; }

/* ===== 小さい画面 ===== */
@media (max-width: 480px) {
  #logo { font-size: 14px; letter-spacing: 0.02em; }
  #step-name { font-size: 13px; }
  #step-dots { display: none; }
  #instr { font-size: 13px; padding: 5px 10px; }
  .meter { font-size: 11px; gap: 6px; }
  .m-label { width: 5.2em; }
  .m-val { width: 5em; }
  .title-ja .t1 { font-size: 40px; }
  .title-ja .t2 { font-size: 16px; }
  #heat button { min-width: 40px; height: 38px; font-size: 14px; }
  .heat-label { display: none; }
  .btn.act { min-height: 44px; padding: 8px 14px; font-size: 15px; }
}
@media (max-width: 360px) {
  #topbar-buttons .icon-btn { width: 28px; height: 28px; font-size: 14px; }
  .title-ja .t1 { font-size: 34px; }
}
@media (max-height: 620px) {
  .title-desc { display: none; }
  .title-panel { padding: 12px 16px 12px; }
  .title-ja .t1 { font-size: 36px; }
  .title-catch { margin-top: 6px; }
  #result-rows { gap: 3px; }
  #result-rows li { padding: 3px 8px; }
  .rr-comment { display: none; }
}
@media (max-height: 460px) {
  .title-en, #title-total { display: none; }
  .title-ja .t1 { font-size: 28px; }
  .title-ja .t2 { font-size: 13px; }
  .title-catch { font-size: 13px; margin: 4px 0 0; }
  .title-buttons { flex-direction: row; gap: 6px; margin-top: 8px; }
  .title-buttons > .btn { flex: 1; }
  .title-buttons .btn-sub { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
  .btn small { display: none; }
  .btn-primary { font-size: 16px; }
  #step-row { display: none; }
  #instr { font-size: 12px; padding: 3px 10px; }
  #meters { padding: 4px 8px; gap: 2px; }
  #controls { bottom: 6px; }
  .btn.act { min-height: 38px; padding: 6px 12px; font-size: 14px; }
  #heat button { height: 34px; }
  .result-panel { padding: 10px 12px; }
  #result-score { font-size: 32px; }
  .result-rank { width: 48px; height: 48px; font-size: 30px; }
  #result-rows { display: grid; grid-template-columns: 1fr 1fr; }
  body.on-title #footer { display: none; }
  body.on-title #screen-title { padding-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .float.go, .banner { animation-duration: 0.01s; }
  .btn.act.btn-primary:not(:disabled), .result-rank.rank-S, .meter.warn .m-val, #result-new, .loading-egg { animation: none; }
}

/* ===== 全国ランキング（共通モジュール sgr-*） ===== */
.sgr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(6, 12, 18, 0.66);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sgr-hidden { display: none !important; }

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--c-panel);
  color: var(--c-text);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
}

.sgr-title {
  margin: 0;
  font-size: 20px;
  text-align: center;
}

.sgr-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.sgr-tab {
  border: 1px solid var(--c-line);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(226, 80, 42, 0.08);
  color: var(--c-text);
  cursor: pointer;
}

.sgr-tab-active {
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  border-color: transparent;
  color: #fff;
}

.sgr-register-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  color: var(--c-orange);
}

.sgr-form { display: flex; gap: 8px; }

.sgr-name {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* iOSズーム防止のため16px以上 */
  font-family: var(--font-jp);
  padding: 8px 10px;
  border: 2px solid var(--c-line);
  border-radius: 8px;
  background: #fff;
  color: var(--c-text);
  -webkit-user-select: text;
  user-select: text;
}

.sgr-name::placeholder { color: var(--c-dim); }

.sgr-name:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 8px rgba(226, 80, 42, 0.3);
}

.sgr-submit {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  color: #fff;
  cursor: pointer;
}

.sgr-submit:hover { filter: brightness(1.1); }

.sgr-submit:disabled { opacity: 0.5; cursor: default; }

.sgr-error {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--c-red);
}

.sgr-status {
  margin: 0;
  font-size: 13px;
  text-align: center;
  color: var(--c-dim);
}

.sgr-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.sgr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.sgr-row:nth-child(even) { background: rgba(226, 80, 42, 0.07); }

.sgr-row.sgr-row-me {
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  color: #fff;
}

.sgr-rank {
  width: 2em;
  text-align: right;
  font-weight: bold;
  flex-shrink: 0;
}

.sgr-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sgr-row-score {
  font-weight: bold;
  font-family: var(--font-num);
  flex-shrink: 0;
}

.sgr-close {
  border: 1px solid var(--c-line);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(226, 80, 42, 0.08);
  color: var(--c-text);
  cursor: pointer;
}

.sgr-close:hover { border-color: var(--c-accent); }

.sgr-cta {
  margin: 2px 0 12px;
  text-align: center;
}

.sgr-cta-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  color: var(--c-orange);
}

.sgr-cta-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: linear-gradient(135deg, #f5a623, #f0741e);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(240, 116, 30, 0.4);
}

.sgr-cta-btn:hover { filter: brightness(1.08); }

.sgr-cta-link {
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(30, 43, 56, 0.08);
  border: 1px solid var(--c-line);
  color: var(--c-text);
  cursor: pointer;
}

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / js/ad-banner.js が挿入する）
   --ad-h    : 広告そのものの高さ。広告なしのときは 0px
   --ad-space: レイアウトが空けるべき高さ（広告 + セーフエリア）
   ========================================================================== */
:root {
  --ad-h: 0px;
  --ad-space: 0px;
}
html.has-ad-banner {
  --ad-space: calc(var(--ad-h, 0px) + env(safe-area-inset-bottom, 0px));
}

.ad-banner {
  /* height は広告そのものの高さ。セーフエリアぶんの padding は外側に足す */
  box-sizing: content-box;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  /* ランキング・リザルト等の全画面オーバーレイ（2147483000）よりは下に置く */
  z-index: 2147482000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: var(--ad-h, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  background: rgba(14, 16, 20, 0.86);
  /* border ではなく inset shadow にして、枠線ぶん高さがずれないようにする */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ad-banner__frame {
  display: block;
  width: 100%;
  height: var(--ad-h, 0px);
  border: 0;
  color-scheme: light;
}

@media print {
  .ad-banner { display: none; }
}
