:root {
  --primary: #1f8a70;
  --accent: #ffb703;
  --bg: #e8f6f1;
  --ink: #16352d;
  --card: #ffffff;
  --muted: color-mix(in srgb, var(--ink) 60%, transparent);
  --ok: #2a9d4b;
  --ng: #d1495b;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.app { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(32px + env(safe-area-inset-bottom)); min-height: 100dvh; }
.screen { display: none; }
.screen.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { text-align: center; padding: 12px 0 20px; }
.hero.compact { padding-bottom: 8px; }
.hero-emoji { font-size: 72px; line-height: 1; }
.hero h1 { font-size: 1.6rem; margin: 6px 0 4px; color: var(--primary); }
.school { margin: 8px 0 0; font-weight: bold; color: var(--muted); }
.subtitle { margin: 0; color: var(--muted); }

.card { background: var(--card); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; box-shadow: 0 4px 0 color-mix(in srgb, var(--primary) 20%, transparent); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { font-size: 1.1rem; }
.label { display: block; font-weight: bold; margin-bottom: 6px; }
input {
  width: 100%; font-size: 1.2rem; padding: 12px 14px; border-radius: 12px;
  border: 2px solid color-mix(in srgb, var(--primary) 35%, #ccc); outline: none; background: #fff; color: var(--ink);
}
input:focus { border-color: var(--primary); }
.hint { font-size: .9rem; color: var(--muted); margin: 8px 0 0; }
.error { color: var(--ng); font-weight: bold; min-height: 1.2em; margin: 8px 0; }
.link { color: var(--primary); font-weight: bold; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 999px; padding: 16px; font-size: 1.15rem; font-weight: bold;
  cursor: pointer; font-family: inherit; transition: transform .08s;
}
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--primary) 60%, #000); }
.btn:disabled { opacity: .6; cursor: default; }

.progress { height: 10px; background: color-mix(in srgb, var(--primary) 15%, #fff); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.qnum { font-weight: bold; color: var(--primary); margin: 14px 0 4px; }
.qtext { font-size: 1.3rem; margin: 0 0 16px; line-height: 1.5; }
.qimage { width: 100%; border-radius: 12px; margin-bottom: 12px; }
.choices { display: grid; gap: 12px; }
.choice {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: #fff; border: 2px solid color-mix(in srgb, var(--primary) 25%, #ddd); border-radius: 14px;
  padding: 14px; font-size: 1.05rem; font-family: inherit; color: var(--ink); cursor: pointer;
}
.choice:active { background: color-mix(in srgb, var(--accent) 25%, #fff); }
.choice .no {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: bold;
}

.big-emoji { font-size: 64px; line-height: 1.1; }
.feedback .fb-title { font-size: 1.6rem; font-weight: bold; margin: 4px 0; }
.feedback.ok .fb-title { color: var(--ok); }
.feedback.ng .fb-title { color: var(--ng); }
.fb-answer { font-weight: bold; }
.fb-explain { text-align: left; background: color-mix(in srgb, var(--bg) 70%, #fff); border-radius: 12px; padding: 12px; }

.badge { display: inline-block; background: var(--accent); color: var(--ink); font-weight: bold; padding: 4px 14px; border-radius: 99px; margin: 6px 0; }
.score-line { font-size: 1.4rem; font-weight: bold; margin: 4px 0; }
.score { font-size: 2.4rem; font-weight: bold; color: var(--primary); margin: 0; }
.rank-line { font-size: 1.2rem; font-weight: bold; }

.board-title { margin: 0 0 8px; font-size: 1.1rem; }
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px dashed color-mix(in srgb, var(--primary) 25%, #ddd); }
.board li:last-child { border-bottom: 0; }
.board .r { width: 2.2em; font-weight: bold; text-align: center; }
.board .n { flex: 1; font-weight: bold; overflow-wrap: anywhere; }
.board .s { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; text-align: right; }
.board li.me { background: color-mix(in srgb, var(--accent) 25%, #fff); border-radius: 10px; }
.board .empty { justify-content: center; color: var(--muted); }
.board.large li { font-size: 1.4rem; padding: 14px 6px; }
#retry-btn { margin-top: 4px; }

@media (min-width: 900px) {
  [data-screen="ranking"].is-active { max-width: 900px; }
}
.hero-img { width: 100%; max-height: 240px; object-fit: contain; border-radius: var(--radius); }
