/* ボウリング - Bowling */
:root {
  --bg: #070b1a;
  --bg2: #171540;
  --panel: rgba(12, 16, 40, 0.92);
  --text: #eef2ff;
  --sub: #98a4d2;
  --accent: #4fe3ff;
  --accent2: #ffcf5c;
  --magenta: #ff5cc8;
  --primary: #3a6ff0;
  --primary-hover: #2f5cd0;
  --secondary: #1d2350;
  --secondary-hover: #29316b;
  --danger: #ff6b7a;
  --line: rgba(152, 164, 210, 0.28);
}

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

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

body {
  background: radial-gradient(120% 100% at 50% 0%, var(--bg2) 0%, var(--bg) 70%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

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

.nowrap { white-space: nowrap; }

.stage-area {
  position: fixed;
  inset: 0;
  /* 共通ヘッダーぶんだけ下げ、フッター固定バナー広告ぶんだけ縮める（広告なしのときは 0px） */
  top: var(--sgh-top, 0px);
  bottom: var(--ad-space, 0px);
  display: flex;
  flex-direction: column;
}

/* スコアシートの下に残った領域すべて。HUD・投球パネルはこの中に重ねる */
.play-area {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

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

/* ==========================================================================
   スコアシート
   ========================================================================== */
.scoreboard {
  flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(10, 14, 34, 0.96), rgba(10, 14, 34, 0.86));
  border-bottom: 1px solid var(--line);
  padding: 3px 3px 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}
.scoreboard[hidden] { display: none; }

.sb-row {
  display: flex;
  align-items: stretch;
}

.sb-name {
  flex: 0 0 auto;
  width: 34px;
  display: flex;
  align-items: center;
  padding-left: 2px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--sub);
  overflow: hidden;
  white-space: nowrap;
}
.sb-row-active .sb-name { color: var(--accent2); }

.sb-frames {
  flex: 1 1 auto;
  display: flex;
  min-width: 0;
}

/* 右端の合計欄（実際のスコアシートの TOTAL） */
.sb-sum {
  flex: 0 0 auto;
  width: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-left: none;
  font-size: 14px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.sb-row-active .sb-sum { color: var(--accent2); }

.sb-frame {
  flex: 1 1 0;
  min-width: 0;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.sb-frame:last-child {
  border-right: 1px solid var(--line);
  flex-grow: 1.5;
}
.sb-frame-now { background: rgba(79, 227, 255, 0.14); }

/* フレーム番号の行（実際のスコアシートと同じく上に1行だけ） */
.sb-row-head { margin-bottom: -1px; }
.sb-row-head .sb-frame,
.sb-row-head .sb-sum { border-color: transparent; }
.sb-row-head .sb-sum,
.sb-fno {
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  line-height: 10px;
  color: var(--sub);
  letter-spacing: 0.02em;
}

/* 投球の記号を書く小さなマス。実物と同じくフレームの右上に置く */
.sb-marks {
  display: flex;
  justify-content: flex-end;
  height: 14px;
}
.sb-mark {
  --ink: var(--text);
  flex: 0 0 40%;
  min-width: 0;
  max-width: 20px;   /* 広い画面でもマスが横に伸びきらないようにする */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  border-left: 1px solid rgba(152, 164, 210, 0.3);
  border-bottom: 1px solid rgba(152, 164, 210, 0.3);
  color: var(--ink);
}
.sb-frame:last-child .sb-mark { flex-basis: 33.333%; }
.sb-mark-g,
.sb-mark-m { color: var(--sub); }

/* ストライク：マスいっぱいの × （対角線を2本） */
.sb-mark-x {
  --ink: var(--accent2);
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), var(--ink) calc(50% - 1px), var(--ink) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to top left, transparent calc(50% - 1px), var(--ink) calc(50% - 1px), var(--ink) calc(50% + 1px), transparent calc(50% + 1px));
}
/* スペア：左下→右上の ／ を引き、右下の半分を塗る */
.sb-mark-s {
  --ink: var(--accent);
  background: linear-gradient(to bottom right, transparent calc(50% - 0.5px), var(--ink) calc(50% + 0.5px));
}
/* スプリット：1投目の本数を ○ で囲む */
.sb-split {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.32em;
  height: 1.32em;
  border: 1px solid var(--danger);
  border-radius: 50%;
  color: var(--danger);
  line-height: 1;
}

.sb-total {
  flex: 1 1 auto;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}

@media (max-width: 400px) {
  .sb-name { width: 28px; font-size: 9px; }
  .sb-sum { width: 30px; font-size: 12px; }
  .sb-marks { height: 12px; }
  .sb-mark { font-size: 9px; }
  .sb-total { height: 16px; font-size: 11px; }
}

/* 結果画面の全体表。紙のスコアシートのように白地に黒インクで書く */
.result-sheet {
  /* 画面の幅いっぱいまで使う（説明の欄より広くてよい） */
  width: min(620px, calc(100vw - 16px));
  margin: 0 0 16px calc(50% - min(310px, 50vw - 8px));
  padding: 6px 5px 7px;
  border: none;
  border-radius: 8px;
  background: #fbfaf4;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
  gap: 5px;
  text-align: left;
}
.result-sheet:empty { display: none; }
.sb-paper { --line: #2a2f45; --sub: #5a6078; }
.sb-paper .sb-name { color: #1d2238; font-size: 12px; width: 44px; padding-left: 4px; }
.sb-paper .sb-sum { color: #12162a; width: 50px; font-size: 19px; }
.sb-paper .sb-row-head .sb-sum,
.sb-paper .sb-fno { color: #5a6078; font-size: 10px; line-height: 13px; }
.sb-paper .sb-mark {
  --ink: #12162a;
  max-width: 24px;
  font-size: 14px;
  border-color: #2a2f45;
}
.sb-paper .sb-marks { height: 21px; }
.sb-paper .sb-mark-x,
.sb-paper .sb-mark-s { --ink: #12162a; }
.sb-paper .sb-mark-g,
.sb-paper .sb-mark-m { color: #12162a; }
.sb-paper .sb-split { border-color: #d0142c; color: #d0142c; }
.sb-paper .sb-total { color: #12162a; height: 28px; font-size: 16px; }
@media (max-width: 520px) {
  .result-sheet { padding: 5px 3px 6px; }
  .sb-paper .sb-name { width: 28px; font-size: 9px; padding-left: 2px; }
  .sb-paper .sb-sum { width: 32px; font-size: 13px; }
  .sb-paper .sb-mark { font-size: 10px; }
  .sb-paper .sb-marks { height: 14px; }
  .sb-paper .sb-total { height: 18px; font-size: 11px; }
}

/* ==========================================================================
   HUD
   ========================================================================== */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 6px calc(env(safe-area-inset-right, 0px) + 8px) 0 calc(env(safe-area-inset-left, 0px) + 10px);
  pointer-events: none;
  z-index: 3;
}
.hud[hidden] { display: none; }

.hud-left {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 12px;
  line-height: 1.3;
}
.hud-frame {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent2);
}
.hud-turn {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.hud-right {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: scale(0.94); }

/* ==========================================================================
   投球パラメータ
   ========================================================================== */
.controls {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  padding: 8px calc(env(safe-area-inset-right, 0px) + 10px)
           calc(env(safe-area-inset-bottom, 0px) + 8px)
           calc(env(safe-area-inset-left, 0px) + 10px);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  z-index: 4;
  pointer-events: none;
}
.controls[hidden] { display: none; }

.panel {
  flex: 1 1 auto;
  min-width: 0;
  pointer-events: auto;
  background: rgba(10, 14, 34, 0.78);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 9px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.setup, .gauges {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.setup[hidden], .gauges[hidden] { display: none; }

/* 構え（立ち位置・角度・回転）。スライダーと ◀ ▶ の微調整 */
.knob {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.knob-label {
  flex: 0 0 auto;
  width: 4.2em;
  font-size: 11px;
  font-weight: 700;
  color: var(--sub);
  white-space: nowrap;
}
.knob-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--secondary);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
}
.knob-btn:active { background: var(--primary); }
.knob-range {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: none;
}
.knob-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(152, 164, 210, 0.28) 0 calc(50% - 1px), var(--accent) calc(50% - 1px) calc(50% + 1px), rgba(152, 164, 210, 0.28) calc(50% + 1px));
}
.knob-range::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(152, 164, 210, 0.28);
}
.knob-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid #06122b;
  background: var(--accent);
}
.knob-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #06122b;
  background: var(--accent);
}
.knob-val {
  flex: 0 0 auto;
  width: 6.4em;
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 横に広い画面では3つを横に並べて、パネルを低くする */
@media (min-width: 900px) {
  .setup, .gauges { flex-direction: row; gap: 16px; }
  .knob, .gauge { flex: 1 1 0; }
  .knob-label, .gauge-label { width: auto; }
  .knob-val { width: 5.6em; }
}

/* 幅のせまい画面では、投球ボタンをパネルの下に置いてスライダーの幅を確保する */
@media (max-width: 640px) {
  .controls { flex-direction: column; align-items: stretch; gap: 6px; }
  .knob-val { width: 5.8em; }
}

/* パワーとリリースのゲージ */
.gauge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 38px;
}
.gauge-label {
  flex: 0 0 auto;
  width: 4.2em;
  font-size: 11px;
  font-weight: 700;
  color: var(--sub);
  white-space: nowrap;
}
.gauge-val {
  flex: 0 0 auto;
  width: 3.4em;
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.gauge-track {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  height: 18px;
  border-radius: 6px;
  background: rgba(152, 164, 210, 0.2);
  overflow: hidden;
}
/* 90%から先は「力み」のゾーン */
.gauge-power { background: linear-gradient(90deg, rgba(152, 164, 210, 0.2) 0 90%, rgba(255, 107, 122, 0.45) 90%); }
.gauge-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, #4fe3ff, #ffcf5c 70%, #ff6b7a);
  opacity: 0.92;
}
.gauge-release { overflow: visible; }
.gauge-sweet {
  position: absolute;
  top: 0; bottom: 0;
  left: 47%;
  width: 6%;
  border-radius: 3px;
  background: var(--accent2);
  box-shadow: 0 0 10px rgba(255, 207, 92, 0.8);
}
.gauge-release::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 35%;
  width: 30%;
  background: rgba(79, 227, 255, 0.22);
}
.gauge-mark {
  position: absolute;
  top: -4px; bottom: -4px;
  left: 0%;
  width: 4px;
  margin-left: -2px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 8px #fff;
}

.hud-data {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.hud-data:empty { display: none; }

.no-webgl {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  z-index: 2;
}
.no-webgl[hidden] { display: none; }

.throw-btn {
  flex: 0 0 auto;
  pointer-events: auto;
  border: none;
  border-radius: 14px;
  padding: 13px 14px;
  min-width: 96px;
  max-width: 34%;
  min-height: 64px;
  line-height: 1.35;
  touch-action: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: #06122b;
  background: linear-gradient(160deg, #7ff0ff, var(--accent));
  box-shadow: 0 4px 18px rgba(79, 227, 255, 0.35);
  cursor: pointer;
}
.throw-btn:active { transform: scale(0.95); }
.throw-btn:disabled { opacity: 0.45; cursor: default; }
.throw-btn-hot { background: linear-gradient(160deg, #ffe7a0, var(--accent2)); box-shadow: 0 4px 22px rgba(255, 207, 92, 0.55); }
@media (min-width: 900px) {
  .throw-btn { min-height: 46px; padding: 8px 18px; }
}
@media (max-width: 640px) {
  .throw-btn { max-width: none; min-height: 50px; padding: 10px 14px; font-size: 16px; }
}

/* ==========================================================================
   ヒント・実況バナー
   ========================================================================== */
.hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 36%;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(10, 14, 34, 0.85);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 4;
  animation: hint-in 0.4s ease;
}
.hint[hidden] { display: none; }
.hint strong { color: var(--accent); }
@keyframes hint-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.banner {
  position: absolute;
  left: 0; right: 0;
  top: 30%;
  text-align: center;
  pointer-events: none;
  z-index: 5;
}
.banner[hidden] { display: none; }
.banner span { display: block; animation: banner-pop 0.35s ease; }
#banner-text {
  font-size: clamp(30px, 9vw, 58px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.7), 0 0 44px rgba(79, 227, 255, 0.7);
}
.banner-sub {
  margin-top: 6px;
  font-size: clamp(14px, 3.6vw, 19px);
  font-weight: 700;
  color: var(--accent2);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}
.banner-sub:empty { display: none; }
@keyframes banner-pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ==========================================================================
   画面共通
   ========================================================================== */
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  justify-content: center;
  background: rgba(6, 9, 24, 0.78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 10;
  touch-action: pan-y;
}
.screen[hidden] { display: none; }

#screen-title {
  background: linear-gradient(180deg, rgba(6, 9, 24, 0.3) 0%, rgba(6, 9, 24, 0.7) 44%, rgba(6, 9, 24, 0.88) 100%);
}

.screen-inner {
  width: min(440px, 100%);
  margin: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 26px) 20px
           calc(env(safe-area-inset-bottom, 0px) + 24px);
  text-align: center;
}

.title-sub {
  color: var(--sub);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.title-logo {
  font-size: 50px;
  font-weight: 900;
  letter-spacing: 0.04em;
  margin: 6px 0 4px;
  background: linear-gradient(160deg, #eaf6ff 10%, var(--accent) 48%, var(--magenta) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 6px 34px rgba(79, 227, 255, 0.32);
}
.title-en {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--sub);
  -webkit-text-fill-color: var(--sub);
}

.title-desc {
  margin: 14px 0 18px;
  font-size: 15px;
  line-height: 1.7;
}

.best-box[hidden] { display: none; }
.best-box {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid rgba(255, 207, 92, 0.4);
  border-radius: 12px;
  padding: 10px 22px;
  margin-bottom: 18px;
}
.best-label { font-size: 11px; color: var(--sub); }
.best-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin: 8px 0 20px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 14px 20px;
  width: min(300px, 100%);
  cursor: pointer;
  color: #fff;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(160deg, #5f9dff, var(--primary));
  box-shadow: 0 6px 18px rgba(58, 111, 240, 0.42);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--secondary);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--secondary-hover); }

.howto {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 0 auto 20px;
  max-width: 380px;
  font-size: 13px;
  color: var(--sub);
}
.howto summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
}
.howto ul, .howto-list {
  margin: 10px 0 4px;
  padding-left: 18px;
  line-height: 1.8;
}
.howto strong, .howto-list strong { color: var(--text); }

