@charset "UTF-8";
/* ==========================================================================
   100人鬼ごっこ - style.css
   夕暮れの街を逃げるイメージ。紫〜オレンジのグラデーションで統一する。
   ========================================================================== */

:root {
  --bg: #16101f;
  --ink: #f4eefb;
  --ink-dim: #b9a9cf;
  --panel: rgba(28, 19, 40, 0.92);
  --panel-line: rgba(255, 255, 255, 0.13);
  --accent: #39c6ff;
  --accent-2: #ff9a5c;
  --danger: #ff4d5e;
  --gold: #ffd34d;
  --green: #3ce6a0;
  --radius: 14px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, sans-serif;
}

* { box-sizing: border-box; }

/* display を指定した要素にも hidden 属性を効かせる（JSでの出し分けが全部これに乗っている） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  /* sg-header.css が padding-top: var(--sgh-top) を付ける。#app は fixed なので影響しない */
  touch-action: none;
}

#app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--sgh-top, 0px);
  bottom: var(--ad-space, 0px);
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #241536;
}

/* ==========================================================================
   読み込み中
   ========================================================================== */

#loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #241536 0%, #5b2f5d 60%, #b8515a 100%);
  z-index: 40;
}
.loading-inner { text-align: center; padding: 0 20px; }
.loading-copy {
  margin: 0 0 10px;
  font-size: clamp(20px, 6vw, 32px);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-shadow: 0 0 22px rgba(255, 120, 120, 0.6);
}
.loading-note { margin: 0; color: var(--ink-dim); font-size: 13px; }

/* 復旧の案内は WebGL や背景ぼかしに依存させない。 */
#render-recovery {
  width: min(420px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  text-align: center;
}
#render-recovery::backdrop { background: #16101f; }
#render-recovery h2 { margin: 0 0 12px; font-size: 20px; }
#render-recovery p { margin: 0; color: var(--ink-dim); line-height: 1.7; }
#render-recovery-retry { margin-top: 20px; }
#btn-render-reload { margin-top: 12px; }

/* ==========================================================================
   HUD
   ========================================================================== */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hud-top {
  position: absolute;
  top: 8px;
  /* 横向きのスマホでノッチ・角丸にかからないよう、左右のセーフエリアを避ける */
  left: max(8px, env(safe-area-inset-left, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.hud-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(20, 12, 30, 0.7);
  border: 1px solid var(--panel-line);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.chip-oni { color: #ffb3ba; }
.chip-bell { color: var(--gold); }
.chip-bell.bells-done {
  color: #0d2a20;
  background: var(--green);
  border-color: var(--green);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.icon-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--panel-line);
  background: rgba(20, 12, 30, 0.7);
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn { touch-action: none; -webkit-tap-highlight-color: transparent; }

#minimap {
  position: absolute;
  top: 52px;
  right: max(8px, env(safe-area-inset-right, 0px));
  width: 116px;
  height: 116px;
  border-radius: 12px;
  border: 1px solid var(--panel-line);
  background: rgba(12, 8, 20, 0.72);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* HP・スタミナは左上に置く。左下はバーチャルスティックが出るため */
.hud-bottom {
  position: absolute;
  left: max(10px, env(safe-area-inset-left, 0px));
  top: 44px;
  right: 150px;
}
.hud-stats { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.hearts { display: flex; gap: 3px; font-size: 20px; line-height: 1; }
.heart { color: var(--danger); text-shadow: 0 0 10px rgba(255, 77, 94, 0.6); }
.heart-empty { color: rgba(255, 255, 255, 0.25); text-shadow: none; }

.stamina {
  position: relative;
  width: min(190px, 44vw);
  height: 14px;
  border-radius: 999px;
  background: rgba(10, 6, 16, 0.75);
  border: 1px solid var(--panel-line);
  overflow: hidden;
}
.stamina-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}
.stamina.stamina-empty { animation: staminaEmpty 0.7s ease-in-out infinite; }
@keyframes staminaEmpty {
  0%, 100% { border-color: var(--panel-line); }
  50% { border-color: rgba(255, 106, 61, 0.95); }
}
#stamina-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2ea8ff, #7ee8ff);
  transition: width 90ms linear;
}
#stamina-fill.stamina-low { background: linear-gradient(90deg, #ff6a3d, #ffb03d); }

/* --- タッチ操作 --- */

#stick {
  position: absolute;
  width: 108px;
  height: 108px;
  margin: -54px 0 0 -54px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}
#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
}

.pad {
  position: absolute;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
/* 広告が無いとき（PC幅・横向き・広告を畳んだとき）は --ad-space が 0 なので、
   ホームインジケータの領域はここで空ける（広告があるときは #app の bottom に含まれる） */
html:not(.has-ad-banner) .pad { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.pad button {
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 70px;
  height: 70px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--panel-line);
  background: rgba(20, 12, 30, 0.66);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  /* 指をもう1本置いたときにブラウザのジェスチャへ横取りされないようにする
     （横取りされると pointercancel が飛んで、押しっぱなしが途切れる） */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.pad button:active { transform: scale(0.94); }
.pad-icon { font-size: 23px; line-height: 1; }
.pad-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1;
}

/* ダッシュ中はボタンとスティックが光る（効いているのが見て分かるように） */
#btn-dash.dashing {
  border-color: rgba(126, 232, 255, 0.9);
  background: rgba(46, 168, 255, 0.32);
  box-shadow: 0 0 18px rgba(90, 200, 255, 0.55);
}
/* 息切れ中（スタミナが戻るまで走れない）はボタンを暗くする */
#btn-dash.dash-tired {
  border-color: rgba(255, 106, 61, 0.5);
  background: rgba(20, 12, 30, 0.5);
  box-shadow: none;
}
#btn-dash.dash-tired .pad-icon { opacity: 0.35; }
#btn-dash.dash-tired .pad-label { color: rgba(255, 255, 255, 0.4); }

