/* =========================================================
 * チョコフォンデュシミュレーター（fondue） スタイル
 * ========================================================= */
: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: #2e2013;
  --c-dim: #7f6c56;
  --c-accent: #e08a12;
  --c-accent-deep: #b3610a;
  --c-gold: #ffd35a;
  --c-gold-deep: #f0a51e;
  --c-panel: rgba(255, 251, 240, 0.97);
  --c-line: rgba(46, 32, 19, 0.14);
  --c-glass: rgba(28, 18, 9, 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: #170c06;
  -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: #170c06;
}
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#game-canvas.grabbing { cursor: grabbing; }
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 58%, rgba(20, 10, 3, 0.42) 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: #fffaf0;
  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: #5a3408; }
#chip-time, #chip-cover { padding: 2px 8px; border-radius: 7px; font-variant-numeric: tabular-nums; }
#chip-time { background: #ffe9ad; 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, 226, 160, 0.14);
}
.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, 210, 0.9); }
.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, #fff0a8, var(--c-gold) 60%, 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(28, 18, 9, 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(150, 80, 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: #170c06; }
.loading-panel { text-align: center; color: #f7ead2; 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(20, 11, 4, 0) 30%, rgba(20, 11, 4, 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: #ffe19a; }
.title-ja { margin: 2px 0 6px; line-height: 1.05; text-shadow: 0 3px 0 #8a4a06, 0 8px 22px rgba(0, 0, 0, 0.7); }
.title-ja .t1 { display: inline-block; font-size: clamp(30px, 9.4vw, 52px); font-weight: 900; letter-spacing: 0.03em; color: #fff6dc; }
.title-ja .t2 { display: inline-block; margin-left: 0.12em; font-size: clamp(22px, 6.6vw, 36px); font-weight: 900; color: var(--c-gold); }
.title-catch { margin: 0 0 6px; font-size: 15px; font-weight: 900; color: #ffeec8; }
.title-desc { margin: 0 auto 8px; max-width: 400px; font-size: 12.5px; font-weight: 700; line-height: 1.6; color: rgba(255, 244, 224, 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: #3a2102;
  font-size: 19px;
  background: linear-gradient(135deg, #ffe07a, #f5a81c);
  box-shadow: 0 6px 18px rgba(214, 138, 14, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-sub { color: #fff4de; font-size: 14px; padding: 10px 12px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 234, 190, 0.24); }
.btn-sub:hover { background: rgba(255, 255, 255, 0.16); }

/* ===== 次のパン ===== */
#screen-intro { background: rgba(14, 8, 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: #ffeec2; 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: #6a4410; background: rgba(255, 211, 90, 0.24); }
.intro-panel > .btn { width: 100%; }

/* ===== 結果 ===== */
#screen-result { align-items: flex-end; background: linear-gradient(180deg, rgba(20, 11, 4, 0) 34%, rgba(20, 11, 4, 0.5)); pointer-events: none; }
#screen-result .result-panel { pointer-events: auto; padding: 10px 14px; }
#screen-final { background: rgba(14, 8, 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(46, 32, 19, 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: #d8780c; }
#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(14, 8, 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, 244, 224, 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(10, 7, 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%; }
.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, 244, 228, 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 { font-size: 28px; } .title-ja .t2 { font-size: 20px; }
  .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(20, 11, 4, 0) 34%, rgba(20, 11, 4, 0.86) 76%); }
  .title-panel { width: 320px; }
}

/* ===== フォンデュ固有 ===== */
#chip-order { padding: 2px 8px; border-radius: 7px; background: #ffe9ad; color: #5a3408; white-space: normal; text-align: center; }
#chip-spill { padding: 2px 7px; border-radius: 7px; background: #e6eef2; color: #46606c; font-variant-numeric: tabular-nums; }
#chip-spill.warn { background: #e8452c; color: #fff; }
#gauges { width: min(420px, 100%); }
.gauge.wide { flex: 1.8; }
#cov-txt { flex: none; min-width: 2.9em; text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; color: #fff; }
.gauge.wide .g-bar { overflow: visible; height: 11px; }
.gauge.wide .g-fill { background: linear-gradient(90deg, #a8693a, #6b3a1a 70%, #4a2410); transition: transform 0.08s linear; }
#cov-mark { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 1.5px #e0452c, 0 0 8px rgba(255, 120, 80, 0.9); }
.g-fill.stock { background: linear-gradient(90deg, #ffd27a, #ff9a3c); }
#free-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; pointer-events: auto; }
#free-items { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--c-glass); }
.free-item { width: 38px; height: 38px; padding: 0; border: none; border-radius: 9px; background: rgba(255, 255, 255, 0.12); font-size: 21px; line-height: 38px; cursor: pointer; }
.free-item:hover { background: rgba(255, 255, 255, 0.24); }
.free-course { padding: 0 12px; border: 1px solid rgba(255, 234, 190, 0.3); border-radius: 12px; background: var(--c-glass); color: #fff4de; font-size: 13px; font-weight: 900; cursor: pointer; min-height: 38px; }
.title-cheese { display: block; margin-top: 2px; font-size: 12.5px; color: #ffd35a; }
.title-main-buttons { display: flex; gap: 8px; }
.title-main-buttons .btn { flex: 1; padding: 12px 6px; font-size: 16px; }
.btn-primary.btn-cheese { background: linear-gradient(135deg, #fff1a0, #ffc93c); }
#btn-choco { color: #fff3e2; background: linear-gradient(135deg, #8a5026, #4d260f); box-shadow: 0 6px 18px rgba(60, 26, 6, 0.6), inset 0 1px 0 rgba(255, 220, 180, 0.35); }
.title-sub-buttons .btn { padding: 10px 4px; font-size: 12.5px; }
#final-rows .f-name { font-size: 12.5px; }
@media (max-width: 380px) { .free-item { width: 33px; height: 33px; font-size: 18px; line-height: 33px; } .title-main-buttons .btn { font-size: 14px; } }

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