.howto-list {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px 14px 34px;
  margin: 0 auto 20px;
  max-width: 400px;
  font-size: 13px;
  color: var(--sub);
}

.footer-credits {
  font-size: 11px;
  color: var(--sub);
  line-height: 1.8;
}
.footer-credits a { color: var(--sub); text-decoration: underline; }

/* ==========================================================================
   モード選択
   ========================================================================== */
.overlay-title {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 14px;
}

.mode-lead {
  font-size: 14px;
  color: var(--sub);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* ボール選び */
.ball-sec {
  text-align: left;
  background: rgba(152, 164, 210, 0.07);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px 14px;
  margin-bottom: 12px;
}
.ball-who { font-size: 15px; font-weight: 800; margin-bottom: 6px; color: var(--accent2); }
.ball-label { font-size: 12px; font-weight: 700; color: var(--sub); margin: 6px 0; }
.ball-weights { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.w-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--secondary);
  color: var(--text);
  font-family: inherit;
  padding: 7px 2px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}
.w-btn b { font-size: 19px; font-weight: 800; }
.w-btn span { font-size: 9px; color: var(--sub); }
.w-btn.is-on { background: var(--primary); border-color: var(--accent); }
.w-btn.is-on span { color: #fff; }
.ball-note { font-size: 12px; color: var(--text); line-height: 1.6; margin-top: 8px; min-height: 3.2em; }
.ball-designs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.d-btn {
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  display: flex;
  justify-content: center;
}
.d-btn.is-on { border-color: var(--accent); background: rgba(79, 227, 255, 0.12); }
.d-swatch {
  display: block;
  width: 100%;
  max-width: 54px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}
.d-swatch-3d { width: 66px; max-width: 100%; height: auto; border-radius: 0; box-shadow: none; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.55)); }

