/* ===== 色・余白のトークン ===== */
:root {
  --bg: #fff8ec;
  --bg2: #ffeef6;
  --card: #ffffff;
  --ink: #1e1b3a;
  --ink-soft: #5b5775;
  --line: #ece4d6;
  --brand: #2f6bff;
  --brand-ink: #ffffff;
  --pop: #ff6fa8;
  --ok: #1dbf73;
  --ok-soft: #e3f8ee;
  --miss: #8b5cf6;
  --miss-soft: #f1ebff;
  --gold: #ffc233;
  --shadow: 0 6px 0 rgba(30, 27, 58, 0.12);
  --radius: 18px;
  --E: 0;
  /* 日本語の見出しは丸ゴシックの極太。Dela Gothic One は小さいと日本語がつぶれるので数字・英字だけに使う */
  --font-head: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', sans-serif;
  --font-num: 'Dela Gothic One', 'Zen Maru Gothic', sans-serif;
  --font-body: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1b1a2e;
    --bg2: #241f3d;
    --card: #26254a;
    --ink: #f4f1ff;
    --ink-soft: #b9b4d6;
    --line: #3a3864;
    --brand: #6e95ff;
    --brand-ink: #10112a;
    --pop: #ff8bbb;
    --ok: #3ddc8e;
    --ok-soft: #1d3b33;
    --miss: #a78bfa;
    --miss-soft: #2f2852;
    --gold: #ffd166;
    --shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

/* スマホ：引っぱって再読み込みでテストが消えないようにする。文字サイズの自動拡大もしない */
html { overscroll-behavior-y: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* スマホ：連打でダブルタップ拡大しない・長押しで文字選択しない */
button, a, .chip, .choice { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  /* color-mix 非対応の古い端末（iOS 16.2 未満など）向けの背景。対応端末では下の指定で上書きされる */
  background: linear-gradient(180deg, var(--bg), var(--bg2));
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--pop) calc(var(--E) * 30%), transparent) 0, transparent 45%),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, var(--brand) calc(var(--E) * 30%), transparent) 0, transparent 45%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); }

.wrap { max-width: 680px; margin: 0 auto; padding: 16px 16px 48px; }

.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.center { text-align: center; }
.hidden { display: none !important; }

h1, h2, h3 { font-family: var(--font-head); font-weight: 900; line-height: 1.35; margin: 0 0 8px; letter-spacing: 0.02em; }

/* ===== ヘッダー ===== */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.topbar__logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.topbar__logo img { width: 44px; height: 44px; }
.topbar__name { font-family: var(--font-head); font-weight: 900; font-size: 22px; letter-spacing: 0.02em; }
.topbar__spacer { flex: 1; }

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

/* ===== ボタン ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 22px;
  border-radius: 999px; border: 0;
  font: inherit; font-weight: 700; font-size: 17px;
  cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(30, 27, 58, 0.12); }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--pop { background: var(--pop); color: #fff; }
.btn--gold { background: var(--gold); color: #3a2a00; }
.btn--ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: default; transform: none; }

/* ===== カード ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* ===== ダイアログ ===== */
.dialog {
  border: 0; border-radius: 22px; padding: 22px; width: min(92vw, 420px);
  background: var(--card); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.dialog::backdrop { background: rgba(20, 18, 40, 0.45); }
/* showModal が使えない端末では、画面中央に固定して最前面に出す */
.dialog--fallback { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 100; margin: 0; }
.dialog__title { font-size: 22px; }
.dialog__msg { font-size: 18px; font-weight: 700; margin: 4px 0 18px; }
.dialog__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

.field { display: grid; gap: 6px; margin: 14px 0; font-weight: 700; }
.field--row { display: flex; justify-content: space-between; align-items: center; }
.field input[type='range'] { width: 100%; accent-color: var(--brand); }
.field input[type='checkbox'] { width: 26px; height: 26px; accent-color: var(--brand); }

/* ===== 演出 ===== */
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

.fx-banner {
  position: fixed; left: 50%; top: 38%; z-index: 60; pointer-events: none;
  transform: translate(-50%, -50%);
  font-family: var(--font-head); font-weight: 900; font-size: clamp(40px, 12vw, 76px);
  color: #fff; white-space: nowrap;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--pop);
  animation: banner 1.25s cubic-bezier(.2,1.4,.4,1) forwards;
}
.fx-banner--perfect { color: var(--gold); text-shadow: 0 6px 0 var(--brand); }
.fx-banner--section { font-size: clamp(26px, 7vw, 40px); text-shadow: 0 4px 0 var(--brand); }
.fx-banner.is-still { animation: fade 1.25s linear forwards; }
@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-8deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1); opacity: 0; }
}
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

.fx-float {
  position: fixed; z-index: 61; pointer-events: none;
  transform: translate(-50%, -50%);
  font-family: var(--font-num); font-size: 30px; color: var(--ok);
  -webkit-text-stroke: 2px #fff; paint-order: stroke fill;
}

.is-bump { animation: bump 0.35s cubic-bezier(.2,1.6,.4,1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* 演出レベル3：画面のふちの電飾 */
html[data-level='3'] body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  border: 10px solid transparent;
  border-image: repeating-linear-gradient(90deg, var(--gold) 0 14px, var(--pop) 14px 28px, var(--brand) 28px 42px) 10;
  opacity: 0.85;
  animation: lights 0.8s steps(3) infinite;
}
@keyframes lights { 50% { filter: hue-rotate(120deg); } }

html[data-motion='off'] *, html[data-motion='off'] *::after { animation: none !important; transition: none !important; }

/* ===== マスコット ===== */
.mascot { width: 72px; height: 72px; }
.mascot.is-hop { animation: hop 0.5s ease; }
@keyframes hop { 30% { transform: translateY(-14px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }

/* ===== 入力 ===== */
.text-input {
  width: 100%; min-height: 56px; padding: 10px 16px;
  border-radius: 14px; border: 3px solid var(--line);
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 22px; font-weight: 700;
}
.text-input:focus { outline: none; border-color: var(--brand); }

.error { color: var(--miss); font-weight: 700; min-height: 1.6em; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
