/* =========================================================
 * gunegune-drive（ぐねぐねドライブ） スタイル
 * ========================================================= */
:root {
  --font-jp: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --c-bg: #16212c;
  --c-text: #f7f5ec;
  --c-dim: #b9c4cf;
  --c-accent: #ffd23f;
  --c-accent-deep: #e7a211;
  --c-red: #f0483e;
  --c-red-deep: #a8241d;
  --c-green: #7ed957;
  --c-panel: rgba(20, 32, 44, 0.94);
  --c-line: rgba(255, 210, 63, 0.38);
  /* ランキング（sgr-*）は明るいパネルで出す */
  --c-sgr-text: #1f2233;
  --c-sgr-dim: #6b6f85;
  --c-sgr-line: rgba(31, 34, 51, 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: var(--c-bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  -webkit-touch-callout: none;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ===== レイアウト =====
   共通ヘッダー(--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 と共通ヘッダーが押す元ボタンは 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;
}

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

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* なぞってもページがスクロール・ズームしないようにする（操作はすべて game.js が受ける） */
  touch-action: none;
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 20;
  /* PC の広い画面では道のまわりに寄せる */
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 6px;
  padding: 8px 10px 0;
  padding-left: calc(10px + env(safe-area-inset-left, 0px));
  padding-right: calc(10px + env(safe-area-inset-right, 0px));
  pointer-events: none;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  padding: 4px 12px 5px;
  border-radius: 12px;
  background: rgba(16, 26, 36, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.hud-left { justify-self: start; min-width: 92px; }
.hud-center { justify-self: center; align-items: center; min-width: 96px; }
.hud-right {
  justify-self: end;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
}

.hud-label {
  font-family: var(--font-num);
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.14em;
  color: var(--c-accent);
}

.hud-value {
  font-family: var(--font-num);
  font-size: 21px;
  font-weight: 900;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.hud-value small {
  margin-left: 2px;
  font-size: 12px;
  font-weight: bold;
  color: var(--c-dim);
}

.hud-sub {
  font-size: 10px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  color: var(--c-dim);
}

.hud-life { display: flex; gap: 3px; }

.hud-life i {
  position: relative;
  display: block;
  width: 20px;
  height: 18px;
  transition: transform 0.25s, opacity 0.25s, filter 0.25s;
}

/* ハート（CSS だけで描く） */
.hud-life i::before,
.hud-life i::after {
  content: "";
  position: absolute;
  top: 1px;
  width: 11px;
  height: 17px;
  border-radius: 11px 11px 0 0;
  background: linear-gradient(180deg, #ff7b8d, #f0354d);
}
.hud-life i::before { left: 10px; transform: rotate(-45deg); transform-origin: 0 100%; }
.hud-life i::after { left: -1px; transform: rotate(45deg); transform-origin: 100% 100%; }

.hud-life i.off { opacity: 0.28; filter: grayscale(1); transform: scale(0.82); }
.hud-life i.pop { animation: life-pop 0.45s ease-out; }

@keyframes life-pop {
  0% { transform: scale(1.7); }
  100% { transform: scale(1); }
}

.hud-pause {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

.hud-pause:active { background: rgba(255, 255, 255, 0.28); }

.hud-chain {
  grid-column: 1 / -1;
  justify-self: start;
  margin: 0;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(16, 26, 36, 0.55);
  font-size: 13px;
  font-weight: 900;
  color: var(--c-accent);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
}

.hud-chain.on { opacity: 1; transform: none; }
.hud-chain.bump { animation: chain-bump 0.3s ease-out; }

@keyframes chain-bump {
  0% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ===== 操作のヒント ===== */
.hint {
  position: absolute;
  left: 50%;
  bottom: 12%;
  z-index: 21;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 26, 36, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 14px;
  font-weight: bold;
  line-height: 1.5;
  text-align: center;
  color: #fff;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.hint.on { opacity: 1; transform: translate(-50%, 0); }

/* ===== エリアの案内 ===== */
.banner {
  position: absolute;
  left: 50%;
  top: 22%;
  z-index: 21;
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 7px 22px;
  border-radius: 999px;
  background: rgba(16, 26, 36, 0.8);
  border: 2px solid var(--c-accent);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #fff;
  opacity: 0;
  transform: translate(-50%, -10px) scale(0.9);
  pointer-events: none;
}

.banner.on { animation: banner-in 2.2s ease-out both; }

@keyframes banner-in {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(0.9); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  20% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -8px) scale(0.96); }
}

/* ===== カウントダウン ===== */
.count {
  position: absolute;
  left: 50%;
  top: 36%;
  z-index: 22;
  margin: 0;
  font-family: var(--font-num);
  font-size: clamp(64px, 22vw, 110px);
  font-weight: 900;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 3px #16212c;
  paint-order: stroke fill;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.count.go { color: var(--c-accent); font-size: clamp(54px, 18vw, 96px); }
.count.on { animation: count-pop 0.5s ease-out both; }

@keyframes count-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.86); }
}

/* ===== 画面（タイトル・リザルト・一時停止） ===== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  padding-bottom: 48px;
  background: radial-gradient(ellipse at 50% 45%, rgba(10, 20, 30, 0.12), rgba(10, 20, 30, 0.55));
  overflow-y: auto;
}

.screen-dim { background: rgba(10, 18, 26, 0.9); padding-bottom: 16px; }

.panel {
  width: min(400px, 100%);
  margin: auto;
  padding: 20px 18px 18px;
  border-radius: 20px;
  background: var(--c-panel);
  border: 1px solid var(--c-line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
}

.title-panel { padding-top: 22px; }

.title-en {
  margin: 0;
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.4em;
  color: var(--c-accent);
}

.title-ja {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 0.12em;
  margin: 6px 0 0;
  font-size: clamp(31px, 9.6vw, 42px);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 3px 0 var(--c-red-deep), 0 6px 14px rgba(0, 0, 0, 0.45);
}

.title-ja span:first-child { color: var(--c-accent); text-shadow: 0 3px 0 #a36a00, 0 6px 14px rgba(0, 0, 0, 0.45); transform: rotate(-3deg); }

.title-catch {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--c-text);
}

.title-catch b { color: var(--c-accent); }

/* 操作の早見表 */
.title-keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.title-keys li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 13px;
  line-height: 1.4;
  color: var(--c-dim);
}

.title-keys b { min-width: 3.4em; font-size: 13px; color: #fff; }

/* マウスの環境ではマウスとキーを、タッチの環境ではなぞる操作を出す */
.title-keys .k-key { display: none; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  margin-right: 2px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255, 210, 63, 0.16);
  border: 1px solid rgba(255, 210, 63, 0.45);
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: bold;
  line-height: 1.5;
  text-align: center;
  color: var(--c-accent);
}

@media (hover: hover) and (pointer: fine) {
  .title-keys .k-touch { display: none; }
  .title-keys .k-key { display: flex; }
}

.title-best {
  display: inline-block;
  margin: 12px 0 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(255, 210, 63, 0.12);
  border: 1px solid rgba(255, 210, 63, 0.3);
  font-size: 13px;
  font-weight: bold;
  color: var(--c-accent);
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.title-sub-buttons {
  display: flex;
  gap: 8px;
}

.title-sub-buttons .btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 14px;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  font-family: var(--font-jp);
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.97); }

.btn:focus-visible {
  outline: 3px solid var(--c-accent);
  outline-offset: 2px;
}

.btn-primary {
  border: 0;
  background: linear-gradient(180deg, #ff6a5c, #e2362c);
  color: #fff;
  font-size: 17px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 0 var(--c-red-deep), 0 8px 18px rgba(226, 54, 44, 0.4);
}

.btn-primary:active { box-shadow: 0 2px 0 var(--c-red-deep); transform: translateY(2px); }

.btn-sub {
  border: 1px solid rgba(255, 210, 63, 0.4);
  background: rgba(255, 210, 63, 0.08);
  color: var(--c-text);
}

/* リザルト */
.result-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #ff8a80;
}

.result-new {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: bold;
  color: var(--c-accent);
  animation: glow 1.2s ease-in-out infinite alternate;
}

@keyframes glow {
  from { text-shadow: 0 0 4px rgba(255, 210, 63, 0.3); }
  to { text-shadow: 0 0 14px rgba(255, 210, 63, 0.9); }
}

.result-score-row {
  margin: 8px 0 0;
  font-family: var(--font-num);
  color: var(--c-accent);
}

#result-score {
  font-size: 46px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.result-unit {
  margin-left: 4px;
  font-family: var(--font-jp);
  font-size: 16px;
  font-weight: bold;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 8px;
}

.rstat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.rstat-label {
  font-size: 11px;
  color: var(--c-dim);
}

.rstat span:last-child {
  font-size: 16px;
  font-weight: bold;
}

.result-best {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--c-dim);
}

.result-buttons {
  display: flex;
  gap: 8px;
}

.result-buttons .btn { flex: 1; }

/* 一時停止 */
.paused-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--c-text);
  font-family: var(--font-jp);
  cursor: pointer;
}

