/* =========================================================
   ゴミ箱チャレンジ — UI
   オフィス／紙の世界観：暗いシーン上に「紙」のシートを置く
   ========================================================= */
:root {
  --bg: #0b0e13;

  /* 紙とインク */
  --paper-1: #fdfaf3;
  --paper-2: #f5efe1;
  --paper-3: #e9e0cd;
  --ink: #1b2330;
  --ink-2: rgba(27, 35, 48, .82);   /* 紙の上で 4.5:1 以上を確保 */
  --ink-3: rgba(27, 35, 48, .66);
  --rule: rgba(60, 50, 30, .18);

  /* アクセント */
  --mint: #34d99b;
  --mint-d: #12855c;
  --mint-ink: #096a47;
  --gold: #ffd166;
  --gold-ink: #855708;
  --danger: #d94a3d;
  --danger-ink: #b3372a;
  --sky: #7fc9ff;

  /* HUD の熱 */
  --hot-1: #ffffff;
  --hot-2: #7ef7c8;
  --hot-3: #ffd166;
  --hot-4: #ff9f45;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --num: ui-rounded, -apple-system, BlinkMacSystemFont, "Hiragino Sans", system-ui, "Segoe UI", Roboto, sans-serif;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-pop: cubic-bezier(.2, 1.5, .35, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #f2f5f8;
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

/* ゲーム領域。
   iOS Safari の 100vh 問題対策として、高さは 100vh ではなく固定要素の上下端で決める
   （「今見えている高さ」になり、JS に依存しないので resize を取りこぼしても崩れない）。
   スマートゲーム共通ヘッダー（--sgh-top）とフッター広告（--ad-space）のぶんだけ縮む。
   レンダラや入力はこの箱の実サイズを測る（engine.js / input.js）。 */
#app {
  position: fixed;
  left: 0; right: 0;
  top: var(--sgh-top, 0px);
  bottom: var(--ad-space, 0px);
  width: 100%;
  overflow: hidden;
  display: block;
  /* #app の上下はヘッダー・広告のぶん（どちらもセーフエリア込み）すでに空いている。
     中の UI が空けるセーフエリアはその残りだけにする（二重に空けるとノッチ付き iPhone で
     タイトルの紙がはみ出し、HUD の上に空の帯ができる）。ヘッダー・広告が無ければ従来どおり */
  --in-sat: max(0px, var(--sat) - var(--sgh-top, 0px));
  --in-sab: max(0px, var(--sab) - var(--ad-space, 0px));
}

/* 共通ヘッダーのメニューから click() される隠しボタン（index.html の .sgh-hooks） */
.sgh-hooks {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  pointer-events: none;
}

#scene, #fx2d {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#fx2d { pointer-events: none; z-index: 2; }

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

:focus { outline: none; }
:focus-visible {
  outline: 3px solid #78d8ff;
  outline-offset: 3px;
  border-radius: 12px;
}
/* 紙のシートの上では濃い色のリングにする */
.sheet :focus-visible { outline-color: #0c62c4; }

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

/* =========================================================
   HUD
   ========================================================= */
#hud {
  position: absolute; inset: 0;
  z-index: 3;
  pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(var(--in-sat) + 12px) calc(var(--sar) + 14px) calc(var(--in-sab) + 14px) calc(var(--sal) + 14px);
}
#hud.hidden { display: none; }

/* 明るい床の上でも文字が読めるよう、ごく薄いスクリム */
.hud-scrim { position: absolute; left: 0; right: 0; pointer-events: none; }
/* 上下とも 3 段のカーブにして、明るいホワイトボードや床の上でも
   文字が沈まないようにする（単純な線形だと中ほどで一気に薄くなる） */
.hud-scrim-top {
  top: 0; height: calc(var(--sat) + 190px);
  background: linear-gradient(180deg,
    rgba(6, 10, 16, .52) 0%,
    rgba(6, 10, 16, .38) 38%,
    rgba(6, 10, 16, .18) 68%,
    rgba(6, 10, 16, 0) 100%);
}
.hud-scrim-bottom {
  bottom: 0; height: calc(var(--sab) + 150px);
  background: linear-gradient(0deg,
    rgba(6, 10, 16, .56) 0%,
    rgba(6, 10, 16, .34) 42%,
    rgba(6, 10, 16, .13) 72%,
    rgba(6, 10, 16, 0) 100%);
}

.hud-top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

/* ---- 連続数 ---- */
.streak-block { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.streak-cap {
  font-size: 11px; letter-spacing: .34em; font-weight: 800;
  color: rgba(255, 255, 255, .78);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
  margin-left: 3px;
}
.streak-num { position: relative; margin-top: 3px; min-width: 1ch; }
.streak-value, .streak-prev {
  display: block;
  font-family: var(--num);
  font-size: clamp(44px, min(13.5vw, 11.5vh), 86px);
  font-weight: 800;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--hot-1);
  text-shadow: 0 2px 18px rgba(0, 0, 0, .72);
  transform-origin: left center;
}
.streak-prev {
  position: absolute; left: 0; top: 0;
  opacity: 0; pointer-events: none;
}
.streak-num.roll .streak-value { animation: rollIn .34s var(--ease-out) both; }
.streak-num.roll .streak-prev { animation: rollOut .34s var(--ease-out) both; }
@keyframes rollIn  { from { opacity: 0; transform: translateY(.42em) scale(.86); } to { opacity: 1; transform: none; } }
@keyframes rollOut { from { opacity: .9; transform: none; } to { opacity: 0; transform: translateY(-.46em) scale(.9); } }

