/* ============================================================
   テキサスホールデム - Texas Hold'em
   ============================================================ */

:root {
  --felt-1: #1a7a52;
  --felt-2: #0f5137;
  --felt-3: #08301f;
  --gold: #e9c46a;
  --gold-hi: #f8e3a8;
  --ui-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  font-family: var(--ui-font);
  background: var(--felt-3);
  color: #f3f7f2;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.hidden { display: none !important; }

/* ============ ヘッダー ============ */

/* 見出しと元ボタンは残しつつ、画面には出さずに高さも取らない
   （ボタンは共通ヘッダーのメニューから click() で呼ばれる） */
.sr-only {
  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;
}

#topbar-buttons { display: flex; gap: 6px; flex: none; }

.icon-btn {
  width: 34px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  transition: background 0.15s ease;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.22); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn.off { opacity: 0.45; }

/* ============ テーブル ============ */

/* 席・ボード・操作エリアはすべて高さを固定して、
   ターンが進んでもレイアウトが動かないようにする */

#table {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  padding: 8px 8px 6px;
  overflow: hidden;
  background: radial-gradient(ellipse 92% 78% at 50% 46%, var(--felt-1) 0%, var(--felt-2) 60%, var(--felt-3) 100%);
}

#table::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, transparent 0, transparent 3px, rgba(0, 0, 0, 0.025) 3px, rgba(0, 0, 0, 0.025) 4px);
  pointer-events: none;
}

#opponents {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 5px;
  flex: none;
}

#you-area {
  position: relative;
  display: flex;
  justify-content: center;
  flex: none;
}

/* ============ 席 ============ */

.seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1 1 0;
  min-width: 0;
  max-width: 150px;
  padding: 5px 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.24);
  transition: box-shadow 0.2s ease, opacity 0.2s ease;
}

.seat-you { max-width: 210px; background: rgba(0, 0, 0, 0.3); }

.seat.folded { opacity: 0.4; }

.seat.turn {
  box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(233, 196, 106, 0.5);
  background: rgba(233, 196, 106, 0.14);
}

.seat.winner {
  box-shadow: 0 0 0 2px #7dffb0, 0 0 18px rgba(125, 255, 176, 0.6);
}

.seat .seat-head {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.seat-avatar { font-size: 15px; line-height: 1; flex: none; }

.seat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.25;
}

.seat-name {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-stack {
  font-size: 10px;
  color: var(--gold-hi);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dealer-btn {
  flex: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #f4f1e6;
  color: #1b1b1b;
  font-size: 9px;
  font-weight: 900;
  line-height: 15px;
  text-align: center;
}

/* ディーラーボタンは常に置いたまま表示だけ切り替える（横幅を動かさない） */
.dealer-btn.off { visibility: hidden; }

/* カード置き場はカード有無にかかわらず同じ高さ */
.seat-cards {
  display: flex;
  gap: 2px;
  justify-content: center;
  height: var(--sgc-ch, 50px);
}

/* 役名はショーダウンでしか出ないので、常に1行ぶん場所を空けておく */
.seat-handname {
  display: block;
  height: 12px;
  font-size: 9px;
  color: var(--gold-hi);
  text-align: center;
  line-height: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* アクション表示とベット額は絶対配置（席の高さに影響させない） */
.seat-action {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 100%;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(20, 20, 26, 0.92);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}

.seat-action.act-fold { background: rgba(120, 40, 34, 0.92); }

.seat-bet {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-hi), #d4a93f);
  color: #3b2a06;
  font-size: 9px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  z-index: 2;
}

.seat-action.off, .seat-bet.off { visibility: hidden; }

.seat-you .seat-bet { bottom: 1px; }   /* 下に飛び出すとテーブル外にはみ出すので内側に置く */

/* ============ ボード ============ */

#board-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
  min-height: 0;
}

/* ポット・ボード・メッセージは縮ませない（縮むとカードが枠からはみ出す） */
#pot-row, #board, #msg { flex: none; }

#pot-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 22px;
}

#pot {
  padding: 2px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: var(--gold-hi);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#street-label {
  width: 4.6em;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* ボードは常に5マス。マスの中身だけ差し替える（枠は動かない） */
#board { display: flex; gap: 4px; justify-content: center; height: var(--sgc-ch, 50px); }

.board-cell {
  width: var(--sgc-cw, 36px);
  height: var(--sgc-ch, 50px);
  flex: none;
}

