/* =========================================================
 * タクシーシミュレーター（taxi） スタイル
 * ========================================================= */
: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: #1c2230;
  --c-dim: #6a7387;
  --c-accent: #e89a10;
  --c-accent-deep: #b56a00;
  --c-gold: #ffd35a;
  --c-gold-deep: #f0a51e;
  --c-panel: rgba(250, 251, 255, 0.97);
  --c-line: rgba(28, 34, 48, 0.14);
  --c-glass: rgba(10, 14, 24, 0.72);
}

* { 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: #0b1020;
  -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); touch-action: manipulation; }
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: #0b1020;
}
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ===== 運転中の表示 ===== */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; color: #fff; }
#hud-left { position: absolute; left: max(8px, env(safe-area-inset-left)); top: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
#chips { display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; font-weight: 900; }
#chips span, #chip-limit {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--c-glass);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#chip-sales.minus { color: #ff9a9a; }
.over-sub { flex-wrap: wrap; gap: 2px 10px; }
#chip-time.warn { background: rgba(200, 30, 40, 0.88); animation: pulse 0.7s ease-in-out infinite alternate; }
#chip-limit { font-size: 13px; font-weight: 900; color: #ffe07a; }
#chip-limit:empty { display: none; }
#chip-limit.late { color: #fff; background: rgba(200, 30, 40, 0.88); }
@keyframes pulse { to { transform: scale(1.06); } }

#meter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 9px;
  background: #0a0c10;
  border: 1.5px solid #343a46;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}