.streak-num.pop .streak-value { animation: rollIn .34s var(--ease-out) both, streakPop .42s var(--ease-pop) both; }
@keyframes streakPop { 0% { scale: 1; } 34% { scale: 1.22; } 100% { scale: 1; } }

.streak-burst {
  position: absolute; left: -14px; top: 50%;
  width: 90px; height: 90px; margin-top: -45px;
  border-radius: 50%;
  border: 2px solid currentColor;
  color: var(--hot-2);
  opacity: 0; pointer-events: none;
}
.streak-num.pop .streak-burst { animation: burst .5s var(--ease-out) both; }
@keyframes burst {
  0% { opacity: .5; transform: scale(.35); }
  100% { opacity: 0; transform: scale(1.05); }
}

/* 熱量 */
.streak-block.lv1 .streak-value { color: var(--hot-2); text-shadow: 0 2px 18px rgba(0,0,0,.6), 0 0 22px rgba(126,247,200,.45); }
.streak-block.lv2 .streak-value { color: var(--hot-3); text-shadow: 0 2px 18px rgba(0,0,0,.6), 0 0 26px rgba(255,209,102,.55); }
.streak-block.lv3 .streak-value {
  color: var(--hot-4);
  text-shadow: 0 2px 18px rgba(0,0,0,.6), 0 0 14px rgba(255,159,69,.75), 0 0 34px rgba(255,110,40,.5);
  animation: emberPulse 1.5s ease-in-out infinite;
}
@keyframes emberPulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
.streak-block.lv1 .streak-burst { color: var(--hot-2); }
.streak-block.lv2 .streak-burst { color: var(--hot-3); }
.streak-block.lv3 .streak-burst { color: var(--hot-4); }

.streak-meter {
  width: 74px; height: 4px; margin: 7px 0 0 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .22);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  overflow: hidden;
}
.streak-meter i {
  display: block; height: 100%; width: 100%;
  border-radius: 99px;
  background: var(--hot-1);
  /* width のアニメは遷移中ずっと layout を走らせるので transform で伸縮させる */
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .4s var(--ease-out), background-color .4s ease;
}
.streak-block.lv1 .streak-meter i { background: var(--hot-2); }
.streak-block.lv2 .streak-meter i { background: var(--hot-3); }
.streak-block.lv3 .streak-meter i { background: var(--hot-4); }

/* ---- 役職（社員証ふうの小さな名札） ----
   ふだんは他の HUD チップと同じ暗いトーンで控えめに。
   昇進した瞬間だけ「紙の名札」に変わって目立つ。 */
.rank-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 7px 0 0 2px;
  padding: 3px 9px 3px 6px;
  max-width: min(46vw, 190px);
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-left: 3px solid rgba(255, 255, 255, .34);
  /* 動き続ける WebGL 背景の上では backdrop-filter が毎フレームの再ぼかしになるため、
     ゲーム中の HUD チップは背景の不透明度を上げるだけにする */
  background: rgba(12, 17, 24, .62);
  line-height: 1.25;
  transform-origin: left center;
  transition: background-color .45s ease, border-color .45s ease, color .45s ease;
}
.rank-chip.hidden { display: none; }
.rank-cap {
  font-size: 9px; font-weight: 800; letter-spacing: .12em;
  color: rgba(255, 255, 255, .58);
  padding-right: 6px;
  border-right: 1px solid rgba(255, 255, 255, .18);
  flex: none;
  transition: color .45s ease, border-color .45s ease;
}
.rank-name {
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  color: rgba(255, 255, 255, .88);
  text-shadow: 0 1px 5px rgba(0, 0, 0, .55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .45s ease;
}

/* 昇進の瞬間：紙の名札に切り替わって跳ねる（1.6s 後にクラスが外れて戻る） */
.rank-chip.up {
  background: linear-gradient(170deg, var(--paper-1), var(--paper-2));
  border-color: rgba(60, 50, 30, .34);
  border-left-color: var(--gold-ink);
  animation: rankUp 1.5s var(--ease-out) both;
}
.rank-chip.up .rank-name { color: var(--gold-ink); text-shadow: none; }
.rank-chip.up .rank-cap { color: var(--ink-3); border-right-color: var(--rule); }
@keyframes rankUp {
  0%   { transform: scale(.92); box-shadow: 0 2px 8px rgba(0, 0, 0, .45); }
  16%  { transform: scale(1.16); box-shadow: 0 0 0 3px rgba(255, 209, 102, .55), 0 4px 14px rgba(0, 0, 0, .5); }
  40%  { transform: scale(1); box-shadow: 0 0 0 3px rgba(255, 209, 102, .4), 0 3px 10px rgba(0, 0, 0, .45); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 209, 102, 0), 0 2px 8px rgba(0, 0, 0, .45); }
}