#stick.stick-dash { border-color: rgba(126, 232, 255, 0.85); }
#stick.stick-dash #stick-knob { background: rgba(126, 232, 255, 0.8); }

#btn-daruma {
  /* --cd は 0〜1。1 で使用可能 */
  background:
    conic-gradient(rgba(57, 198, 255, 0.5) calc(var(--cd, 1) * 360deg), rgba(255, 255, 255, 0.07) 0),
    rgba(20, 12, 30, 0.66);
}
#btn-daruma.ready {
  border-color: rgba(57, 198, 255, 0.85);
  box-shadow: 0 0 16px rgba(57, 198, 255, 0.45);
}
#btn-daruma:not(.ready) .pad-icon { opacity: 0.45; }
.pad-cd {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* --- 画面の縁（鬼が近いと赤くなる） --- */

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 15;
  background: radial-gradient(ellipse at center,
    rgba(255, 0, 40, 0) 42%, rgba(255, 0, 40, 0.28) 78%, rgba(160, 0, 20, 0.6) 100%);
  transition: opacity 140ms linear;
}

/* --- 目標の方向 --- */

#objective-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 18;
  pointer-events: none;
  color: var(--gold);
}
#objective-arrow .arrow-head {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(-30vmin);
  font-size: 26px;
  text-shadow: 0 0 12px currentColor;
}
#objective-arrow .arrow-dist {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(-26vmin);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
#objective-arrow.arrow-gate { color: var(--green); }

/* --- 中央の帯・トースト --- */

#banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 34%;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  text-align: center;
  padding: 0 16px;
}
#banner-main {
  font-size: clamp(20px, 5.4vw, 34px);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.75), 0 0 24px rgba(255, 140, 90, 0.5);
}
#banner-sub {
  font-size: clamp(12px, 3.2vw, 15px);
  color: var(--ink-dim);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}
.banner-in { animation: bannerIn 340ms cubic-bezier(0.2, 1.2, 0.3, 1); }
@keyframes bannerIn {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 420px) {
  #minimap { width: 96px; height: 96px; }
  .hud-bottom { right: 112px; }
  .stamina { width: min(150px, 40vw); }
  .pad button { width: 64px; height: 64px; }
}
/* 320px 幅では、チップが3つ並ぶと2段に折り返して HP・スタミナに重なるので小さくする */
@media (max-width: 359px) {
  .hud-chips { gap: 4px; }
  .chip { padding: 4px 6px; font-size: 11px; }
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 26;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(20, 12, 30, 0.86);
  border: 1px solid var(--panel-line);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
.toast-in { animation: toastIn 220ms ease-out; }
/* 360px 未満では長い案内が画面の両端で切れるので、折り返して収める */
@media (max-width: 359px) {
  #toast { width: max-content; max-width: calc(100% - 16px); white-space: normal; text-align: center; border-radius: 14px; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%); }
}

.hidden-controls {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ==========================================================================
   オーバーレイ画面
   ========================================================================== */

.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.screen-dim { background: rgba(10, 6, 16, 0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }

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

.title-box {
  background: linear-gradient(180deg, rgba(36, 21, 54, 0.95), rgba(24, 14, 34, 0.95));
}

.title-catch {
  margin: 0 0 6px;
  font-size: clamp(14px, 3.8vw, 18px);
  font-weight: 800;
  letter-spacing: 0.24em;
  color: #ff9aa4;
  text-shadow: 0 0 18px rgba(255, 60, 80, 0.55);
}
.title-logo {
  margin: 0 0 12px;
  font-size: clamp(30px, 9vw, 50px);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1.1;
  background: linear-gradient(180deg, #fff 30%, #ffb26b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 16px rgba(255, 120, 60, 0.35));
}
.title-en {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.42em;
  color: var(--ink-dim);
  -webkit-text-fill-color: var(--ink-dim);
}
.title-lead {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-dim);
}
.title-lead strong { color: var(--danger); }

.title-records {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 16px;
}
.title-records div {
  padding: 8px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-line);
}
.title-records dt { font-size: 10px; color: var(--ink-dim); letter-spacing: 0.06em; }
.title-records dd { margin: 4px 0 0; font-size: 16px; font-weight: 800; color: var(--gold); }

/* --- ボタン --- */

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }

.btn {
  appearance: none;
  padding: 13px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 90ms ease, filter 120ms ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(180deg, #ff8a4c, #ff5b6e);
  color: #fff;
  box-shadow: 0 8px 22px rgba(255, 90, 110, 0.36);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--panel-line);
  color: var(--ink);
}
.btn-ghost {
  background: transparent;
  border-color: var(--panel-line);
  color: var(--ink-dim);
  font-size: 13px;
  padding: 10px 18px;
}

/* --- 遊び方 --- */

.howto-inline { margin: 16px 0 0; text-align: left; }
.howto-inline summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  padding: 8px 0;
  text-align: center;
}
.howto-body { font-size: 13px; line-height: 1.85; color: var(--ink-dim); text-align: left; }
.howto-body h2, .howto-body h3 {
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--accent-2);
  letter-spacing: 0.06em;
}
.howto-body ul { margin: 0; padding-left: 1.2em; }
.howto-body li { margin: 3px 0; }
.howto-body strong { color: var(--ink); }
.howto-body p { margin: 6px 0; }

