/* =========================================================
 * ビールシミュレーター（beer） スタイル
 * ========================================================= */
: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: #2b1a0c;
  --c-dim: #7a6552;
  --c-accent: #e08a00;
  --c-accent-deep: #a85a00;
  --c-gold: #ffd15c;
  --c-gold-deep: #f09a12;
  --c-panel: rgba(255, 251, 242, 0.97);
  --c-line: rgba(43, 26, 12, 0.14);
  --c-glass: rgba(30, 16, 6, 0.74);
}

* { 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: #1a0f08;
  -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; }
button { font-family: var(--font-jp); }
button:focus-visible, a:focus-visible { outline: 3px solid #7fc4ff; outline-offset: 2px; }

/* ===== レイアウト =====
   共通ヘッダー(--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 に残す */
#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; }
.icon-btn { width: 32px; height: 32px; padding: 0; }

/* ===== ステージ ===== */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #1a0f08;
}
#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% 46%, transparent 58%, rgba(14, 7, 2, 0.34) 100%);
  z-index: 1;
}

/* ===== 状況の表示 ===== */
#hud {
  position: absolute;
  top: 6px;
  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: 5px;
  pointer-events: none;
}
#chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 12px;
  background: #fff8ea;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  border-top: 3px solid var(--c-accent);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}