#meter-state { padding: 3px 7px; border-radius: 5px; font-size: 13px; font-weight: 900; letter-spacing: 0.1em; }
.st-vacant { color: #fff; background: #d3202c; box-shadow: 0 0 10px rgba(255, 60, 60, 0.7); }
.st-pickup { color: #201400; background: #ffb02a; }
.st-hired { color: #062412; background: #3fe07d; box-shadow: 0 0 10px rgba(60, 230, 120, 0.6); }
.st-pay { color: #fff; background: #2a7fe0; }
#meter-fare { min-width: 4.6em; text-align: right; font-family: var(--font-num); font-size: 19px; font-weight: 800; color: #ffb53a; text-shadow: 0 0 8px rgba(255, 160, 40, 0.65); font-variant-numeric: tabular-nums; }

#sat-row { display: flex; align-items: center; gap: 5px; }
#sat { display: flex; align-items: center; gap: 5px; padding: 3px 9px 3px 5px; border-radius: 999px; background: var(--c-glass); }
#sat-face { font-size: 17px; line-height: 1; }
.sat-bar { display: block; width: 70px; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
#sat-fill { display: block; height: 100%; width: 70%; border-radius: 4px; background: linear-gradient(90deg, #ff6b5a, #ffd24a 50%, #55e08a); background-size: 70px 100%; transition: width 0.3s; }

#hud-right { position: absolute; right: max(8px, env(safe-area-inset-right)); top: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
#minimap { width: 124px; height: 124px; border-radius: 50%; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45); }
#nav { display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px 6px; border-radius: 999px; background: var(--c-glass); max-width: 200px; }
#nav-arrow { display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center; font-size: 17px; color: #ffe07a; transition: transform 0.12s linear; }
.nav-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
#nav-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav-dist { font-size: 11.5px; font-weight: 800; color: #ffe07a; font-variant-numeric: tabular-nums; }

#bubble {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  width: min(430px, calc(100% - 380px));
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px 9px 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--c-text);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
  animation: pop 0.22s ease-out;
}
#bubble.req { border: 2.5px solid #ff9a1f; }
#bubble.sleep { background: rgba(220, 228, 250, 0.95); }
@keyframes pop { from { transform: translateX(-50%) scale(0.85); opacity: 0; } }
#bubble-face, .face { flex: none; width: 40px; height: 40px; border-radius: 50%; background: #e7ebf5; font-size: 26px; line-height: 40px; text-align: center; }
.bubble-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
#bubble-name { font-size: 11px; color: var(--c-dim); }
#bubble-text { font-size: 14.5px; font-weight: 800; line-height: 1.4; }
.bubble-track { display: none; height: 5px; margin-top: 5px; border-radius: 3px; background: rgba(0, 0, 0, 0.12); overflow: hidden; }
#bubble.req .bubble-track { display: block; }
#bubble-bar { display: block; height: 100%; background: #ff9a1f; transform-origin: left center; }

#toast {
  position: absolute;
  left: 50%;
  top: 42%;
  margin: 0;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(10, 14, 24, 0.86);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast.good { background: rgba(20, 120, 70, 0.92); }
#toast.bad { background: rgba(190, 30, 40, 0.92); }

#instr {
  position: absolute;
  left: 50%;
  bottom: calc(172px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 4px 13px;
  border-radius: 999px;
  background: var(--c-glass);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
}
#instr:empty { display: none; }

#speed {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 12px;
  border-radius: 12px;
  background: var(--c-glass);
}
#speed-num { min-width: 1.7em; text-align: right; font-family: var(--font-num); font-size: 21px; font-variant-numeric: tabular-nums; }
#speed span { font-size: 11px; font-weight: 800; opacity: 0.8; }
#speed em { display: none; margin-left: 6px; padding: 1px 7px; border-radius: 999px; border: 2px solid #ff4a4a; background: #fff; color: #111; font-size: 11px; font-weight: 900; font-style: normal; }
#speed.limit em { display: inline-block; }
#speed.over { background: rgba(200, 30, 40, 0.9); }

/* ===== 運転の操作 ===== */
#ctl { position: absolute; left: 0; right: 0; bottom: 0; z-index: 12; padding: 0 max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); pointer-events: none; }
#dash { display: flex; justify-content: center; gap: 5px; margin-bottom: 8px; pointer-events: none; }
.dash-btn {
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 50px;
  padding: 0;
  border-radius: 11px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(16, 20, 30, 0.8);
  color: #dfe5f2;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.dash-btn span { font-size: 19px; line-height: 1.15; }
.dash-btn kbd { display: none; position: absolute; right: 3px; top: 2px; font-family: var(--font-num); font-size: 9px; opacity: 0.6; }
.dash-btn.on { background: #ffcf4a; color: #2a1a00; border-color: #fff3c0; box-shadow: 0 0 14px rgba(255, 200, 60, 0.8); }
.dash-btn:active { transform: scale(0.94); }
#pads { display: flex; justify-content: space-between; align-items: flex-end; }
.pad-group { display: flex; gap: 8px; pointer-events: auto; }
.pad {
  width: 74px;
  height: 74px;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(16, 20, 30, 0.62);
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  cursor: pointer;
  touch-action: none;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.pad-brake, .pad-gas { font-size: 13px; }
.pad-brake { background: rgba(170, 30, 36, 0.66); }
.pad-gas { height: 96px; background: rgba(24, 130, 70, 0.7); }
.pad.down { transform: scale(0.94); filter: brightness(1.5); }
@media (hover: hover) and (pointer: fine) {
  #pads { display: none; }
  .dash-btn kbd { display: block; }
  #instr { bottom: 72px; }
}

/* ===== 車内の場面（会話・起こす・会計・評価） ===== */
.scene-panel {
  position: absolute;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  width: min(440px, calc(100% - 16px));
  max-height: calc(100% - 20px);
  overflow-y: auto;
  padding: 12px 14px 13px;
  border-radius: 18px;
  background: var(--c-panel);
  color: var(--c-text);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
}
.scene-panel > .btn { width: 100%; }
.talk-head { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.talk-head b { font-size: 13px; color: var(--c-dim); }
#talk-text { margin: 0 0 6px; font-size: 16.5px; font-weight: 800; line-height: 1.55; white-space: pre-line; }
#talk-style { margin: 0 0 9px; padding: 5px 10px; border-radius: 9px; background: #fff1cf; color: #6b4300; font-size: 13px; font-weight: 900; }
#talk-style:empty { display: none; }

.wake-title { margin: 0 0 6px; font-size: 15px; font-weight: 900; text-align: center; }
.wake-bar { height: 14px; border-radius: 7px; background: #dfe3ee; overflow: hidden; }
#wake-fill { display: block; height: 100%; width: 0; border-radius: 7px; background: linear-gradient(90deg, #7aa7ff, #ffd24a 70%, #ff8a3a); transition: width 0.1s linear; }
#wake-msg { margin: 6px 0 8px; min-height: 1.5em; font-size: 13.5px; font-weight: 800; text-align: center; }
.wake-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.wake-buttons .btn-primary { grid-column: 1 / -1; padding: 14px; }
.scene-panel .btn-sub { color: var(--c-text); background: #e9ecf4; border: 1px solid var(--c-line); }
.scene-panel .btn-sub:hover { background: #dfe4ef; }
.scene-panel .btn-sub:disabled { opacity: 0.45; }

.pay-rows { border-radius: 12px; background: #0d1018; color: #fff; padding: 7px 10px; }
.pay-row { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: 13px; font-weight: 800; }
.pay-row > span:first-child { flex: none; width: 4.4em; color: #aab3c8; }
.pay-row b { margin-left: auto; font-family: var(--font-num); font-size: 18px; color: #ffb53a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pay-row.tray { margin-top: 4px; padding-top: 6px; border-top: 1px dashed rgba(255, 255, 255, 0.25); min-height: 44px; align-items: flex-start; }
.pay-row.tray b { color: #6ff0a4; }
.money-line { display: flex; flex-wrap: wrap; gap: 3px; flex: 1; min-width: 0; align-items: center; }
#pay-msg { margin: 6px 0; min-height: 2.6em; font-size: 13px; font-weight: 800; line-height: 1.35; text-align: center; }
#pay-msg.bad { color: #c21e2a; }
#pay.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(calc(-50% - 7px)); } 75% { transform: translateX(calc(-50% + 7px)); } }
#pay-drawer { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; padding: 8px 6px; border-radius: 12px; background: #2b2f3a; justify-items: center; align-items: center; }
.bill, .coin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: var(--font-num);
  font-weight: 900;
  cursor: pointer;
  border: none;
  line-height: 1;
}
.bill { width: 54px; height: 30px; border-radius: 3px; font-size: 12px; color: #2b2410; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5), inset 0 0 0 3px rgba(0, 0, 0, 0.15), 0 2px 3px rgba(0, 0, 0, 0.4); }
.b10000 { background: linear-gradient(135deg, #d9c9a0, #b99f6a); }
.b5000 { background: linear-gradient(135deg, #d5bfd8, #a98bb0); }
.b1000 { background: linear-gradient(135deg, #bcd3e0, #86a6ba); }
.b500 { background: linear-gradient(135deg, #cfe0c4, #93ad86); }
.coin { width: 40px; height: 40px; border-radius: 50%; font-size: 12px; color: #33290f; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45), inset 0 -3px 4px rgba(0, 0, 0, 0.25), 0 2px 3px rgba(0, 0, 0, 0.45); }
.c500 { background: radial-gradient(circle at 35% 30%, #f1e7b8, #c9b46a); width: 44px; height: 44px; }
.c100 { background: radial-gradient(circle at 35% 30%, #f1e7b8, #c9b46a); }
/* 50¢: plain silver coin (no hole on the US half-dollar) */
.c50 { width: 38px; height: 38px; font-size: 10px; background: radial-gradient(circle at 35% 30%, #f2f2f2, #9da2a9); }
.c10 { background: radial-gradient(circle at 35% 30%, #eef0f2, #a4a9b0); width: 34px; height: 34px; }
button.bill:active, button.coin:active { transform: scale(0.9); }
.money-line .bill { width: 38px; height: 21px; font-size: 10px; }
.money-line .coin { width: 25px; height: 25px; font-size: 9px; }
.money-line .c500 { width: 27px; height: 27px; }
.money-line .c50 { font-size: 8px; }
.pay-buttons { display: flex; gap: 7px; margin-top: 8px; }
.pay-buttons .btn-sub { flex: 1; }
.pay-buttons .btn-primary { flex: 2; }

#rate-stars { margin: 0; font-size: 30px; letter-spacing: 2px; color: #cfd4e0; line-height: 1; }
#rate-stars .on { display: inline-block; color: #ffb81f; animation: star 0.35s ease-out both; }
@keyframes star { from { transform: scale(2.2) rotate(-30deg); opacity: 0; } }
#rate-say { margin: 4px 0 2px; font-size: 15.5px; font-weight: 800; }
#rate-note { margin: 0 0 6px; font-size: 12.5px; font-weight: 800; color: var(--c-accent-deep); }
#rate-note:empty { display: none; }
.rate-rows { list-style: none; margin: 0 0 9px; padding: 6px 10px; border-radius: 10px; background: #eef1f7; }
.rate-rows li { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 800; padding: 2px 0; }
.rate-rows b { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.rate-rows .total { margin-top: 3px; padding-top: 5px; border-top: 1px solid var(--c-line); font-size: 16px; }
.rate-rows .total b { color: #c8590a; }

/* ===== 画面オーバーレイ共通 ===== */
.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: #0b1020; }
.loading-panel { text-align: center; color: #e6ebf7; 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(6, 8, 18, 0) 34%, rgba(6, 8, 18, 0.84) 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.42em; color: #ffe19a; }
.title-ja { margin: 2px 0 6px; line-height: 1.08; text-shadow: 0 3px 0 #6b3d00, 0 8px 22px rgba(0, 0, 0, 0.7); }
.title-ja .t1 { display: inline-block; font-size: clamp(34px, 10.5vw, 54px); font-weight: 900; letter-spacing: 0.03em; color: var(--c-gold); }
.title-ja .t2 { display: block; font-size: clamp(24px, 7.4vw, 38px); font-weight: 900; color: #fff6dc; }
.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(240, 244, 255, 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: #3a2102;
  font-size: 18px;
  background: linear-gradient(135deg, #ffe07a, #f5a81c);
  box-shadow: 0 6px 18px rgba(214, 138, 14, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-sub { color: #f1f4ff; font-size: 14px; padding: 10px 12px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(220, 230, 255, 0.24); }
.btn-sub:hover { background: rgba(255, 255, 255, 0.16); }

/* ===== 営業終了 ===== */
#screen-over { background: rgba(6, 8, 18, 0.6); align-items: flex-start; }
.over-panel { width: min(440px, 100%); margin: auto 0; padding: 14px 16px 12px; border-radius: 18px; background: var(--c-panel); box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5); }
.over-eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 900; letter-spacing: 0.2em; text-align: center; color: var(--c-dim); }
.over-top { display: flex; align-items: center; gap: 12px; }
.over-rank { flex: none; width: 58px; height: 58px; margin: 0; border-radius: 14px; background: linear-gradient(135deg, #ffe07a, #f5a81c); color: #3a2102; font-size: 36px; font-weight: 900; line-height: 58px; text-align: center; }
.over-main { min-width: 0; }
.over-title { margin: 0; font-size: 15px; font-weight: 900; }
.over-sales-row { margin: 0; font-family: var(--font-num); font-size: 36px; font-weight: 900; color: #c8590a; line-height: 1.15; font-variant-numeric: tabular-nums; }
#over-new { margin: 6px 0 0; font-size: 14px; font-weight: 900; text-align: center; color: #d33a2c; }
.over-sub { display: flex; justify-content: space-around; margin: 8px 0 6px; padding: 6px; border-radius: 10px; background: #eef1f7; font-size: 13px; font-weight: 800; }
.over-sub b { font-size: 15px; }
#over-rows { margin: 0 0 8px; padding: 0; list-style: none; max-height: 132px; overflow-y: auto; }
#over-rows li { display: flex; align-items: center; gap: 6px; padding: 3px 4px; font-size: 12.5px; font-weight: 800; border-bottom: 1px solid var(--c-line); }
#over-rows li span:first-child { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#over-rows .st { color: #f0a51e; font-size: 11px; letter-spacing: 1px; }
#over-rows b { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.over-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.over-buttons .btn-primary { grid-column: 1 / -1; }
.over-panel .btn-sub { color: var(--c-text); background: #e9ecf4; border: 1px solid var(--c-line); }
#over-msg { margin: 6px 0 0; min-height: 1.2em; font-size: 12px; font-weight: 800; text-align: center; color: var(--c-dim); }

/* ===== 一時停止・エラー ===== */
#screen-paused, #gl-error { background: rgba(6, 8, 18, 0.72); cursor: pointer; z-index: 40; }
.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(235, 240, 255, 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(6, 8, 14, 0.66);
}
.modal-box {
  width: min(520px, 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; }
.modal-buttons { display: flex; gap: 8px; }
.modal-buttons .btn { flex: 1; }
.modal .btn-sub { color: var(--c-text); background: #e9ecf4; border: 1px solid var(--c-line); }

/* ===== フッター ===== */
#footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(235, 240, 255, 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-width: 760px) {
  #bubble { top: 176px; width: calc(100% - 16px); }
}
@media (max-width: 760px) and (max-height: 560px) {
  #bubble { top: 6px; width: calc(100% - 330px); }
}
@media (max-width: 400px) {
  #chips { font-size: 12px; }
  #minimap { width: 100px; height: 100px; }
  .dash-btn { width: 52px; }
  #bubble-text { font-size: 13.5px; }
  .pad { width: 68px; height: 68px; }
  .pad-gas { height: 90px; }
}
@media (max-height: 560px) {
  #minimap { width: 92px; height: 92px; }
  #instr { bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%; }
  #speed-num { font-size: 18px; }
  #dash { margin-bottom: -44px; }
  .dash-btn { width: 50px; height: 42px; font-size: 10px; }
  .dash-btn span { font-size: 16px; }
  .pad { width: 66px; height: 66px; }
  .pad-gas { height: 80px; }
  .title-ja .t1 { font-size: 30px; }
  .title-ja .t2 { font-size: 22px; }
  .title-desc { display: none; }
  .scene-panel { left: auto; right: max(8px, env(safe-area-inset-right)); bottom: 8px; transform: none; width: min(380px, 52%); padding: 8px 10px; }
  @keyframes shake { 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
  #talk-text { font-size: 14.5px; }
  .pay-row { min-height: 24px; }
  #pay-msg { min-height: 1.4em; margin: 3px 0; font-size: 12px; }
  #pay-drawer { padding: 4px; }
  .coin { transform: scale(0.86); }
  .scene-panel .btn { padding: 8px 10px; font-size: 14px; }
  #screen-title { align-items: center; justify-content: flex-end; background: linear-gradient(90deg, rgba(6, 8, 18, 0) 34%, rgba(6, 8, 18, 0.86) 76%); }
  .title-panel { width: 320px; }
  .over-panel { padding: 8px 12px; }
  #over-rows { max-height: 60px; }
  .over-rank { width: 44px; height: 44px; font-size: 28px; line-height: 44px; }
  .over-sales-row { font-size: 28px; }
}
@media (max-height: 560px) and (hover: hover) and (pointer: fine) { #dash { margin-bottom: 8px; } }

/* ===== 全国ランキング（共通モジュール 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; }
}