/* --- 強化の選択 --- */

.overlay-title { margin: 0 0 6px; font-size: clamp(20px, 5.4vw, 27px); font-weight: 900; }
.overlay-lead { margin: 0 0 4px; font-size: 13px; color: var(--ink-dim); }
.upgrade-hint { margin: 0 0 14px; font-size: 12px; color: var(--accent); letter-spacing: 0.1em; }

.up-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 560px) { .up-cards { grid-template-columns: repeat(3, 1fr); } }

.up-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--panel-line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: transform 100ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.up-card:hover { border-color: rgba(57, 198, 255, 0.7); box-shadow: 0 0 18px rgba(57, 198, 255, 0.25); }
.up-card:active { transform: scale(0.97); }
.up-icon { font-size: 30px; line-height: 1; }
.up-name { font-size: 16px; font-weight: 800; }
.up-desc { font-size: 12px; line-height: 1.6; color: var(--ink-dim); }
.up-stack { font-size: 10px; color: var(--accent); letter-spacing: 0.08em; }

/* --- 結果 --- */

.result-win { color: var(--green); text-shadow: 0 0 22px rgba(60, 230, 160, 0.5); }
.result-lose { color: #ff8b96; }
.result-newbest {
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
  animation: pulse 1.2s ease-in-out infinite;
}

.score-box {
  margin: 14px 0;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-line);
}
.score-label { display: block; font-size: 11px; letter-spacing: 0.24em; color: var(--ink-dim); }
.score-value {
  display: block;
  font-size: clamp(34px, 10vw, 48px);
  font-weight: 900;
  line-height: 1.1;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 211, 77, 0.35);
}
.score-best { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-dim); }

.result-rows { list-style: none; margin: 0 0 12px; padding: 0; text-align: left; }
.result-rows li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
  font-size: 13px;
}
.result-rows .rk { color: var(--ink-dim); }
.result-rows .rv { font-weight: 800; }

.result-sub { margin: 12px 0 6px; font-size: 12px; color: var(--accent-2); letter-spacing: 0.1em; }
.result-upgrades {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.result-upgrades li { display: flex; }
.result-upgrades .up-none {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-dim);
}

/* 強化のチップ（タップすると下に効果が出る） */
.up-chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-line);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  transition: transform 100ms ease, border-color 120ms ease, background-color 120ms ease;
}
.up-chip:hover { border-color: rgba(57, 198, 255, 0.7); }
.up-chip:active { transform: scale(0.96); }
.up-chip.sel {
  border-color: var(--accent);
  background: rgba(57, 198, 255, 0.2);
  box-shadow: 0 0 14px rgba(57, 198, 255, 0.25);
}

.up-detail {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-line);
  text-align: left;
}
.up-detail p { margin: 0; }
.up-detail-hint {
  font-size: 11px;
  color: var(--ink-dim);
  text-align: center;
}
.up-detail .up-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.up-detail-icon { font-size: 22px; line-height: 1; }
.up-detail-name { font-size: 15px; font-weight: 800; }
.up-detail-mult { font-size: 12px; font-weight: 800; color: var(--accent); }
.up-detail-body { font-size: 12px; line-height: 1.7; color: var(--ink-dim); }
.up-detail .up-detail-foot { margin-top: 4px; font-size: 10px; letter-spacing: 0.08em; color: var(--accent); }