/* ---- 右上 ---- */
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.best-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(12, 17, 24, .62);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: 6px 12px 6px 9px;
  font-size: 15px; font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .5);
  transition: color .3s ease, border-color .3s ease, background-color .3s ease;
}
.best-chip .chip-ic { width: 14px; height: 14px; color: var(--gold); }
.best-label { font-size: 10px; letter-spacing: .16em; opacity: .72; font-weight: 700; }
.best-chip.beating {
  color: var(--gold);
  border-color: rgba(255, 209, 102, .55);
  background: rgba(60, 43, 12, .7);
}

/* 明るいホワイトボードの前に来ることが多いので、素の文字ではなく小さなチップにする */
.best-delta {
  font-size: 11.5px; font-weight: 800; letter-spacing: .02em;
  color: #fff;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .6);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(12, 17, 24, .66);
  border: 1px solid rgba(255, 255, 255, .13);
  white-space: nowrap;
}
.best-delta:empty { display: none; }
.best-delta.gold {
  color: var(--gold);
  border-color: rgba(255, 209, 102, .4);
  background: rgba(52, 38, 11, .72);
  animation: deltaGlow 1.6s ease-in-out infinite;
}
@keyframes deltaGlow { 0%,100% { opacity: .85; } 50% { opacity: 1; } }

.wind-chip {
  display: flex; align-items: center; gap: 7px;
  background: rgba(12, 24, 38, .65);
  border: 1px solid rgba(127, 201, 255, .34);
  color: #a9dcff;
  border-radius: 999px; padding: 5px 11px;
  font-size: 12px; font-weight: 800;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .5);
}
.wind-chip.hidden { display: none; }
.wind-icon { width: 17px; height: 17px; transition: transform .3s ease; }
.wind-text { letter-spacing: .04em; }
.wind-bars { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.wind-bars i { width: 3px; border-radius: 1px; background: currentColor; opacity: .25; }
.wind-bars i:nth-child(1) { height: 5px; }
.wind-bars i:nth-child(2) { height: 8px; }
.wind-bars i:nth-child(3) { height: 12px; }
.wind-chip.l1 .wind-bars i:nth-child(1) { opacity: 1; }
.wind-chip.l2 .wind-bars i:nth-child(-n+2) { opacity: 1; }
.wind-chip.l3 .wind-bars i { opacity: 1; }
.wind-chip.l3 { color: #ffc48a; border-color: rgba(255, 178, 110, .45); background: rgba(46, 26, 12, .7); }

/* ---- 中央のコールアウト ---- */
.hud-center {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 14vh;   /* ゴミ箱の上あたりに出す */
}
/* 文字数に応じて JS が --co-size を入れる。
   入っていなくても（あるいは想定外に長くても）はみ出さないよう、
   clamp を保険にしたうえで折り返しも許す。日本語は文節で折るため keep-all。 */
.callout {
  font-size: var(--co-size, clamp(26px, 8.6vw, 46px));
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.16;
  opacity: 0;
  transform: scale(.7);
  /* 明るい床の上に出ることが多いので、広いグローだけでなく
     文字際の濃い影も重ねて縁取りのように効かせる */
  text-shadow:
    0 0 3px rgba(0, 0, 0, .85),
    0 1px 3px rgba(0, 0, 0, .9),
    0 0 12px rgba(0, 0, 0, .7),
    0 3px 26px rgba(0, 0, 0, .8),
    0 0 34px rgba(0, 0, 0, .45);
  max-width: 84%;          /* 演出のピーク(×1.1)でも画面内に収まる幅 */
  text-align: center;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.callout.show { animation: calloutPop 1.05s var(--ease-out) forwards; }
@keyframes calloutPop {
  0%   { opacity: 0; transform: scale(.62) translateY(12px); }
  16%  { opacity: 1; transform: scale(1.1) translateY(0); }
  30%  { transform: scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05) translateY(-18px); }
}

/* ---- 下部のヒント ---- */
.hud-bottom { position: relative; display: flex; justify-content: center; }
.swipe-hint {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #fff;
  opacity: .92;
  transition: opacity .4s ease, transform .4s ease;
}
/* 非表示中も無限アニメがスタイル計算を回し続けないよう、フェードアウト後に
   visibility を切ってシェブロンのアニメも止める。visibility の遅延は隠すときだけに
   効かせたいので、この transition は .hidden 側にのみ置く（表示側は基底の transition）。 */
.swipe-hint.hidden {
  opacity: 0; transform: translateY(8px);
  visibility: hidden;
  transition: opacity .4s ease, transform .4s ease, visibility 0s linear .4s;
}
.swipe-hint.hidden .hc { animation-play-state: paused; }
.hint-fig { width: 36px; height: 50px; color: #fff; filter: drop-shadow(0 2px 7px rgba(0,0,0,.75)); }
.hint-fig .hc {
  fill: none; stroke: currentColor;
  stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
  opacity: .22;
  animation: chevPulse 1.7s ease-in-out infinite;
}
.hint-fig .hc1 { animation-delay: 0s; }
.hint-fig .hc2 { animation-delay: .16s; }
.hint-fig .hc3 { animation-delay: .32s; }
.hint-finger { fill: currentColor; opacity: .92; }
@keyframes chevPulse { 0%, 70%, 100% { opacity: .22; } 22% { opacity: 1; } }
.hint-text {
  font-size: 13px; font-weight: 800; letter-spacing: .06em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .85), 0 0 3px rgba(0, 0, 0, .75);
}

/* ---- 一時停止からの復帰 ---- */
.pause-veil {
  position: absolute; inset: 0;
  z-index: 5;
  display: grid; place-items: center;
  pointer-events: none;                 /* スワイプ入力を絶対に邪魔しない */
  background: rgba(6, 10, 16, .42);
  backdrop-filter: blur(2px);
  animation: fadeIn .18s ease both;
}
.pause-veil.hidden { display: none; }
.pause-card {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 18px 11px 15px;
  border-radius: 999px;
  background: rgba(14, 19, 27, .82);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 14px; font-weight: 800; letter-spacing: .06em;
  box-shadow: 0 10px 28px -12px rgba(0, 0, 0, .9);
  backdrop-filter: blur(10px);
}
.pause-card svg { width: 19px; height: 19px; color: var(--mint); flex: none; }
/* 復帰後の「再開」表示はゲームがもう動いている状態なので、
   暗幕とぼかしを外してプレイ画面を隠さないようにする（カードだけ残す） */
.pause-veil.resume { background: transparent; backdrop-filter: none; }
.pause-veil.resume .pause-card { animation: pauseBreathe 1.9s ease-in-out infinite; }
@keyframes pauseBreathe { 0%, 100% { opacity: .82; } 50% { opacity: 1; } }

/* ---- アイコンボタン ---- */
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(12, 17, 24, .62);
  color: #fff;
  pointer-events: auto;
  display: grid; place-items: center;
  padding: 0; cursor: pointer;
  transition: transform .12s ease, background-color .2s ease, opacity .2s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn .ic-off { display: none; }
.icon-btn.muted .ic-on { display: none; }
.icon-btn.muted .ic-off { display: block; }
.icon-btn.muted { color: rgba(255, 255, 255, .55); }

.icon-btn-sheet {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 44px; height: 44px;
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
  backdrop-filter: none;
}
.icon-btn-sheet:active { background: rgba(27, 35, 48, .07); }
.icon-btn-sheet.muted { color: var(--ink-3); }

/* =========================================================
   オーバーレイ / 紙のシート
   ========================================================= */
.overlay {
  position: absolute; inset: 0;
  z-index: 6;
  display: grid; place-items: center;
  padding: calc(var(--in-sat) + 14px) calc(var(--sar) + 14px) calc(var(--in-sab) + 14px) calc(var(--sal) + 14px);
  /* メニューの背後でも描画ループが回り続けるため、全画面の backdrop-filter は
     使わずグラデーションを少し濃くして可読性を保つ */
  background: radial-gradient(130% 88% at 50% 30%, rgba(9, 13, 19, .30), rgba(7, 10, 15, .78) 80%);
  animation: fadeIn .3s ease both;
}
.overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.overlay-howto { z-index: 7; }

.sheet {
  position: relative;
  width: min(410px, 100%);
  max-height: 100%;
  /* overflow-y:auto だけだと overflow-x が auto に計算され、
     スタンプ演出（scale 1.9）のぶん横スクロールが生まれる */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex; flex-direction: column;
  border-radius: 20px;
  color: var(--ink);
  background:
    linear-gradient(168deg, var(--paper-1) 0%, var(--paper-2) 55%, var(--paper-3) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .85) inset,
    0 0 0 1px rgba(60, 50, 30, .16),
    0 26px 60px -20px rgba(0, 0, 0, .85),
    0 6px 18px -8px rgba(0, 0, 0, .6);
  animation: sheetIn .42s var(--ease-out) both;
}
/* 紙の繊維 */
.sheet::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background-image:
    repeating-linear-gradient(0deg, rgba(90, 74, 45, .035) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(90, 74, 45, .03) 0 1px, transparent 1px 4px);
  opacity: .8;
  border-radius: inherit;
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(20px) scale(.975); } to { opacity: 1; transform: none; } }

