:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #17202c;
  --ink-2: #4b5768;
  --ink-3: #7c8797;
  --line: #e2e7ee;
  --navy: #142235;
  --accent: #ff8a00;
  --accent-ink: #b85d00;
  --ok: #16a36a;
  --ok-soft: #e3f6ee;
  --ng: #e0413a;
  --ng-soft: #fdeceb;
  --info: #2f6fde;
  --info-soft: #e8f0fd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .08);
  font-family: "BIZ UDPGothic", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; padding-bottom: calc(var(--nb, 44px) + 8px); }
a { color: var(--info); }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* ---- 上部バー ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: inherit; padding: 0; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, #1d1d1d 8px 16px);
  font-weight: 900; letter-spacing: .02em; color: #fff; text-shadow: 0 1px 2px #000;
}
.brand-name { display: flex; flex-direction: column; align-items: flex-start; font-weight: 800; font-size: 17px; line-height: 1.1; }
.brand-name small { font-size: 11px; font-weight: 500; opacity: .6; }
.topbar-mid { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .92; }
.score-chip { display: flex; align-items: baseline; gap: 8px; padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.1); }
.score-chip span { font-size: 12px; opacity: .7; }
.score-chip b { font-size: 20px; font-variant-numeric: tabular-nums; color: var(--accent); }

