/* ============================================
   スライドライン (Slide Line)  -  style.css
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-1: #0b1230;
  --bg-2: #131b45;
  --bg-3: #1c1440;
  --panel: rgba(16, 24, 56, 0.72);
  --text: #eaf0ff;
  --text-dim: #93a0c8;
  --accent-1: #4fc3f7;
  --accent-2: #b388ff;
  --accent-3: #ffb74d;
  --danger: #ff5d7a;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 15% -10%, #23306e 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 110%, #3a1c5e 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 55%, var(--bg-3) 100%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

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

/* ---------- HUD ---------- */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 6px;
  flex-wrap: wrap;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.stat .label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.stat .value {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat.main .value {
  font-size: 28px;
  background: linear-gradient(180deg, #fff 20%, #9fd8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 18px rgba(88, 166, 255, 0.35);
}

.btns {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.icon-btn:active { transform: scale(0.92); }

/* ---------- Stage ---------- */
#stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px 10px;
}

#game {
  display: block;
  touch-action: none;
  border-radius: 18px;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.07) inset;
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 28, 0.66);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
  animation: fadeIn 0.35s ease both;
  padding: 20px;
  /* 共通ヘッダー・広告枠に隠れないよう上下に余白を取り、収まらない小さな画面ではスクロールさせる。
     上下を同じ値にして、収まる画面では従来どおり画面の中央に置く */
  padding-block: max(20px, calc(var(--sgh-top, 0px) + 8px), calc(var(--ad-space, 0px) + 8px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* はみ出すときは上端から並べる（align-items: center のままだと上側が切れてスクロールでも見られない） */
.overlay > .panel { margin: auto; }

.overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 34px 28px 30px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  animation: popIn 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes popIn {
  from { transform: scale(0.86) translateY(14px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.logo {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
  margin-bottom: 10px;
}

.logo .t1 {
  background: linear-gradient(120deg, #6ad2ff, #4fc3f7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo .t2 {
  background: linear-gradient(120deg, #c7a5ff, #ffb74d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 22px;
}

.rules {
  list-style: none;
  text-align: left;
  margin: 0 auto 26px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rules li {
  font-size: 13.5px;
  font-weight: 700;
  color: #c9d4f2;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 9px 12px;
}

.rules .ico { font-size: 17px; }

.btn-primary {
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #081020;
  background: linear-gradient(120deg, #6ad2ff 0%, #4fc3f7 45%, #b388ff 100%);
  border: none;
  border-radius: 999px;
  padding: 14px 44px;
  cursor: pointer;
  box-shadow:
    0 10px 26px rgba(79, 195, 247, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.25) inset;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 14px 32px rgba(79, 195, 247, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
}

.btn-primary:active { transform: translateY(1px) scale(0.97); }

.over-title {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 20px;
  background: linear-gradient(120deg, #ff8fa5, #ff5d7a);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result {
  display: flex;
  justify-content: center;
  gap: 34px;
  margin-bottom: 16px;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-item .label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}

.result-item .big {
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.new-record {
  font-size: 15px;
  font-weight: 800;
  color: #ffe66d;
  margin-bottom: 14px;
  animation: bounce 0.9s ease infinite;
}

.new-record.hidden { display: none; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.over-title + .result { margin-top: 4px; }

#overOverlay .btn-primary { margin-top: 6px; }

/* ---------- Title footer ---------- */
.title-footer {
  margin-top: 20px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.title-footer .footer-version { opacity: 0.85; }

/* 背の低い画面では、著作表記（日本版へのリンクつき）が 2 行に折れるぶんだけ余白を詰める（タイトル画面が上下にはみ出さないように） */
@media (max-height: 700px) {
  .title-footer { margin-top: 6px; gap: 1px; }
}

.title-footer a {
  color: #c9d4f2;
  text-decoration: none;
}

.title-footer a:hover { text-decoration: underline; }

/* ---------- Small screens ---------- */
@media (max-width: 420px) {
  .hud-group { gap: 10px; }
  .stat.main .value { font-size: 24px; }
  .stat .value { font-size: 16px; }
  .logo { font-size: 34px; }
  .icon-btn { width: 34px; height: 34px; }
}

/* ---------- ランキングボタン（タイトル） ---------- */
.btn-ranking {
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 10px 28px;
  margin-top: 12px;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
}

.btn-ranking:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-ranking:active { transform: translateY(1px) scale(0.97); }

/* ---------- 全国ランキング（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 + env(safe-area-inset-bottom, 0px));
  background: rgba(6, 10, 28, 0.72);
}

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  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: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
}

.sgr-tab-active {
  background: var(--accent-1);
  color: #081020;
}

.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 rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

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

.sgr-submit {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: bold;
  background: var(--accent-1);
  color: #081020;
  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(--danger);
}

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

.sgr-row.sgr-row-me {
  background: var(--accent-1);
  color: #081020;
}

.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: rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
}

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

.sgr-cta-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  color: #ffe66d;
}

.sgr-cta-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(120deg, var(--accent-3) 0%, #ff9e40 100%);
  color: #081020;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 183, 77, 0.45);
}

.sgr-cta-link {
  border: none;
  background: none;
  padding: 6px;
  font-size: 13px;
  color: inherit;
  text-decoration: underline;
  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; }
}