.paused-panel:focus-visible {
  outline: 3px solid var(--c-accent);
  outline-offset: 3px;
}

.paused-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--c-accent);
}

.paused-note {
  font-size: 13px;
  line-height: 1.6;
  color: #ffe6a8;
}

.paused-hint {
  font-size: 13px;
  color: var(--c-dim);
}

/* ===== 遊び方モーダル ===== */
.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(10, 18, 26, 0.74);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.modal-box {
  width: min(480px, 100%);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px 18px 18px;
  border-radius: 16px;
  background: var(--c-panel);
  border: 1px solid var(--c-line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 900;
  color: var(--c-accent);
}

.howto-lead {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.7;
  text-align: left;
}

.howto-lead b, .howto b, .item-list b { color: var(--c-accent); }

.op-list,
.item-list,
.howto {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.op-list li {
  margin-bottom: 6px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 13px;
  line-height: 1.6;
  color: var(--c-text);
}

.op-list b { display: inline-block; min-width: 5.4em; color: #fff; }

.item-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.item-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 12px;
  line-height: 1.5;
  color: var(--c-dim);
}

.item-list b { font-size: 13px; }

.item-icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #5d626b;
}

.howto li {
  position: relative;
  margin-bottom: 6px;
  padding-left: 1.1em;
  font-size: 13px;
  line-height: 1.7;
  color: var(--c-text);
}

.howto li::before {
  content: "";
  position: absolute;
  left: 0.15em;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-accent);
}

