/* ============================================================
   リバースライト - Reverse Light  style.css
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg1: #060a1a;
  --bg2: #172a55;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #eaf0ff;
  --text-dim: #93a0cc;
  --accent: #5cd8ff;
  --accent2: #ffcc55;
  --danger: #ff6a6a;
  --radius: 14px;
}

html, body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: radial-gradient(130% 95% at 50% 0%, var(--bg2) 0%, var(--bg1) 72%);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  height: calc(100vh - var(--sgh-top, 0px) - var(--ad-space, 0px));   /* dvh 未対応ブラウザ向けフォールバック */
  height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 上のセーフエリアは共通ヘッダー（--sgh-top）が、下は広告があるとき --ad-space が含むので二重に空けない */
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
html.has-ad-banner #app { padding-bottom: 0; }

/* ---------- ヘッダー ---------- */
#topbar {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px 4px;
}

#logo-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }

#logo {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff, #9fd8ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

#mode-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent2);
  background: rgba(255, 204, 85, 0.12);
  border: 1px solid rgba(255, 204, 85, 0.35);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- 難易度バー ---------- */
#mode-bar {
  width: 100%;
  max-width: 460px;
  display: flex;
  gap: 6px;
  padding: 6px 14px 2px;
}

.mode-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 2px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.mode-btn .mode-size {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.75;
  font-family: "SF Mono", "Courier New", monospace;
}
.mode-btn.active {
  background: rgba(92, 216, 255, 0.16);
  border-color: var(--accent);
  color: var(--accent);
}
.mode-btn:active { transform: scale(0.96); }

/* ---------- ステータスバー ---------- */
#status-bar {
  width: 100%;
  max-width: 460px;
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 8px 14px 4px;
}

.status-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 10px;
}

.status-icon { font-size: 13px; }

.status-value {
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 17px;
  font-weight: 700;
  color: #d6ecff;
}

.status-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
}

#moves-box.perfect .status-value { color: var(--accent2); }

.status-btn {
  flex-shrink: 0;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  padding: 6px 8px;
  cursor: pointer;
}
.status-btn:active { transform: scale(0.94); }
.status-btn:disabled { opacity: 0.35; cursor: default; }
#hint-count { font-size: 11px; color: var(--accent2); }

/* ---------- 残り点灯数 ---------- */
#remain-bar {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 0 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
#remain-value {
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent2);
  transition: color 0.2s;
}
#remain-bar.done #remain-value { color: #6ef0a8; }

/* ---------- 盤面 ---------- */
#board-wrap {
  width: 100%;
  max-width: 640px;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px 12px 10px;
}

