/* ことばあて */

:root {
  --bg-top: #1a2647;
  --bg-mid: #101731;
  --bg-deep: #0a0e22;
  --panel: rgba(23, 32, 66, 0.78);
  --line: rgba(150, 166, 214, 0.26);
  --text: #eef2ff;
  --text-dim: #97a2cd;
  --tile-line: rgba(150, 166, 214, 0.38);
  --correct: #3f9e63;
  --present: #cc9c28;
  --absent: #39415f;
  --accent: #56d8c4;
  --accent3: #ffe14d;
  --danger: #ff5a5f;
  --font-jp: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-jp);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-deep) 100%);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font-family: var(--font-jp);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  max-width: 520px;
  margin: 0 auto;
  /* 上のセーフエリアは共通ヘッダー（--sgh-top）が、広告があるときの下のセーフエリアは --ad-space が取るので、ここでは二重に取らない */
  padding: 0 max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
}
html.has-ad-banner #app { padding-bottom: 0; }

.hidden { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent3);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- ヘッダー ---------- */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 2px 5px;
  gap: 8px;
  flex-shrink: 0;
}

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

#logo {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
  background: linear-gradient(180deg, #ffffff 30%, #9fe8dc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#diff-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: bold;
  color: #05231f;
  background: linear-gradient(180deg, #9defdd 0%, var(--accent) 100%);
  border-radius: 999px;
  padding: 4px 10px;
}

#topbar-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 17px;
  line-height: 1;
  background: rgba(150, 166, 214, 0.14);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: rgba(150, 166, 214, 0.26); }

/* ---------- ステータスバー ---------- */

#status-bar {
  display: flex;
  gap: 6px;
  padding: 0 2px 6px;
  flex-shrink: 0;
}

.status-box {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  padding: 5px 4px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.status-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.status-value {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- 盤面 ---------- */

#board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}

#board {
  --tile: 48px;
  --gap: 6px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  perspective: 800px;
}

.row {
  display: flex;
  gap: var(--gap);
}

.tile {
  width: var(--tile);
  height: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--tile) * 0.56);
  font-weight: 800;
  line-height: 1;
  border: 2px solid var(--tile-line);
  border-radius: 8px;
  background: rgba(10, 14, 34, 0.35);
  color: var(--text);
  transform-style: preserve-3d;
}

.tile.filled { border-color: rgba(150, 166, 214, 0.62); }

.tile.correct { background: var(--correct); border-color: var(--correct); }
.tile.present { background: var(--present); border-color: var(--present); color: #211a02; }
.tile.absent  { background: var(--absent);  border-color: var(--absent); color: rgba(238, 242, 255, 0.72); }

.tile-ghost {
  color: rgba(86, 216, 196, 0.5);
  border-style: dashed;
  border-color: rgba(86, 216, 196, 0.45);
}

/* 正解表示（濁点つきの本当のよみ） */
.tile-real {
  background: var(--correct);
  border-color: #7de3a4;
  box-shadow: 0 0 14px rgba(63, 158, 99, 0.55);
}

/* ヒントで使えなくなった行 */
.row-void { opacity: 0.32; }
.row-void .tile {
  border-style: dashed;
  background: repeating-linear-gradient(135deg, rgba(150, 166, 214, 0.08) 0 6px, transparent 6px 12px);
}

.row-answer .tile { animation: pop 0.3s ease; }

@keyframes pop {
  0% { transform: scale(0.86); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.tile.pop { animation: pop 0.14s ease; }

@keyframes flip {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.tile.flip {
  animation: flip 520ms ease forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.row.shake { animation: shake 0.36s ease; }

/* ---------- ヒント・メッセージ ---------- */

#hint-bar {
  flex-shrink: 0;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: var(--accent);
  padding: 2px 0 4px;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: calc(38% + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 50;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: bold;
  white-space: nowrap;
  background: rgba(238, 242, 255, 0.94);
  color: #15203c;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* ---------- キーボード（QWERTY） ---------- */

#keyboard-wrap {
  flex-shrink: 0;
  padding: 0 0 6px;
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* どの段のキーも同じ幅にして中央寄せする */
.kb-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.kb-row .key {
  flex: 0 0 auto;
  width: calc((100% - 36px) / 10);
}

.key {
  height: clamp(34px, 10.5vw, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 3.7vw, 19px);
  font-weight: bold;
  line-height: 1;
  border-radius: 7px;
  background: rgba(150, 166, 214, 0.2);
  border: 1px solid rgba(150, 166, 214, 0.18);
  color: var(--text);
  transition: transform 0.08s, background 0.15s;
}

.key:hover { background: rgba(150, 166, 214, 0.34); }
.key:active { transform: scale(0.9); }

.key-gap {
  background: none;
  border-color: transparent;
  pointer-events: none;
}

.key-correct { background: var(--correct); border-color: var(--correct); }
.key-present { background: var(--present); border-color: var(--present); color: #211a02; }
.key-absent  { background: rgba(45, 51, 75, 0.9); border-color: rgba(45, 51, 75, 0.9); color: rgba(238, 242, 255, 0.34); }

#action-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.act {
  height: clamp(38px, 9.5vw, 48px);
  border-radius: 9px;
  font-size: clamp(13px, 3.6vw, 16px);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.act-sub {
  flex: 1;
  background: rgba(150, 166, 214, 0.2);
  border: 1px solid var(--line);
  color: var(--text);
}

.act-sub:hover { background: rgba(150, 166, 214, 0.32); }

.act-main {
  flex: 1.5;
  background: linear-gradient(180deg, #9defdd 0%, var(--accent) 60%, #24b09c 100%);
  color: #05231f;
  font-weight: 800;
  box-shadow: 0 3px 0 #16887a;
}

.act-main:active { transform: translateY(2px); box-shadow: 0 1px 0 #16887a; }

.act:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
}

/* ---------- フッター ---------- */

#footer {
  flex-shrink: 0;
  text-align: center;
  font-size: 10px;
  line-height: 1.6;
  color: var(--text-dim);
  padding: 2px 0 6px;
}

#footer a { color: var(--text-dim); }

/* ---------- 結果オーバーレイ ---------- */

#result-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 14, 34, 0.76);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#result-box {
  width: min(400px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  background: linear-gradient(180deg, #1f2b52 0%, var(--bg-mid) 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(86, 216, 196, 0.14);
}

#result-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
}

#result-title.is-lose { color: var(--text-dim); }

#result-sub {
  font-size: 13px;
  font-weight: bold;
  color: var(--accent3);
  text-shadow: 0 0 12px rgba(255, 225, 77, 0.4);
}

#result-answer {
  padding: 12px 10px;
  border-radius: 12px;
  background: rgba(10, 14, 34, 0.45);
  border: 1px solid var(--line);
}

#result-word {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

#result-kana {
  margin-top: 4px;
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--accent);
}

#result-main {
  font-size: 15px;
  color: var(--text-dim);
}

#result-attempts {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  margin-right: 3px;
}

#result-stats {
  display: flex;
  gap: 8px;
}

