:root {
  --bg: #f3efe6;
  --bg-deep: #dfe8df;
  --card: rgba(255, 252, 247, 0.78);
  --card-solid: #fffdf9;
  --text: #2f3a3a;
  --muted: #6d7a76;
  --accent: #7ba59a;
  --accent-deep: #5f8d82;
  --accent-soft: #e4efe9;
  --danger: #d96f6f;
  --danger-soft: #fde8e8;
  --gold: #d7b46a;
  --shadow: 0 20px 60px rgba(79, 102, 94, 0.16);
  --shadow-soft: 0 10px 30px rgba(79, 102, 94, 0.1);
  --radius: 32px;
  --radius-sm: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at top, #fbf8f2 0%, var(--bg) 45%, var(--bg-deep) 100%);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}
.orb-a { width: 340px; height: 340px; background: rgba(168, 206, 192, 0.35); top: -80px; left: -60px; }
.orb-b { width: 420px; height: 420px; background: rgba(239, 219, 186, 0.3); bottom: -140px; right: -100px; }
.orb-c { width: 220px; height: 220px; background: rgba(255, 255, 255, 0.55); top: 35%; right: 12%; }

.app {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100% - 32px));
  margin: 32px auto;
  display: grid;
  gap: 24px;
}

.float-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.topbar {
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.brand h1, .screen h2 { margin: 0; line-height: 1.1; }
.brand h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; }

.status { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; }
.hearts { display: flex; gap: 8px; align-items: center; min-height: 40px; }
.heart {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  filter: drop-shadow(0 4px 8px rgba(217, 111, 111, 0.25));
  transition: transform 0.2s ease, opacity 0.25s ease;
}
.heart svg { width: 100%; height: 100%; display: block; }
.heart.lost { opacity: 0.28; filter: grayscale(0.5); transform: scale(0.92); }
.heart.pop { animation: pop 0.35s ease; }
@keyframes pop { 50% { transform: scale(1.2); } }

.score-pill {
  background: var(--card-solid);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 800;
  color: var(--accent-deep);
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
}

.game-shell { padding: 32px; min-height: 560px; }
.screen { display: none; }
.screen.active { display: block; animation: fadeUp 0.35s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

#start-screen, #end-screen { text-align: center; max-width: 720px; margin: 0 auto; padding: 20px 0; }
.screen h2 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: 16px; }
.lead { font-size: 1.1rem; line-height: 1.7; color: var(--muted); margin: 0 auto 28px; max-width: 58ch; }

.start-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, #8eb7ac, var(--accent-deep));
  color: #fff;
  box-shadow: 0 12px 28px rgba(95, 141, 130, 0.35);
}
.btn.ghost {
  background: rgba(255,255,255,0.7);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.top5-preview {
  margin-top: 20px;
  text-align: left;
  background: rgba(255,255,255,0.55);
  border-radius: 24px;
  padding: 20px 24px;
  border: 1px solid rgba(255,255,255,0.7);
}
.top5-preview h3 { margin: 0 0 12px; font-size: 1rem; letter-spacing: 0.04em; color: var(--accent-deep); }
.top5-list { margin: 0; padding-left: 24px; color: var(--text); }
.top5-list li { padding: 6px 0; border-bottom: 1px dashed rgba(109,122,118,0.2); }
.top5-list li:last-child { border-bottom: 0; }
.top5-list .empty { list-style: none; margin-left: -24px; color: var(--muted); padding: 4px 0; }
.top5-meta { color: var(--muted); font-size: 0.9em; font-weight: 600; }

.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 18px;
  min-height: 28px;
}
.feedback { font-weight: 800; min-height: 24px; }
.feedback.ok { color: #5d917f; }
.feedback.bad { color: var(--danger); }

.prompt {
  text-align: center;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  margin: 10px 0 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
#quiz-screen .eyebrow { text-align: center; }

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.option {
  appearance: none;
  border: 2px solid rgba(123, 165, 154, 0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(244, 249, 246, 0.95));
  border-radius: 28px;
  padding: 24px 20px;
  font-family: "Noto Sans JP", "Nunito", sans-serif;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(95, 141, 130, 0.08);
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.option-main {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.1;
}
.option-reading {
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
  line-height: 1;
}
.option.correct .option-reading { color: #5d917f; }
.option.wrong .option-reading { color: #b35656; }
.option:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: rgba(123, 165, 154, 0.45);
  box-shadow: 0 16px 34px rgba(95, 141, 130, 0.14);
}
.option:disabled { cursor: default; }
.option.correct {
  background: linear-gradient(180deg, #edf8f2, #dfeee6);
  border-color: rgba(95, 141, 130, 0.55);
  color: #3f7467;
}
.option.wrong {
  background: linear-gradient(180deg, #fff3f3, var(--danger-soft));
  border-color: rgba(217, 111, 111, 0.45);
  color: #b35656;
}
.option.dim { opacity: 0.55; }

.end-score { display: flex; justify-content: center; margin: 24px 0; }
.end-score-box {
  background: linear-gradient(180deg, #fff, #f3f8f5);
  border-radius: 28px;
  padding: 24px 40px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(123,165,154,0.12);
}
.end-score-label { display: block; font-size: 0.85rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.end-score-box strong { font-size: clamp(2.8rem, 7vw, 4rem); color: var(--accent-deep); line-height: 1; }

.save-form { margin: 0 0 20px; padding: 20px; background: rgba(255,255,255,0.55); border-radius: 24px; }
.save-form label { display: block; font-weight: 700; margin-bottom: 12px; }
.save-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.save-form input {
  font: inherit;
  padding: 13px 18px;
  border-radius: 999px;
  border: 2px solid rgba(123,165,154,0.2);
  background: #fff;
  min-width: 220px;
  color: var(--text);
  outline: none;
}
.save-form input:focus { border-color: rgba(123,165,154,0.55); }
.save-status { min-height: 24px; color: var(--accent-deep); font-weight: 700; margin: 0 0 16px; }
.hidden { display: none !important; }

@media (max-width: 720px) {
  .app { width: min(100% - 20px, 960px); margin: 16px auto; gap: 16px; }
  .topbar { padding: 20px; flex-direction: column; align-items: stretch; }
  .status { justify-content: space-between; }
  .game-shell { padding: 22px; min-height: 0; }
  .options { grid-template-columns: 1fr; }
  .option { min-height: 88px; padding: 22px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}