/* =========================================================
 * door-rush（ドアラッシュ） スタイル
 * ========================================================= */
:root {
  --font-jp: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Sans", sans-serif;
  --font-num: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --c-bg: #14182a;
  --c-text: #f6f3ea;
  --c-dim: #b7b9cc;
  --c-accent: #ffb02e;
  --c-accent-deep: #d9780f;
  --c-red: #ff4d5a;
  --c-green: #4fd18b;
  --c-panel: rgba(22, 25, 44, 0.95);
  --c-line: rgba(255, 176, 46, 0.35);
  /* ランキング（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;
}

#logo {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--c-accent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

#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: #0d1020;
}

#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: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px 8px;
  padding: 8px 12px 0;
  padding-left: calc(12px + env(safe-area-inset-left, 0px));
  padding-right: calc(12px + env(safe-area-inset-right, 0px));
  pointer-events: none;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  min-width: 78px;
  padding: 4px 10px 5px;
  border-radius: 10px;
  background: rgba(10, 12, 24, 0.62);
  border: 1px solid rgba(255, 176, 46, 0.24);
}

.hud-left { align-items: flex-start; }
.hud-center { align-items: center; min-width: 64px; }
.hud-right { align-items: flex-end; }

.hud-label {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.16em;
  color: var(--c-dim);
}

.hud-value {
  font-family: var(--font-num);
  font-size: 20px;
  font-weight: bold;
  line-height: 1.15;
  color: var(--c-accent);
  font-variant-numeric: tabular-nums;
}

.hud-value.bump { animation: bump 0.3s ease-out; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.hud-life {
  display: flex;
  gap: 3px;
  height: 23px;
  align-items: center;
}

/* ハート（CSS だけで描く。絵文字は端末で見た目が変わるため使わない） */
.hud-life i {
  position: relative;
  display: block;
  width: 18px;
  height: 16px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.hud-life i::before,
.hud-life i::after {
  content: "";
  position: absolute;
  top: 0;
  width: 10px;
  height: 15px;
  border-radius: 10px 10px 0 0;
  background: #ff4d5a;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.hud-life i::before { left: 9px; transform: rotate(-45deg); transform-origin: 0 100%; }
.hud-life i::after { left: -1px; transform: rotate(45deg); transform-origin: 100% 100%; }

.hud-life i.lost { opacity: 0.22; transform: scale(0.8); }
.hud-life i.lost::before,
.hud-life i.lost::after { background: #8a8fa6; box-shadow: none; }
.hud-life i.gain { animation: heart-gain 0.6s ease-out; }

@keyframes heart-gain {
  0% { transform: scale(0.4); }
  50% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

#hud.hurt .hud-right { animation: hud-shake 0.4s ease-out; }

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

/* 残り時間のバー（扉にぶつかるまで） */
.hud-time {
  flex: 0 0 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(10, 12, 24, 0.55);
  overflow: hidden;
}

.hud-time span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ffd166, #ffb02e);
  transform-origin: 0 50%;
  will-change: transform;
}

.hud-time.warn span { background: linear-gradient(90deg, #ff7a52, #ff4d5a); }
.hud-time.passive span { background: linear-gradient(90deg, #7fd8ff, #4fb4e8); }

.hud-combo {
  flex: 0 0 100%;
  margin: 0;
  min-height: 20px;
  text-align: center;
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.hud-combo b { color: var(--c-accent); font-size: 18px; }
.hud-combo .mult { margin-left: 6px; color: #7fe3a8; }

/* ===== 操作のヒント（新しい種類の扉が初めて出たとき） ===== */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 12;
  margin: 0;
  padding: 7px 16px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(10, 12, 24, 0.78);
  border: 1px solid rgba(255, 176, 46, 0.55);
  color: #fff;
  font-size: clamp(14px, 4vw, 18px);
  font-weight: 800;
  width: max-content;
  max-width: calc(100% - 24px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.hint.show { opacity: 1; }
.hint b { color: var(--c-accent); }

/* ===== 案内の帯 ===== */
.banner {
  position: absolute;
  left: 50%;
  top: 30%;
  z-index: 12;
  margin: 0;
  padding: 7px 20px;
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(10, 12, 24, 0.72);
  border: 1px solid rgba(255, 176, 46, 0.45);
  color: #fff;
  font-size: clamp(16px, 4.8vw, 24px);
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.banner.good { color: var(--c-green); border-color: rgba(79, 209, 139, 0.6); }
.banner.bad { color: #ff8a92; border-color: rgba(255, 77, 90, 0.65); }
.banner.info { color: var(--c-accent); }
.banner.big { font-size: clamp(26px, 8vw, 40px); padding: 8px 28px; letter-spacing: 0.12em; }

/* ===== 得点・判定のポップ ===== */
#floats {
  position: absolute;
  inset: 0;
  z-index: 13;
  pointer-events: none;
  overflow: hidden;
}

.float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 900;
  color: var(--c-accent);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  text-align: center;
  animation: float-up 0.9s ease-out forwards;
}

.float small {
  display: block;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
}

.float.perfect { color: #ffe066; font-size: 26px; }
.float.great { color: #7fe3a8; }
.float.good { color: #9cc8ff; }
.float.pass { color: #7fd8ff; }
.float.bad {
  color: #ff4d5a;
  font-family: var(--font-jp);
  font-size: clamp(34px, 11vw, 56px);
  -webkit-text-stroke: 2px #fff;
  animation: float-hit 0.9s ease-out forwards;
}
.float.bad small { color: #fff; font-size: 15px; -webkit-text-stroke: 0; }
.float.up { color: #ff7a8a; font-family: var(--font-jp); font-size: 20px; }

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(1); }
}

@keyframes float-hit {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-8deg); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(0.95) rotate(-4deg); }
  24% { transform: translate(-50%, -50%) scale(1.06) rotate(-4deg); }
  75% { opacity: 1; transform: translate(-50%, -56%) scale(1) rotate(-4deg); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1) rotate(-4deg); }
}

/* ===== 画面（タイトル・リザルト・一時停止） ===== */
.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(12, 14, 28, 0.25), rgba(8, 9, 20, 0.72));
  overflow-y: auto;
}

.screen-dim { background: rgba(8, 9, 20, 0.94); padding-bottom: 16px; }

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

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

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

.title-ja {
  margin: 4px 0 0;
  font-size: clamp(32px, 10vw, 42px);
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff4d1, #ffc24d 55%, #e3780c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}

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

/* 操作の早見表 */
.title-keys {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.title-keys li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  line-height: 1.35;
  color: var(--c-dim);
}

.title-keys li.wide { grid-column: 1 / -1; flex-direction: row; align-items: baseline; gap: 10px; }
.title-keys b { font-size: 13px; color: #fff; }

/* マウスの環境ではキーを、タッチの環境ではジェスチャーを出す */
.title-keys .k-key { display: none; }
.title-keys kbd {
  display: inline-block;
  min-width: 1.6em;
  margin-right: 2px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255, 176, 46, 0.16);
  border: 1px solid rgba(255, 176, 46, 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: inline; }
}

.title-best {
  display: inline-block;
  margin: 12px 0 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(255, 176, 46, 0.12);
  border: 1px solid rgba(255, 176, 46, 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, #ff9a2e, #e5650c);
  color: #fff;
  font-size: 17px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 0 #9c3f05, 0 8px 18px rgba(229, 101, 12, 0.4);
}

.btn-primary:active { box-shadow: 0 2px 0 #9c3f05; transform: translateY(2px); }

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

/* リザルト */
.result-title {
  margin: 0;
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: #ff7a82;
}

.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, 176, 46, 0.3); }
  to { text-shadow: 0 0 14px rgba(255, 176, 46, 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.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.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: #ffd0a0;
}

.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(8, 9, 20, 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;
  color: var(--c-accent);
}

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

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

.door-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.door-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  line-height: 1.45;
}

.door-list b { color: #fff; font-size: 13px; }

.door-icon {
  flex: none;
  width: 36px;
  height: 48px;
  border-radius: 4px;
}

.door-list .op { color: var(--c-accent); font-weight: bold; }
.door-list .op-key { display: none; font-family: var(--font-num); color: var(--c-dim); }
@media (hover: hover) and (pointer: fine) {
  .door-list .op-key { display: inline; }
}

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

.howto {
  margin: 0 0 16px;
  padding: 0 0 0 1.2em;
  text-align: left;
  font-size: 13px;
  line-height: 1.7;
}

.howto li + li { margin-top: 5px; }
.howto b { color: var(--c-accent); }

.modal-box .btn { min-width: 160px; }

/* ===== フッター ===== */
#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.8);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  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-catch { display: none; }
  .title-en { font-size: 11px; }
  .title-ja { margin-top: 2px; font-size: 32px; }
  .title-keys { margin-top: 10px; gap: 5px; }
  .title-keys li { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 6px; padding: 4px 8px; }
  .title-best { margin-top: 10px; }
  .title-buttons { margin-top: 10px; gap: 8px; }
}

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

/* 低い画面（横向きのスマホなど） */
@media (max-height: 560px) {
  .title-catch { display: none; }
  .title-keys { grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
  .title-keys li { padding: 4px 7px; }
  .title-keys li.wide { grid-column: span 2; }
  .panel { padding: 12px 16px; }
  .title-panel { padding-top: 12px; }
  .title-ja { font-size: 30px; }
  #result-score { font-size: 36px; }
  .result-stats { margin: 8px 0 6px; }
  #hud { padding-top: 4px; }
  .hud-cell { min-width: 62px; padding: 2px 8px 3px; }
  .hud-label { font-size: 9px; }
  .hud-value { font-size: 15px; }
  .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; }
}