.rstat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 4px;
  border-radius: 9px;
  background: rgba(150, 166, 214, 0.12);
  font-size: 16px;
  font-weight: 800;
}

.rstat-label {
  font-size: 10px;
  font-weight: normal;
  color: var(--text-dim);
}

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

.btn {
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: bold;
  font-family: var(--font-jp);
}

.btn-primary {
  background: linear-gradient(180deg, #9defdd 0%, var(--accent) 60%, #24b09c 100%);
  color: #05231f;
  font-weight: 800;
}

.btn-sub {
  background: rgba(150, 166, 214, 0.18);
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-sub:hover { background: rgba(150, 166, 214, 0.3); }

.btn-danger {
  background: rgba(255, 90, 95, 0.16);
  border: 1px solid rgba(255, 90, 95, 0.5);
  color: #ff9598;
}

.btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- メニュー ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 14, 34, 0.76);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-box {
  width: min(420px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #1f2b52 0%, var(--bg-mid) 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-size: 19px;
  font-weight: 800;
  text-align: center;
}

.menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-caption {
  font-size: 12px;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.menu-caption-sub {
  color: var(--text-dim);
  margin-top: 2px;
}

.menu-note {
  font-size: 11px;
  color: var(--text-dim);
}

.diff-buttons {
  display: flex;
  gap: 6px;
}

.diff-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 4px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: bold;
  background: rgba(150, 166, 214, 0.16);
  border: 1px solid var(--line);
  color: var(--text);
}

.diff-btn small {
  font-size: 10px;
  font-weight: normal;
  color: var(--text-dim);
}

.diff-btn-active {
  background: linear-gradient(180deg, #9defdd 0%, var(--accent) 100%);
  border-color: var(--accent);
  color: #05231f;
}

.diff-btn-active small { color: rgba(5, 35, 31, 0.72); }

#stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.sbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 2px;
  border-radius: 9px;
  background: rgba(150, 166, 214, 0.12);
}

.sbox span {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sbox small {
  font-size: 9px;
  color: var(--text-dim);
}

#dist-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dist-label {
  width: 1.2em;
  text-align: right;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.dist-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 1.6em;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  background: var(--correct);
  color: #fff;
}

.dist-bar-zero {
  background: rgba(150, 166, 214, 0.2);
  color: var(--text-dim);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(150, 166, 214, 0.12);
  cursor: pointer;
}

.switch-text {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: bold;
}

.switch-text small {
  font-size: 10px;
  font-weight: normal;
  color: var(--text-dim);
}

.switch-row input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch-ui {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(150, 166, 214, 0.3);
  transition: background 0.2s;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.switch-row input:checked ~ .switch-ui { background: var(--accent); }
.switch-row input:checked ~ .switch-ui::after { transform: translateX(20px); }
.switch-row input:focus-visible ~ .switch-ui { outline: 2px solid var(--accent3); outline-offset: 2px; }

.howto {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
}

.howto li {
  padding-left: 15px;
  position: relative;
}

.howto li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.howto b { color: var(--text); }

.chip {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
}

.chip-correct { background: var(--correct); }
.chip-present { background: var(--present); color: #211a02; }
.chip-absent { background: var(--absent); }

/* ---------- 高さが足りない端末むけの詰めたレイアウト ----------
   盤面の行数に対して高さが足りないとき、js/game.js が #app に .tight を付ける。
   ヘッダー・ステータス・キーボード・フッターを少しずつ削って盤面の取り分を増やす */

#app.tight #topbar { padding: 4px 2px 3px; }
#app.tight #logo { font-size: 16px; }
#app.tight #diff-badge { font-size: 11px; padding: 3px 8px; }
#app.tight .icon-btn { width: 30px; height: 30px; font-size: 15px; }
#app.tight #status-bar { padding-bottom: 4px; gap: 4px; }
#app.tight .status-box { padding: 3px 4px; }
#app.tight .status-value { font-size: 14px; }
#app.tight #board-wrap { padding: 0; }
#app.tight #hint-bar { font-size: 11px; padding: 1px 0 3px; }
#app.tight #keyboard { gap: 3px; }
#app.tight #keyboard { gap: 4px; }
#app.tight .key { height: 32px; font-size: 15px; border-radius: 6px; }
#app.tight #action-row { margin-top: 4px; gap: 4px; }
#app.tight .act { height: 34px; font-size: 13px; }
#app.tight #keyboard-wrap { padding-bottom: 3px; }
#app.tight #footer { font-size: 9px; line-height: 1.4; padding: 0 0 3px; }

/* ---------- 横長・大きい画面 ---------- */

@media (min-width: 560px) {
  .key { height: 50px; font-size: 20px; }
  #toast { font-size: 15px; }
}

@media (max-height: 600px) {
  #logo { font-size: 16px; }
  .icon-btn { width: 30px; height: 30px; font-size: 15px; }
  .status-value { font-size: 14px; }
  #footer { display: none; }
}

/* ---------- 全国ランキング（SGRanking 共通モジュール） ---------- */

.sgr-hidden { display: none !important; }

.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(10, 14, 34, 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, #1f2b52 0%, var(--bg-mid) 100%);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(86, 216, 196, 0.12);
}

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

.sgr-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.sgr-tab {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  background: rgba(150, 166, 214, 0.16);
  color: var(--text);
  cursor: pointer;
}

.sgr-tab-active {
  background: var(--accent);
  color: #05231f;
}

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

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

.sgr-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-family: var(--font-jp);
  padding: 8px 10px;
  border: 2px solid rgba(150, 166, 214, 0.45);
  border-radius: 8px;
  background: rgba(10, 14, 34, 0.65);
  color: var(--text);
}

.sgr-name::placeholder { color: var(--text-dim); }

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

.sgr-submit {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: linear-gradient(180deg, #9defdd 0%, var(--accent) 60%, #24b09c 100%);
  color: #05231f;
  cursor: pointer;
}

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

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

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

.sgr-status {
  margin: 0;
  font-size: 13px;
  text-align: center;
  color: var(--text-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(150, 166, 214, 0.1); }

.sgr-row.sgr-row-me {
  background: var(--accent);
  color: #05231f;
}

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

.sgr-close {
  border: 1px solid rgba(150, 166, 214, 0.4);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(150, 166, 214, 0.16);
  color: var(--text);
  cursor: pointer;
}

.sgr-close:hover { background: rgba(150, 166, 214, 0.28); }

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

.sgr-cta-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  color: var(--accent3);
  text-shadow: 0 0 12px rgba(255, 225, 77, 0.4);
}

.sgr-cta-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font-jp);
  background: linear-gradient(180deg, #fff0a0 0%, var(--accent3) 55%, #ffc93e 100%);
  color: #3a2c00;
  cursor: pointer;
  box-shadow: 0 4px 0 #b8892a, 0 8px 22px rgba(255, 225, 77, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.sgr-cta-btn:active {
  transform: scale(0.94);
  box-shadow: 0 2px 0 #b8892a, 0 4px 12px rgba(255, 225, 77, 0.35);
}

.sgr-cta-link {
  border: none;
  background: none;
  padding: 6px;
  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; }
}