.sheet-main { position: relative; z-index: 2; padding: 22px 20px 6px; text-align: center; }
.sheet-foot {
  position: sticky; bottom: 0; z-index: 2;
  padding: 12px 20px calc(18px);
  background: linear-gradient(180deg, rgba(240, 233, 216, 0) 0%, var(--paper-2) 24%, var(--paper-3) 100%);
}

/* ---- タイトル ---- */
.brand { margin-bottom: 4px; }
.brand-kicker {
  font-size: 10px; font-weight: 800; letter-spacing: .34em;
  color: var(--mint-ink);
  margin-bottom: 6px;
}
.brand-jp {
  margin: 0;
  font-size: clamp(32px, 9.4vw, 44px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: .005em;
  background: linear-gradient(180deg, #262f3c 10%, #47525f 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-jp em {
  font-style: normal; display: block;
  font-size: .62em; font-weight: 800;
  letter-spacing: .3em; text-indent: .3em;
  margin-top: 4px;
  color: #5c6774;
  -webkit-text-fill-color: #5c6774;
}
.brand-rule { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; }
.brand-rule i { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--rule), transparent); }
.brand-rule span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 1px var(--rule), 0 1px 2px rgba(0,0,0,.18);
}
.brand-sub { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }

.best-card {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 14px auto 0;
  padding: 7px 16px 7px 12px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .62);
  border: 1px dashed rgba(60, 50, 30, .3);
}
.best-medal { width: 22px; height: 22px; color: var(--gold-ink); flex: none; }
.best-card-txt { display: flex; align-items: baseline; gap: 9px; }
.best-card-t { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--ink-3); }
.best-card-v { font-family: var(--num); font-variant-numeric: tabular-nums; line-height: 1; }
.best-card-v b { font-size: 26px; font-weight: 800; color: var(--gold-ink); letter-spacing: -.02em; }
.best-card-v small { font-size: 11px; font-weight: 800; color: var(--ink-3); margin-left: 3px; }

