/* =========================================================
 * 鍛冶屋シミュレーター（kajiya） スタイル
 * ========================================================= */
:root {
  --font-jp: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  --font-num: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --c-text: #2a1c12;
  --c-dim: #7c6a58;
  --c-accent: #e2581a;
  --c-accent-deep: #b23c0c;
  --c-gold: #ffb347;
  --c-gold-deep: #f07a1e;
  --c-panel: rgba(253, 247, 236, 0.97);
  --c-line: rgba(42, 28, 18, 0.14);
  --c-glass: rgba(16, 10, 7, 0.78);
}

* { 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: #120b07;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
button { font-family: var(--font-jp); }
button:focus-visible, a:focus-visible { outline: 3px solid #7fc4ff; outline-offset: 2px; }

/* ===== レイアウト =====
   共通ヘッダー(--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 と、共通ヘッダーのメニューが click() で押す元ボタンは 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: 16px; }
.icon-btn { width: 32px; height: 32px; padding: 0; }

/* ===== ステージ ===== */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #120b07;
}
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 55%, rgba(6, 3, 2, 0.5) 100%);
  z-index: 1;
}

/* ===== 状況の表示 ===== */
#hud {
  position: absolute;
  top: 6px;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
#step-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 6px; max-width: 100%; }
#step-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 4px 10px;
  border-radius: 12px;
  background: #fdf7ec;
  border-top: 3px solid var(--c-accent);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}
#step-no { font-family: var(--font-num); font-size: 11px; color: var(--c-dim); }
#step-name { color: #4a2408; }
#chips { display: flex; align-items: center; gap: 4px; }
#chips:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 190, 120, 0.22);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip small { font-size: 10.5px; font-weight: 800; color: rgba(255, 226, 190, 0.85); }
.chip.warn { background: #c8321e; border-color: #ff9a80; }
#temp {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(400px, 100%);
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 190, 120, 0.22);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}
#temp.burn { border-color: #ff5a3c; box-shadow: 0 0 14px rgba(255, 90, 40, 0.8); }
#temp.cold #temp-num { color: #8fc4ff; }
#temp-bar { position: relative; flex: 1; height: 14px; border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
#temp-zone { position: absolute; top: -3px; bottom: -3px; border: 2px solid #fff; border-radius: 6px; box-shadow: 0 0 6px rgba(255, 255, 255, 0.7); }
#temp-mark { position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 1.5px #1a0f08, 0 0 8px #fff; transition: left 0.1s linear; }
#temp-num { min-width: 4.6em; text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
#map {
  width: min(400px, 100%);
  height: 46px;
  border-radius: 10px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 190, 120, 0.22);
}
#instr {
  margin: 0;
  max-width: min(560px, 100%);
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
  color: #fff;
  background: rgba(28, 18, 9, 0.6);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#instr:empty { display: none; }

/* ===== 操作 ===== */
#controls {
  position: absolute;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  bottom: 8px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
#ctl { display: flex; gap: 8px; width: min(430px, 100%); pointer-events: auto; }
#ctl:empty { display: none; }
#ctl .btn { flex: 1; min-height: 56px; padding: 8px 6px; font-size: 15px; touch-action: none; }
#ctl .btn-primary { flex: 1.5; font-size: 18px; }
#ctl .btn-sub { background: rgba(26, 16, 10, 0.82); border-color: rgba(255, 190, 120, 0.4); }
#ctl .btn-hold:active { transform: scale(0.95); filter: brightness(1.15); }
#power {
  position: relative;
  width: min(430px, 100%);
  height: 18px;
  border-radius: 9px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 190, 120, 0.3);
  overflow: hidden;
}
#power-fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, #7a2a10, #e2581a 60%, #ffb347); }
#power-zone { position: absolute; top: 0; bottom: 0; left: 86%; right: 0; background: rgba(255, 236, 120, 0.55); border-left: 2px solid #fff3a0; }
#power::after { content: ""; position: absolute; top: 0; bottom: 0; left: 55%; width: 2px; background: rgba(255, 255, 255, 0.45); }

