/* ============================================================
   スリザーリンク - Slitherlink  style.css
   ============================================================ */

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

:root {
  --bg1: #0f1729;
  --bg2: #1a2846;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #eaf0ff;
  --text-dim: #8fa0c0;
  --accent: #4da3ff;
  --accent2: #ffd166;
  --danger: #ff5d5d;
  --radius: 14px;

  /* 盤面 */
  --board-bg: #16203a;
  --dot: #5d6f92;
  --line: #6cc0ff;
  --line-hint: #ffd166;
  --cross: #64769a;
  --clue: #eaf0ff;
  --clue-done: #55688c;
}

html, body { height: 100%; }

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

#app {
  /* 盤面の大きさはビューポートから自動算出する。
     縦は「ヘッダー・広告・盤面以外のUI」を差し引いた高さを行数で、
     横は画面幅を列数で割り、小さいほうに合わせて画面内に必ず収める。
     盤の外周には辺を押しやすいよう pad（マスの0.45倍）の余白を取る。
     ★この式は js/game.js の edgeAtPoint() が幅から1マスの大きさを
       逆算するのに使っている。変えるときは両方そろえること★ */
  --cols: 5;
  --rows: 5;
  --cell-w: calc((min(100vw, 600px) - 20px) / (var(--cols) + 0.9));
  --cell-h: calc((100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px) - 258px) / (var(--rows) + 0.9));
  --cell: clamp(20px, min(var(--cell-w), var(--cell-h)), 58px);
  --pad: calc(var(--cell) * 0.45);
  --board-w: calc(var(--cell) * var(--cols) + var(--pad) * 2);

  --lw: clamp(3px, calc(var(--cell) * 0.11), 6px);
  --ds: clamp(3px, calc(var(--cell) * 0.14), 7px);
  --xs: clamp(7px, calc(var(--cell) * 0.32), 15px);

  min-height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 上のセーフエリアは共通ヘッダー（body の padding-top = --sgh-top）が、
     広告があるときの下のセーフエリアは --ad-space が含んでいるので、ここでは足さない */
  padding: 0 env(safe-area-inset-right) max(0px, calc(env(safe-area-inset-bottom, 0px) - var(--ad-space, 0px))) env(safe-area-inset-left);
}

/* 盤面の大きさが難易度で変わっても、ステータスと操作列の幅は変えない */
#status-bar, #tools {
  width: 100%;
  max-width: 440px;
  padding-left: 10px;
  padding-right: 10px;
}

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

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

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

#diff-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent2);
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid rgba(255, 209, 102, 0.35);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
#diff-badge:active { transform: scale(0.95); }

#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); }

/* ---------- ステータスバー ---------- */
#status-bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.status-box {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px 8px;
  font-family: inherit;
  color: var(--text);
}

button.status-box { cursor: pointer; }
button.status-box:active { transform: scale(0.96); }

.status-label { font-size: 11px; font-weight: 700; color: var(--text-dim); }

.status-value {
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent2);
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.35);
}

/* ---------- 盤面 ---------- */
#board-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;   /* 余白ができたときは上下中央に置く */
  padding: 4px 0 10px;
  flex: 1;
}

#board-stage { position: relative; }

#board {
  position: relative;
  width: var(--board-w);
  height: calc(var(--cell) * var(--rows) + var(--pad) * 2);
  background: var(--board-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  touch-action: none;   /* なぞって線を引くのでスクロールさせない */
}
#board:focus { outline: none; }
#board:focus-visible { box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.5), 0 10px 40px rgba(0, 0, 0, 0.45); }

/* 位置はすべて「マス単位の座標」--x / --y で指定する */
.clue, .edge, .dot {
  position: absolute;
  left: calc(var(--pad) + var(--cell) * var(--x));
  top: calc(var(--pad) + var(--cell) * var(--y));
  transform: translate(-50%, -50%);
}

.clue {
  font-size: calc(var(--cell) * 0.5);
  font-weight: 800;
  line-height: 1;
  color: var(--clue);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  transition: color 0.15s;
}
.clue.done { color: var(--clue-done); }
.clue.err { color: var(--danger); text-shadow: 0 0 10px rgba(255, 93, 93, 0.5); }

.dot {
  width: var(--ds);
  height: var(--ds);
  border-radius: 50%;
  background: var(--dot);
  pointer-events: none;
  transition: background-color 0.15s;
}
/* 線が通っている点は線と同じ色にして、角がとぎれて見えないようにする */
.dot.used { background: var(--line); }
.dot.err { background: var(--danger); box-shadow: 0 0 8px rgba(255, 93, 93, 0.7); }

.edge {
  pointer-events: none;   /* 当たり判定は座標で行う（js/game.js の edgeAtPoint） */
}
.edge.h { width: var(--cell); height: var(--lw); }
.edge.v { width: var(--lw); height: var(--cell); }

/* 線本体 */
.edge::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line);
  box-shadow: 0 0 8px rgba(108, 192, 255, 0.55);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.11s ease-out, transform 0.11s ease-out;
}
.edge.on::before { opacity: 1; transform: none; }
.edge.on.hint::before { background: var(--line-hint); box-shadow: 0 0 10px rgba(255, 209, 102, 0.6); }