.howto-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 100%;
  margin: 16px 0 2px;
  padding: 12px 8px 10px;
  border: 1px solid rgba(60, 50, 30, .16);
  border-radius: 14px;
  background: rgba(255, 255, 255, .5);
  color: var(--ink);
  cursor: pointer;
  position: relative;
  text-align: center;
  transition: transform .12s ease, background-color .2s ease;
}
.howto-strip:active { transform: scale(.985); background: rgba(255, 255, 255, .75); }
.howto-item { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.howto-item svg { width: 100%; max-width: 62px; height: 40px; color: var(--mint-ink); }
.howto-item b { font-size: 11px; font-weight: 800; color: var(--ink-2); letter-spacing: .01em; }
.howto-more {
  grid-column: 1 / -1;
  margin-top: 8px;
  font-size: 11.5px; font-weight: 800; color: var(--mint-ink);
  text-decoration: underline; text-underline-offset: 3px;
}
.fig-finger { animation: figFinger 2.1s var(--ease-out) infinite; }
@keyframes figFinger {
  0%   { transform: translateY(0); opacity: 1; }
  46%  { transform: translateY(-11px); opacity: .12; }
  47%  { transform: translateY(0); opacity: 0; }
  68%  { opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}
.howto-strip.attention {
  border-color: rgba(52, 217, 155, .55);
  box-shadow: 0 0 0 3px rgba(52, 217, 155, .18);
}

/* ---- ボタン ---- */
.primary-btn {
  display: block; width: 100%;
  min-height: 54px;
  padding: 15px 20px;
  border: none; border-radius: 15px;
  font-size: 17px; font-weight: 800; letter-spacing: .1em;
  color: #04170f;
  background: linear-gradient(180deg, #63e7b0 0%, #26bd86 100%);
  box-shadow: 0 5px 0 var(--mint-d), 0 14px 24px -10px rgba(18, 133, 92, .8);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.primary-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--mint-d), 0 6px 12px -8px rgba(18, 133, 92, .7);
}

.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 46px;
  padding: 11px 14px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .55);
  border: 1px solid rgba(27, 35, 48, .18);
  color: #2c3542;
  font-size: 14px; font-weight: 800; letter-spacing: .04em;
  cursor: pointer;
  transition: transform .1s ease, background-color .2s ease;
}
.ghost-btn svg { width: 17px; height: 17px; flex: none; }
.ghost-btn:active { transform: scale(.98); background: rgba(255, 255, 255, .85); }
.btn-row { display: flex; gap: 9px; margin-top: 9px; }

.guide-row {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: 8px 10px; margin-top: 14px;
}
.guide-label { font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--ink-3); }
.seg {
  display: flex; gap: 2px; padding: 3px;
  background: rgba(27, 35, 48, .09);
  border-radius: 12px;
}
.seg button {
  min-height: 44px; min-width: 56px;
  border: none; border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px; font-weight: 800; letter-spacing: .04em;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}
.seg button.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .16), 0 0 0 1px rgba(60, 50, 30, .1);
}
.guide-desc {
  margin: 8px 0 0;
  font-size: 11.5px; line-height: 1.6; color: var(--ink-3);
  min-height: 1.6em;
}
.key-tip {
  margin: 10px 0 0;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  color: var(--ink-3);
  display: none;
}
@media (hover: hover) and (pointer: fine) { .key-tip { display: block; } }

/* ---- クレジット（タイトルの紙の末尾） ---- */
.sg-credits {
  margin: 12px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: 10.5px; line-height: 1.55; letter-spacing: .03em;
  color: var(--ink-3);
  text-align: center;
}
.sg-credits p { margin: 0; }
.sg-credits a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.sg-credits a:hover { color: var(--ink); }

/* ---- 遊び方 ---- */
.howto-title {
  margin: 2px 0 14px;
  font-size: 20px; font-weight: 800; letter-spacing: .08em;
}
.howto-list { list-style: none; margin: 0; padding: 0; text-align: left; }
.howto-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}
.howto-list li:first-child { border-top: none; }
.howto-fig { width: 68px; height: 48px; flex: none; color: var(--mint-ink); }
.howto-list b { display: block; font-size: 13.5px; font-weight: 800; color: var(--ink); }
.howto-list span { display: block; font-size: 11.5px; line-height: 1.55; color: var(--ink-3); margin-top: 2px; }
.sheet-howto .ghost-btn { margin-top: 9px; }

