/* ============================================================
   エアホッケー - style.css
   ============================================================ */

:root {
  --bg: #070d1a;
  --bg-deco: #0d1830;
  --ink: #eaf2ff;
  --ink-soft: #8fa2c0;
  --card: #101c33;
  --line: #1f3357;
  --cyan: #3fd2ff;
  --p1: #ff5a7a;
  --p2: #39b7ff;
  --accent: #ffd94a;
  --shadow: 0 6px 20px rgba(0, 0, 0, .45);
  --radius: 18px;
}

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

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--bg-deco) 9%, transparent 10%),
    radial-gradient(var(--bg-deco) 9%, transparent 10%);
  background-size: 44px 44px;
  background-position: 0 0, 22px 22px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  animation: screen-in .3s ease both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.hidden { display: none !important; }

/* ---------- ボタン共通 ---------- */

.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 12px 24px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  box-shadow: var(--shadow);
}

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

.btn-big {
  width: 100%;
  font-size: 18px;
  padding: 15px 24px;
}

.btn-primary {
  background: linear-gradient(135deg, #29b6f0, #1f7de0);
  border-color: transparent;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  box-shadow: none;
  color: var(--ink-soft);
}

.btn-mode {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.btn-mode-icon { font-size: 26px; }
.btn-mode-text { flex: 1; }

.icon-btn {
  font-family: inherit;
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn:active { transform: scale(.94); }
.icon-btn.is-off { opacity: .45; }

/* ---------- タイトル画面 ---------- */

/* 設定パネルや「遊び方」を開いて縦に収まらないときは、この中でスクロールさせる。
   justify-content: center のままだと上下に均等にはみ出し、ロゴと見出しが
   共通ヘッダーの下に隠れて戻せなかった（下端も広告の裏に入っていた）。
   収まるときは .title-inner（flex: 1）が余白を吸収するので見た目は変わらない */
#screen-title {
  justify-content: flex-start;
  overflow-y: auto;
}

.title-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 340px;
  gap: 14px;
}

.title-logo { width: 110px; filter: drop-shadow(0 0 18px rgba(63, 210, 255, .35)); }
.title-logo svg { width: 100%; height: auto; display: block; }

.title-jp {
  font-size: 34px;
  letter-spacing: .12em;
  text-shadow: 0 0 22px rgba(63, 210, 255, .45);
}

.title-desc {
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.7;
}

.menu-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.config-group { display: flex; flex-direction: column; gap: 8px; }

.config-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.config-note {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.7;
}

.seg {
  display: flex;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.seg-btn {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 9px 0;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.seg-btn.is-active {
  background: linear-gradient(135deg, #29b6f0, #1f7de0);
  color: #fff;
}

/* ---------- 遊び方 ---------- */

.howto {
  width: 100%;
  margin-top: 6px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
}

.howto summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 4px 0;
}

.howto[open] summary { color: var(--ink); }

.howto ul {
  margin: 8px 0 6px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink-soft);
  line-height: 1.6;
}

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

.footer {
  margin-top: 14px;
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.8;
}

.footer a { color: inherit; }

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

.screen-game {
  padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  gap: 8px;
  animation: none;
}

#game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#game-mode-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

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

#table {
  display: block;
  border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(63, 210, 255, .25), 0 0 34px rgba(63, 210, 255, .18), var(--shadow);
  touch-action: none;
}

/* ---------- 結果オーバーレイ ---------- */

#result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, .72);
  display: grid;
  place-items: center;
  z-index: 30;
  animation: overlay-in .25s ease both;
  padding: 20px;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#result-panel {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: panel-in .3s cubic-bezier(.2, 1.4, .4, 1) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: none; }
}

#result-emoji { font-size: 44px; }

#result-text {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}

#result-sub {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-soft);
}

.result-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

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