/* =========================================================
 * クレープシミュレーター（crepe） スタイル
 * ========================================================= */
: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: #4a2f25;
  --c-dim: #94786c;
  --c-accent: #ec5f7e;
  --c-accent-deep: #c93c60;
  --c-gold: #f2a93b;
  --c-green: #4fb46a;
  --c-red: #d64545;
  --c-panel: rgba(255, 251, 246, 0.97);
  --c-line: rgba(74, 47, 37, 0.14);
  --c-glass: rgba(255, 250, 245, 0.9);
}

* { 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: #e9dcd6;
  -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 #4d9fe6; 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: 30px; height: 30px; padding: 0; }

/* ===== ステージ ===== */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #d9e0dc;
}
#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% 50%, transparent 62%, rgba(70, 40, 30, 0.22) 100%);
  z-index: 1;
}

/* ===== 注文票と工程 ===== */
#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 10;
  padding: 6px 8px 0;
  pointer-events: none;
}
#steps {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0 auto 5px;
  padding: 0;
  max-width: 460px;
}
#steps li {
  flex: 1;
  padding: 3px 2px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  text-align: center;
  color: rgba(74, 47, 37, 0.55);
  background: rgba(255, 250, 245, 0.72);
  border: 1px solid rgba(74, 47, 37, 0.1);
}
#steps li.on { color: #fff; background: var(--c-accent); border-color: var(--c-accent-deep); }
#steps li.done { color: #fff; background: #c9a48f; }
#ticket {
  max-width: 460px;
  margin: 0 auto;
  padding: 6px 9px 7px;
  border-radius: 12px;
  background: var(--c-glass);
  border: 1px solid rgba(74, 47, 37, 0.12);
  box-shadow: 0 4px 14px rgba(74, 47, 37, 0.16);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#ticket-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 4px; }
