/* ===== 色・余白のトークン（落ち着いた配色。強調色は1色に絞る） ===== */
:root {
  --bg: #f5f3ef;
  --bg2: #f5f3ef;
  --card: #ffffff;
  --ink: #1f2328;
  --ink-soft: #6a6f76;
  --line: #e2ded6;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --pop: #1f3a5f;
  --ok: #2f7d5b;
  --ok-soft: #e9f3ee;
  --miss: #b0413e;
  --miss-soft: #f8ecea;
  --gold: #a07c2c;
  --shadow: 0 1px 2px rgba(31, 35, 40, 0.06);
  --radius: 10px;
  --E: 0;
  --font-head: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --font-num: 'Inter', 'Noto Sans JP', sans-serif;
  --font-body: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  /* 英文は試験問題に近い見た目にするため明朝系 */
  --font-en: 'Source Serif 4', 'Times New Roman', 'Noto Serif JP', serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #15171a;
    --bg2: #15171a;
    --card: #1e2125;
    --ink: #e8e6e1;
    --ink-soft: #9a9fa6;
    --line: #2f3338;
    --brand: #8fb0d8;
    --brand-ink: #10161f;
    --pop: #8fb0d8;
    --ok: #6cc29a;
    --ok-soft: #1c2e26;
    --miss: #e08a85;
    --miss-soft: #33211f;
    --gold: #d2b26a;
    --shadow: none;
    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;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  -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: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.4; margin: 0 0 8px; letter-spacing: 0.01em; }
h2 { font-size: 16px; }

/* ===== ヘッダー ===== */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.topbar__logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.topbar__name { font-family: var(--font-head); font-weight: 700; font-size: 18px; letter-spacing: 0.08em; }
.topbar__spacer { flex: 1; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 18px; cursor: pointer; display: grid; place-items: center;
}

/* ===== ボタン ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 500; font-size: 16px;
  cursor: pointer; text-decoration: none;
  transition: opacity 0.1s ease;
}
.btn:active { opacity: 0.8; }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--pop { background: var(--brand); color: var(--brand-ink); }
.btn--gold { background: var(--gold); color: #fff; }
.btn--ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: default; }

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

/* ===== ダイアログ ===== */
.dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(92vw, 420px);
  background: var(--card); color: var(--ink);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.dialog::backdrop { background: rgba(15, 17, 20, 0.4); }
/* showModal が使えない端末では、画面中央に固定して最前面に出す */
.dialog--fallback { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 100; margin: 0; }
.dialog__title { font-size: 18px; }
.dialog__msg { font-size: 16px; font-weight: 500; 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: 500; }
.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: 22px; height: 22px; 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: 40%; z-index: 60; pointer-events: none;
  transform: translate(-50%, -50%);
  font-family: var(--font-head); font-weight: 700; font-size: clamp(18px, 5vw, 24px);
  color: var(--brand-ink); background: var(--brand);
  padding: 10px 22px; border-radius: 8px; white-space: nowrap;
  animation: banner 1.2s ease forwards;
}
.fx-banner--perfect { background: var(--ok); color: #fff; }
.fx-banner--section { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.fx-banner.is-still { animation: fade 1.2s linear forwards; }
@keyframes banner {
  0% { transform: translate(-50%, -40%); opacity: 0; }
  20% { transform: translate(-50%, -50%); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -55%); 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-weight: 600; font-size: 18px; color: var(--ok);
}

.is-bump { animation: bump 0.25s ease; }
@keyframes bump { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }

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

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

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

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