#banner {
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 13;
  transform: translate(-50%, -50%);
  max-width: 94%;
  font-size: clamp(22px, 6vw, 38px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(140, 40, 0, 0.9), 0 6px 18px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  opacity: 0;
}
#banner.show { animation: banner-pop 1.6s ease-out forwards; }
@keyframes banner-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  22% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}
@media (prefers-reduced-motion: reduce) { #banner.show { animation-duration: 1.6s; } }

/* 一打ごとの手ごたえ */
#pop {
  position: absolute;
  left: 50%;
  top: 30%;
  z-index: 13;
  transform: translate(-50%, -50%);
  font-size: clamp(20px, 5.4vw, 30px);
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7), 0 4px 14px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0;
}
#pop.great { color: #ffe36a; }
#pop.good { color: #ffd0a0; }
#pop.weak { color: #c9c2ba; }
#pop.bad { color: #ff7a5c; }
#pop.show { animation: pop-up 0.7s ease-out forwards; }
@keyframes pop-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  70% { opacity: 1; transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -95%) scale(1); }
}

/* ===== 画面オーバーレイ共通 ===== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#screen-loading { background: #120b07; }
.loading-panel { text-align: center; color: #f7ead2; font-size: 14px; }
.loading-pan {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--c-gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== タイトル ===== */
#screen-title { align-items: flex-end; background: linear-gradient(180deg, rgba(10, 6, 4, 0) 34%, rgba(10, 6, 4, 0.86) 78%); }
.title-panel { width: min(460px, 100%); text-align: center; color: #fff; }
.title-en { margin: 0; font-size: 12px; font-weight: 900; letter-spacing: 0.36em; color: #ffc98a; }
.title-ja { margin: 2px 0 6px; line-height: 1.05; text-shadow: 0 3px 0 #7a2206, 0 8px 22px rgba(0, 0, 0, 0.8); }
.title-ja .t1 { display: block; font-size: clamp(48px, 15vw, 76px); font-weight: 900; letter-spacing: 0.03em; color: #fff6dc; }
.title-ja .t2 { display: block; font-size: clamp(26px, 8vw, 40px); letter-spacing: 0.06em; font-weight: 900; color: var(--c-gold); }
.title-catch { margin: 0 0 6px; font-size: 15px; font-weight: 900; color: #ffeec8; }
.title-desc { margin: 0 auto 8px; max-width: 400px; font-size: 12.5px; font-weight: 700; line-height: 1.6; color: rgba(255, 244, 224, 0.88); }
#title-best { margin: 0 0 10px; min-height: 1.3em; font-size: 13px; font-weight: 900; color: var(--c-gold); }
.title-buttons { display: flex; flex-direction: column; gap: 8px; }
.title-sub-buttons { display: flex; gap: 8px; }
.title-sub-buttons .btn { flex: 1; }

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-family: var(--font-jp);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1.25;
}
.btn small { font-size: 11px; font-weight: 700; opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  color: #2a0f02;
  font-size: 19px;
  background: linear-gradient(135deg, #ffc35a, #f0661c);
  box-shadow: 0 6px 18px rgba(226, 88, 26, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-sub { color: #fff4de; font-size: 14px; padding: 10px 12px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 234, 190, 0.24); }
.btn-sub:hover { background: rgba(255, 255, 255, 0.16); }

/* ===== 注文 ===== */
#screen-intro { background: rgba(10, 6, 4, 0.55); }
.intro-panel, .final-panel {
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--c-panel);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6);
}
.intro-no { margin: 0 0 8px; font-size: 12px; font-weight: 900; letter-spacing: 0.2em; color: var(--c-accent-deep); text-align: center; }
.intro-head { display: flex; align-items: center; gap: 12px; }
.intro-emoji { flex: none; width: 60px; height: 60px; border-radius: 50%; background: #f3dfc4; font-size: 36px; line-height: 60px; text-align: center; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.07); }
.intro-say { margin: 0; padding: 8px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--c-line); font-size: 14px; font-weight: 800; line-height: 1.5; }
.intro-h { margin: 12px 0 6px; font-size: 12px; font-weight: 900; letter-spacing: 0.16em; color: var(--c-dim); text-align: center; }
.intro-order { padding: 10px 12px; border-radius: 12px; background: #2a1c14; color: #fff; text-align: center; }
.intro-name { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: 0.08em; color: #ffd9a0; }
.intro-name small { margin-left: 4px; font-size: 13px; font-weight: 800; letter-spacing: 0; color: rgba(255, 236, 210, 0.8); }
.intro-star { margin: 2px 0 8px; font-size: 13px; font-weight: 900; color: #ffb347; }
#intro-sample { display: block; width: 100%; height: auto; }
.intro-desc { margin: 10px 0 12px; font-size: 13.5px; font-weight: 800; line-height: 1.6; color: #5a3410; text-align: center; }
.intro-panel > .btn { width: 100%; }

/* ===== 結果（打ち上がった刀を上に見せる） ===== */
#screen-final { align-items: flex-end; padding: 8px; background: linear-gradient(180deg, rgba(10, 6, 4, 0) 22%, rgba(10, 6, 4, 0.72) 60%); pointer-events: none; }
#screen-final .final-panel { pointer-events: auto; padding: 10px 14px; max-height: 68%; }
.result-top { display: flex; align-items: center; justify-content: center; gap: 14px; }
.result-rank {
  flex: none;
  width: 58px;
  height: 58px;
  margin: 0;
  border-radius: 12px;
  font-size: 34px;
  font-weight: 900;
  line-height: 58px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, #d8452a, #8e1c10);
  box-shadow: 0 4px 12px rgba(160, 40, 20, 0.45);
  font-family: Georgia, "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", serif;
}
.result-rank.rank-S { background: linear-gradient(135deg, #ffd45a, #e2581a); text-shadow: 0 2px 0 rgba(120, 40, 0, 0.6); }
.result-rank.rank-B, .result-rank.rank-C { background: linear-gradient(135deg, #6f8fb8, #34507a); box-shadow: none; }
.result-rank.rank-D, .result-rank.rank-E { background: linear-gradient(135deg, #a79d94, #6b6058); box-shadow: none; }
.result-title { margin: 0; font-size: 20px; font-weight: 900; letter-spacing: 0.08em; font-family: Georgia, "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", serif; }
.result-score-row { margin: 0; line-height: 1.1; }
#final-score { font-family: var(--font-num); font-size: 38px; font-weight: 900; color: var(--c-accent-deep); font-variant-numeric: tabular-nums; }
.result-unit { margin-left: 4px; font-size: 14px; font-weight: 900; color: var(--c-dim); }
.result-speech { margin: 6px 0; padding: 7px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--c-line); font-size: 13px; font-weight: 800; line-height: 1.5; }
.final-spec { margin: 0 0 6px; font-size: 12px; font-weight: 800; line-height: 1.5; color: #5a3410; text-align: center; }
#final-rows { margin: 0 0 8px; padding: 0; list-style: none; border-top: 2px dashed var(--c-line); }
#final-rows li { display: grid; grid-template-columns: 7.2em 1fr auto; align-items: baseline; gap: 6px; padding: 3px 2px; border-bottom: 1px dashed var(--c-line); font-size: 12.5px; font-weight: 800; }
#final-rows .r-name { font-weight: 900; }
#final-rows .r-note { color: var(--c-dim); font-size: 12px; min-width: 0; }
#final-rows .r-pt { font-family: var(--font-num); font-weight: 900; color: var(--c-accent-deep); white-space: nowrap; }
.final-buttons, .modal-buttons { display: flex; gap: 8px; }
.final-buttons .btn, .modal-buttons .btn { flex: 1; }
.final-panel .btn-sub, .modal-buttons .btn-sub { color: var(--c-text); background: rgba(42, 28, 18, 0.08); border: 1px solid var(--c-line); }
.final-panel .btn { padding: 9px 10px; }
#final-msg { margin: 6px 0 0; min-height: 1.2em; font-size: 12px; font-weight: 800; text-align: center; color: var(--c-dim); }
#final-msg:empty { display: none; }
#final-new { margin: 4px 0 0; font-size: 14px; font-weight: 900; text-align: center; color: #d8580c; }
.final-buttons { flex-wrap: wrap; }
.final-buttons .btn-primary { flex: 1 1 100%; font-size: 16px; }

/* ===== 一時停止・エラー ===== */
#screen-paused, #gl-error { background: rgba(14, 8, 3, 0.72); cursor: pointer; }
.paused-panel { text-align: center; color: #fff; }
.paused-title { margin: 0 0 6px; font-size: 24px; font-weight: 900; }
.paused-hint { margin: 0; font-size: 13px; font-weight: 700; color: rgba(255, 244, 224, 0.8); }

/* ===== モーダル。広告より上に出すため body 直下に置く ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2147482800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + var(--sgh-top, 0px));
  padding-bottom: calc(16px + var(--ad-space, 0px));
  background: rgba(10, 7, 4, 0.66);
}
.modal-box {
  width: min(500px, 100%);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 16px;
  border-radius: 16px;
  background: var(--c-panel);
  color: var(--c-text);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  -webkit-user-select: text;
  user-select: text;
}
.modal-title { margin: 0 0 10px; font-size: 19px; text-align: center; }
.howto { margin: 0 0 14px; padding-left: 1.4em; font-size: 13.5px; line-height: 1.7; }
.howto li { margin-bottom: 6px; }
.howto b { color: var(--c-accent-deep); }
.modal-box > .btn { width: 100%; }
.confirm-box { width: min(400px, 100%); }
.confirm-text { margin: 4px 0 12px; font-size: 15px; font-weight: 800; line-height: 1.6; text-align: center; white-space: pre-line; }

/* ===== フッター ===== */
#footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(255, 244, 228, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 40;
  display: none;
}
#footer a { color: var(--c-gold); pointer-events: auto; }
body.on-title #footer { display: block; }
body.on-title #screen-title { padding-bottom: 48px; }

/* ===== 小さい画面・横向き ===== */
@media (max-height: 560px) {
  #hud { top: 3px; gap: 3px; }
  #instr { font-size: 12px; padding: 3px 10px; }
  #temp { padding: 3px 10px 3px 6px; }
  #map { height: 34px; }
  .title-ja .t1 { font-size: 40px; }
  .title-ja .t2 { font-size: 22px; }
  .title-desc { display: none; }
  #ctl .btn { min-height: 42px; font-size: 14px; }
  #ctl .btn-primary { font-size: 16px; }
  #ctl .btn small { display: none; }
  .intro-emoji { width: 46px; height: 46px; font-size: 28px; line-height: 46px; }
  .intro-desc { margin: 6px 0 8px; }
}
@media (max-width: 380px) {
  .chip { font-size: 12px; padding: 3px 6px; }
  #instr { font-size: 12px; padding: 3px 10px; }
  #ctl .btn { font-size: 13.5px; }
  #ctl .btn-primary { font-size: 16px; }
}
@media (max-height: 700px) {
  #final-score { font-size: 30px; }
  .result-rank { width: 46px; height: 46px; font-size: 27px; line-height: 46px; }
}
@media (max-height: 560px) and (min-width: 640px) {
  /* 横向きスマホ: 表示を左右に寄せる */
  #hud { align-items: flex-start; right: auto; max-width: 48%; }
  #step-row { justify-content: flex-start; }
  #controls { left: auto; width: 300px; }
  #screen-final { align-items: center; justify-content: flex-end; padding: 6px; background: linear-gradient(90deg, rgba(10, 6, 4, 0) 40%, rgba(10, 6, 4, 0.7) 70%); }
  #screen-final .final-panel { width: 330px; max-height: 100%; padding: 6px 10px; }
  .result-speech { margin: 3px 0; padding: 4px 8px; font-size: 12px; }
  #final-rows li { font-size: 11.5px; padding: 1px 2px; }
  .final-panel .btn { padding: 6px 4px; min-height: 0; font-size: 12.5px; }
  .final-buttons { flex-wrap: nowrap; }
  .final-buttons .btn-primary { flex: 1.5; font-size: 12.5px; }
  .final-spec { margin: 0 0 3px; font-size: 11px; }
  #final-new { margin: 2px 0 0; font-size: 12px; }
  .result-title { font-size: 17px; }
  #screen-title { align-items: center; justify-content: flex-end; background: linear-gradient(90deg, rgba(10, 6, 4, 0) 34%, rgba(10, 6, 4, 0.86) 76%); }
  .title-panel { width: 320px; }
}

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

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

.sgr-tab-active {
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  border-color: transparent;
  color: #fff;
}

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

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

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

.sgr-name:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 8px rgba(226, 80, 42, 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, var(--c-accent), var(--c-accent-deep));
  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: var(--c-red);
}

.sgr-status {
  margin: 0;
  font-size: 13px;
  text-align: center;
  color: var(--c-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(226, 80, 42, 0.07); }

.sgr-row.sgr-row-me {
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  color: #fff;
}

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

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

.sgr-close:hover { border-color: var(--c-accent); }

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

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

.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, #f5a623, #f0741e);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(240, 116, 30, 0.4);
}

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

.sgr-cta-link {
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(30, 43, 56, 0.08);
  border: 1px solid var(--c-line);
  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; }
}
