/* 居合斬り - Iaigiri */

:root {
  --sumi: #100d0c;          /* 墨（背景） */
  --sumi2: #1b1512;
  --panel: #241c18;
  --panel-border: rgba(233, 216, 186, 0.16);
  --text: #f0e6d2;          /* 和紙色 */
  --text-dim: #a2907a;
  --aka: #c8352b;           /* 朱 */
  --aka-lit: #ff5a45;
  --kin: #e4b552;           /* 金 */
  --ao: #5b8fc9;            /* 藍 */
  --good: #6fbf73;
  --danger: #e2554a;
  --accent: var(--kin);
  --accent2: var(--kin);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, serif;
  font-variant-numeric: lining-nums;
  background:
    repeating-linear-gradient(112deg, rgba(255, 255, 255, 0.014) 0 2px, transparent 2px 7px),
    radial-gradient(1000px 520px at 50% -60px, #2a1d18 0%, var(--sumi) 62%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  touch-action: manipulation;
}

#app {
  min-height: calc(100vh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  min-height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  display: flex;
  flex-direction: column;
  /* 上のセーフエリアは共通ヘッダー（body の padding-top = --sgh-top）が含んでいるので足さない */
  padding: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn:active { transform: scale(0.94); }

/* ===================== ホーム画面 ===================== */

#screen-home {
  flex: 1;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 16px 16px 8px;
}

#home-head {
  position: relative;
  text-align: center;
  padding-top: 4px;
}

#home-head-btns {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 8px;
}

#logo {
  margin: 18px 0 2px;
  font-size: clamp(28px, 8.4vw, 40px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: var(--text);
  text-shadow: 0 0 22px rgba(200, 53, 43, 0.55);
}

/* ロゴの後ろの日輪 */
#home-head::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 108px;
  height: 108px;
  margin-left: -54px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 53, 43, 0.62), rgba(200, 53, 43, 0.05) 70%);
  z-index: -1;
}

#tagline {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

#home-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 0 4px;
}

.mode-card {
  background: linear-gradient(180deg, rgba(48, 36, 30, 0.92), rgba(28, 21, 18, 0.92));
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
}

.mode-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.mode-emoji {
  font-size: 26px;
  line-height: 1.1;
  flex-shrink: 0;
}

.mode-name {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.mode-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-dim);
}
.mode-desc b { color: var(--kin); }

.diff-seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 12px 0 10px;
}

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.diff-btn small { font-size: 9.5px; font-weight: 600; opacity: 0.8; }
.diff-btn.on {
  background: rgba(200, 53, 43, 0.24);
  border-color: var(--aka-lit);
  color: var(--text);
}

.start-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #d24236, #97231b);
  color: #fff5ee;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(200, 53, 43, 0.35);
}
.start-btn:active { transform: scale(0.985); }
.best-chip {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

#howto-card .mode-name { margin-bottom: 8px; }

#howto {
  margin: 0;
  padding-left: 1.2em;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--text-dim);
}
#howto b { color: var(--kin); }

/* ===================== ゲーム画面 ===================== */

#screen-game {
  flex: 1;
  width: min(640px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#game-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 4px;
}

#game-mode-label {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

#game-top-btns { display: flex; gap: 8px; }

#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 14px 6px;
  min-height: 46px;
}

#hud-foe {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

#foe-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 2px 6px;
  flex-shrink: 0;
}

#foe-name {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.06em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hud-score {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#pips { display: flex; gap: 5px; }

.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.3);
}
.pip.win { background: var(--kin); border-color: var(--kin); }
.pip.lose { background: var(--danger); border-color: var(--danger); }

#hud-note {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}

/* ---------- 立ち合いの場 ---------- */

#arena {
  position: relative;
  flex: 1;
  min-height: 260px;
  margin: 0 10px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #191110 0%, #241814 58%, #120c0b 100%);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#arena:focus { outline: none; }
#arena:focus-visible {
  outline: 2px solid var(--kin);
  outline-offset: 2px;
}

/* 日輪。縁がはっきり出るように色を止めてから外側へぼかす */
#sun {
  position: absolute;
  top: 11%;
  left: 50%;
  width: min(35%, 190px);
  aspect-ratio: 1 / 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, #8f2620 0 80%, rgba(143, 38, 32, 0.5) 80% 92%, rgba(143, 38, 32, 0) 97%);
  box-shadow: 0 0 70px 14px rgba(150, 38, 30, 0.26);
}

#haze {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 55% at 50% 108%, rgba(255, 200, 150, 0.09), transparent 70%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.13) 0 1px, transparent 1px 4px);
  pointer-events: none;
}

#ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26%;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.9));
  border-top: 1px solid rgba(233, 216, 186, 0.14);
  pointer-events: none;
}

/* ---------- 侍 ---------- */

.fighter {
  position: absolute;
  bottom: 16%;
  width: 40%;
  max-width: 205px;
  pointer-events: none;
  transition: transform 180ms ease-out;
}

.fighter .sam {
  display: block;
  width: 100%;
  height: auto;
}

/* 縁に色を落として、暗い地面の上でも輪郭が沈まないようにする */
.fighter-me {
  left: 1%;
  color: #08070a;
  filter: drop-shadow(0 0 3px rgba(240, 214, 160, 0.3));
}

.fighter-foe {
  right: 1%;
  color: #0b0608;
  transform: scaleX(-1);
  filter: drop-shadow(0 0 3px rgba(255, 110, 82, 0.34));
}

.sam-body { fill: currentColor; }
.sam-sheath { fill: #4b3a2c; }
.sam-hilt { fill: #755a3a; }
.sam-blade { fill: #d3dbe4; }
.sam-dropped { fill: #7d8794; }   /* 地面に転がった刀は光らせない */

/* ポーズはクラスで出し分ける（既定＝構え） */
.pose { display: none; }
.fighter .pose-stance { display: inline; }
.fighter.is-slash .pose-stance,
.fighter.is-fall .pose-stance { display: none; }
.fighter.is-slash .pose-slash { display: inline; }
.fighter.is-fall .pose-fall { display: inline; }

/* 抜刀した側は少し前へ踏み込む */
.fighter-me.is-slash { transform: translateX(9%); }
.fighter-foe.is-slash { transform: scaleX(-1) translateX(9%); }
.fighter-me.is-fall { transform: translateX(-5%); }
.fighter-foe.is-fall { transform: scaleX(-1) translateX(-5%); }

/* 合図の瞬間に体が沈む（緊張） */
#arena.state-signal .fighter { transition-duration: 90ms; }

/* ---------- 斬撃エフェクト ---------- */

.slash-fx {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  height: 5px;
  margin-top: -2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15) 18%, #fff 50%, rgba(255, 255, 255, 0.15) 82%, transparent);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.85);
  opacity: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
}

#slash-me { transform: translate(-50%, -50%) rotate(-26deg) scaleX(0); }
#slash-foe { transform: translate(-50%, -50%) rotate(26deg) scaleX(0); }

#slash-me.go { animation: slash-l 420ms ease-out forwards; }
#slash-foe.go { animation: slash-r 420ms ease-out forwards; }

@keyframes slash-l {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(-26deg) scaleX(0); }
  14%  { opacity: 1; }
  40%  { opacity: 1; transform: translate(-50%, -50%) rotate(-26deg) scaleX(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-26deg) scaleX(1); }
}
@keyframes slash-r {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(26deg) scaleX(0); }
  14%  { opacity: 1; }
  40%  { opacity: 1; transform: translate(-50%, -50%) rotate(26deg) scaleX(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(26deg) scaleX(1); }
}

/* ---------- 合図 ---------- */

#flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, rgba(255, 120, 90, 0.55), rgba(200, 40, 30, 0.18) 60%, transparent 78%);
}
#arena.state-signal #flash { animation: cue-flash 260ms ease-out forwards; }
#arena.state-feint #flash {
  background: radial-gradient(circle at 50% 42%, rgba(120, 180, 255, 0.4), rgba(40, 90, 200, 0.14) 60%, transparent 78%);
  animation: cue-flash 220ms ease-out forwards;
}

@keyframes cue-flash {
  0% { opacity: 0; }
  8% { opacity: 1; }
  100% { opacity: 0; }
}

#kanji {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(96px, 34vw, 190px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
#kanji.zan {
  color: #fff2ec;
  text-shadow: 0 0 12px #ff6a4e, 0 0 40px rgba(255, 60, 40, 0.9);
  animation: kanji-in 90ms ease-out forwards;
}
#kanji.matsu {
  color: #dfeeff;
  text-shadow: 0 0 12px #58a0ff, 0 0 34px rgba(60, 120, 255, 0.8);
  animation: kanji-feint 380ms ease-out forwards;
}

@keyframes kanji-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(1.35); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes kanji-feint {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- 文字表示 ---------- */

#cue {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8%;
  margin: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  z-index: 4;
  pointer-events: none;
  padding: 0 12px;
}
#cue.blink { animation: cue-blink 1.4s ease-in-out infinite; }
@keyframes cue-blink { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

#readout {
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  display: flex;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 4;
  pointer-events: none;
}