#chip-no { font-family: var(--font-num); font-size: 11px; color: var(--c-dim); }
#chip-name { color: #6b3a00; }
#chip-time, #chip-cover { padding: 2px 8px; border-radius: 7px; font-variant-numeric: tabular-nums; }
#chip-time { background: #ffe7b0; min-width: 4.6em; text-align: center; }
#chip-time.warn { background: #e8452c; color: #fff; animation: warn-blink 0.5s steps(2) infinite; }
@keyframes warn-blink { 50% { opacity: 0.6; } }
#chip-cover { background: #dcefd6; color: #1f5a2a; min-width: 5.4em; text-align: center; }
#gauges {
  display: flex;
  gap: 10px;
  width: min(380px, 100%);
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 220, 160, 0.16);
}
.gauge { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; color: #fff; font-size: 11.5px; font-weight: 800; }
.g-label { flex: none; white-space: nowrap; color: rgba(255, 240, 214, 0.92); }
.g-bar { position: relative; flex: 1; height: 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.g-fill {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform: scaleX(0);
  border-radius: 999px;
  background: linear-gradient(90deg, #fff3cf, var(--c-gold) 55%, var(--c-gold-deep));
  transition: transform 0.12s linear;
}
.g-fill.stock { background: linear-gradient(90deg, #fff6cf, #ffe58a); }
#instr {
  margin: 0;
  max-width: min(560px, 100%);
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
  color: #fff;
  background: rgba(30, 16, 6, 0.6);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#instr:empty { display: none; }

/* ===== 操作 ===== */
#controls {
  position: absolute;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  bottom: 8px;
  z-index: 12;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
#ctl { display: flex; width: min(320px, 100%); pointer-events: auto; }
#ctl .btn { flex: 1; min-height: 48px; font-size: 17px; }

#banner {
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 13;
  transform: translate(-50%, -50%);
  max-width: 94%;
  font-size: clamp(22px, 6vw, 38px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(120, 60, 0, 0.9), 0 6px 18px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0;
}
#banner.show { animation: banner-pop 1.6s ease-out forwards; }
@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); }
}
@media (prefers-reduced-motion: reduce) { #banner.show { animation-duration: 1.6s; } #chip-time.warn { animation: none; } }

/* ===== 画面オーバーレイ共通 ===== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#screen-loading { background: #1a0f08; }
.loading-panel { text-align: center; color: #fff0d6; font-size: 14px; }
.loading-pan {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--c-gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== タイトル ===== */
#screen-title { align-items: flex-end; background: linear-gradient(180deg, rgba(18, 9, 3, 0) 30%, rgba(18, 9, 3, 0.84) 76%); }
.title-panel { width: min(460px, 100%); text-align: center; color: #fff; }
.title-en { margin: 0; font-size: 12px; font-weight: 900; letter-spacing: 0.42em; color: #ffdf9a; }
.title-ja { margin: 2px 0 6px; line-height: 1.05; text-shadow: 0 3px 0 #6a3200, 0 8px 22px rgba(0, 0, 0, 0.7); }
.title-ja .t1 { display: inline-block; font-size: clamp(38px, 11.5vw, 58px); font-weight: 900; letter-spacing: 0.03em; color: #fffaf0; }
.title-ja .t2 { display: inline-block; margin-left: 0.12em; font-size: clamp(38px, 11.5vw, 58px); font-weight: 900; color: var(--c-gold); }
.title-catch { margin: 0 0 6px; font-size: 15px; font-weight: 900; color: #ffeecb; }
.title-desc { margin: 0 auto 8px; max-width: 400px; font-size: 12.5px; font-weight: 700; line-height: 1.6; color: rgba(255, 240, 214, 0.88); }
#title-best { margin: 0 0 10px; min-height: 1.3em; font-size: 13px; font-weight: 900; color: var(--c-gold); }
.title-buttons { display: flex; flex-direction: column; gap: 8px; }
.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: #3a1c00;
  font-size: 19px;
  background: linear-gradient(135deg, #ffe08a, #f5a623);
  box-shadow: 0 6px 18px rgba(224, 138, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-sub { color: #fff4dc; font-size: 14px; padding: 10px 12px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 226, 170, 0.26); }
.btn-sub:hover { background: rgba(255, 255, 255, 0.16); }

/* ===== 次の注文 ===== */
#screen-intro { align-items: flex-end; background: linear-gradient(180deg, rgba(18, 9, 3, 0) 40%, rgba(18, 9, 3, 0.5)); }
.intro-panel, .result-panel, .final-panel {
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--c-panel);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
.intro-no { margin: 0 0 8px; font-size: 12px; font-weight: 900; letter-spacing: 0.2em; color: var(--c-accent-deep); text-align: center; }
.intro-head { display: flex; align-items: center; gap: 12px; }
.intro-emoji { flex: none; width: 64px; height: 64px; border-radius: 50%; background: #ffecc2; font-size: 40px; line-height: 64px; text-align: center; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.07); }
.intro-main { min-width: 0; }
.intro-name { margin: 0 0 2px; font-size: 22px; font-weight: 900; }
.intro-limit { margin: 0; font-size: 13px; font-weight: 800; color: var(--c-dim); }
.intro-limit b { font-size: 17px; color: var(--c-accent-deep); }
.intro-limit small { display: block; font-size: 11px; font-weight: 700; }
.intro-desc { margin: 10px 0 12px; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; font-weight: 800; line-height: 1.6; color: #6b3a00; background: rgba(255, 209, 92, 0.28); }
.intro-panel > .btn { width: 100%; }

/* ===== 結果 ===== */
#screen-result { align-items: flex-end; background: linear-gradient(180deg, rgba(18, 9, 3, 0) 34%, rgba(18, 9, 3, 0.5)); pointer-events: none; }
#screen-result .result-panel { pointer-events: auto; padding: 10px 14px; }
#screen-final { background: rgba(18, 9, 3, 0.7); }
.result-top { display: flex; align-items: center; justify-content: center; gap: 14px; }
.result-rank {
  flex: none;
  width: 58px;
  height: 58px;
  margin: 0;
  border-radius: 50%;
  font-size: 34px;
  font-weight: 900;
  line-height: 58px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, #f7c444, #e2802a);
  box-shadow: 0 4px 12px rgba(226, 128, 42, 0.45);
}
.result-rank.rank-S { background: linear-gradient(135deg, #ffe27a, #ff9a1c); text-shadow: 0 2px 0 rgba(150, 70, 0, 0.6); }
.result-rank.rank-B { background: linear-gradient(135deg, #8cc7ff, #3d7be0); box-shadow: none; }
.result-rank.rank-C, .result-rank.rank-D { background: linear-gradient(135deg, #b9aea4, #7d7067); box-shadow: none; }
.result-title { margin: 0; font-size: 14px; font-weight: 900; }
.result-score-row { margin: 0; line-height: 1.1; }
#result-score, #final-score { font-family: var(--font-num); font-size: 40px; font-weight: 900; color: var(--c-accent-deep); font-variant-numeric: tabular-nums; }
.result-unit { margin-left: 4px; font-size: 14px; font-weight: 900; color: var(--c-dim); }
.result-speech { margin: 6px 0; padding: 7px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--c-line); font-size: 13px; font-weight: 800; line-height: 1.5; }
#result-rows, #final-rows { margin: 0 0 8px; padding: 0; list-style: none; }
#result-rows li { display: grid; grid-template-columns: 5.4em 1fr auto; align-items: baseline; gap: 6px; padding: 3px 2px; border-bottom: 1px dashed var(--c-line); font-size: 12.5px; font-weight: 800; }
#result-rows .r-name { font-weight: 900; }
#result-rows .r-note { color: var(--c-dim); font-size: 12px; min-width: 0; }
#result-rows .r-pt { font-family: var(--font-num); font-weight: 900; color: var(--c-accent-deep); white-space: nowrap; }
.result-buttons, .final-buttons, .modal-buttons { display: flex; gap: 8px; }
.result-buttons .btn, .final-buttons .btn, .modal-buttons .btn { flex: 1; }
.result-buttons .btn-primary { flex: 1.5; font-size: 17px; }
.result-panel .btn-sub, .final-panel .btn-sub, .modal-buttons .btn-sub { color: var(--c-text); background: rgba(43, 26, 12, 0.07); border-color: var(--c-line); }
#share-msg, #final-msg { margin: 6px 0 0; min-height: 1.2em; font-size: 12px; font-weight: 800; text-align: center; color: var(--c-dim); }
#share-msg:empty { display: none; }
.final-eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 900; letter-spacing: 0.3em; color: var(--c-accent-deep); text-align: center; }
#final-new { margin: 6px 0 0; font-size: 14px; font-weight: 900; text-align: center; color: #d97a00; }
#final-rows { margin-top: 10px; border-top: 2px dashed var(--c-line); }
#final-rows li { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px dashed var(--c-line); font-size: 13px; font-weight: 800; }
#final-rows .f-face { font-size: 20px; }
#final-rows .f-name { flex: 1; min-width: 0; }
#final-rows .f-sub { display: block; font-size: 11.5px; color: var(--c-dim); }
#final-rows .f-pt { font-family: var(--font-num); font-size: 16px; font-weight: 900; color: var(--c-accent-deep); }
.final-buttons { flex-wrap: wrap; }
.final-buttons .btn-primary { flex: 1 1 100%; }

/* ===== 一時停止・エラー ===== */
#screen-paused, #gl-error { background: rgba(18, 9, 3, 0.72); cursor: pointer; }
.paused-panel { text-align: center; color: #fff; }
.paused-title { margin: 0 0 6px; font-size: 24px; font-weight: 900; }
.paused-hint { margin: 0; font-size: 13px; font-weight: 700; color: rgba(255, 240, 214, 0.8); }

/* ===== モーダル。広告より上に出すため body 直下に置く ===== */
.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(14, 7, 2, 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%; }
.confirm-box { width: min(400px, 100%); }
.confirm-text { margin: 4px 0 12px; font-size: 15px; font-weight: 800; line-height: 1.6; text-align: center; white-space: pre-line; }

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

/* ===== 小さい画面・横向き ===== */
@media (max-height: 560px) {
  #hud { top: 3px; gap: 3px; }
  #instr { font-size: 12px; padding: 3px 10px; }
  #gauges { padding: 3px 10px; }
  .title-ja .t1, .title-ja .t2 { font-size: 32px; }
  .title-desc { display: none; }
  #ctl .btn { min-height: 38px; font-size: 15px; }
  .intro-emoji { width: 46px; height: 46px; font-size: 28px; line-height: 46px; }
}
@media (max-width: 380px) {
  #chips { font-size: 12px; gap: 3px 4px; }
  #instr { font-size: 12px; padding: 3px 10px; }
  .result-buttons .btn-primary { font-size: 15px; }
}
@media (max-height: 700px) {
  #result-score { font-size: 30px; }
  .result-rank { width: 44px; height: 44px; font-size: 26px; line-height: 44px; }
}
@media (max-height: 560px) and (min-width: 640px) {
  /* 横向きスマホ: 表示を左右に寄せる */
  #hud { align-items: flex-start; right: auto; max-width: 46%; }
  #controls { left: auto; width: 230px; }
  #screen-result { align-items: center; justify-content: flex-end; padding: 6px; }
  #screen-result .result-panel { width: 320px; padding: 6px 10px; }
  .result-speech { margin: 3px 0; padding: 4px 8px; font-size: 12px; }
  #result-rows { margin-bottom: 4px; }
  #result-rows li { font-size: 11.5px; padding: 1px 2px; }
  .result-buttons .btn { padding: 6px 4px; min-height: 0; font-size: 13px; }
  .result-buttons .btn-primary { font-size: 14px; }
  #screen-title { align-items: center; justify-content: flex-end; background: linear-gradient(90deg, rgba(18, 9, 3, 0) 34%, rgba(18, 9, 3, 0.86) 76%); }
  .title-panel { width: 320px; }
}

/* ===== グラスの札（目安の線・採点のときのビールと泡） ===== */
.g-tag {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  margin-left: 6px;
  padding: 2px 7px 2px 9px;
  font-size: 11.5px;
  font-weight: 900;
  line-height: 1.5;
  color: #fff;
  white-space: nowrap;
  background: #e2321e;
  border-radius: 3px 6px 6px 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  will-change: transform;
}
.g-tag::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  margin-top: -6px;
  border: 6px solid transparent;
  border-right-color: #e2321e;
  border-left-width: 0;
}
#tag-beer, #tag-foam { font-size: 13.5px; font-family: var(--font-num); padding: 3px 9px 3px 10px; }
#tag-beer { background: #d97a00; }
#tag-beer::before { border-right-color: #d97a00; }
#tag-foam { background: #fff8ea; color: #5a3a10; }
#tag-foam::before { border-right-color: #fff8ea; }

/* ===== レバーの倒れぐあい ===== */
#lever-ui {
  position: absolute;
  left: max(calc(8px + env(safe-area-inset-left, 0px)), calc(50% - 330px));
  top: 54%;
  z-index: 9;
  width: 52px;
  height: min(220px, 40%);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
.lv-label {
  flex: none;
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
  color: rgba(255, 240, 214, 0.92);
  background: rgba(30, 16, 6, 0.72);
  transition: background 0.1s, color 0.1s;
}
.lv-track {
  position: relative;
  flex: 1;
  width: 14px;
  border-radius: 999px;
  background: rgba(30, 16, 6, 0.72);
  border: 1px solid rgba(255, 220, 160, 0.28);
}
.lv-track::before {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: rgba(255, 255, 255, 0.55);
}
#lever-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #626262, #101010);
  border: 2px solid #d9a436;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
#lever-ui.is-beer #lever-knob { border-color: #ffb52e; box-shadow: 0 0 12px rgba(255, 181, 46, 0.85); }
#lever-ui.is-beer .lv-beer { color: #3a1c00; background: #ffb52e; }
#lever-ui.is-foam #lever-knob { border-color: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, 0.8); }
#lever-ui.is-foam .lv-foam { color: #5a3a10; background: #fffaf0; }

/* ===== 注文の表示 ===== */
#chip-ratio { padding: 2px 8px; border-radius: 7px; background: #2b1a0c; color: #ffd15c; font-variant-numeric: tabular-nums; }
.intro-say { margin: 0; font-size: 14.5px; font-weight: 900; line-height: 1.5; }
.intro-order { display: flex; align-items: center; gap: 14px; margin: 10px 0 0; padding: 8px 14px; border-radius: 12px; background: #2b1a0c; color: #fff; }
.io-ratio { flex: none; text-align: center; }
.io-ratio small { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; color: #ffdf9a; }
.io-ratio b { font-family: var(--font-num); font-size: 30px; line-height: 1.1; color: #ffd15c; white-space: nowrap; }
.io-detail { min-width: 0; font-size: 12.5px; font-weight: 800; line-height: 1.5; color: rgba(255, 240, 214, 0.9); }
.io-detail b { display: block; font-size: 17px; color: #fff; }
.intro-note { margin: 0 0 10px; font-size: 12px; font-weight: 800; text-align: center; color: var(--c-dim); }
.intro-desc { margin-bottom: 6px; }
#btn-done.is-off { filter: grayscale(0.7) brightness(0.8); opacity: 0.75; }
#game-canvas { cursor: ns-resize; }
@media (max-height: 560px) {
  .io-ratio b { font-size: 22px; }
  .intro-desc { display: none; }
  #lever-ui { height: 46%; }
}

/* ===== 全国ランキング（共通モジュール 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; }
}