.card-slot {
  width: var(--sgc-cw, 36px);
  height: var(--sgc-ch, 50px);
  flex: none;
  border-radius: 7%;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.1);
}

/* めくられた瞬間の1枚だけに付ける。付けっぱなしにすると毎ターン再生されてしまう */
.dealt { animation: deal-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1); }

@keyframes deal-in {
  from { opacity: 0; transform: translateY(-20px) rotate(-5deg); }
  to { opacity: 1; transform: none; }
}

#msg {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  height: 17px;
  line-height: 17px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ============ 操作エリア ============ */

/* 3つのパネル（テーブル選択・アクション・結果）は同じマスに重ねて置き、
   高さを --ctl-h に固定する。パネルが切り替わっても操作エリアは1pxも動かない */
#controls {
  flex: none;
  display: grid;
  grid-template: 1fr / 1fr;
  height: calc(var(--ctl-h) + 16px + env(safe-area-inset-bottom));
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.34);
  box-shadow: inset 0 1px 0 rgba(233, 196, 106, 0.18);
}

#controls > .panel {
  grid-area: 1 / 1;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

/* 非表示のパネルも場所は取ったままにする（display:none にすると高さが変わる） */
#controls > .panel.hidden {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

.stakes-row { display: flex; align-items: center; gap: 8px; justify-content: center; }

.bet-label { font-size: 11px; color: rgba(255, 255, 255, 0.65); flex: none; }

/* 文言が1行のときも2行ぶん確保して、下のボタンを動かさない */
.stakes-note {
  height: 33px;
  font-size: 11px;
  line-height: 16.5px;
  color: rgba(255, 255, 255, 0.62);
  text-align: center;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

.sgc-btn.wide { width: min(320px, 100%); padding: 12px; font-size: 15px; }

#action-buttons {
  display: flex;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

/* ボタンは「見出し＋金額」の2段組で高さを固定。
   文字数が変わっても折り返さないので高さが変化しない */
#action-buttons .sgc-btn {
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
  height: 46px;
  padding: 4px 3px;
}

.ab-main {
  display: block;
  max-width: 100%;
  font-size: 13px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ab-sub {
  display: block;
  max-width: 100%;
  height: 13px;
  font-size: 10px;
  line-height: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#raise-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: min(420px, 100%);
}

/* レイズ操作は出したり消したりせず、場所を確保したまま表示だけ切り替える */
#raise-row.hidden {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

#raise-slider {
  width: 100%;
  height: 26px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

#raise-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d4a93f, rgba(255, 255, 255, 0.18));
}

#raise-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-hi), #d4a93f);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

#raise-slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

#raise-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-hi), #d4a93f);
}

/* 4つ横並びで固定（折り返させない） */
#raise-quick { display: flex; gap: 4px; }

#raise-quick button {
  flex: 1 1 0;
  min-width: 0;
  height: 26px;
  padding: 0 2px;
  border: 1px solid rgba(233, 196, 106, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #f3f7f2;
  font-family: var(--ui-font);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

#raise-quick button:hover { background: rgba(233, 196, 106, 0.18); }

.result-buttons { display: flex; gap: 8px; width: min(360px, 100%); }
.result-buttons .sgc-btn { flex: 1 1 0; min-width: 0; height: 46px; padding: 0 6px; font-size: 14px; white-space: nowrap; }

/* 見出し・金額・内訳の3行ぶんを常に確保する */
#result-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  height: 66px;
  text-align: center;
  max-width: 100%;
}