.mode-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid rgba(79, 227, 255, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.mode-btn:hover, .mode-btn:focus-visible {
  border-color: var(--accent);
  background: rgba(79, 227, 255, 0.12);
  transform: translateY(-1px);
}

.mode-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(79, 227, 255, 0.16);
  font-size: 17px;
}

.mode-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mode-name { font-size: 16px; font-weight: 800; }
.mode-sub { font-size: 12px; color: var(--sub); line-height: 1.5; }

/* ==========================================================================
   結果画面
   ========================================================================== */
.result-mode {
  font-size: 14px;
  font-weight: 700;
  color: var(--sub);
  margin-bottom: 10px;
}

.result-new-best[hidden] { display: none; }
.result-new-best {
  color: var(--accent2);
  font-weight: 800;
  font-size: 17px;
  margin-bottom: 10px;
  animation: banner-pop 0.4s ease;
}

.result-scores {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.res-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 120px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 18px;
}
.res-card-win { border-color: rgba(255, 207, 92, 0.65); box-shadow: 0 0 20px rgba(255, 207, 92, 0.18); }
.res-name { font-size: 12px; color: var(--sub); font-weight: 700; }
.res-score {
  font-size: 34px;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.res-card-win .res-score { color: var(--accent2); }
.res-tag { font-size: 11px; font-weight: 800; color: var(--accent2); }

.statcard {
  width: min(320px, 100%);
  margin: 0 auto 18px;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.statcard td {
  padding: 5px 8px;
  border-bottom: 1px dashed rgba(152, 164, 210, 0.22);
}
.statcard tr:last-child td { border-bottom: none; }
.st-key { color: var(--sub); text-align: left; }
.st-val { font-weight: 800; text-align: right; }

@media (max-height: 660px) {
  .title-logo { font-size: 40px; }
  .title-desc { margin: 8px 0 12px; }
  .screen-inner { padding-top: 14px; }
}

/* ==========================================================================
   全国ランキング（SGRanking 共通モジュール）
   ========================================================================== */
.sgr-hidden { display: none !important; }

.sgr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(6, 9, 24, 0.82);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #131a3c;
  color: var(--text);
  border: 1px solid rgba(255, 207, 92, 0.4);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.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(--line);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  font-family: inherit;
  background: var(--secondary);
  color: var(--text);
  cursor: pointer;
}
.sgr-tab-active { background: var(--primary); border-color: transparent; color: #fff; }

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

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

.sgr-name {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* iOSズーム防止のため16px以上 */
  font-family: inherit;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 9, 24, 0.8);
  color: var(--text);
  -webkit-user-select: text;
  user-select: text;
}
.sgr-name::placeholder { color: var(--sub); }
.sgr-name:focus { outline: none; border-color: var(--primary); }

.sgr-submit {
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: bold;
  font-family: inherit;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.sgr-submit:hover { filter: brightness(1.12); }
.sgr-submit:active { transform: scale(0.95); }
.sgr-submit:disabled { opacity: 0.5; cursor: default; }

.sgr-error { margin: 6px 0 0; font-size: 12px; text-align: center; color: var(--danger); }
.sgr-status { margin: 0; font-size: 13px; text-align: center; color: var(--sub); }

.sgr-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.sgr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
}
.sgr-row:nth-child(even) { background: rgba(152, 164, 210, 0.08); }

.sgr-row-me {
  background: rgba(255, 207, 92, 0.14) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 207, 92, 0.5);
}