.ro-side {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 74px;
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(233, 216, 186, 0.12);
  opacity: 0;
  transition: opacity 120ms linear;
}
#readout.show .ro-side { opacity: 1; }
.ro-foe { text-align: right; }

.ro-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.ro-val {
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.ro-side.faster .ro-val { color: var(--kin); }
.ro-side.slower .ro-val { color: var(--text-dim); }

#verdict {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: -14px;
  text-align: center;
  font-size: clamp(26px, 8.5vw, 44px);
  font-weight: 900;
  letter-spacing: 0.14em;
  opacity: 0;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.85);
}
#verdict.show { animation: verdict-in 320ms cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }
#verdict.win { color: var(--kin); }
#verdict.lose { color: var(--danger); }
#verdict.draw { color: #cfd6e2; }
#verdict.foul { color: var(--ao); }

@keyframes verdict-in {
  from { opacity: 0; transform: scale(0.72); }
  to   { opacity: 1; transform: scale(1); }
}

/* 画面が揺れる（斬撃時） */
#arena.shake { animation: shake 260ms ease-out; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 2px); }
  45% { transform: translate(4px, -3px); }
  70% { transform: translate(-3px, 1px); }
}

@media (prefers-reduced-motion: reduce) {
  #arena.shake { animation: none; }
  #cue.blink { animation: none; opacity: 1; }
}

/* ===================== 結果 ===================== */

#result-overlay {
  position: fixed;
  inset: 0;
  top: var(--sgh-top, 0px);   /* 共通ヘッダーの下から。結果の見出しがヘッダーに隠れないように */
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--ad-space, 0px));
  background: rgba(10, 7, 6, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#result-box {
  width: min(400px, 100%);
  max-height: min(88vh, 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
  background: linear-gradient(180deg, #33251f, #1d1512);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 22px 18px 18px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6);
}

#result-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.18em;
}
#result-title.win { color: var(--kin); }
#result-title.lose { color: var(--danger); }

#result-sub {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--kin);
}

#result-main {
  margin: 10px 0 2px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

#result-value {
  font-size: 46px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

#result-unit {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-dim);
}

#result-rankname {
  margin: 6px auto 0;
  display: inline-block;
  padding: 4px 14px;
  border: 1px solid var(--kin);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--kin);
}

#result-stats {
  margin: 14px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--text-dim);
}
.rs-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
}
.rs-row b { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }

#result-buttons {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(180deg, #d24236, #97231b);
  color: #fff5ee;
  box-shadow: 0 4px 16px rgba(200, 53, 43, 0.35);
}

.btn-sub {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  color: var(--text);
}

/* ===================== トースト ===================== */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px) + var(--ad-space, 0px));
  transform: translateX(-50%);
  z-index: 95;
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(20, 14, 12, 0.94);
  border: 1px solid var(--panel-border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  text-align: center;
}

/* ===================== フッター ===================== */

#footer {
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-dim);
}
#footer a { color: var(--text-dim); }

/* ===================== 広めの画面 ===================== */

@media (min-width: 700px) {
  #logo { font-size: 46px; }
  #arena { min-height: 320px; }
  .fighter { width: 36%; }
  #cue { font-size: 15px; }
}

/* 横向き・低い画面ではホームの余白を詰める */
@media (max-height: 520px) {
  #logo { margin-top: 10px; font-size: 32px; }
  #arena { min-height: 190px; }
}

/* ---------- 全国ランキング（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(10, 7, 6, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, #33251f, #1d1512);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 20px 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.sgr-title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}

.sgr-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.sgr-tab {
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.sgr-tab-active {
  background: rgba(228, 181, 82, 0.18);
  border-color: var(--kin);
  color: var(--kin);
}

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

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

.sgr-name {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}

.sgr-name:focus {
  outline: none;
  border-color: var(--kin);
}

.sgr-submit {
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(180deg, #d24236, #97231b);
  color: #fff5ee;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(200, 53, 43, 0.35);
}

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

.sgr-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

.sgr-error {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
}

.sgr-status {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.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: 8px;
  font-size: 14px;
}

.sgr-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

.sgr-row.sgr-row-me {
  background: rgba(228, 181, 82, 0.22);
  color: #fff;
}

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

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

.sgr-row-score {
  font-weight: 800;
  color: var(--kin);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.sgr-row.sgr-row-me .sgr-row-score {
  color: #fff;
}

.sgr-close {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.sgr-close:active { transform: scale(0.97); }

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

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

.sgr-cta-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(180deg, #f0c766, #d2a03b);
  color: #3a2503;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(228, 181, 82, 0.35);
}
.sgr-cta-btn:active { transform: scale(0.97); }

.sgr-cta-link {
  border: none;
  background: none;
  color: var(--kin);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  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; }
}
