:root {
  --navy: #1f3a68;
  --navy-2: #2b4f8a;
  --gold: #f2b705;
  --paper: #fffaf0;
  --ink: #1d1d1f;
  --muted: #6b6b73;
  --line: #e6dfcf;
  --ok: #1a7f37;
  --ok-bg: #e6f4ea;
  --ng: #c62828;
  --ng-bg: #fdecea;
  --card: #ffffff;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}
.screen { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Title */
.title-wrap { text-align: center; padding-top: 12px; }
.badge {
  display: inline-block; background: var(--navy); color: #fff; font-size: .8rem;
  padding: 2px 10px; border-radius: 999px; letter-spacing: .08em;
}
h1.title {
  font-size: clamp(1.7rem, 7vw, 2.3rem); line-height: 1.25; margin: 12px 0 6px;
  color: var(--navy); letter-spacing: .02em;
}
.catch { font-weight: 700; font-size: 1.05rem; margin: 0 0 16px; }
.catch em { font-style: normal; background: linear-gradient(transparent 60%, #ffe17a 60%); }

/* Host (いばらいおん) */
.host { display: flex; align-items: flex-end; gap: 10px; margin: 12px 0; }
.host.center { justify-content: center; }
.host-img {
  flex: 0 0 auto; width: 84px; height: 84px; border-radius: 12px; overflow: hidden;
  background: #fff; border: 2px dashed #c9bfa6; display: grid; place-items: center;
}
.host-img.lg { width: 140px; height: 140px; }
.host-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.host-placeholder { font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.3; padding: 4px; }
.bubble {
  position: relative; background: #fff; border: 2px solid var(--navy); border-radius: 14px;
  padding: 8px 12px; font-weight: 700; max-width: 75%;
}
.bubble::before {
  content: ""; position: absolute; left: -10px; bottom: 14px; border: 8px solid transparent;
  border-right-color: var(--navy); border-left: 0;
}

/* Buttons */
.btn {
  display: block; width: 100%; border: 0; border-radius: var(--radius); cursor: pointer;
  font: inherit; font-weight: 700; font-size: 1.05rem; padding: 14px 16px; min-height: 52px;
  background: var(--navy); color: #fff; text-align: center; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--navy); border: 2px solid var(--navy); }
.btn.gold { background: var(--gold); color: #1d1d1f; }
.btn + .btn { margin-top: 10px; }
.btn:focus-visible, .choice:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Progress */
.progress { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.stage {
  display: inline-block; font-weight: 700; font-size: .85rem; padding: 2px 10px; border-radius: 999px;
  background: var(--navy); color: #fff;
}
.stage.hard { background: var(--ng); }

/* Question */
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.lead { font-weight: 800; color: var(--ng); margin: 0 0 4px; font-size: 1.05rem; }
.question { font-size: 1.12rem; font-weight: 700; margin: 0; }
.qimg { margin: 0 0 12px; border-radius: 10px; overflow: hidden; background: #f1ece0; }
.qimg img { width: 100%; height: auto; max-height: 240px; object-fit: cover; display: block; }
.qimg figcaption { font-size: .7rem; color: var(--muted); padding: 4px 8px; }
.choices { display: grid; gap: 10px; margin-top: 14px; }
.choice {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px;
  padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff;
  font: inherit; font-size: 1.05rem; font-weight: 700; text-align: left; cursor: pointer; color: var(--ink);
}
.choice .key {
  flex: 0 0 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy); color: #fff; font-size: .85rem;
}
.choice .mark { margin-left: auto; font-size: .85rem; font-weight: 800; white-space: nowrap; }
.choice:disabled { cursor: default; }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.correct .key { background: var(--ok); }
.choice.correct .mark { color: var(--ok); }
.choice.wrong { border-color: var(--ng); background: var(--ng-bg); }
.choice.wrong .key { background: var(--ng); }
.choice.wrong .mark { color: var(--ng); }
.choice.dim { opacity: .55; }

/* Answer panel */
.verdict { font-size: 1.3rem; font-weight: 800; margin: 14px 0 4px; display: flex; align-items: center; gap: 8px; }
.verdict.ok { color: var(--ok); }
.verdict.ng { color: var(--ng); }
.explain { background: #fff; border-left: 4px solid var(--gold); padding: 10px 12px; border-radius: 6px; margin: 8px 0 12px; }
details.sources { margin: 8px 0 14px; font-size: .85rem; }
details.sources summary { cursor: pointer; color: var(--navy-2); font-weight: 700; padding: 6px 0; }
details.sources ul { padding-left: 1.2em; margin: 6px 0; }
details.sources li { margin-bottom: 6px; word-break: break-all; }
details.sources a { color: var(--navy-2); }

/* Result */
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.score { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.score .label { font-size: .85rem; color: var(--muted); font-weight: 700; }
.score .num { font-size: 2rem; font-weight: 800; color: var(--navy); line-height: 1.2; }
.score.hard .num { color: var(--ng); }
.visit { background: #fff; border: 2px solid var(--gold); border-radius: var(--radius); padding: 14px; margin: 16px 0; }
.visit .type { display: inline-block; background: var(--gold); font-weight: 800; font-size: .8rem; padding: 1px 8px; border-radius: 6px; }
.visit h3 { margin: 6px 0 4px; font-size: 1.1rem; }
.visit p { margin: 0 0 8px; }
.visit a { color: var(--navy-2); font-weight: 700; }
.offer { background: #fff7d6; border: 1px dashed #d9a400; border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: .9rem; }
.review { margin: 12px 0; }
.review li { margin-bottom: 4px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: .9rem; z-index: 10;
}
.share-fallback textarea { width: 100%; min-height: 120px; font: inherit; font-size: .9rem; padding: 8px; border-radius: 8px; border: 1px solid var(--line); }
.notice { background: #eef3fb; border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 10px 0; }
footer.foot { text-align: center; font-size: .75rem; color: var(--muted); margin-top: 24px; }
footer.foot a { color: var(--muted); }
.qimg a { color: var(--navy-2); }

/* いばらいおん画像（背景透過） */
.host-img.has-img { border: 0; background: transparent; width: 116px; height: 116px; overflow: visible; }
.host-img.has-img.lg { width: 190px; height: 190px; }
.host.center .host-img.has-img.lg { margin-bottom: -4px; }
.bye { text-align: center; margin: 16px 0 4px; }
.bye img { width: 110px; height: auto; }

.hint { margin: 8px 0 0; padding: 8px 10px; background: #eef3fb; border-left: 4px solid var(--navy-2); border-radius: 6px; font-size: .92rem; }
.hint strong { color: var(--navy); }
.pr { margin: 10px 0 0; padding: 10px 12px; background: #fff6e0; border-left: 4px solid #e8a317; border-radius: 6px; font-size: .92rem; }
.pr strong { color: #8a5a00; }
.pr p { margin: 4px 0; }
.pr a { font-weight: 700; }

/* ---- 茨城テーマ: 筑波山・ネモフィラ・梅 ---- */
:root { --sky: #bfe3fb; --nemo: #6cb4ee; --ume: #f4a6c0; --leaf: #7dbb6a; }
body { background: #eaf6ff; position: relative; }
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.app { position: relative; z-index: 1; }
.bg .sky { position: absolute; inset: 0; background: linear-gradient(#a9d8f8 0%, #d6efff 45%, #fff6e6 80%); }
.bg .tsukuba {
  position: absolute; left: 0; right: 0; bottom: 70px; height: 190px; opacity: .55;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 190' preserveAspectRatio='none'%3E%3Cpath d='M0 190 L0 150 C60 140 110 120 170 80 C195 62 215 40 235 28 C250 20 262 30 275 50 C300 90 330 100 360 70 C380 48 400 26 420 18 C440 12 455 30 475 60 C510 110 560 130 600 140 L600 190Z' fill='%236f8fb8'/%3E%3C/svg%3E") center bottom / 100% 100% no-repeat;
}
.bg .field {
  position: absolute; left: 0; right: 0; bottom: 0; height: 90px;
  background:
    radial-gradient(circle at 12px 12px, #fff 2px, transparent 3px) 0 0 / 26px 20px,
    linear-gradient(#8ac4f2, var(--nemo));
  opacity: .9; animation: field 14s linear infinite;
}
@keyframes field { to { background-position: 26px 0, 0 0; } }
.bg i {
  position: absolute; top: -20px; left: var(--x); width: var(--s); height: var(--s);
  background: radial-gradient(circle at 30% 30%, #fff, var(--ume)); border-radius: 80% 0 80% 0;
  opacity: .85; animation: fall var(--w) linear var(--d) infinite;
}
@keyframes fall {
  0% { transform: translate(0, -20px) rotate(0); }
  50% { transform: translate(24px, 50vh) rotate(180deg); }
  100% { transform: translate(-12px, 105vh) rotate(360deg); }
}
h1.title { text-shadow: 0 2px 0 rgba(255,255,255,.8); }
.title-wrap .badge { background: var(--nemo); }
.badge { background: linear-gradient(90deg, var(--nemo), var(--navy-2)); }
.notice, .qcard, .sources { background: rgba(255,255,255,.94); }
.host-img.has-img img { animation: bob 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-4px) rotate(1deg); } }
.screen .host .bubble { animation: pop .35s ease; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.choice { transition: transform .12s, box-shadow .12s; }
.choice:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(31,58,104,.15); }
.choice.correct { animation: ok .5s ease; }
@keyframes ok { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
.choice.wrong { animation: shake .35s ease; }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* コース選択 */
.courses { display: grid; gap: 10px; margin: 6px 0 4px; }
.course {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px; width: 100%; min-height: 60px;
  padding: 12px 16px; border-radius: var(--radius); border: 0; cursor: pointer; font: inherit; color: #fff;
  background: linear-gradient(90deg, var(--navy), var(--navy-2)); box-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.course.c30 { background: linear-gradient(90deg, #1f6fb2, #3a95d6); }
.course.c50 { background: linear-gradient(90deg, #c2477a, #e0709b); }
.course .cq { font-weight: 800; font-size: 1.15rem; }
.course .cn { font-size: .85rem; opacity: .95; }
.course:disabled { opacity: .45; cursor: not-allowed; }
.course:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.course:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* 進行バー */
.pbar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.75); border: 1px solid var(--line); overflow: hidden; margin-bottom: 6px; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--nemo), var(--ume)); transition: width .4s ease; }

@media (prefers-reduced-motion: reduce) {
  .bg i, .bg .field, .host-img.has-img img, .screen, .screen .host .bubble, .choice.correct, .choice.wrong { animation: none !important; }
}

/* 広告（LINEスタンプ） */
.promo { margin: 14px 0; padding: 12px 14px; background: #fffdf2; border: 2px solid var(--gold); border-radius: var(--radius); font-size: .92rem; }
.promo-label { display: inline-block; margin-right: 8px; padding: 0 8px; border-radius: 4px; background: var(--gold); color: #1d1d1f; font-size: .75rem; font-weight: 800; }
.promo p { margin: 4px 0; }
.promo ul { margin: 6px 0 0; padding-left: 1.2em; }
.promo a { font-weight: 700; }
.foot .promo { margin-top: 18px; }
