:root {
  --bg: #071426;
  --panel: #0d2037;
  --panel-2: #102942;
  --line: rgba(159, 205, 235, .17);
  --ink: #f5fbff;
  --muted: #9fb5c8;
  --cyan: #43e5d3;
  --blue: #4d8cff;
  --yellow: #ffd452;
  --orange: #ff8b45;
  --red: #ff6b70;
  --green: #49dfa0;
  --shadow: 0 22px 60px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 38vw;
  height: 38vw;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .13;
  pointer-events: none;
}
.ambient-a { top: -12vw; right: -8vw; background: #1edcc8; }
.ambient-b { bottom: -16vw; left: -10vw; background: #346dff; }

.app-shell { width: min(1160px, 100%); min-height: 100vh; margin: 0 auto; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 78px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 20, 38, .91);
  backdrop-filter: blur(18px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: #c4d8e8;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.back-link > span:first-child { color: var(--cyan); font-size: 21px; line-height: 1; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--cyan);
  transform: skew(-8deg);
  color: var(--cyan);
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: 20px;
  letter-spacing: .05em;
  box-shadow: 5px 5px 0 rgba(67, 229, 211, .16);
}
.brand b { display: block; font-size: 17px; font-style: italic; letter-spacing: .08em; }
.brand small { display: block; margin-top: 2px; color: #7894aa; font-size: 8px; font-weight: 900; letter-spacing: .12em; }

.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.best-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: #0b1b30;
}
.best-chip span { color: #718ba0; font-size: 9px; font-weight: 1000; letter-spacing: .12em; }
.best-chip strong { color: var(--yellow); font-size: 15px; }
.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #0b1b30;
  color: var(--cyan);
  font-weight: 1000;
  cursor: pointer;
}
.icon-button[aria-pressed="false"] { color: #627a90; }

.screen { padding: 44px 28px 64px; }

.setup-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr);
  gap: 10px 48px;
  align-items: end;
  margin: 14px 0 42px;
}
.setup-intro .eyebrow, .setup-intro h1 { grid-column: 1; }
.setup-intro > p, .intro-pills { grid-column: 2; }
.setup-intro > p { grid-row: 2; align-self: center; margin: 0; color: #a9bfd0; font-size: 15px; line-height: 1.9; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: .08em;
}
.eyebrow span { width: 28px; height: 2px; background: var(--cyan); }
.setup-intro h1 {
  margin: 10px 0 0;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1.08;
  letter-spacing: -.055em;
}
.setup-intro h1 em { color: var(--yellow); font-style: normal; }
.intro-pills { grid-row: 3; display: flex; align-self: start; flex-wrap: wrap; gap: 7px; margin-top: 2px; }
.intro-pills span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  color: #8ea8bc;
  font-size: 11px;
  font-weight: 800;
}