.sgr-rank {
  width: 2em;
  text-align: center;
  font-weight: 700;
  color: var(--sub);
  flex: none;
}
.sgr-rank-top1, .sgr-rank-top2, .sgr-rank-top3 { font-size: 16px; }

.sgr-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sgr-row-score { font-weight: 700; color: var(--accent); flex: none; }

.sgr-close {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 0;
  font-size: 14px;
  font-weight: bold;
  font-family: inherit;
  background: var(--secondary);
  color: var(--text);
  cursor: pointer;
}
.sgr-close:hover { background: var(--secondary-hover); }

/* 結果画面に差し込む登録CTA */
.sgr-cta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  margin-bottom: 14px;
}

.sgr-cta-msg { margin: 0; font-size: 15px; font-weight: bold; color: var(--accent2); }

.sgr-cta-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 36px;
  font-size: 16px;
  font-weight: bold;
  font-family: inherit;
  background: linear-gradient(135deg, var(--accent2) 0%, #ff9f43 100%);
  color: #3a2400;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 207, 92, 0.35);
  transition: filter 0.15s, transform 0.1s;
}
.sgr-cta-btn:hover { filter: brightness(1.1); }
.sgr-cta-btn:active { transform: scale(0.95); }

.sgr-cta-link {
  border: none;
  background: none;
  font-size: 13px;
  font-family: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / js/ad-banner.js が挿入する）
   --ad-h    : 広告そのものの高さ。広告なしのときは 0px
   --ad-space: レイアウトが空けるべき高さ（広告 + セーフエリア）
   ========================================================================== */
:root {
  --ad-h: 0px;
  --ad-space: 0px;
}
html.has-ad-banner {
  --ad-space: calc(var(--ad-h, 0px) + env(safe-area-inset-bottom, 0px));
}

.ad-banner {
  /* height は広告そのものの高さ。セーフエリアぶんの padding は外側に足す */
  box-sizing: content-box;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  /* ランキング・リザルト等の全画面オーバーレイ（2147483000）よりは下に置く */
  z-index: 2147482000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: var(--ad-h, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  background: rgba(14, 16, 20, 0.86);
  /* border ではなく inset shadow にして、枠線ぶん高さがずれないようにする */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ad-banner__frame {
  display: block;
  width: 100%;
  height: var(--ad-h, 0px);
  border: 0;
  color-scheme: light;
}

@media print {
  .ad-banner { display: none; }
}