/* ---- ゲームオーバー ---- */
.over-head { display: flex; justify-content: center; }
.over-title {
  font-size: 11.5px; font-weight: 800; letter-spacing: .32em;
  color: var(--danger-ink);
  padding: 5px 12px 5px 14px;
  border: 1px solid rgba(217, 74, 61, .35);
  border-radius: 999px;
  background: rgba(217, 74, 61, .07);
}
.over-scoreblock { margin-top: 14px; }
.over-score {
  font-family: var(--num);
  font-size: clamp(64px, 19vw, 92px);
  font-weight: 800; line-height: .96;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.over-score small { font-size: 15px; font-weight: 800; color: var(--ink-3); margin-left: 8px; letter-spacing: .12em; }
.sheet-over.newbest .over-score {
  background: linear-gradient(180deg, #c98f13 0%, #8a5c00 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.over-best { margin-top: 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
.over-best.new { color: var(--ink-2); }
.over-delta { margin-top: 5px; font-size: 13px; font-weight: 800; color: var(--mint-ink); min-height: 1.2em; }
.over-delta.gold { color: var(--gold-ink); }

/* 最終役職：主役は連続数なので、罫線ひとつぶんの添え物にとどめる */
.over-rank {
  display: inline-flex; align-items: baseline; gap: 9px;
  max-width: 100%;
  margin: 12px auto 0;
  padding: 6px 4px 0;
  border-top: 1px solid var(--rule);
}
.over-rank.hidden { display: none; }
.over-rank-cap {
  font-size: 10px; font-weight: 800; letter-spacing: .16em;
  color: var(--ink-3);
  flex: none;
}
.over-rank-name {
  font-size: 15px; font-weight: 800; letter-spacing: .04em;
  color: var(--ink-2);
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sheet-over.newbest .over-rank-name { color: var(--gold-ink); }
.over-reason {
  margin: 12px 0 2px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-3);
  min-height: 1.3em;
}

/* スタンプは飛び込みの瞬間に scale(1.9) まで大きくなる。
   シート自身が overflow-y:auto のスクロールコンテナなので、
   ここで閉じ込めておかないと横方向のスクロール量が生まれてしまう */
.stamp-wrap {
  position: absolute; inset: 0; z-index: 3;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.stamp {
  position: absolute; top: 44px; right: 12px; z-index: 3;
  width: 86px; height: 86px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2.5px solid rgba(200, 48, 38, .82);
  box-shadow: 0 0 0 4px rgba(200, 48, 38, .1) inset;
  color: rgba(200, 48, 38, .88);
  font-size: 17px; font-weight: 800; letter-spacing: .08em;
  opacity: 0; transform: rotate(-16deg) scale(1.9);
  pointer-events: none;
}
.stamp span { display: block; }
.stamp.on { animation: stampIn .42s cubic-bezier(.2, .9, .3, 1) .5s forwards; }
@keyframes stampIn {
  0%   { opacity: 0; transform: rotate(-16deg) scale(1.9); }
  60%  { opacity: .95; transform: rotate(-16deg) scale(.98); }
  100% { opacity: .9; transform: rotate(-16deg) scale(1); }
}

/* =========================================================
   3D に紐づくポップアップ
   ========================================================= */
#popups { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--num);
  font-size: 24px; font-weight: 800;
  letter-spacing: .01em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .8);
  white-space: nowrap;
  animation: popupRise 1.1s var(--ease-out) forwards;
}
/* prefers-reduced-motion 用：位置は動かさず不透明度だけ */
@keyframes calloutFade { 0% { opacity: 0 } 10% { opacity: 1 } 74% { opacity: 1 } 100% { opacity: 0 } }
@keyframes popupFade   { 0% { opacity: 0 } 12% { opacity: 1 } 70% { opacity: 1 } 100% { opacity: 0 } }
@keyframes popupRise {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  20%  { opacity: 1; transform: translate(-50%, -60%) scale(1.16); }
  35%  { transform: translate(-50%, -62%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -145%) scale(1); }
}

/* =========================================================
   トースト
   ========================================================= */
.toast {
  position: absolute; left: 50%; bottom: calc(var(--in-sab) + 26px);
  z-index: 9;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(18, 24, 32, .94);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 13px; font-weight: 800; letter-spacing: .03em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0; transform: translate(-50%, 14px);
  transition: opacity .24s ease, transform .24s var(--ease-out);
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   ローディング
   ========================================================= */
.overlay-load {
  background: radial-gradient(120% 90% at 50% 34%, #1a222d 0%, #0a0d12 78%);
  backdrop-filter: none;
  z-index: 8;
  transition: opacity .4s ease;
}
.overlay-load.fading { opacity: 0; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.loader-ball { width: 62px; height: 62px; animation: ballSpin 2.6s ease-in-out infinite; filter: drop-shadow(0 8px 18px rgba(0,0,0,.55)); }
@keyframes ballSpin {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  50%      { transform: rotate(8deg) translateY(-8px); }
}
.loader-word {
  font-size: 16px; font-weight: 800; letter-spacing: .16em;
  color: rgba(255, 255, 255, .92);
}
.loader-bar {
  width: 132px; height: 3px; border-radius: 99px;
  background: rgba(255, 255, 255, .14);
  overflow: hidden;
}
.loader-bar i {
  display: block; width: 40%; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
  animation: loadSlide 1.25s ease-in-out infinite;
}
@keyframes loadSlide { 0% { transform: translateX(-110%); } 100% { transform: translateX(360%); } }
.loader-text { font-size: 11px; letter-spacing: .24em; color: rgba(255, 255, 255, .5); }

/* =========================================================
   横持ち / 低い画面
   ========================================================= */
@media (orientation: landscape) and (max-height: 560px) {
  .overlay { padding: calc(var(--in-sat) + 10px) calc(var(--sar) + 12px) calc(var(--in-sab) + 10px) calc(var(--sal) + 12px); }

  .sheet-title, .sheet-over, .sheet-howto {
    width: min(720px, 100%);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    align-items: center;
  }
  .sheet-title .sheet-main, .sheet-over .sheet-main, .sheet-howto .sheet-main { padding: 16px 10px 16px 20px; }
  .sheet-title .sheet-foot, .sheet-over .sheet-foot, .sheet-howto .sheet-foot {
    position: static; background: none; padding: 16px 20px 16px 10px;
  }
  /* 右上のままだと右カラムのスタートボタンの角に重なる（押すとサウンドが切り替わる）ので、
     空いている左カラムの左上へ移す */
  .sheet-title .icon-btn-sheet { right: auto; left: 8px; }

  .brand-kicker { margin-bottom: 3px; }
  .brand-jp { font-size: 27px; }
  .brand-rule { margin: 8px 0 6px; }
  .brand-sub { font-size: 11.5px; }
  .best-card { margin-top: 10px; padding: 5px 13px 5px 10px; }
  .best-card-v b { font-size: 22px; }
  .howto-strip { margin: 10px 0 0; padding: 8px 6px; }
  .howto-item svg { height: 32px; }
  .howto-item b { font-size: 10px; }
  .howto-more { margin-top: 5px; }

  .over-score { font-size: 62px; }
  .over-scoreblock { margin-top: 8px; }
  .over-reason { margin: 8px 0 0; }
  .stamp { top: 4px; right: 2px; width: 70px; height: 70px; font-size: 14px; }

  .howto-list li { padding: 6px 0; }
  .howto-fig { width: 54px; height: 36px; }
  .howto-list span { font-size: 10.5px; }
  .howto-title { margin-bottom: 8px; }

  .guide-row { margin-top: 10px; gap: 6px 8px; }
  .seg button { min-width: 48px; font-size: 12.5px; }
  .primary-btn { min-height: 50px; padding: 13px 18px; }

  .streak-cap { font-size: 10px; }
  .hud-scrim-top { height: calc(var(--sat) + 150px); }
  .hud-scrim-bottom { height: calc(var(--sab) + 96px); }
  .hint-fig { width: 30px; height: 38px; }

  .streak-meter { margin-top: 5px; }
  .rank-chip { margin-top: 6px; padding: 2px 8px 2px 6px; }
  .rank-name { font-size: 11.5px; }
  .over-rank { margin-top: 9px; padding-top: 5px; }
}

/* 極端に低い画面（横持ちの小型端末） */
@media (orientation: landscape) and (max-height: 400px) {
  .brand-jp { font-size: 23px; }
  .howto-item svg { height: 26px; }
  .over-score { font-size: 52px; }
  .sheet-main { padding-top: 12px; padding-bottom: 12px; }
  .howto-title { font-size: 17px; margin-bottom: 6px; }
  .howto-list li { padding: 4px 0; gap: 9px; }
  .howto-fig { width: 46px; height: 30px; }
  .howto-list b { font-size: 12px; }
  .howto-list span { font-size: 10px; }
}

/* 小さい縦画面（iPhone SE など） */
@media (orientation: portrait) and (max-height: 640px) {
  .sheet-main { padding: 16px 18px 4px; }
  .brand-jp { font-size: 30px; }
  .best-card { margin-top: 10px; }
  .howto-strip { margin-top: 12px; }
  .howto-title { margin-bottom: 8px; }
  .howto-list li { padding: 7px 0; gap: 10px; }
  .howto-fig { width: 56px; height: 40px; }
  .howto-list span { font-size: 11px; }
  .over-score { font-size: 58px; }
  .over-rank { margin-top: 10px; }
}

/* 極端に狭い縦画面（320px 級）：HUD の要素を少しだけ詰める */
@media (max-width: 340px) {
  .rank-chip { max-width: 54vw; margin-top: 6px; padding-left: 8px; }
  /* 「役職」の文字は隠すが、読み上げには残す（display:none だと消えてしまう） */
  .rank-cap {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    border: 0; clip-path: inset(50%);
  }
  .best-delta { font-size: 11px; padding: 3px 8px; }
  .best-chip { font-size: 14px; padding: 5px 10px 5px 8px; }
  .streak-meter { width: 64px; }
}

/* 大画面 */
@media (min-width: 900px) and (min-height: 700px) {
  .sheet { width: min(440px, 100%); }
  .streak-value, .streak-prev { font-size: 76px; }
}

/* =========================================================
   アクセシビリティ
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .stamp { opacity: .9; transform: rotate(-16deg) scale(1); }
  .stamp:not(.on) { opacity: 0; }
  .swipe-hint { opacity: .92; }
  /* アニメーションの終端が「消えた状態」になるものは静止形を用意する */
  .hint-fig .hc { opacity: .9; }
  .hint-fig .hc1 { opacity: 1; }
  .fig-finger { opacity: 1; }
  .loader-bar i { width: 100%; background: var(--mint); opacity: .55; }
  /* 動きは無くすが、得点フィードバックは残す（不透明度だけの変化にする） */
  .callout.show {
    animation-name: calloutFade !important;
    animation-duration: 1.1s !important;
    transform: none;
  }
  .popup {
    animation-name: popupFade !important;
    animation-duration: 1.1s !important;
    transform: translate(-50%, -78%);
  }
  .streak-num.roll .streak-prev, .streak-num.pop .streak-prev { opacity: 0; }
  .streak-burst { display: none; }
}

@media (prefers-contrast: more) {
  .best-delta, .streak-cap { color: #fff; }
  .guide-desc, .over-reason, .over-best { color: rgba(27, 35, 48, .82); }
  .howto-list span { color: rgba(27, 35, 48, .78); }
  .ghost-btn { border-color: rgba(27, 35, 48, .4); }
  .best-delta { background: rgba(8, 12, 18, .78); border-color: rgba(255, 255, 255, .3); }
  .rank-cap { color: rgba(27, 35, 48, .8); }
  .over-rank-cap { color: rgba(27, 35, 48, .8); }
  .over-rank-name { color: var(--ink); }
  .hud-scrim-top { background: linear-gradient(180deg, rgba(6, 10, 16, .74), rgba(6, 10, 16, .3) 60%, rgba(6, 10, 16, 0)); }
  .hud-scrim-bottom { background: linear-gradient(0deg, rgba(6, 10, 16, .72), rgba(6, 10, 16, .28) 60%, rgba(6, 10, 16, 0)); }
}

/* =========================================================
   全国ランキング（js/ranking.js が生成するオーバーレイ。紙のシートに合わせる）
   ========================================================= */
.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(7, 10, 15, .78);
  font-family: var(--ui);
  animation: fadeIn .2s ease both;
}
.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex; flex-direction: column; gap: 10px;
  padding: 20px 18px;
  border-radius: 20px;
  color: var(--ink);
  background: linear-gradient(168deg, var(--paper-1) 0%, var(--paper-2) 55%, var(--paper-3) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .85) inset,
    0 0 0 1px rgba(60, 50, 30, .16),
    0 26px 60px -20px rgba(0, 0, 0, .85);
  user-select: text; -webkit-user-select: text;
}
.sgr-title { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: .06em; text-align: center; color: var(--ink); }
.sgr-tabs { display: flex; gap: 6px; justify-content: center; }
.sgr-tab {
  border: 1px solid rgba(27, 35, 48, .18); border-radius: 9px;
  padding: 6px 12px; font-size: 13px; font-weight: 800; font-family: inherit;
  background: rgba(255, 255, 255, .55); color: var(--ink-2); cursor: pointer;
}
.sgr-tab-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.sgr-register-msg { margin: 0 0 6px; font-size: 14px; font-weight: 800; text-align: center; color: var(--gold-ink); }
.sgr-form { display: flex; gap: 8px; }
.sgr-name {
  flex: 1; min-width: 0;
  font-size: 16px; font-family: inherit;
  padding: 9px 11px;
  border: 1px solid rgba(27, 35, 48, .28); border-radius: 11px;
  background: #fff; color: var(--ink);
}
.sgr-name:focus { outline: none; border-color: var(--mint-d); box-shadow: 0 0 0 3px rgba(52, 217, 155, .25); }
.sgr-submit {
  border: none; border-radius: 11px;
  padding: 9px 18px; font-size: 15px; font-weight: 800; font-family: inherit;
  color: #04170f;
  background: linear-gradient(180deg, #63e7b0 0%, #26bd86 100%);
  box-shadow: 0 3px 0 var(--mint-d);
  cursor: pointer;
}
.sgr-submit:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--mint-d); }
.sgr-submit:disabled { opacity: .5; cursor: default; transform: none; }
.sgr-error { margin: 4px 0 0; font-size: 12px; font-weight: 700; color: var(--danger-ink); }
.sgr-status { margin: 0; font-size: 13px; font-weight: 700; text-align: center; color: var(--ink-3); }
.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: 7px 9px; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.sgr-row:nth-child(even) { background: rgba(27, 35, 48, .06); }
.sgr-row.sgr-row-me { background: var(--ink); color: #fff; }
.sgr-rank { width: 2em; text-align: right; font-weight: 800; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.sgr-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgr-row-score { font-weight: 800; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.sgr-close {
  border: 1px solid rgba(27, 35, 48, .18); border-radius: 13px;
  padding: 11px; font-size: 14px; font-weight: 800; font-family: inherit;
  background: rgba(255, 255, 255, .55); color: #2c3542; cursor: pointer;
}
.sgr-close:active { background: rgba(255, 255, 255, .85); }

/* ゲームオーバーの紙に差し込まれる登録CTA */
.sgr-cta { margin: 0 0 10px; text-align: center; }
.sgr-cta-msg { margin: 0 0 7px; font-size: 13px; font-weight: 800; color: var(--gold-ink); }
.sgr-cta-btn {
  display: block; width: 100%; min-height: 46px;
  padding: 11px 16px;
  border: none; border-radius: 13px;
  font-size: 14.5px; font-weight: 800; font-family: inherit; letter-spacing: .04em;
  color: #3a2a06;
  background: linear-gradient(180deg, #ffe08a 0%, #f2b93a 100%);
  box-shadow: 0 4px 0 #b77f10, 0 12px 20px -10px rgba(183, 127, 16, .8);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.sgr-cta-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b77f10; }
.sgr-cta-link {
  border: none; background: none; padding: 6px;
  font-size: 13px; font-weight: 700; font-family: inherit;
  color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.sgr-cta-link:hover { color: var(--ink); }

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