/* =========================================================
 * 3D将棋崩し（shogi-kuzushi） スタイル
 * ========================================================= */
: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-min: Georgia, "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --font-num: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --c-text: #2a2118;
  --c-dim: #7b6d5c;
  --c-accent: #b4532a;
  --c-accent-deep: #8a3a18;
  --c-gold: #e9b84a;
  --c-orange: #d9791f;
  --c-red: #c8402f;
  --c-panel: rgba(250, 245, 234, 0.97);
  --c-line: rgba(42, 33, 24, 0.14);
}

* { 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: #120e0a;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ===== レイアウト =====
   共通ヘッダー(--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 に残す。
   position: absolute でフローから外れるので、#stage（flex: 1）が共通ヘッダーの直下から全部を使う */
#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-family: var(--font-min);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #f7e7c8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); }

/* ===== ステージ ===== */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #120e0a;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* 周辺減光 */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 48%, transparent 58%, rgba(0, 0, 0, 0.4) 100%);
  z-index: 1;
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 8px;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 10;
}
.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}
.hud-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 88px;
  padding: 4px 12px 5px;
  border-radius: 12px;
  background: rgba(18, 13, 9, 0.6);
  border: 1px solid rgba(255, 230, 180, 0.13);
  color: #fff;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.hud-box.active { border-color: var(--c-gold); box-shadow: 0 0 14px rgba(233, 184, 74, 0.5); }
.hud-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: rgba(255, 233, 195, 0.62);
}
.hud-val {
  font-family: var(--font-num);
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.hud-mid { min-width: 64px; }
.hud-box.lives .hud-val { font-size: 17px; letter-spacing: 0.18em; color: #ffd58a; line-height: 1.42; }

/* 音メーター */
#meter {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(320px, 78%);
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: rgba(18, 13, 9, 0.6);
  border: 1px solid rgba(255, 230, 180, 0.13);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.meter-label {
  flex: none;
  font-family: var(--font-min);
  font-size: 13px;
  font-weight: 900;
  color: #f7e7c8;
}
.meter-track {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}
#meter-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #7fd08a, #c9dd6b);
}
#meter-fill.warn { background: linear-gradient(90deg, #c9dd6b, #f0a43a); }
#meter-fill.over { background: linear-gradient(90deg, #f0a43a, #e2402c); }
.meter-line {
  position: absolute;
  left: 86.96%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #ff6b57;
}
.meter-out { flex: none; font-size: 10px; font-weight: 800; color: #ff8d7c; letter-spacing: 0.06em; }
#meter.shake { animation: meter-shake 0.4s; }
@keyframes meter-shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

#turn-label {
  margin: 0;
  min-height: 1.5em;
  font-size: 13px;
  font-weight: 800;
  color: #fff3dc;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.6);
}

/* 取った駒 */
#trays {
  position: absolute;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(54px + env(safe-area-inset-right, 0px));
  bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  pointer-events: none;
  z-index: 10;
}
.tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 5px;
  min-height: 30px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(18, 13, 9, 0.55);
  border: 1px solid rgba(255, 230, 180, 0.1);
}
.tray:empty { display: none; }
.tray-name { font-size: 10.5px; font-weight: 800; color: rgba(255, 233, 195, 0.75); margin-right: 2px; }
.tk { display: inline-flex; align-items: center; gap: 1px; }
.tk b { font-family: var(--font-num); font-size: 11px; color: #fff; }
.koma {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: 19px;
  height: 22px;
  padding-bottom: 1px;
  font-family: var(--font-min);
  font-style: normal;
  font-size: 12.5px;
  font-weight: 900;
  line-height: 1.15;
  color: #1c120a;
  background: linear-gradient(180deg, #f1d79c, #dcb56c);
  clip-path: polygon(50% 0, 88% 16%, 100% 100%, 0 100%, 12% 16%);
}

#btn-view {
  position: absolute;
  right: calc(8px + env(safe-area-inset-right, 0px));
  bottom: 8px;
  z-index: 11;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(18, 13, 9, 0.62);
}

#hint {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 14px;
  width: max-content;
  max-width: 92%;
  border-radius: 999px;
  background: rgba(18, 13, 9, 0.72);
  color: #fff3dc;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
  z-index: 9;
}