#board {
  --n: 4;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.cell {
  position: relative;
  border: none;
  padding: 0;
  border-radius: 22%;
  background: linear-gradient(180deg, #1b2750, #101833);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 2px 5px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease;
}
.cell:active { transform: scale(0.94); }

.cell .bulb {
  position: absolute;
  inset: 26%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.cell.on {
  background: radial-gradient(120% 120% at 32% 26%, #fff4d2 0%, #ffcf5c 42%, #ff9d24 100%);
  box-shadow:
    0 0 16px rgba(255, 180, 60, 0.55),
    0 0 38px rgba(255, 150, 30, 0.26),
    inset 0 -3px 8px rgba(170, 80, 0, 0.35);
}
.cell.on .bulb {
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

/* 反転した瞬間のポップ */
.cell.flip { animation: cellflip 0.28s ease-out; }
@keyframes cellflip {
  0% { transform: scale(0.82); }
  55% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* 押されたマス（中心）は少し強く */
.cell.tapped { animation: celltap 0.32s ease-out; }
@keyframes celltap {
  0% { transform: scale(0.8) rotate(-3deg); }
  55% { transform: scale(1.1) rotate(2deg); }
  100% { transform: scale(1); }
}

/* ヒント */
.cell.hint::before {
  content: "";
  position: absolute;
  inset: -4%;
  border-radius: 24%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 14px rgba(92, 216, 255, 0.7);
  animation: hintpulse 1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes hintpulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.06); }
}

/* キーボード選択 */
.cell.cursor { outline: 2px dashed rgba(255, 255, 255, 0.55); outline-offset: 2px; }
.cell:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* クリア演出 */
.cell.cleared { animation: cellclear 0.7s ease-out both; }
@keyframes cellclear {
  0% { background: linear-gradient(180deg, #1b2750, #101833); }
  35% {
    background: radial-gradient(120% 120% at 32% 26%, #e9fff4 0%, #6ef0a8 45%, #17b673 100%);
    box-shadow: 0 0 20px rgba(110, 240, 168, 0.7), 0 0 46px rgba(23, 182, 115, 0.35);
    transform: scale(1.06);
  }
  100% { background: linear-gradient(180deg, #1b2750, #101833); transform: scale(1); }
}

/* ---------- 結果オーバーレイ ---------- */
#result-overlay {
  position: fixed;
  inset: 0;
  top: var(--sgh-top, 0px);   /* 共通ヘッダーの下に結果が隠れないように */
  background: rgba(5, 9, 26, 0.74);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--ad-space, 0px));
  animation: fadein 0.25s ease-out;
  overflow-y: auto;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

#result-box {
  width: min(92vw, 360px);
  background: linear-gradient(180deg, #23386e, #131f42);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  animation: rise 0.3s ease-out;
}
@keyframes rise {
  from { transform: translateY(24px) scale(0.95); opacity: 0; }
  to { transform: none; opacity: 1; }
}

#result-icon {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 8px;
  animation: bounce 0.5s ease-out;
}
@keyframes bounce {
  0% { transform: scale(0.3); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

#result-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffeeb5, #ffb648);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#result-mode {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}

#result-time {
  margin-top: 10px;
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 40px;
  font-weight: 800;
  color: #d6ecff;
  line-height: 1.1;
}
#result-time .time-unit { font-size: 15px; margin-left: 4px; color: var(--text-dim); }

#result-sub {
  margin-top: 6px;
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}

#result-perfect {
  margin-top: 12px;
  font-size: 14px;
  font-weight: 800;
  color: var(--accent2);
  animation: bounce 0.5s ease-out 0.15s both;
}

#result-record {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 800;
  color: #6ef0a8;
}

#result-best {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  min-height: 1em;
}

#result-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- ボタン共通 ---------- */
.btn {
  padding: 13px 18px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(180deg, #5cd8ff, #2091d6);
  color: #04202e;
  box-shadow: 0 6px 18px rgba(92, 216, 255, 0.32);
}

.btn-sub {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
}
.btn-sub.danger {
  background: rgba(255, 106, 106, 0.18);
  border-color: rgba(255, 106, 106, 0.5);
  color: #ffb3b3;
}

/* ---------- モーダル ---------- */
.modal {
  position: fixed;
  inset: 0;
  top: var(--sgh-top, 0px);   /* 共通ヘッダーの下にメニューが隠れないように */
  background: rgba(5, 9, 26, 0.74);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--ad-space, 0px));
  animation: fadein 0.2s ease-out;
}

.modal-box {
  width: min(92vw, 400px);
  max-height: 86vh;   /* dvh 未対応ブラウザ向けフォールバック */
  max-height: 86dvh;
  max-height: min(86dvh, calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px) - env(safe-area-inset-bottom, 0px) - 32px));
  overflow-y: auto;
  background: linear-gradient(180deg, #23386e, #131f42);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 22px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  margin-bottom: 16px;
}

.menu-section { margin-bottom: 18px; }

.menu-caption {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 2px;
  font-size: 14px;
  font-weight: 600;
}

.toggle {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.1);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on .knob { transform: translateX(20px); }

.record-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 2px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}
.record-row span:last-child {
  font-weight: 800;
  color: var(--accent2);
  font-family: "SF Mono", "Courier New", monospace;
  text-align: right;
}

#btn-reset {
  width: 100%;
  margin-top: 12px;
  font-size: 13px;
  padding: 10px 14px;
}

.howto {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  line-height: 1.55;
  color: #ccd6f5;
}
.howto li { padding-left: 1.1em; position: relative; }
.howto li::before { content: "•"; position: absolute; left: 0; color: var(--accent); }

#btn-close-menu { width: 100%; }