.r-head {
  height: 19px;
  font-size: 13px;
  line-height: 19px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.r-amount {
  height: 27px;
  font-size: 19px;
  line-height: 27px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#result-text.win .r-amount { color: #7dffb0; }
#result-text.lose .r-amount { color: #ff9c90; }
#result-text.push .r-amount { color: rgba(255, 255, 255, 0.85); }

.r-detail {
  height: 16px;
  font-size: 11px;
  line-height: 16px;
  color: rgba(255, 255, 255, 0.62);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hand-rank-list li { margin-bottom: 2px; }

/* ============ クレジット（設定モーダルの末尾） ============ */

.credits {
  margin-top: 14px;
  text-align: center;
  font-size: 10px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.42);
}

.credits a { color: rgba(255, 255, 255, 0.6); text-decoration: none; }
.credits a:hover { text-decoration: underline; }

/* ============ カードサイズ・操作エリアの高さ ============
   --ctl-h は操作エリアの中身の高さ。テーブル選択／アクション／結果の
   どのパネルでも収まる値を入れておく（＝パネルが変わっても高さが動かない） */

:root {
  --sgc-cw: 42px;
  --sgc-ch: 59px;
  --ctl-h: 132px;
}

@media (min-width: 420px) {
  :root { --sgc-cw: 48px; --sgc-ch: 67px; }
}

@media (min-width: 700px) {
  :root { --sgc-cw: 64px; --sgc-ch: 89px; --ctl-h: 140px; }
  #msg { font-size: 14px; height: 20px; line-height: 20px; }
  #pot { font-size: 16px; }
  #pot-row { height: 26px; }
  #street-label { font-size: 11px; }
  .seat { max-width: 190px; padding: 7px 6px 8px; }
  .seat-you { max-width: 260px; }
  .seat-name, .seat-stack { font-size: 12px; }
  .seat-avatar { font-size: 19px; }
  .seat-action, .seat-bet { font-size: 11px; }
  .seat-handname { font-size: 11px; height: 15px; line-height: 15px; }
  #action-buttons .sgc-btn, .result-buttons .sgc-btn { height: 52px; }
  .ab-main { font-size: 14px; line-height: 18px; }
}

/* 画面が低いときは、はみ出さないよう全体を詰める */
@media (max-height: 680px) {
  :root { --sgc-cw: 38px; --sgc-ch: 53px; --ctl-h: 126px; }
  #table { padding: 8px 6px 4px; gap: 3px; }
  #board-area { gap: 3px; }
  #msg { height: 15px; line-height: 15px; font-size: 11px; }
  .seat { padding: 4px 3px 5px; }
  .seat-handname { height: 11px; line-height: 11px; }
  /* ランキングの登録CTAが入ったときも操作エリア（126px）に収める */
  #result-panel:has(.sgr-cta) { gap: 5px; }
  #result-panel:has(.sgr-cta) .result-buttons .sgc-btn { height: 46px; }
}

/* さらに低い画面（iPhone SE の Safari ≒ 375×553 など）。
   上の段階のままだと席・ボードが縮めず、ボードのカードが「あなた」の席に重なる */
@media (max-height: 620px) {
  :root { --sgc-cw: 32px; --sgc-ch: 45px; }
  #table { padding: 4px 6px 2px; gap: 2px; }
  #board-area { gap: 2px; }
  #pot-row { height: 20px; }
  #msg { height: 14px; line-height: 14px; }
  .seat { padding: 4px 3px 2px; gap: 1px; }   /* 上は詰めない（アクション表示が名前に重なる） */
  .seat-info { line-height: 1.15; }
  .seat-handname { height: 10px; line-height: 10px; }
  .seat-bet { bottom: -5px; }            /* 下に飛び出すぶんを減らし、ポット表示に重ねない */
  .seat-you .seat-bet { bottom: 0; }
}

/* 極端に狭い端末ではボタンの見出しだけ少し縮める */
@media (max-width: 359px) {
  .ab-main { font-size: 11px; }
  #raise-quick button { font-size: 10px; }
  /* テーブル選択の行が操作エリアの幅（300px）からはみ出さないように詰める */
  .stakes-row { gap: 4px; }
  #seg-stakes button { padding: 6px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .dealt { animation: none !important; }
}

/* ============ モーダル ============ */

.modal {
  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));
  background: rgba(4, 20, 14, 0.78);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.modal-box {
  width: min(460px, 100%);
  max-height: min(84vh, 720px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 18px;
  border: 1px solid rgba(233, 196, 106, 0.3);
  border-radius: 14px;
  background: #0a2418;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6);
  -webkit-user-select: text;
  user-select: text;
}

.modal-box h2 {
  margin-bottom: 12px;
  font-size: 19px;
  text-align: center;
  color: var(--gold-hi);
}

.modal-box h3 {
  margin: 14px 0 5px;
  font-size: 14px;
  color: var(--gold);
}

.modal-box section:first-of-type h3 { margin-top: 0; }

.modal-box p, .modal-box li {
  font-size: 13px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.88);
}

.modal-box ul, .modal-box ol { padding-left: 1.3em; margin: 4px 0; }
.modal-box li { margin-bottom: 3px; }
.modal-box strong { color: var(--gold-hi); }

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.rule-name { font-size: 13px; font-weight: 700; }

.settings-sub { margin-top: 18px !important; }

.seg { display: flex; gap: 4px; }

.seg button {
  padding: 6px 11px;
  border: 1px solid rgba(233, 196, 106, 0.3);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: #f3f7f2;
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.seg button.on {
  background: linear-gradient(180deg, var(--gold-hi), #d4a93f);
  border-color: transparent;
  color: #3b2a06;
}

#stats-list { list-style: none; padding: 0; margin-top: 6px; }

#stats-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

#stats-list strong { font-variant-numeric: tabular-nums; color: #fff; }
#stats-list strong.plus { color: #7dffb0; }
#stats-list strong.minus { color: #ff9c90; }

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

.sgr-overlay {
  position: fixed;
  inset: 0;
  /* フッター固定バナー広告（2147482000）より上に出す */
  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(4, 20, 14, 0.8);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0a2418;
  color: #f3f7f2;
  border: 1px solid rgba(233, 196, 106, 0.32);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6);
}

.sgr-title {
  margin: 0;
  font-size: 20px;
  text-align: center;
  color: var(--gold-hi);
}

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

.sgr-tab {
  border: 1px solid rgba(233, 196, 106, 0.32);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  font-family: var(--ui-font);
  background: rgba(255, 255, 255, 0.06);
  color: #f3f7f2;
  cursor: pointer;
}

.sgr-tab-active {
  background: linear-gradient(180deg, var(--gold-hi), #d4a93f);
  border-color: transparent;
  color: #3b2a06;
}

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

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

.sgr-name {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* iOSズーム防止のため16px以上 */
  font-family: var(--ui-font);
  padding: 8px 10px;
  border: 2px solid rgba(233, 196, 106, 0.32);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: #f3f7f2;
  -webkit-user-select: text;
  user-select: text;
}

.sgr-name::placeholder { color: rgba(255, 255, 255, 0.45); }
.sgr-name:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(233, 196, 106, 0.3);
}

.sgr-submit {
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: bold;
  font-family: var(--ui-font);
  background: linear-gradient(180deg, var(--gold-hi), #d4a93f);
  color: #3b2a06;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.sgr-submit:hover { filter: brightness(1.1); }
.sgr-submit:active { transform: scale(0.96); }
.sgr-submit:disabled { opacity: 0.5; cursor: default; }

.sgr-error { margin: 6px 0 0; font-size: 12px; text-align: center; color: #ff9c90; }
.sgr-status { margin: 0; font-size: 13px; text-align: center; color: rgba(255, 255, 255, 0.55); }

.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(255, 255, 255, 0.05); }

.sgr-row-me {
  background: rgba(233, 196, 106, 0.18) !important;
  box-shadow: inset 0 0 0 1px rgba(233, 196, 106, 0.5);
}

.sgr-rank {
  width: 2em;
  text-align: center;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
  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(--gold-hi); flex: none; }

.sgr-close {
  border: 1px solid rgba(233, 196, 106, 0.32);
  border-radius: 999px;
  padding: 10px 0;
  font-size: 14px;
  font-weight: bold;
  font-family: var(--ui-font);
  background: rgba(255, 255, 255, 0.06);
  color: #f3f7f2;
  cursor: pointer;
}

.sgr-close:hover { background: rgba(255, 255, 255, 0.12); }

/* 結果画面に差し込まれる登録CTA。
   操作エリアの高さは固定なので、CTA が入るときは結果表示を詰めて収める */
.sgr-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0;
}

#result-panel .sgr-cta {
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 28px;
}

#result-panel .sgr-cta-msg { font-size: 11px; }
#result-panel .sgr-cta-btn { padding: 7px 12px; font-size: 12px; }
#result-panel .sgr-cta-link { padding: 2px 4px; }

#result-panel:has(.sgr-cta) #result-text { height: 42px; }
#result-panel:has(.sgr-cta) .r-amount { height: 22px; font-size: 16px; line-height: 22px; }
#result-panel:has(.sgr-cta) .r-detail { display: none; }

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

.sgr-cta-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 800;
  font-family: var(--ui-font);
  background: linear-gradient(180deg, var(--gold-hi), #d4a93f);
  color: #3b2a06;
  cursor: pointer;
}

.sgr-cta-link {
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-family: var(--ui-font);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / 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 {
  box-sizing: content-box;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  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);
  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; }
}
