:root {
  color-scheme: light;
  --navy: #0b2948;
  --navy-soft: #173f66;
  --ink: #12263a;
  --muted: #69798a;
  --paper: #f4f7f9;
  --white: #ffffff;
  --accent: #f2b13d;
  --answer: #eaf6f1;
  --answer-border: #bfe1d3;
  --answer-ink: #0b684a;
  --shadow: 0 20px 60px rgba(11, 41, 72, 0.12);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--navy); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 6%, rgba(242, 177, 61, 0.16), transparent 24rem),
    linear-gradient(180deg, var(--navy) 0 13rem, var(--paper) 13rem 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.app-shell {
  width: min(100%, 32rem);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.1rem max(1.2rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 7rem;
  color: var(--white);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  width: fit-content;
  margin: 0;
  padding: 0.45rem 0.65rem;
  border-radius: 0.55rem;
  color: #111820;
  background: rgba(255, 255, 255, 0.96);
  font-size: clamp(0.88rem, 3.7vw, 1.03rem);
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.reset-button {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.reset-button:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.16); }

.progress-area {
  margin: 0.55rem 0 1.2rem;
  padding: 0 0.15rem;
}

.mode-switch {
  margin-bottom: 0.9rem;
  padding: 0.28rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}

.mode-button {
  min-height: 2.65rem;
  padding: 0.55rem 0.35rem;
  border: 0;
  border-radius: 0.65rem;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 160ms ease, background 160ms ease, transform 120ms ease;
}

.mode-button.is-active {
  color: #111820;
  background: var(--white);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.14);
}

.mode-button:active { transform: scale(0.98); }
.mode-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.progress-copy {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.progress-track { height: 0.42rem; overflow: hidden; border-radius: 999px; background: #dfe6eb; }

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #f7ca71);
  transition: width 320ms ease;
}

.question-jump {
  margin-top: 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d8e1e8;
  border-radius: 0.8rem;
  color: var(--ink);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(11, 41, 72, 0.06);
}

.question-jump[hidden] { display: none; }

.select-wrap { position: relative; }

.select-wrap::after {
  content: "▼";
  position: absolute;
  top: 50%;
  right: 0.72rem;
  color: var(--navy);
  font-size: 0.58rem;
  pointer-events: none;
  transform: translateY(-50%);
}

#questionSelect {
  min-width: 7rem;
  min-height: 2.35rem;
  padding: 0.4rem 1.8rem 0.4rem 0.75rem;
  border: 1px solid #cbd6df;
  border-radius: 0.65rem;
  color: var(--navy);
  background: #f7f9fb;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  appearance: none;
  cursor: pointer;
}

#questionSelect:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.study-card {
  flex: 1;
  min-height: 22rem;
  padding: clamp(1.35rem, 5vw, 1.8rem);
  border: 1px solid rgba(11, 41, 72, 0.06);
  border-radius: 1.35rem;
  background: var(--white);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.card-label {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.card-label span {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 0.5rem;
  color: var(--white);
  background: var(--navy);
  display: grid;
  place-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.question {
  margin: 1.15rem 0 0;
  font-size: clamp(1.32rem, 5.5vw, 1.68rem);
  font-weight: 750;
  line-height: 1.72;
  letter-spacing: 0.025em;
}

.answer-panel {
  margin-top: auto;
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--answer-border);
  border-radius: 1rem;
  background: var(--answer);
  opacity: 0;
  transform: translateY(0.75rem);
  visibility: hidden;
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms;
}

.answer-panel.is-visible { opacity: 1; transform: translateY(0); visibility: visible; }
.answer-panel.no-transition { transition: none; }
.answer-label { color: var(--answer-ink); }
.answer-label span { background: var(--answer-ink); }

.answer {
  margin: 0.8rem 0 0;
  color: var(--answer-ink);
  font-size: clamp(1.23rem, 5.2vw, 1.55rem);
  font-weight: 800;
  line-height: 1.55;
}

.action-area { padding-top: 1rem; }

.main-button {
  width: 100%;
  min-height: 3.75rem;
  padding: 0.9rem 1.25rem;
  border: 0;
  border-radius: 1rem;
  color: var(--white);
  background: var(--navy);
  box-shadow: 0 10px 24px rgba(11, 41, 72, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, background 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.main-button.answer-shown { color: var(--navy); background: var(--accent); }
.main-button:active { transform: translateY(2px) scale(0.99); }
.main-button:focus-visible, .reset-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.hint { margin: 0.65rem 0 0; color: var(--muted); text-align: center; font-size: 0.75rem; }

.completion {
  flex: 1;
  min-height: 22rem;
  padding: 2.25rem 1.5rem;
  border-radius: 1.35rem;
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: center;
}

.completion-mark {
  width: 5rem;
  height: 5rem;
  margin: 1.4rem auto 1.7rem;
  border-radius: 50%;
  color: var(--white);
  background: var(--answer-ink);
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  box-shadow: 0 12px 28px rgba(11, 104, 74, 0.22);
}

.completion-kicker { margin: 0; color: var(--answer-ink); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.15em; }
.completion h2 { margin: 0.65rem 0 0.75rem; font-size: 1.65rem; }
.completion > p:last-child { margin: 0; color: var(--muted); line-height: 1.8; }

[hidden] { display: none !important; }

@media (min-width: 33rem) {
  body { padding: 1.5rem 0; }
  .app-shell { min-height: calc(100dvh - 3rem); border-radius: 2rem; background: var(--paper); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