/* ---------- トースト ---------- */
#toast {
  position: fixed;
  left: 50%;
  /* フッター固定バナー広告に隠れないよう持ち上げる（広告なしのときは 0px） */
  bottom: calc(80px + env(safe-area-inset-bottom) + var(--ad-space, 0px));
  transform: translateX(-50%);
  background: rgba(20, 30, 66, 0.95);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 70;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastin 0.25s ease-out;
}
@keyframes toastin {
  from { transform: translate(-50%, 10px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ---------- 紙吹雪 ---------- */
.confetti {
  position: fixed;
  top: -12px;
  width: 9px;
  height: 14px;
  z-index: 55;
  pointer-events: none;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to {
    transform: translateY(105vh) rotate(720deg);   /* dvh 未対応ブラウザ向けフォールバック */
    transform: translateY(105dvh) rotate(720deg);
    opacity: 0.7;
  }
}

/* ---------- フッター ---------- */
#footer {
  padding: 4px 0 12px;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.7;
}
#footer a { color: var(--text-dim); }

/* ---------- 汎用 ---------- */
.hidden { display: none !important; }

/* ---------- レスポンシブ ---------- */
@media (min-width: 700px) {
  #logo { font-size: 22px; }
  .mode-btn { font-size: 12px; padding: 8px 2px; }
  .status-value { font-size: 19px; }
}

/* 幅が狭いと「18 / 最少 16」などが枠からはみ出すので、手数の 👆 を省いて詰める */
@media (max-width: 374px) {
  #moves-box .status-icon { display: none; }
}
@media (max-width: 359px) {
  #status-bar { gap: 4px; padding-left: 10px; padding-right: 10px; }
  .status-box { gap: 3px; padding: 6px 6px; }
  .status-btn { min-width: 38px; padding: 6px 5px; }
}

/* スマホ横向き：縦に並べると盤面の下の段が画面外・広告の下に隠れるので、情報を左・盤面を右に並べる */
@media (orientation: landscape) and (max-height: 540px) {
  #app {
    display: grid;
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    column-gap: 8px;
    justify-items: center;
    align-items: stretch;   /* 縦方向は中央寄せにしない（盤面の枠を列の高さいっぱいに広げる） */
  }
  #topbar, #mode-bar, #status-bar, #remain-bar { grid-column: 1; }
  #footer {
    grid-column: 1;
    grid-row: 5;
    align-self: end;        /* safe 未対応ブラウザ向けフォールバック */
    align-self: safe end;   /* 左列に収まらない背の低い画面では、上にはみ出して「残り」の表示に重ならないよう下へ逃がす */
  }
  #board-wrap { grid-column: 2; grid-row: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  #result-overlay, #result-box, #result-icon, #result-perfect, .modal, #toast { animation: none; }
  .cell.flip, .cell.tapped, .cell.cleared, .cell.hint::before { animation: none; }
  .confetti { display: none; }
}

/* ---------- 全国ランキング（SGRanking 共通モジュール） ---------- */
.sgr-hidden {
  display: none !important;
}

.sgr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000; /* 既存モーダル(60)・トースト(70)より上 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--ad-space, 0px));
  background: rgba(4, 8, 22, 0.76);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, #23386e, #131f42);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 20px 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.sgr-tabs {
  display: flex;
  flex-wrap: wrap;   /* 難易度4つでも狭い端末で溢れないように */
  gap: 6px;
  justify-content: center;
}

.sgr-tab {
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.sgr-tab-active {
  background: rgba(92, 216, 255, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

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

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

.sgr-name {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}

.sgr-name:focus {
  outline: none;
  border-color: var(--accent);
}

.sgr-submit {
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(180deg, #5cd8ff, #2091d6);
  color: #04202e;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(92, 216, 255, 0.35);
}

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

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

.sgr-error {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
}

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

.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: 8px;
  font-size: 14px;
}

.sgr-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

.sgr-row.sgr-row-me {
  background: rgba(92, 216, 255, 0.25);
  color: #fff;
}

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

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

.sgr-row-score {
  font-weight: 800;
  color: var(--accent2);
  flex-shrink: 0;
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 13px;
}

.sgr-row.sgr-row-me .sgr-row-score {
  color: #fff;
}

.sgr-close {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.sgr-close:active { transform: scale(0.97); }

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

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

.sgr-cta-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(180deg, #ffe08a, #ffb648);
  color: #4a3200;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 209, 102, 0.35);
}
.sgr-cta-btn:active { transform: scale(0.97); }

.sgr-cta-link {
  border: none;
  background: none;
  padding: 6px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: underline;
  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; }
}
