:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #3b3355;
  --muted: #7a7393;
  --accent: #ff8a3d;
  --accent-ink: #ffffff;
  --good: #2bb673;
  --bad: #e5484d;
  --line: #f0e3cf;
  --g12: #ff8a3d;
  --yoji: #f06aa6;
  --g34: #3d9bff;
  --g56: #7a5cff;
  --radius: 20px;
  --shadow: 0 4px 0 rgba(59, 51, 85, 0.12);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  max-width: 720px;
  margin: 0 auto;
}
.topbar .home {
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.icon-btn {
  border: 0;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 999px;
  font-size: 22px;
  width: 48px;
  height: 48px;
  cursor: pointer;
}

h1 { font-size: 28px; line-height: 1.3; margin: 8px 0 4px; }
h2 { font-size: 22px; margin: 28px 0 12px; }
.lead { color: var(--muted); margin: 0 0 16px; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.lang-link {
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.lang-hint { margin: 0 0 14px; font-weight: 700; }

/* Cards on menu pages */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.card {
  display: block;
  text-decoration: none;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border: 3px solid transparent;
  transition: transform 0.1s;
}
.card:active { transform: translateY(2px); box-shadow: none; }
.card .emoji { font-size: 44px; line-height: 1; }
.card .title { font-weight: 700; font-size: 20px; margin-top: 8px; }
.card .desc { color: var(--muted); font-size: 15px; }
.card .best { font-size: 14px; color: var(--accent); margin-top: 4px; min-height: 1.4em; }
.card.soon { opacity: 0.55; pointer-events: none; }

.grade-card { color: #fff; text-align: center; padding: 22px 12px; }
.grade-card .title { font-size: 24px; }
.grade-card .desc { color: rgba(255, 255, 255, 0.9); }
.grade-yoji { background: var(--yoji); }
.grade-g12 { background: var(--g12); }
.grade-g34 { background: var(--g34); }
.grade-g56 { background: var(--g56); }

/* Game screens */
.screen { display: none; }
.screen.active { display: block; }

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  text-align: center;
}

.status {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  color: var(--muted);
  margin: 4px 0 10px;
}

.big { font-size: 64px; line-height: 1.1; margin: 8px 0; }
.question { font-size: 40px; font-weight: 700; margin: 8px 0 16px; letter-spacing: 0.02em; }

.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.choices.one-col { grid-template-columns: 1fr; }

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 24px;
  border: 0;
  border-radius: 16px;
  padding: 16px 12px;
  min-height: 64px;
  background: #fff3e2;
  color: var(--ink);
  box-shadow: 0 4px 0 #f1d6b0;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #f1d6b0; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 #d9682a; }
.btn.correct { background: var(--good); color: #fff; box-shadow: 0 4px 0 #1d8f58; }
.btn.wrong { background: var(--bad); color: #fff; box-shadow: 0 4px 0 #b3343a; }
.btn:disabled { cursor: default; }
.btn.small { font-size: 18px; min-height: 48px; padding: 10px 16px; }

.options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 12px 0 20px;
}
.options .btn { font-size: 20px; }
.options .btn.selected { background: var(--accent); color: #fff; box-shadow: 0 4px 0 #d9682a; }

.feedback {
  min-height: 2em;
  font-size: 24px;
  font-weight: 700;
  margin-top: 14px;
}
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.stars { font-size: 52px; letter-spacing: 6px; margin: 8px 0; color: #ffb400; }
.result-score { font-size: 26px; font-weight: 700; }
#result-note { white-space: pre-line; }
#result .choices .btn { font-size: 20px; }

.how {
  font-size: 16px;
  color: var(--muted);
  text-align: left;
  background: #fffaf2;
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 18px;
}
.how strong { color: var(--ink); }

.speak-btn {
  border: 0;
  background: #eef5ff;
  border-radius: 999px;
  font-size: 20px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

footer {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  padding: 24px 16px 32px;
}
footer a { color: var(--muted); }

.prose { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 20px 20px; }
.prose h2 { font-size: 20px; }
.prose li { margin: 4px 0; }

@media (max-width: 380px) {
  .question { font-size: 32px; }
  .btn { font-size: 20px; }
  .big { font-size: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.pop { animation: pop 0.35s ease-out; }