.version-note { margin: 10px 0 0; font-size: 11px; color: var(--ink-dim); }

.credits {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  line-height: 1.9;
  color: var(--ink-dim);
}
.credits p { margin: 0; }
.credits a { color: var(--accent); text-decoration: none; }
.credits a:hover { text-decoration: underline; }

/* --- 画面が低いときは詰める --- */

@media (max-height: 620px) {
  .screen-box { padding: 14px 14px 12px; }
  .title-logo { font-size: clamp(24px, 7vw, 36px); }
  .title-lead { margin-bottom: 10px; }
  .title-records { margin-bottom: 10px; }
  .credits { margin-top: 10px; }
}

/* ==========================================================================
   全国ランキング（js/ranking.js が作る共通UI。クラスは sgr- プレフィックス）
   このゲームのダークな見た目に合わせて指定する。
   ゲーム側の button / input / ol の指定に影響されないよう、
   効かせたいプロパティは省略せず明示する。
   ========================================================================== */

.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-top: calc(16px + var(--sgh-top, 0px));
  padding-bottom: calc(16px + max(var(--ad-space, 0px), env(safe-area-inset-bottom, 0px)));
  background: rgba(10, 6, 16, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  overscroll-behavior: contain;
}

/* body は操作用に touch-action: none にしてあるが、
   それだと一覧を指でスクロールできないので、開いている間だけ戻す */
body:has(.sgr-overlay:not(.sgr-hidden)) { touch-action: auto; }

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px 16px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  color: var(--ink);
  font-family: var(--font);
  text-align: center;
}

.sgr-title {
  margin: 0;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.sgr-tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.sgr-tab {
  appearance: none;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.sgr-tab-active {
  background: rgba(57, 198, 255, 0.22);
  border-color: rgba(57, 198, 255, 0.65);
  color: var(--ink);
}

.sgr-register {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 211, 77, 0.35);
  background: rgba(255, 211, 77, 0.08);
}
.sgr-register-msg {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
}
.sgr-form { display: flex; gap: 8px; }
.sgr-name {
  flex: 1;
  min-width: 0;
  /* 16px 未満だと iOS でフォーカス時に画面が拡大される */
  font-size: 16px;
  font-family: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-line);
  background: rgba(10, 6, 16, 0.7);
  color: var(--ink);
}
.sgr-name::placeholder { color: rgba(185, 169, 207, 0.65); }
.sgr-name:focus { outline: none; border-color: var(--accent); }
.sgr-submit {
  appearance: none;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #ff8a4c, #ff5b6e);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(255, 90, 110, 0.36);
  transition: transform 90ms ease;
}
.sgr-submit:active { transform: scale(0.96); }
.sgr-submit:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

.sgr-error { margin: 8px 0 0; font-size: 12px; font-weight: 700; color: var(--danger); }
.sgr-status { margin: 0; font-size: 13px; color: var(--ink-dim); }

.sgr-list {
  margin: 0;
  padding: 0;
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  text-align: left;
}
.sgr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.sgr-row:nth-child(even) { background: rgba(255, 255, 255, 0.05); }
.sgr-row-me {
  background: rgba(57, 198, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(57, 198, 255, 0.55);
}
.sgr-rank {
  width: 2.2em;
  flex-shrink: 0;
  text-align: right;
  font-weight: 900;
  color: var(--ink-dim);
}
.sgr-rank-top1 { color: var(--gold); }
.sgr-rank-top2 { color: #d9e2f2; }
.sgr-rank-top3 { color: #e2a15c; }
.sgr-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sgr-row-score { flex-shrink: 0; font-weight: 800; color: var(--gold); }

.sgr-close {
  appearance: none;
  padding: 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.sgr-close:active { transform: scale(0.96); }

/* 結果画面に差し込まれる「登録する」CTA */
.sgr-cta { margin: 14px 0 12px; text-align: center; }
.sgr-cta-msg {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
}
.sgr-cta-btn {
  appearance: none;
  padding: 13px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #ffd76b, #ffab3d);
  color: #3a2410;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(255, 180, 70, 0.38);
  transition: transform 90ms ease;
}
.sgr-cta-btn:active { transform: scale(0.96); }
.sgr-cta-link {
  appearance: none;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.sgr-cta-link:active { transform: scale(0.96); }

@media (max-width: 380px) {
  .sgr-form { flex-wrap: wrap; }
  .sgr-submit { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .banner-in, .toast-in, .chip-bell.bells-done, .result-newbest,
  .stamina.stamina-empty { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / 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; }
}