/* 得点の浮き文字 */
#floats { position: absolute; inset: 0; pointer-events: none; z-index: 12; overflow: hidden; }
.float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.5);
  opacity: 0;
}
.float.show { animation: float-up 1.15s ease-out forwards; }
.float.big { color: #ffd75e; font-size: 23px; }
.float.combo { color: #9fe3ff; font-size: 14px; font-style: italic; }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

.banner {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: 94%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  z-index: 13;
}
.banner:empty { display: none; }
.banner-main {
  font-family: var(--font-min);
  font-size: clamp(22px, 5.6vw, 38px);
  font-weight: 900;
  color: #fff4dc;
  text-shadow: 0 3px 0 rgba(60, 35, 10, 0.85), 0 6px 20px rgba(0, 0, 0, 0.8);
}
.banner-sub { font-size: 13px; font-weight: 800; color: #fff; text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9); }
.banner.bad .banner-main { color: #ffb4a4; text-shadow: 0 3px 0 #6e1a10, 0 6px 20px rgba(0, 0, 0, 0.8); }
.banner.show { animation: banner-pop 2.2s ease-out forwards; }
.banner.bad.show { animation: banner-bad 2.2s ease-out forwards; }
@keyframes banner-pop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.92); }
  10% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%); }
}
@keyframes banner-bad {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.25); }
  8% { opacity: 1; transform: translate(-52%, -50%) scale(1); }
  14% { transform: translate(-48%, -50%); }
  20% { transform: translate(-50%, -50%); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== 画面（タイトル・結果・一時停止） ===== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(10, 7, 5, 0.5);
  z-index: 30;
  overflow-y: auto;
}
#screen-loading { background: #120e0a; }
.loading-panel { text-align: center; color: #f3e3c6; font-size: 14px; }
.loading-koma {
  width: 46px;
  height: 52px;
  margin: 0 auto 14px;
  background: linear-gradient(180deg, #f1d79c, #d6ab60);
  clip-path: polygon(50% 0, 88% 16%, 100% 100%, 0 100%, 12% 16%);
  animation: koma-rock 1s ease-in-out infinite;
}
@keyframes koma-rock { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }

#screen-title { background: linear-gradient(180deg, rgba(10, 7, 5, 0.28), rgba(10, 7, 5, 0.62)); }
.title-panel {
  width: min(400px, 100%);
  margin: auto;
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: rgba(22, 16, 11, 0.74);
  border: 1px solid rgba(255, 225, 170, 0.16);
  color: #fff;
  text-align: center;
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}
.title-en { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: 0.4em; color: rgba(255, 225, 170, 0.7); }
.title-ja {
  margin: 2px 0 4px;
  font-family: var(--font-min);
  font-size: clamp(36px, 11vw, 50px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #f9ebcd;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), 0 0 26px rgba(233, 184, 74, 0.25);
}
.title-ja small { font-size: 0.5em; color: var(--c-gold); margin-right: 0.15em; vertical-align: 0.35em; }
.title-catch { margin: 0 0 6px; font-size: 14px; font-weight: 800; color: #ffdf9f; }
.title-desc { margin: 0 0 8px; font-size: 12.5px; line-height: 1.65; color: rgba(255, 240, 218, 0.84); }
#title-best { margin: 0; font-size: 12px; font-weight: 800; color: rgba(255, 233, 195, 0.8); }
.title-buttons { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.title-sub-buttons { display: flex; gap: 8px; }
.title-sub-buttons .btn { flex: 1; }
.cpu-row { display: flex; gap: 8px; align-items: stretch; }
.cpu-row .btn { flex: 1; }
#level-select {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
  flex: none;
}
#level-select button {
  padding: 2px 10px;
  min-height: 19px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--font-jp);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
#level-select button.on { background: var(--c-gold); border-color: var(--c-gold); color: #2a1c08; }
.title-hint { margin: 10px 0 0; font-size: 11px; color: rgba(255, 235, 205, 0.6); }

.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-family: var(--font-jp);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}
.btn small { font-size: 10.5px; font-weight: 700; opacity: 0.86; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #c9652c, #9a3d17);
  box-shadow: 0 6px 18px rgba(170, 70, 25, 0.45);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-second {
  color: #2a1c08;
  background: linear-gradient(135deg, #f0cf7c, #d8a544);
  box-shadow: 0 6px 16px rgba(190, 140, 40, 0.3);
}
.btn-second:hover { filter: brightness(1.06); }
.btn-third {
  color: #fff;
  background: linear-gradient(135deg, #4f6a55, #33483a);
}
.btn-third:hover { filter: brightness(1.1); }
.btn-sub {
  padding: 9px 10px;
  font-size: 13px;
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-sub:hover { background: rgba(255, 255, 255, 0.16); }

.result-panel {
  width: min(380px, 100%);
  margin: auto;
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: var(--c-panel);
  text-align: center;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
#result-title { margin: 0; font-family: var(--font-min); font-size: 24px; font-weight: 900; color: var(--c-accent-deep); }
#result-sub { margin: 2px 0 0; min-height: 1.2em; font-size: 12px; font-weight: 700; color: var(--c-dim); }
#result-new { margin: 6px 0 0; font-size: 13px; font-weight: 900; color: var(--c-orange); }
.result-score-row { margin: 4px 0 8px; }
#result-score {
  font-family: var(--font-num);
  font-size: 44px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--c-text);
}
#result-unit { margin-left: 4px; font-size: 18px; font-weight: 800; color: var(--c-dim); }
#result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.rstat {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(42, 33, 24, 0.06);
}
.rstat-label { font-size: 11px; font-weight: 700; color: var(--c-dim); }
.rstat span:last-child { font-size: 16px; font-weight: 900; }
#result-vs { margin: 0 0 12px; font-size: 14px; font-weight: 800; line-height: 1.9; }
#result-vs p { margin: 0; padding: 4px 8px; border-radius: 10px; background: rgba(42, 33, 24, 0.06); }
#result-vs p + p { margin-top: 6px; }
.result-buttons { display: flex; gap: 8px; }
.result-buttons .btn { flex: 1; }
.result-panel .btn-sub { color: var(--c-text); background: rgba(42, 33, 24, 0.07); border-color: var(--c-line); }

.paused-panel {
  padding: 22px 28px;
  border-radius: 18px;
  background: rgba(22, 16, 11, 0.85);
  color: #fff;
  text-align: center;
  max-width: 340px;
}
.paused-title { margin: 0 0 6px; font-size: 22px; font-weight: 900; }
.paused-hint { margin: 0; font-size: 13px; line-height: 1.6; color: rgba(255, 235, 205, 0.75); }

/* ===== 遊び方 ===== */
.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(8, 6, 4, 0.66);
  z-index: 60;
}
.modal-box {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px;
  border-radius: 18px;
  background: var(--c-panel);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
.modal-title { margin: 0 0 10px; font-family: var(--font-min); font-size: 20px; text-align: center; }
.howto { margin: 0 0 12px; padding-left: 1.2em; font-size: 13.5px; line-height: 1.7; }
.howto li { margin-bottom: 6px; }
.pts { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 14px; padding: 8px 10px; border-radius: 10px; background: rgba(42, 33, 24, 0.06); font-size: 12.5px; font-weight: 800; }
.pts span { display: inline-flex; align-items: center; gap: 3px; }
.modal-box .btn { width: 100%; }

/* ===== フッター ===== */
#footer {
  flex: none;
  padding: 3px 10px 4px;
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
  color: rgba(255, 235, 205, 0.5);
  background: #120e0a;
}
#footer a { color: rgba(255, 235, 205, 0.72); }

@media (max-height: 560px) {
  #footer { display: none; }
  .title-desc { display: none; }
  .title-panel { padding: 12px 16px; }
  .title-ja { font-size: 30px; }
}
@media (min-width: 900px) {
  #hud { top: 12px; }
  .hud-val { font-size: 24px; }
  #turn-label { font-size: 15px; }
}

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