@media (max-width: 400px) {
  .item-list { grid-template-columns: 1fr; }
}

/* ===== フッター ===== */
#footer {
  position: absolute;
  left: 0;
  right: 0;
  /* #app がすでに広告の上で終わっているので、広告ぶん（--ad-space）は足さない */
  bottom: 6px;
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  pointer-events: none;
  z-index: 31;
}

#footer a {
  color: var(--c-accent);
  pointer-events: auto;
}

body.playing #footer { display: none; }

/* 縦が短めのスマホ（iPhone SE など。広告と共通ヘッダーのぶん、ゲームの高さは 530px 前後になる） */
@media (max-height: 760px) {
  .title-panel { padding-top: 16px; padding-bottom: 14px; }
  .title-en { font-size: 11px; }
  .title-ja { margin-top: 2px; font-size: 32px; }
  .title-keys { margin-top: 10px; gap: 5px; }
  .title-best { margin-top: 10px; }
  .title-buttons { margin-top: 10px; gap: 8px; }
}

@media (max-height: 700px) {
  .title-en { display: none; }
  .title-catch { font-size: 13px; margin-top: 6px; }
  .title-buttons .btn { min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
}

/* 低い画面（横向きのスマホなど） */
@media (max-height: 560px) {
  .title-catch { display: none; }
  .title-keys { margin-top: 8px; }
  .title-keys li { padding: 4px 8px; }
  .panel { padding: 12px 16px; }
  .title-panel { padding-top: 12px; }
  .title-ja { font-size: 28px; }
  #result-score { font-size: 36px; }
  .result-stats { margin: 8px 0 6px; }
  #hud { padding-top: 4px; }
  .hud-cell { padding: 2px 8px 3px; }
  .hud-label { font-size: 9px; }
  .hud-value { font-size: 16px; }
  .banner { top: 26%; padding: 4px 14px; font-size: 15px; }
  .screen { padding-bottom: 40px; }
}

@media (max-height: 420px) {
  .title-keys { display: none; }
}

/* ===== 全国ランキング（共通モジュール 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, 7, 16, 0.7);
  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: #fbf8f0;
  color: var(--c-sgr-text);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  -webkit-user-select: text;
  user-select: text;
}

.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-sgr-line);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(201, 47, 56, 0.06);
  color: var(--c-sgr-text);
  cursor: pointer;
}

.sgr-tab-active {
  background: linear-gradient(135deg, #e2434b, #b52a32);
  border-color: transparent;
  color: #fff;
}

.sgr-register-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  color: #c4620c;
}

.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-sgr-line);
  border-radius: 8px;
  background: #fff;
  color: var(--c-sgr-text);
  -webkit-user-select: text;
  user-select: text;
}

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

.sgr-name:focus {
  outline: none;
  border-color: #e2434b;
  box-shadow: 0 0 8px rgba(226, 67, 75, 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, #e2434b, #b52a32);
  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: #c9252e;
}

.sgr-status {
  margin: 0;
  font-size: 13px;
  text-align: center;
  color: var(--c-sgr-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(201, 47, 56, 0.06); }

.sgr-row.sgr-row-me {
  background: linear-gradient(135deg, #e2434b, #b52a32);
  color: #fff;
}

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

.sgr-rank-top1 { color: #c98d1c; }
.sgr-rank-top2 { color: #8a93a6; }
.sgr-rank-top3 { color: #b0703a; }
.sgr-row-me .sgr-rank { color: #fff; }

.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-sgr-line);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(201, 47, 56, 0.06);
  color: var(--c-sgr-text);
  cursor: pointer;
}

.sgr-close:hover { border-color: #e2434b; }

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

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

.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, #f5c24e, #e08a1a);
  color: #2a1a00;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(224, 138, 26, 0.4);
}

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

.sgr-cta-link {
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
  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; }
}