/* ×（線を引かない印） */
.edge::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--xs);
  height: var(--xs);
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
  transition: opacity 0.11s ease-out, transform 0.11s ease-out;
  background:
    linear-gradient(45deg, transparent 43%, var(--cross) 43%, var(--cross) 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, var(--cross) 43%, var(--cross) 57%, transparent 57%);
}
.edge.x::after { opacity: 1; transform: translate(-50%, -50%); }
.edge.x.hint::after { filter: drop-shadow(0 0 4px rgba(255, 209, 102, 0.9)); }

/* キーボード操作中の選択位置 */
.edge.cur {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 999px;
}

/* クリア演出 */
#board.cleared .edge.on::before {
  animation: loop-glow 1.1s ease-out 2;
  background: var(--accent2);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.8);
}
#board.cleared .dot.used { background: var(--accent2); }
@keyframes loop-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.7); }
}

/* ---------- 一時停止・生成中オーバーレイ ---------- */
#pause-overlay, #loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  /* 一時停止中に盤面を読めてしまわないよう、透けない色で覆う */
  background: #131d33;
  border-radius: 12px;
  z-index: 10;
}

#pause-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#pause-title { font-size: 17px; font-weight: 800; color: var(--text-dim); }

#loading-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ツール ---------- */
#tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-bottom: 10px;
}

.tool-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 9px 2px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.tool-btn:active { transform: scale(0.95); }
.tool-btn:disabled { opacity: 0.35; cursor: default; }
.tool-btn:disabled:active { transform: none; }
.tool-icon { font-size: 18px; line-height: 1; }
.tool-label { line-height: 1; }

.tool-state {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 9px;
  font-weight: 800;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

#btn-cross[aria-pressed="true"] {
  background: rgba(255, 209, 102, 0.18);
  border-color: rgba(255, 209, 102, 0.5);
  color: var(--accent2);
}
#btn-cross[aria-pressed="true"] .tool-state { color: var(--accent2); }

/* ---------- 結果オーバーレイ ---------- */
#result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 24, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 50;
  animation: fadein 0.25s ease-out;
  padding: 16px;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

#result-box {
  width: min(92vw, 380px);
  max-height: 88dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, #223154, #16203a);
  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.5);
  animation: rise 0.3s ease-out;
}
@keyframes rise {
  from { transform: translateY(24px) scale(0.95); opacity: 0; }
  to { transform: none; opacity: 1; }
}

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

#result-sub {
  margin-top: 8px;
  color: var(--accent2);
  font-weight: 800;
  font-size: 14px;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0.4; } }

#result-time-row { margin: 14px 0 4px; }
#result-time {
  font-size: 44px;
  font-weight: 900;
  font-family: "SF Mono", "Courier New", monospace;
}

#result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0 12px;
}
.rstat { display: flex; flex-direction: column; gap: 3px; }
.rstat-label { font-size: 10px; color: var(--text-dim); font-weight: 700; }
.rstat span:last-child { font-size: 14px; font-weight: 800; }

#result-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.6;
}

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

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

.btn-primary {
  background: linear-gradient(180deg, #5db1ff, #2f7fe0);
  color: #fff;
  box-shadow: 0 6px 18px rgba(77, 163, 255, 0.35);
}

.btn-sub {
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

/* ---------- モーダル ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 24, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 60;
  animation: fadein 0.2s ease-out;
  padding: 16px;
}

.modal-box {
  width: min(92vw, 400px);
  max-height: 86dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, #223154, #16203a);
  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;
}

.diff-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.diff-btn small { font-size: 10px; font-weight: 600; color: var(--text-dim); }
.diff-btn.active {
  border-color: var(--accent);
  background: rgba(77, 163, 255, 0.15);
  color: var(--accent);
}
.diff-btn.active small { color: var(--accent); }

.menu-wide-btn { width: 100%; margin-top: 10px; font-size: 14px; }

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

.toggle {
  flex-shrink: 0;
  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;
}
.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); }

#best-list { display: flex; flex-direction: column; }
.best-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 2px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}
.best-row span:last-child { font-weight: 800; color: var(--accent2); }

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

/* ---------- トースト ---------- */
#toast {
  position: fixed;
  left: 50%;
  /* 操作ボタン列を隠さない高さに出す（広告があるぶんはさらに持ち上げる） */
  bottom: calc(112px + env(safe-area-inset-bottom) + var(--ad-space, 0px));
  transform: translateX(-50%);
  background: rgba(20, 30, 55, 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;
  /* 操作ボタン列の上端に少し重なるので、表示中もタップを下へ通す */
  pointer-events: none;
}
@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(105dvh) rotate(720deg); opacity: 0.7; }
}

/* ---------- フッター ---------- */
#footer {
  padding: 8px 0 14px;
  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 (prefers-reduced-motion: reduce) {
  .confetti, #result-sub, #board.cleared .edge.on::before { animation: none !important; }
  .edge::before, .edge::after, .clue, .dot { transition: none !important; }
}

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

/* ---------- 全国ランキング（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));
  background: rgba(8, 12, 24, 0.72);
  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, #223154, #16203a);
  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;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

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

.sgr-tab-active {
  background: rgba(77, 163, 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, #5db1ff, #2f7fe0);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(77, 163, 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(77, 163, 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;
}

.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; }
}