/* ---- 一覧 ---- */
.home { max-width: 1180px; margin: 0 auto; padding: 32px 20px 48px; }
.home-hero h1 { font-size: clamp(22px, 3vw, 32px); line-height: 1.35; margin: 0 0 12px; letter-spacing: .01em; }
.home-hero p { color: var(--ink-2); line-height: 1.8; max-width: 760px; margin: 0; }
.home-hero p.home-terms { margin-top: 10px; font-size: 13px; color: var(--ink-3); }
.home-hero p.home-terms a { font-weight: 700; }
.home-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); }
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-top: 24px; }
.scene-card {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.scene-card:hover, .scene-card:focus-visible { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(16,24,40,.14); outline: none; }
.scene-card img { display: block; width: 100%; aspect-ratio: 8 / 5; object-fit: cover; background: #dfe6ee; }
.scene-card .meta { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.scene-card .no { font-size: 12px; color: var(--accent-ink); font-weight: 800; letter-spacing: .06em; }
.scene-card .ttl { font-weight: 800; font-size: 16px; line-height: 1.4; }
.scene-card .row { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-3); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: var(--ink-2); font-size: 11px; font-weight: 700; }
.tag.best { background: var(--ok-soft); color: var(--ok); }
.home-note { margin-top: 28px; font-size: 12px; color: var(--ink-3); line-height: 1.7; }

/* ---- 遊ぶ画面 ---- */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; padding: 18px; max-width: 1600px; margin: 0 auto; }
.stage-wrap { position: relative; }
.stage {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  cursor: crosshair; touch-action: manipulation; user-select: none;
}
.stage svg { display: block; width: 100%; height: auto; }
.toast {
  position: absolute; left: 50%; top: 14px; transform: translate(-50%, -8px); opacity: 0;
  padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; pointer-events: none;
  background: var(--navy); color: #fff; box-shadow: var(--shadow); transition: opacity .2s, transform .2s; max-width: 90%;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ok); }
.toast.info { background: var(--info); }
.toast.ng { background: var(--ng); }

.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.brief-place { font-size: 12px; font-weight: 800; color: var(--accent-ink); letter-spacing: .04em; }
.brief p { margin: 6px 0 14px; line-height: 1.7; color: var(--ink-2); font-size: 14px; }
.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; }
.progress-bar { flex: 1; height: 8px; border-radius: 99px; background: #eceff3; overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffb300); transition: width .3s; }
.side-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn {
  flex: 1; border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 800; font-size: 14px;
  background: var(--navy); color: #fff; transition: filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn.ghost { background: #eef1f5; color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; filter: none; }

.found-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.found-item { background: var(--panel); border-radius: 12px; border: 1px solid var(--line); padding: 12px 14px; display: grid; grid-template-columns: 28px 1fr; gap: 4px 10px; }
.found-item .num { grid-row: span 2; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ok); color: #fff; font-weight: 800; font-size: 13px; }
.found-item.decoy .num { background: var(--info); }
.found-item .lbl { font-weight: 800; font-size: 14px; line-height: 1.45; }
.found-item .sub { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.found-item .sub b.ok { color: var(--ok); }
.found-item .sub b.ng { color: var(--ng); }

/* ---- 絵の上の印 ---- */
.ky-mark { fill: rgba(22, 163, 106, .14); stroke: var(--ok); stroke-width: 5; vector-effect: non-scaling-stroke; }
.ky-mark.decoy { fill: rgba(47, 111, 222, .12); stroke: var(--info); stroke-dasharray: 10 6; }
.ky-mark.missed { fill: rgba(224, 65, 58, .14); stroke: var(--ng); stroke-dasharray: 12 6; }
.ky-mark.hint { fill: rgba(255, 138, 0, .10); stroke: var(--accent); stroke-width: 4; animation: kyPulse 1.2s ease-in-out 3; }
.ky-mark.debug { fill: rgba(255, 0, 140, .12); stroke: #e0007a; stroke-width: 2; }
.ky-badge circle { fill: var(--ok); stroke: #fff; stroke-width: 3; }
.ky-badge.decoy circle { fill: var(--info); }
.ky-badge.missed circle { fill: var(--ng); }
.ky-badge text { fill: #fff; font-weight: 800; font-size: 22px; text-anchor: middle; dominant-baseline: central; font-family: inherit; }
.ky-debug-label { font-size: 14px; font-weight: 800; fill: #e0007a; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.ky-miss { stroke: var(--ng); stroke-width: 5; stroke-linecap: round; animation: kyFade 0.9s ease-out forwards; }
@keyframes kyPulse { 50% { opacity: .25; } }
@keyframes kyFade { from { opacity: 1; } to { opacity: 0; } }

/* ---- モーダル ---- */
.modal { position: fixed; inset: 0 0 var(--nb, 44px) 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(12, 19, 30, .55); backdrop-filter: blur(3px); }
.modal-card { width: min(560px, 100%); max-height: calc(100vh - var(--nb, 44px) - 32px); max-height: calc(100dvh - var(--nb, 44px) - 32px); overflow: auto; background: var(--panel); border-radius: 18px; padding: 22px 22px 18px; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.modal-card.wide { width: min(820px, 100%); }
.modal-kicker { font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--accent-ink); }
.modal-card h2 { margin: 6px 0 4px; font-size: 21px; line-height: 1.4; }
.quiz-q { margin: 8px 0 12px; color: var(--ink-2); font-size: 14px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 14px;
  font-size: 14px; line-height: 1.55; color: var(--ink); transition: border-color .15s, background .15s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt b { display: block; font-size: 13px; color: var(--ink-2); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--ng); background: var(--ng-soft); }
.opt:disabled { cursor: default; }
.quiz-answer { margin-top: 14px; border-radius: 12px; background: #f6f8fb; padding: 14px; font-size: 14px; line-height: 1.75; }
.quiz-answer h3 { margin: 0 0 4px; font-size: 14px; }
.quiz-answer .verdict { font-weight: 900; font-size: 16px; margin-bottom: 6px; }
.quiz-answer .verdict.ok { color: var(--ok); }
.quiz-answer .verdict.ng { color: var(--ng); }
.quiz-answer p { margin: 4px 0 10px; }
.law-quote { border-left: 4px solid var(--accent); background: #fff; padding: 10px 12px; border-radius: 0 8px 8px 0; font-size: 13px; color: var(--ink-2); white-space: pre-wrap; }
.law-quote cite { display: block; margin-top: 6px; font-style: normal; font-size: 11px; color: var(--ink-3); }
.kind { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px; margin-right: 6px; vertical-align: 1px; }
.kind.law { background: #fff1e0; color: var(--accent-ink); }
.kind.guide { background: var(--info-soft); color: var(--info); }
.kind.related { background: #eef1f5; color: var(--ink-2); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }

.result-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.result-summary .stat { text-align: center; }
.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.result-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.result-item .head { display: flex; gap: 8px; align-items: center; font-weight: 800; }
.result-item .head .st { flex: none; white-space: nowrap; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.result-item .head .st.found { background: var(--ok-soft); color: var(--ok); }
.result-item .head .st.missed { background: var(--ng-soft); color: var(--ng); }
.result-item .head .st.decoy { background: var(--info-soft); color: var(--info); }
.result-item p { margin: 6px 0 0; font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.result-item p b { color: var(--ink); }

/* ---- 免責の帯（どの画面でも常に出す・モーダルより前面）。高さは app.js が --nb に入れる（スマホでは折り返して高くなる） ---- */
.notice-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; min-height: 44px;
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 14px calc(6px + env(safe-area-inset-bottom)); background: #fff8e6; border-top: 1px solid #f0d9a8;
  font-size: 12px; line-height: 1.5; color: #5b4a1f; text-align: center;
}
.notice-bar a { font-weight: 800; color: var(--accent-ink); white-space: nowrap; }
.notice-links { display: inline-flex; gap: 12px; white-space: nowrap; }

/* ---- 一覧の下の欄・出典 ---- */
.home-foot { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--ink-3); }
.home-foot a { font-weight: 700; }
.sources { max-width: 820px; margin: 0 auto; padding: 28px 20px 48px; }
.doc { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 26px; line-height: 1.8; }
.doc h1 { font-size: 24px; margin: 0 0 8px; }
.doc h2 { font-size: 17px; margin: 22px 0 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.doc p, .doc li { font-size: 14px; color: var(--ink-2); }
.doc ul { padding-left: 20px; margin: 6px 0; }
.doc .muted { color: var(--ink-3); font-size: 12px; margin-left: 4px; }
/* 法令ID・版などの長い英数字で、スマホの画面が横に広がらないようにする */
.doc p, .doc li { overflow-wrap: anywhere; }
.doc a.ext { white-space: normal; }
.doc .btn { flex: none; }
a.ext { font-weight: 700; white-space: nowrap; }
a.ext::after { content: " ↗"; font-size: .9em; }
.boot-error { padding: 24px; }

/* ---- 結果の共有と導線 ---- */
.share { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.share h3, .cta h3 { margin: 0 0 8px; font-size: 15px; }
.share-text { margin: 0 0 10px; padding: 10px 12px; background: #f6f8fb; border-radius: 8px; font: inherit; font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; }
.share-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.share-actions .btn { flex: 1 1 140px; }
.btn.x { background: #000; }
.share-msg { margin: 8px 0 0; font-size: 12px; color: var(--ok); min-height: 1em; }
.cta { margin-top: 14px; border-radius: 12px; padding: 16px; background: linear-gradient(135deg, var(--navy), #24395a); color: #fff; }
.cta-eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .06em; color: #ffc46b; }
.cta p { margin: 0 0 12px; font-size: 13px; line-height: 1.7; color: #d8e0ec; }
.cta-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cta-actions .btn { flex: 1 1 180px; text-align: center; text-decoration: none; background: var(--accent); color: #1b1200; }
.cta-actions .btn.ghost { background: rgba(255,255,255,.12); color: #fff; }
a.btn.ext::after { content: ""; }

@media (max-width: 980px) {
  .play { grid-template-columns: 1fr; padding: 12px; }
  .result-summary { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand-name small { display: none; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 120px; }
}
@media (max-width: 600px) {
  .home { padding: 20px 14px 40px; }
  .modal { padding: 8px; }
  .modal-card { padding: 18px 16px 14px; max-height: calc(100vh - var(--nb, 44px) - 16px); max-height: calc(100dvh - var(--nb, 44px) - 16px); }
  .doc { padding: 18px 16px; }
  .topbar-mid { font-size: 13px; }
  .score-chip { padding: 4px 10px; }
  .notice-bar { font-size: 11px; gap: 8px; }
}