.ticket-lab {
  flex: none;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 900;
  color: #fff;
  background: var(--c-accent);
}
#menu-name { font-size: 15px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chips { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px 6px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 800;
  background: #fff;
  border: 1px solid var(--c-line);
  overflow: hidden;
}
.chip-ic { font-size: 13px; line-height: 1; }
.chip-ic.dot, .tool-ic.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(74, 47, 37, 0.3);
}
.chip-need { color: var(--c-dim); font-size: 10.5px; }
.chip-num { font-family: var(--font-num); font-size: 10.5px; color: var(--c-dim); }
.chip-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(74, 47, 37, 0.1); }
.chip-bar i { display: block; height: 100%; width: 0; background: var(--c-gold); transition: width 0.15s; }
.chip.ok { border-color: var(--c-green); background: #f0faf1; }
.chip.ok .chip-bar i { background: var(--c-green); }
.chip.ok .chip-num { color: #2c8a47; }
.chip.over { border-color: var(--c-red); background: #fdf0ee; }
.chip.over .chip-bar i { background: var(--c-red); }
.chip.over .chip-num { color: var(--c-red); }

/* ===== 操作パネル ===== */
#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 7px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--c-glass);
  border-top: 1px solid rgba(74, 47, 37, 0.12);
  box-shadow: 0 -4px 16px rgba(74, 47, 37, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
html.has-ad-banner #controls { padding-bottom: 8px; }
#controls > * { max-width: 520px; margin-left: auto; margin-right: auto; }
#instr {
  margin: 0 auto 6px;
  min-height: 2.7em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}
#instr.warn { color: var(--c-red); }
#controls.compact #instr { min-height: 1.6em; margin-bottom: 0; }
#meters { display: flex; flex-direction: column; gap: 4px; margin-bottom: 7px; }
.meter { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 800; }
.meter-lab { flex: none; width: 7.6em; color: var(--c-dim); }
.meter-num { flex: none; width: 3.6em; text-align: right; font-family: var(--font-num); }
.meter-bar {
  position: relative;
  flex: 1;
  height: 11px;
  border-radius: 6px;
  background: rgba(74, 47, 37, 0.12);
  overflow: hidden;
}
.meter-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; background: linear-gradient(90deg, #f7e3a8, #f0cf7c); }
.meter-bar em { position: absolute; top: 0; bottom: 0; }
#pour-mark { width: 3px; margin-left: -1.5px; background: var(--c-accent-deep); z-index: 2; }
.meter-bar.bake { background: linear-gradient(90deg, #f6e7b4 0%, #eec377 30%, #d9963f 52%, #a9642a 72%, #5a3216 88%, #1f1611 100%); }
.meter-bar.bake i {
  background: none;
  border-radius: 0;
  border-right: 3px solid #fff;
  box-shadow: 2px 0 0 rgba(0, 0, 0, 0.55);
  transition: width 0.2s linear;
}
#bake-zone { border: 2px solid #fff; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.35); z-index: 2; }
.act-row { display: flex; gap: 6px; }
.act {
  flex: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 6px 6px;
  border: 1px solid rgba(74, 47, 37, 0.2);
  border-radius: 12px;
  background: #fff;
  color: var(--c-text);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
}
.act small { font-size: 10px; font-weight: 700; opacity: 0.85; }
.act:active:not(:disabled) { transform: scale(0.97); }
.act:disabled { opacity: 0.42; cursor: default; }
.act-main { flex: 1.5; color: #fff; border-color: var(--c-accent-deep); background: linear-gradient(135deg, #f58aa0, #e04f73); box-shadow: 0 3px 10px rgba(224, 79, 115, 0.35); }
#btn-pour { touch-action: none; }
.act.pulse:not(:disabled) { border-color: var(--c-gold); animation: act-pulse 0.9s ease-in-out infinite; }
@keyframes act-pulse { 50% { box-shadow: 0 0 0 5px rgba(242, 169, 59, 0.45); background: #fff6df; } }
#tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 6px; }
.tool {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 4px 1px 3px;
  border: 1px solid rgba(74, 47, 37, 0.16);
  border-radius: 10px;
  background: #fff;
  color: var(--c-text);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0.62;
}
.tool-ic { font-size: 18px; line-height: 1; }
.tool-ic.dot { width: 17px; height: 17px; }
.tool-name { white-space: nowrap; letter-spacing: -0.04em; }
.tool-key { display: none; position: absolute; top: 2px; right: 4px; font-family: var(--font-num); font-size: 9px; color: var(--c-dim); }
.tool.wanted, .tool.filled { opacity: 1; }
.tool.wanted { border-color: var(--c-gold); background: #fff8e8; }
.tool.filled::after { content: "✓"; position: absolute; top: 1px; left: 4px; font-size: 11px; font-weight: 900; color: var(--c-green); }
.tool.on { opacity: 1; border: 2px solid var(--c-accent-deep); background: #ffe9ee; box-shadow: 0 2px 8px rgba(224, 79, 115, 0.3); }

/* ===== 文字の演出 ===== */
#banner {
  position: absolute;
  left: 50%;
  bottom: 30%;
  z-index: 20;
  transform: translate(-50%, 10px);
  max-width: 92%;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  background: rgba(201, 60, 96, 0.92);
  box-shadow: 0 6px 18px rgba(74, 47, 37, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#banner.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ===== 読み込み中 ===== */
#screen-loading { background: #f3e6df; }
.loading-panel { text-align: center; color: var(--c-text); font-size: 14px; font-weight: 700; }
.loading-ball {
  width: 50px;
  height: 50px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #f6dc9c, #e0a552 60%, #b9702a);
  animation: ball-turn 1.1s ease-in-out infinite;
}
@keyframes ball-turn { 50% { transform: scale(1.12, 0.5); } }

/* ===== タイトル・結果（クレープが見えるように、スマホは下・横長は右に寄せる） ===== */
#screen-title, #screen-result { align-items: flex-end; pointer-events: none; }
.title-panel, .result-panel {
  pointer-events: auto;
  width: min(430px, 100%);
  padding: 14px 16px 14px;
  border-radius: 18px;
  background: var(--c-panel);
  color: var(--c-text);
  text-align: center;
  box-shadow: 0 10px 36px rgba(74, 47, 37, 0.3);
}
body.on-title .title-panel { margin-bottom: 40px; }
.title-en { margin: 0; font-size: 10.5px; font-weight: 800; letter-spacing: 0.34em; color: var(--c-accent); }
.title-ja { margin: 2px 0 0; font-weight: 900; line-height: 1.12; }
.title-ja .t1 { font-size: clamp(30px, 9.4vw, 42px); color: var(--c-accent-deep); }
.title-ja .t2 { display: block; font-size: clamp(20px, 6.2vw, 27px); color: #8a5a3c; letter-spacing: 0.04em; }
.title-catch { margin: 5px 0 3px; font-size: 14px; font-weight: 900; }
.title-desc { margin: 0 auto 6px; max-width: 360px; font-size: 12px; line-height: 1.55; color: var(--c-dim); }
#title-best { margin: 0 0 6px; min-height: 1.2em; font-size: 12.5px; font-weight: 800; color: #c98212; }
.title-buttons { display: flex; flex-direction: column; gap: 7px; align-items: stretch; max-width: 330px; margin: 0 auto; }
.title-sub-buttons { display: flex; gap: 7px; }
.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: 11px 16px;
  font-family: var(--font-jp);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1.25;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  color: #fff;
  font-size: 18px;
  background: linear-gradient(135deg, #f58aa0, #e04f73);
  box-shadow: 0 6px 16px rgba(224, 79, 115, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-sub { color: var(--c-text); font-size: 13.5px; padding: 9px 10px; background: rgba(74, 47, 37, 0.07); border: 1px solid var(--c-line); }
.btn-sub:hover { background: rgba(74, 47, 37, 0.12); }

/* ===== 結果 ===== */
.result-eyebrow { margin: 0; font-size: 12px; font-weight: 800; color: var(--c-dim); }
.result-rank { margin: 1px 0 0; font-size: 22px; font-weight: 900; color: var(--c-accent-deep); }
.result-score-row { margin: 0; font-family: var(--font-num); }
#result-score { font-size: 42px; font-weight: 900; line-height: 1.1; }
.result-unit { margin-left: 4px; font-size: 13px; font-weight: 800; color: var(--c-dim); }
#result-new { margin: 1px 0 0; font-size: 12.5px; font-weight: 900; color: #c98212; }
.result-msg { margin: 2px 0 7px; font-size: 12px; font-weight: 700; color: var(--c-dim); }
#result-rows { list-style: none; margin: 0 0 9px; padding: 0; text-align: left; }
#result-rows li { display: grid; grid-template-columns: 5.2em 1fr 4.6em; align-items: center; column-gap: 8px; padding: 4px 2px; border-top: 1px solid var(--c-line); }
.rr-name { font-size: 12.5px; font-weight: 900; }
.rr-bar { height: 7px; border-radius: 4px; background: rgba(74, 47, 37, 0.1); overflow: hidden; }
.rr-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #f7b6c3, #e04f73); }
.rr-pt { font-family: var(--font-num); font-size: 12.5px; font-weight: 900; text-align: right; }
.rr-note { grid-column: 1 / -1; font-size: 11px; color: var(--c-dim); }
.result-buttons { display: flex; flex-wrap: wrap; gap: 7px; }
.result-buttons .btn-primary { flex: 1 1 100%; }
.result-buttons .btn-sub { flex: 1; }
#share-msg { margin: 4px 0 0; min-height: 0.6em; font-size: 12px; color: var(--c-dim); }

/* ===== 一時停止・エラー ===== */
#screen-paused, #gl-error { background: rgba(60, 36, 28, 0.5); }
#screen-paused { cursor: pointer; }
.paused-panel { padding: 22px 26px; border-radius: 16px; text-align: center; color: var(--c-text); background: var(--c-panel); box-shadow: 0 10px 36px rgba(74, 47, 37, 0.3); }
.paused-title { margin: 0 0 6px; font-size: 21px; font-weight: 900; }
.paused-hint { margin: 0; font-size: 13px; line-height: 1.6; color: var(--c-dim); }

/* ===== モーダル（遊び方）。広告より上に出すため 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(60, 36, 28, 0.55);
}
.modal-box {
  width: min(520px, 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(74, 47, 37, 0.4);
  -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: 5px;
  text-align: center;
  font-size: 10.5px;
  line-height: 1.5;
  color: rgba(74, 47, 37, 0.8);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  pointer-events: none;
  z-index: 40;
  display: none;
}
#footer a { color: var(--c-accent-deep); pointer-events: auto; }
body.on-title #footer { display: block; }

/* ===== PC・タブレット ===== */
@media (min-width: 768px) and (min-height: 560px) {
  #tools { grid-template-columns: repeat(10, 1fr); }
  #controls > * { max-width: 760px; }
  .tool { font-size: 11px; min-height: 52px; }
  .tool-name { letter-spacing: 0; }
  #instr { font-size: 14px; min-height: 1.8em; }
  #menu-name { font-size: 17px; }
  .chip { font-size: 12.5px; }
}
@media (hover: hover) and (pointer: fine) {
  .tool-key { display: block; }
  .tool:hover { opacity: 1; }
  .act:hover:not(:disabled) { filter: brightness(0.97); }
}

/* ===== 小さいスマホ ===== */
@media (max-height: 640px) {
  .title-desc { display: none; }
  #instr { min-height: 2.5em; font-size: 12px; margin-bottom: 4px; }
  .act { min-height: 40px; font-size: 13px; }
  .tool { min-height: 39px; }
  #meters { margin-bottom: 5px; }
  #result-score { font-size: 34px; }
  .result-msg, .rr-note { display: none; }
  .title-panel, .result-panel { padding: 10px 14px; }
}

/* ===== 横長（PC・横向きのスマホ）: タイトルと結果は右に寄せて、左にクレープ ===== */
@media (min-aspect-ratio: 23/20) {
  #screen-title, #screen-result { align-items: center; justify-content: flex-end; padding-right: max(16px, 4vw); }
  .title-panel, .result-panel { width: min(400px, 46%); }
  body.on-title .title-panel { margin-bottom: 0; }
}
/* 横向きのスマホ（背が低い）: 注文票を左、操作を右に寄せて、まん中に作業面 */
@media (max-height: 480px) and (min-aspect-ratio: 23/20) {
  #hud { right: auto; bottom: 0; width: 168px; padding: 6px 0 6px max(8px, env(safe-area-inset-left, 0px)); }
  #steps { flex-direction: column; margin-bottom: 4px; }
  #steps li { padding: 2px; font-size: 10.5px; }
  #ticket-head { flex-direction: column; gap: 2px; }
  #menu-name { white-space: normal; font-size: 13px; }
  #hud { overflow: hidden; }
  .chip { font-size: 10.5px; padding: 2px 5px 5px; white-space: nowrap; }
  .chip-need { display: none; }
  #controls {
    left: auto;
    top: 0;
    width: 236px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) 6px 8px;
    border-top: 0;
    border-left: 1px solid rgba(74, 47, 37, 0.12);
  }
  #controls > * { max-width: none; margin-left: 0; margin-right: 0; width: 100%; }
  #tools { grid-template-columns: repeat(4, 1fr); }
  .tool { min-height: 36px; font-size: 9px; }
  .tool-ic { font-size: 15px; }
  .act { min-height: 38px; font-size: 12px; }
  .meter-lab { width: 6.4em; font-size: 10px; }
  .title-desc, .result-msg, .rr-note { display: none; }
  .title-panel, .result-panel { padding: 9px 12px; }
  .title-ja .t1 { font-size: 26px; }
  .title-ja .t2 { font-size: 16px; }
  #result-score { font-size: 28px; }
  .result-rank { font-size: 17px; }
  .btn { padding: 7px 10px; font-size: 14px; }
  .btn-primary { font-size: 15px; }
  #result-rows li { padding: 2px; }
}

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