/* バウンドブレイカー - Bound Breaker */

:root {
  --color-bg: #0e1420;
  --color-panel: #1a2334;
  --color-cell: #263248;
  --color-line: #384963;
  --color-text: #e6eefc;
  --color-text-dim: #8ba0bf;
  --color-accent: #3edcff;
  --color-accent-hover: #7ae8ff;
  --color-accent-ink: #04252f;
  --color-danger: #ff5f6d;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: calc(100vh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 10px calc(6px + var(--safe-bottom));
  gap: 6px;
}

/* ---------- ヘッダー ---------- */

/* ボタンは共通ヘッダーのメニューへ集約済みで、タイトルだけの帯は縦幅を圧迫するので隠す。
   h1 と共通ヘッダーが押す元ボタンは DOM に残す（見えなくするだけ。#app の flex の流れからも外れる） */
#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 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
  background: linear-gradient(180deg, #b9f4ff, #3edcff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: var(--color-cell);
  color: var(--color-text);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- HUD ---------- */

#hud {
  width: 100%;
  display: flex;
  gap: 6px;
}

.hud-box {
  flex: 1;
  background: var(--color-panel);
  border-radius: 10px;
  padding: 5px 4px;
  text-align: center;
  min-width: 0;
}

.hud-box.hud-main {
  flex: 1.4;
}

.hud-label {
  display: block;
  font-size: 10px;
  color: var(--color-text-dim);
  letter-spacing: 0.08em;
}

.hud-value {
  display: block;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-main .hud-value {
  color: var(--color-accent);
}

/* ---------- ゲーム画面 ---------- */

#game-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#game {
  display: block;
  border-radius: 12px;
  background: #0a0f18;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#btn-speed {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 800;
  background: rgba(62, 220, 255, 0.9);
  color: var(--color-accent-ink);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

#btn-speed:active {
  transform: scale(0.94);
}

/* 発射台が右下のボタンの下に隠れるときだけ左下へ逃がす（js の placeSpeedBtn()） */
#btn-speed.at-left {
  right: auto;
  left: 8px;
}

/* ---------- オーバーレイ共通 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  background: rgba(6, 10, 17, 0.8);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* 遊び方・はじめからの確認は、結果画面（DOM で後ろにある）より手前に出す */
#overlay-howto,
#overlay-confirm {
  z-index: 101;
}

.overlay-box {
  width: min(360px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 16px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}

.start-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #b9f4ff, #3edcff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.start-sub {
  font-size: 13px;
  color: var(--color-text-dim);
  letter-spacing: 0.28em;
  margin-top: -8px;
}

.howto {
  list-style: none;
  text-align: left;
  font-size: 13px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--color-bg);
  border-radius: 10px;
  padding: 12px 14px;
}

.howto strong {
  color: var(--color-accent);
}

.start-best {
  font-size: 14px;
  color: var(--color-text-dim);
}

.start-best span {
  color: var(--color-accent);
  font-weight: 800;
  font-size: 16px;
}

.overlay-title {
  font-size: 24px;
  font-weight: 800;
}

.result-new {
  color: var(--color-accent);
  font-weight: 800;
  font-size: 14px;
  animation: pulse-glow 1.2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

#result-score-row {
  font-size: 44px;
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.result-unit {
  font-size: 18px;
  margin-left: 4px;
  color: var(--color-text-dim);
}

#result-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.rstat {
  flex: 1;
  background: var(--color-bg);
  border-radius: 10px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rstat-label {
  font-size: 10px;
  color: var(--color-text-dim);
}

.rstat span:last-child {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #7ae8ff, #22c8ee);
  color: var(--color-accent-ink);
  box-shadow: 0 4px 14px rgba(62, 220, 255, 0.32);
}

.btn-sub {
  background: var(--color-cell);
  color: var(--color-text);
  font-size: 14px;
  padding: 11px 16px;
}

.btn-danger {
  background: linear-gradient(180deg, #ff7d88, #ee3b4c);
  color: #2d0409;
}

.confirm-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-dim);
}

/* ---------- フッター ---------- */

#footer {
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: var(--color-text-dim);
  line-height: 1.5;
}

#footer a {
  color: var(--color-text-dim);
}

/* ---------- 全国ランキング（SGRanking 共通モジュール） ---------- */

.sgr-hidden {
  display: none !important;
}

.sgr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  background: rgba(6, 10, 17, 0.72);
}

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-panel);
  color: var(--color-text);
  border: 1px solid var(--color-line);
  border-radius: 12px;
  padding: 20px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

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

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

.sgr-tab {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  background: var(--color-cell);
  color: var(--color-text);
  cursor: pointer;
}

.sgr-tab-active {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

.sgr-register-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
}

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

.sgr-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 8px 10px;
  border: 2px solid var(--color-line);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--color-text);
}

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

.sgr-submit {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: bold;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  cursor: pointer;
}

.sgr-submit:hover {
  background: var(--color-accent-hover);
}

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

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

.sgr-status {
  margin: 0;
  font-size: 13px;
  text-align: center;
  color: var(--color-text-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;
}

.sgr-row:nth-child(even) {
  background: var(--color-cell);
}

.sgr-row.sgr-row-me {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

.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;
  flex-shrink: 0;
}

.sgr-close {
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: bold;
  background: var(--color-cell);
  color: var(--color-text);
  cursor: pointer;
}

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

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

.sgr-cta-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: bold;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(62, 220, 255, 0.4);
}

.sgr-cta-link {
  border: none;
  background: none;
  padding: 6px;
  font-size: 13px;
  color: var(--color-text-dim);
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- 横長画面（PC等） ---------- */

@media (min-width: 700px) and (min-height: 700px) {
  #logo { font-size: 24px; }
  .hud-value { font-size: 20px; }
  #footer { font-size: 11px; }
}

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