.mode-panel, .category-panel, .breakdown-card {
  margin-top: 22px;
  border: 1px solid var(--line);
  background: rgba(12, 31, 52, .74);
  box-shadow: var(--shadow);
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 19px 22px 15px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2 { margin: 2px 0 0; font-size: 19px; letter-spacing: -.02em; }
.step-label { color: var(--cyan); font-size: 9px; font-weight: 1000; letter-spacing: .15em; }
.shuffle-label, .category-note { color: #7791a6; font-size: 11px; font-weight: 800; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px; }
.mode-card {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 13px;
  align-items: center;
  min-height: 110px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background: #112b47;
  cursor: pointer;
  text-align: left;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.mode-card::after {
  position: absolute;
  right: -25px;
  bottom: -42px;
  width: 125px;
  height: 125px;
  border: 19px solid rgba(255, 255, 255, .035);
  border-radius: 50%;
  content: "";
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--cyan); background: #143452; }
.mode-master { border-left: 4px solid var(--yellow); }
.mode-quick { border-left: 4px solid var(--cyan); }
.mode-icon { display: grid; width: 54px; height: 54px; place-items: center; background: rgba(255, 255, 255, .07); font-size: 28px; }
.mode-copy { min-width: 0; }
.mode-copy b { display: block; margin-bottom: 7px; font-size: 17px; }
.mode-copy small { color: #8fa8bb; font-size: 11px; }
.mode-count { position: relative; z-index: 1; color: var(--yellow); font-family: Impact, "Arial Narrow", sans-serif; font-size: 38px; font-style: italic; }
.mode-quick .mode-count { color: var(--cyan); }
.mode-count small { margin-left: 3px; font-family: inherit; font-size: 12px; }

.category-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 18px; }
.category-card {
  position: relative;
  min-height: 132px;
  padding: 15px 12px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 3px solid var(--cat);
  background: #0c223b;
  cursor: pointer;
  text-align: left;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.category-card:hover { z-index: 2; transform: translateY(-4px); background: #112c49; box-shadow: 0 14px 24px rgba(0, 0, 0, .22); }
.category-card .cat-icon { display: block; margin-bottom: 16px; font-size: 28px; }
.category-card b { display: block; font-size: 13px; line-height: 1.35; }
.category-card small { display: block; margin-top: 5px; color: #728ca1; font-size: 10px; }
.category-card .cat-arrow { position: absolute; right: 11px; bottom: 10px; color: var(--cat); font-size: 17px; font-weight: 1000; }

.safety-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 12px 15px;
  border-left: 3px solid #62829a;
  background: rgba(98, 130, 154, .08);
  color: #8199ac;
}
.safety-note span { color: #aac1d3; }
.safety-note p { margin: 0; font-size: 11px; line-height: 1.65; }

.quiz-screen { max-width: 990px; margin: 0 auto; }
.quiz-toolbar { display: grid; grid-template-columns: 90px 1fr 90px; align-items: center; gap: 18px; margin-bottom: 28px; }
.text-button { padding: 8px 0; border: 0; background: none; color: #8099ad; font-size: 12px; font-weight: 800; cursor: pointer; text-align: left; }
.progress-meta { display: flex; justify-content: space-between; margin-bottom: 7px; color: #8da7ba; font-size: 10px; font-weight: 900; letter-spacing: .04em; }
.progress-track { height: 7px; overflow: hidden; background: #18334e; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--cyan); transition: width .45s cubic-bezier(.22,.75,.25,1); }
.score-display { text-align: right; }
.score-display small { display: block; color: #6f899d; font-size: 8px; font-weight: 1000; letter-spacing: .15em; }
.score-display strong { color: var(--yellow); font-family: Impact, "Arial Narrow", sans-serif; font-size: 27px; letter-spacing: .04em; }

.quiz-layout { display: grid; grid-template-columns: 74px 1fr; gap: 18px; align-items: stretch; }
.run-meter { display: flex; flex-direction: column; align-items: center; min-height: 490px; padding: 12px 8px; }
.runner-dot { position: relative; z-index: 2; display: grid; width: 49px; height: 49px; place-items: center; border: 2px solid var(--cyan); border-radius: 50%; background: #102a43; font-size: 24px; transition: transform .3s ease; }
.runner-dot.bump { animation: runner-bump .45s ease; }
.meter-line { position: relative; width: 4px; flex: 1; margin: 2px 0; overflow: hidden; background: #18334e; }
.meter-line span { position: absolute; right: 0; bottom: 0; left: 0; height: 0; background: var(--cyan); transition: height .4s ease; }
.streak-box { width: 64px; padding: 8px 3px; border: 1px solid var(--line); background: #0d2239; text-align: center; }
.streak-box small { display: block; color: #6e899e; font-size: 7px; font-weight: 1000; letter-spacing: .12em; }
.streak-box strong { color: var(--cyan); font-size: 22px; }

.question-card {
  position: relative;
  min-height: 520px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--line);
  border-top: 4px solid var(--cat-color, var(--cyan));
  background: #0d2239;
  box-shadow: var(--shadow);
}
.question-card::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 110px;
  height: 110px;
  background: linear-gradient(135deg, transparent 49%, rgba(255,255,255,.018) 50%);
  content: "";
  pointer-events: none;
}
.question-topline { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.category-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-left: 3px solid var(--cat-color, var(--cyan));
  background: rgba(255, 255, 255, .045);
  color: #c8d9e6;
  font-size: 11px;
  font-weight: 900;
}
.question-number { color: #638097; font-size: 9px; font-weight: 1000; letter-spacing: .14em; }
.question-card > h2 { max-width: 760px; margin: 23px 0 17px; font-size: clamp(21px, 3.4vw, 30px); line-height: 1.55; letter-spacing: -.02em; }
.hint-button { padding: 7px 0; border: 0; background: none; color: var(--yellow); font-size: 11px; font-weight: 900; cursor: pointer; }
.hint-box { margin: 3px 0 14px; padding: 10px 12px; border-left: 2px solid var(--yellow); background: rgba(255, 212, 82, .07); color: #c8bb89; font-size: 12px; line-height: 1.65; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 18px; }
.answer-button {
  position: relative;
  display: grid;
  grid-template-columns: 37px 1fr 20px;
  gap: 10px;
  align-items: center;
  min-height: 76px;
  padding: 11px 13px;
  border: 1px solid #25435e;
  background: #102942;
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.answer-button:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--cyan); background: #13304e; }
.answer-letter { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid #355570; color: #9db3c5; font-size: 12px; font-weight: 1000; }
.answer-text { font-size: 13px; font-weight: 750; line-height: 1.5; }
.answer-state { color: transparent; font-weight: 1000; }
.answer-button:disabled { cursor: default; }
.answer-button.correct { border-color: var(--green); background: rgba(73, 223, 160, .11); }
.answer-button.correct .answer-letter { border-color: var(--green); background: var(--green); color: #06291e; }
.answer-button.correct .answer-state { color: var(--green); }
.answer-button.wrong { border-color: var(--red); background: rgba(255, 107, 112, .09); }
.answer-button.wrong .answer-letter { border-color: var(--red); background: var(--red); color: #351014; }
.answer-button.wrong .answer-state { color: var(--red); }
.answer-button.dim { opacity: .52; }

.feedback-panel { margin-top: 20px; padding-top: 19px; border-top: 1px solid var(--line); animation: reveal .32s ease both; }
.feedback-head { display: flex; align-items: center; gap: 11px; }
.feedback-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; background: var(--green); color: #06291e; font-size: 21px; font-weight: 1000; }
.feedback-panel.is-wrong .feedback-icon { background: var(--red); color: #351014; }
.feedback-head small { color: #6e899e; font-size: 8px; font-weight: 1000; letter-spacing: .13em; }
.feedback-head h3 { margin: 2px 0 0; font-size: 18px; }
.choice-feedback { margin: 12px 0; color: #b3c6d5; font-size: 13px; line-height: 1.7; }
.learn-box { padding: 12px 14px; border-left: 3px solid var(--cyan); background: #0a1c30; }
.learn-box b { color: var(--cyan); font-size: 10px; letter-spacing: .06em; }
.learn-box p { margin: 5px 0 0; color: #acbfd0; font-size: 12px; line-height: 1.7; }
.source-link { display: inline-block; margin-top: 11px; color: #7695ad; font-size: 10px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.next-button { display: flex; justify-content: space-between; align-items: center; width: min(290px, 100%); margin: 18px 0 0 auto; padding: 13px 16px; border: 0; background: var(--yellow); color: #172132; font-weight: 1000; cursor: pointer; box-shadow: 5px 5px 0 #9b6b08; }
.next-button:hover { filter: brightness(1.06); }
.keyboard-help { margin: 14px 0 0 92px; color: #516c82; font-size: 9px; text-align: center; }

.result-screen { max-width: 900px; margin: 0 auto; }
.result-card { position: relative; overflow: hidden; padding: 45px 25px 35px; border: 1px solid var(--line); border-top: 4px solid var(--yellow); background: #0d2239; text-align: center; box-shadow: var(--shadow); }
.result-glow { position: absolute; top: -180px; left: 50%; width: 390px; height: 390px; transform: translateX(-50%); border-radius: 50%; background: var(--rank-color, var(--yellow)); filter: blur(110px); opacity: .14; }
.result-kicker { position: relative; color: var(--cyan); font-size: 10px; font-weight: 1000; letter-spacing: .18em; }
.result-medal { position: relative; display: grid; width: 150px; height: 150px; margin: 20px auto 16px; place-items: center; border: 3px solid var(--rank-color, var(--yellow)); border-radius: 50%; background: #0a1b2e; box-shadow: 0 0 0 9px rgba(255, 255, 255, .025); }
.result-medal span { position: absolute; top: -12px; right: -7px; font-size: 38px; transform: rotate(12deg); }
.result-medal strong { color: var(--rank-color, var(--yellow)); font-family: Impact, "Arial Narrow", sans-serif; font-size: 48px; font-style: italic; letter-spacing: .02em; }
.result-card h1 { position: relative; margin: 0; font-size: clamp(25px, 5vw, 39px); letter-spacing: -.035em; }
.result-card > p { position: relative; margin: 9px auto 23px; color: #96adbe; font-size: 13px; }
.result-stats { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); max-width: 510px; margin: 0 auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-stats > div { padding: 14px 8px; border-right: 1px solid var(--line); }
.result-stats > div:last-child { border-right: 0; }
.result-stats small { display: block; margin-bottom: 4px; color: #6f899d; font-size: 9px; font-weight: 900; }
.result-stats strong { font-size: 18px; }
.new-best { position: relative; width: fit-content; margin: 18px auto 0; padding: 6px 11px; transform: skew(-7deg); background: var(--yellow); color: #172132; font-size: 11px; font-weight: 1000; letter-spacing: .1em; }

.breakdown-card { margin-top: 18px; box-shadow: none; }
.breakdown-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 22px; padding: 20px 22px; }
.breakdown-row { display: grid; grid-template-columns: 28px 100px 1fr 38px; gap: 8px; align-items: center; }
.breakdown-icon { font-size: 18px; text-align: center; }
.breakdown-name { font-size: 11px; font-weight: 800; }
.breakdown-track { height: 6px; background: #18334e; }
.breakdown-track span { display: block; height: 100%; background: var(--bar-color); }
.breakdown-score { color: #a9bfd0; font-size: 10px; font-weight: 900; text-align: right; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.primary-action, .secondary-action { min-height: 52px; padding: 13px 16px; border: 0; font-weight: 1000; cursor: pointer; }
.primary-action { background: var(--yellow); color: #172132; box-shadow: 5px 5px 0 #9b6b08; }
.secondary-action { border: 1px solid #31516b; background: #102942; color: #bad0df; }

footer { display: flex; align-items: center; gap: 10px; padding: 22px 28px 30px; border-top: 1px solid var(--line); color: #607b91; }
footer b { color: #8ea9bd; font-size: 11px; letter-spacing: .07em; }
footer span { font-size: 10px; }
footer small { margin-left: auto; max-width: 570px; font-size: 9px; line-height: 1.55; text-align: right; }

@keyframes reveal { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
@keyframes runner-bump { 0%,100% { transform: translateY(0) rotate(0); } 40% { transform: translateY(-8px) rotate(-8deg); } }

@media (max-width: 860px) {
  .setup-intro { grid-template-columns: 1fr; }
  .setup-intro .eyebrow, .setup-intro h1, .setup-intro > p, .intro-pills { grid-column: 1; grid-row: auto; }
  .setup-intro > p { grid-row: auto; max-width: 650px; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .breakdown-list { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .topbar { grid-template-columns: 42px 1fr 74px; min-height: 68px; padding: 9px 13px; }
  .back-link > span:last-child { display: none; }
  .brand { justify-self: center; }
  .brand-mark { width: 36px; height: 36px; font-size: 17px; }
  .brand b { font-size: 14px; }
  .brand small { font-size: 6px; }
  .best-chip { padding: 5px 7px; }
  .best-chip span { display: none; }
  .best-chip strong { font-size: 13px; }
  .icon-button { width: 33px; height: 33px; }
  .top-actions { gap: 5px; }
  .screen { padding: 30px 15px 48px; }
  .setup-intro { margin: 5px 0 27px; gap: 9px; }
  .setup-intro h1 { font-size: clamp(36px, 11.5vw, 50px); }
  .setup-intro > p { font-size: 13px; line-height: 1.75; }
  .mode-grid { grid-template-columns: 1fr; padding: 13px; }
  .mode-card { min-height: 96px; grid-template-columns: 49px 1fr auto; padding: 14px; }
  .mode-icon { width: 46px; height: 46px; font-size: 24px; }
  .mode-copy b { font-size: 15px; }
  .mode-count { font-size: 32px; }
  .panel-heading { padding: 15px 14px 12px; }
  .panel-heading h2 { font-size: 16px; }
  .shuffle-label, .category-note { max-width: 95px; text-align: right; }
  .category-grid { gap: 8px; padding: 12px; }
  .category-card { min-height: 116px; padding: 12px 10px 10px; }
  .category-card .cat-icon { margin-bottom: 11px; font-size: 25px; }

  .quiz-toolbar { grid-template-columns: 50px 1fr 58px; gap: 9px; margin-bottom: 18px; }
  .score-display strong { font-size: 23px; }
  .quiz-layout { grid-template-columns: 1fr; }
  .run-meter { display: none; }
  .question-card { min-height: 0; padding: 20px 15px 24px; }
  .question-topline { align-items: flex-start; }
  .question-card > h2 { margin-top: 18px; font-size: 20px; line-height: 1.55; }
  .answer-grid { grid-template-columns: 1fr; gap: 9px; }
  .answer-button { min-height: 64px; }
  .keyboard-help { display: none; }
  .next-button { width: 100%; }
  .result-screen { padding-top: 25px; }
  .result-card { padding: 32px 15px 27px; }
  .result-medal { width: 132px; height: 132px; }
  .result-medal strong { font-size: 43px; }
  .breakdown-list { padding: 16px 13px; }
  .breakdown-row { grid-template-columns: 25px 83px 1fr 34px; gap: 6px; }
  .result-actions { grid-template-columns: 1fr; }
  footer { display: block; padding: 18px 15px 24px; }
  footer span { margin-left: 6px; }
  footer small { display: block; margin: 9px 0 0; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
