:root {
  /* パッケージ準拠: 左＝ピンク（恋）、右＝ネイビー（ヤンキー） */
  --bg: #110d22;
  --surface: #1e1838;
  --surface2: #2a2248;
  --line: #3b3160;
  --text: #f6f1fa;
  --muted: #a69cc2;
  --pink: #ff4fa3;      /* ネオンピンク（主アクセント） */
  --pink-deep: #e0187a; /* 帯・ボタン */
  --on-pink: #fff;
  --blue: #6f9bff;      /* ネオンブルー（副アクセント） */
  --blue-deep: #2b4fc9;
  --chain: #e8c46a;     /* ロゴ下のチェーン */
  --red: #ff4d5e;
  --neon-pink: 0 0 4px #ff4fa3, 0 0 12px #ff4fa3, 0 0 28px #e0187a;
  --neon-blue: 0 0 4px #6f9bff, 0 0 12px #4a7bff;
  --radius: 12px;
  --display: "Dela Gothic One", "Hiragino Sans", sans-serif;
  --script: "Zen Kurenaido", "Hiragino Maru Gothic ProN", sans-serif;
  --serif: "Shippori Mincho B1", "Hiragino Mincho ProN", serif;
  --body: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
  /* 画面幅に比例する単位（1u＝画面幅の1%、最大4.8px＝幅480px）。
     文字・余白をこの単位で指定し、どの端末でも同じ位置で改行・同じ見た目になるようにする */
  --u: min(1vw, 4.8px);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-weight: 500;
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
/* 画面下の固定操作エリアの高さぶん余白をとる（--dock-h は JS で設定） */
body { padding-bottom: var(--dock-h, 0px); }
body.modal-open { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
small { font-size: .78em; color: var(--muted); font-weight: 500; }

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 8px calc(var(--u) * 4.27) 32px;
}

.app-header { display: flex; justify-content: flex-end; height: 44px; align-items: center; }
.icon-btn {
  background: var(--surface);
  border: none;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- ボタン ---------- */
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 28px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.btn {
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 15px 18px;
  font-weight: 900;
  font-size: 16px;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--pink-deep); color: var(--on-pink); }
.btn-secondary { background: transparent; border-color: var(--blue); color: var(--text); }
.btn-accent { background: var(--blue-deep); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-text { background: none; color: var(--muted); font-weight: 700; padding: 10px; }
.btn-text.danger { color: #ff7285; }
.btn-chip { background: var(--surface); padding: 10px 6px; font-size: 14px; }

/* ---------- タイトル ---------- */
/* パッケージと同じ左右2色の背景（グラデーションではなくベタ塗りの境目） */
body.on-title { background: linear-gradient(90deg, #3d0c2c 50%, #0e1a46 50%); }
.hero { text-align: center; padding: 40px 0 8px; }
/* ロゴは画像素材（img/logo.png）。キャッチ・鎖・読み仮名も画像に含まれる */
.logo { margin: 0; line-height: 0; }
.logo img { display: block; width: 100%; max-width: 380px; height: auto; margin: 0 auto; }
.hero-lead {
  display: inline-block;
  margin: 28px 0 0;
  padding: 6px 14px;
  background: var(--pink-deep);
  color: #fff;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: .04em;
}

/* ---------- セットアップ ---------- */
.screen-title { font-size: 24px; font-weight: 900; margin: 8px 0 20px; }
.field { margin-bottom: 24px; }
.field-label { display: block; font-weight: 900; margin-bottom: 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  flex: 1 0 48px;
  background: var(--surface);
  border: none;
  border-radius: 10px;
  padding: 10px 0;
  font-weight: 700;
}
.seg-btn.on { background: var(--pink); color: var(--on-pink); }
.name-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: n; }
.name-list li { display: flex; align-items: center; gap: 10px; counter-increment: n; }
.name-list li::before {
  content: counter(n);
  width: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px; font-weight: 900;
  flex: none;
}
input[type="text"], textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
input:focus, textarea:focus { outline: none; border-color: var(--pink); }
textarea { resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  --c: var(--pink);
  background: var(--surface);
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.chip.on { background: var(--c); color: #fff; }

/* ---------- ラウンド ---------- */
.round-info { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin: 0 0 12px; }
.ri-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex; flex-direction: column; justify-content: center;
}
.ri-label { font-size: 11px; font-weight: 900; letter-spacing: .12em; color: var(--muted); }
.ri-val { font-size: 15px; font-weight: 900; color: var(--muted); line-height: 1.2; }
.ri-val b { font-size: calc(var(--u) * 8); color: var(--text); }
.ri-parent { border: 2px solid var(--blue); min-width: 0; }
.ri-name { font-size: calc(var(--u) * 6.9); font-weight: 900; color: var(--blue); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round-guide { margin: 0 0 12px; text-align: center; font-size: 15px; font-weight: 700; }
.round-actions { margin-top: 16px; }
.rules-tabs { margin-bottom: 12px; flex: none; }
.rules-btn { border: 1px solid var(--pink); color: var(--text); font-weight: 900; padding: 5px 16px; }
.rules-tabs .seg-btn { background: var(--surface2); }
.rules-tabs .seg-btn.on { background: var(--pink-deep); color: #fff; }
.rules ol { margin: 0; }

/* ---------- シチュエーションカード（ラブフレーザーのカード構成に準拠） ---------- */
.topic-card {
  --card-head: #2e2a72; /* 背景（濃紺）と区別がつくよう明るめの藍色 */
  --card-body: #ff5fae;
  --card-ink: #17122e;
  display: flex; flex-direction: column;
  /* 高さは内容に合わせる（余白を作らない）。角丸は各パーツ側でつける */
  border-radius: 16px;
  background: var(--card-body);
  color: var(--card-ink);
}
.tc-head { border-radius: 16px 16px 0 0; }
.topic-card.flip { animation: fade .3s ease-out; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* 上部（濃紺）: シチュエーション・2人の関係・ヒアリング例 */
.tc-head { background: var(--card-head); color: #fff; padding: calc(var(--u) * 3.2) calc(var(--u) * 2.67); }
.tc-situation {
  margin: 0 0 8px;
  font-size: 28px; font-weight: 900; line-height: 1.35;
  text-align: center;
  white-space: nowrap; /* 常に1行。長いときは JS で文字を小さくする */
  overflow: hidden;
}
.tc-situation::after { content: ""; display: block; width: 72%; height: 3px; margin: 4px auto 0; background: var(--pink); }
.tc-row { display: flex; align-items: flex-start; gap: calc(var(--u) * 2.67); margin-top: calc(var(--u) * 2.13); }
.tc-pill {
  flex: none;
  border: 1px solid #fff;
  border-radius: 999px;
  padding: 1px calc(var(--u) * 2.13);
  font-size: calc(var(--u) * 2.67); font-weight: 900;
  white-space: nowrap;
  margin-top: 2px;
}
.tc-rel { flex: 1; border-collapse: separate; border-spacing: 4px 2px; margin: -2px -4px; }
.tc-rel th { font-size: calc(var(--u) * 2.93); font-weight: 900; color: #fff; line-height: 1.3; }
.tc-rel td { background: #fff; color: var(--card-ink); font-size: calc(var(--u) * 3.47); font-weight: 900; text-align: center; padding: 2px 4px; width: 50%; }
.tc-hearing { flex: 1; min-width: 0; margin: 0; font-size: 13px; font-weight: 700; line-height: 1.6; }

/* 下部（ピンク）: 親が読むセリフ（最優先で大きく） → 回答者の「???」 → お題 */
.tc-main { display: flex; flex-direction: column; padding: calc(var(--u) * 3.2) calc(var(--u) * 3.73) calc(var(--u) * 3.73); border-radius: 0 0 16px 16px; }
.tc-bubble {
  margin: 0;
  background: #fff;
  border: 2px solid var(--card-ink);
  border-radius: 20px;
  padding: calc(var(--u) * 3.73) calc(var(--u) * 4.27);
  font-size: calc(var(--u) * 5.6); font-weight: 900; line-height: 1.55;
  text-align: center;
  white-space: pre-line;
}
.tc-who {
  flex: none;
  background: var(--card-ink); color: #fff;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: calc(var(--u) * 2.93); font-weight: 900;
  align-self: flex-start;
  margin-bottom: 4px;
}
.tc-who-reply { margin-top: 12px; }
.tc-odai {
  margin: 0;
  background: var(--card-ink); color: #fff;
  border-radius: 28px;
  padding: calc(var(--u) * 3.2) calc(var(--u) * 4.27);
  text-align: center;
  font-size: calc(var(--u) * 4); font-weight: 900; line-height: 1.6;
  white-space: pre-line;
}

/* ---------- 結果 ---------- */
[data-screen="result"] { text-align: center; }
.result-sub { color: var(--muted); letter-spacing: .3em; margin: 24px 0 0; font-size: 13px; }
.result-title { font-size: 24px; font-weight: 900; margin: 4px 0 8px; }
.winner span { text-shadow: var(--neon-pink); color: #ffe3f1; }
.winner {
  font-size: 36px;
  font-weight: 900;
  color: var(--pink);
  margin: 0 0 24px;
  display: flex; flex-direction: column; gap: 4px;
}
.ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; text-align: left; }
.ranking li {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 16px;
}
.ranking li.first { background: var(--pink); color: var(--on-pink); }
.ranking li.first .rk, .ranking li.first small { color: inherit; }
.ranking .rk { width: 40px; color: var(--muted); font-weight: 900; }
.ranking .nm { flex: 1; font-weight: 900; font-size: 17px; }
.ranking .pt { font-size: 22px; font-weight: 900; }
.history { margin-top: 20px; text-align: left; background: var(--surface); border-radius: 10px; padding: 10px 14px; }
.history summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.history ol { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 10px; }
.history li { border-top: 1px solid var(--line); padding-top: 10px; font-size: 14px; }
.h-meta { color: var(--muted); font-size: 12px; }
.h-win { color: var(--pink); font-weight: 900; }

/* ---------- 画面下の固定エリア（主操作＋得点） ---------- */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 12px calc(8px + var(--safe-b));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.score-panel { background: var(--surface); border-radius: 12px; }
.score-handle {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: none; border: none;
  padding: 10px 14px;
  min-height: 44px;
  font-size: 13px;
}
.score-summary { flex: 1; min-width: 0; text-align: left; color: var(--muted); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-open { flex: none; font-weight: 900; color: var(--text); white-space: nowrap; }
.score-caret { color: var(--muted); transition: transform .2s; font-size: 11px; display: inline-block; }
.score-panel.open .score-caret { transform: rotate(180deg); }
.score-body { display: none; padding: 14px 12px 4px; }
.score-panel.open .score-body { display: block; }
.score-title { margin: 0 0 8px; font-weight: 900; }
.score-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 50dvh; overflow-y: auto; }
.score-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-list li {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 6px 8px 6px 12px;
}
.score-name {
  flex: 1; min-width: 0; text-align: left;
  display: flex; align-items: center;
  background: none; border: none; padding: 6px 0;
  font-weight: 900; font-size: 16px;
}
.tag { flex: none; font-size: 11px; background: var(--blue-deep); color: #fff; padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
.score-adj {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  font-size: 18px; font-weight: 900;
}
.score-val { flex: none; font-size: 20px; font-weight: 900; min-width: 32px; text-align: center; }
.score-foot { display: flex; justify-content: space-between; }

/* ---------- モーダル ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); }
.modal-box {
  position: relative;
  width: 100%; max-width: 440px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
}
.modal-box.tall { height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.modal-box.tall .modal-content { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head .icon-btn { background: var(--surface2); }
.modal-title { margin: 0 0 12px; font-size: 18px; font-weight: 900; }
.modal-head .modal-title { margin: 0; }
.modal-title small { margin-left: 8px; }
.modal-msg { font-size: 16px; text-align: center; margin: 8px 0 20px; line-height: 1.8; }
.modal-msg b { color: var(--pink); }
.modal-content .btn-row { margin-top: 16px; }
.modal-content input[type="text"], .modal-content textarea { background: var(--bg); }

.topic-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 6px; align-content: start;
  overflow-y: auto; flex: 1; min-height: 0;
}
.topic-item {
  width: 100%;
  text-align: left;
  background: var(--surface2);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.5;
  display: block;
}
button.topic-item:active { background: var(--line); }
.topic-item.used { opacity: .45; }
.list-filters { flex: none; display: grid; gap: 8px; margin-bottom: 10px; }
.list-filters .chip { background: var(--surface2); }
.list-filters .chip.on { background: var(--pink-deep); color: #fff; }
.chip.toggle { justify-self: start; border: 1px solid var(--blue); color: var(--text); }
.chip.toggle::before { content: "□ "; }
.chip.toggle.on { background: var(--blue-deep); border-color: var(--blue-deep); }
.chip.toggle.on::before { content: "✓ "; }
.topic-none { color: var(--muted); text-align: center; padding: 24px 0; }
.ti-cat { display: block; font-size: 11px; font-weight: 900; color: var(--pink); }
.ti-situation { display: block; font-size: 15px; font-weight: 900; }
.ti-text { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.ti-used { font-size: 11px; margin-left: 8px; color: var(--muted); }

.rules { overflow-y: auto; font-size: 15px; }
.rules ol { padding-left: 1.3em; display: grid; gap: 10px; }
.rules b, .rules strong { color: var(--pink); }
.roles { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; background: var(--surface2); border-radius: 10px; padding: 10px 12px; margin: 0; }
.roles dt { font-weight: 900; color: var(--blue); }
.roles dd { margin: 0; }
.love-hint { display: block; margin-top: 6px; padding: 6px 10px; background: var(--surface2); border-radius: 8px; font-size: 13px; color: var(--muted); }
/* ルールの画像と見出し（画像は img/rules/） */
.rules-sec { margin: 0 0 22px; }
.rules-sec h4 { margin: 0 0 10px; padding-left: 8px; border-left: 3px solid var(--pink); font-size: 16px; font-weight: 900; color: var(--text); }
.rules-sec p { margin: 8px 0 0; }
.rules-fig { margin: 10px auto 0; text-align: center; }
.rules-fig img { display: block; width: 100%; height: auto; margin: 0 auto; }
.rules-fig figcaption { margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.rules-fig-hero img { max-width: 280px; border-radius: 8px; }
.rules-fig-mid img { max-width: 150px; }
.rules-fig-small img { max-width: 70px; }
.fig-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; margin-top: 10px; }
.fig-pair .rules-fig { margin: 0; }
.fig-pair .rules-fig img { max-width: 140px; }
.fig-pair .rules-fig-small img { max-width: 70px; }
.fig-note { margin: 0; align-self: center; font-size: 13px; color: var(--muted); }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%; top: 20px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--pink); color: var(--on-pink);
  font-weight: 900;
  padding: 10px 20px;
  border-radius: 999px;
  white-space: nowrap;
}
.toast.show { animation: toast 1.8s ease forwards; }
@keyframes toast {
  0% { opacity: 0; }
  12%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 360px) {
  .hero-lead { font-size: 18px; }
}

/* ---------- お題の改行位置 ----------
   topics.js の文節区切り（​）でだけ改行し、単語の途中で折り返さない。
   長すぎる文節だけは最後の手段として途中で折り返す。行の長さもなるべく揃える。 */
.tc-situation, #tc-text, .tc-odai, .tc-hearing,
.ti-situation, .ti-text, .h-topic {
  word-break: keep-all;
  overflow-wrap: anywhere;
}
#tc-text, .tc-odai { text-wrap: balance; }

/* ---------- タイマー ---------- */
.timer-display {
  margin: 4px 0 0;
  text-align: center;
  font-size: calc(var(--u) * 17);
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.timer-display.warn { color: var(--pink); }
.timer-btns { justify-content: center; }
.btn-mute { background: var(--surface2); color: var(--muted); }
/* 時間切れで画面を点滅させる */
body.flash::after {
  content: "";
  position: fixed; inset: 0;
  z-index: 40;
  pointer-events: none;
  background: var(--pink);
  animation: flash .5s ease-in-out 3;
  opacity: 0;
}
@keyframes flash { 50% { opacity: .55; } }
/* タイマー終了後の得点案内（常に1行） */
.done-guide {
  margin: 0;
  text-align: center;
  white-space: nowrap;
  font-size: calc(var(--u) * 3.9);
  font-weight: 900;
  color: var(--pink);
}
