:root {
  --ink: #1d2733;
  --muted: #627083;
  --line: #dbe2ea;
  --paper: #fffdfa;
  --wash: #f5f7fb;
  --navy: #183b67;
  --red: #b8343a;
  --green: #168552;
  --gold: #d5a11e;
  --sky: #dbeaff;
  --shadow: 0 18px 48px rgba(32, 45, 64, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background:
    linear-gradient(90deg, rgba(24, 59, 103, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(24, 59, 103, 0.05) 1px, transparent 1px),
    var(--wash);
  background-size: 28px 28px;
}

button {
  font: inherit;
}

.site-header {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 88px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--red);
  border: 3px solid #fff;
  outline: 1px solid var(--red);
  font-weight: 800;
  font-size: 25px;
}

.eyebrow,
.exam-label,
.side-label,
.question-meta {
  margin: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(22px, 3vw, 32px);
  letter-spacing: 0;
}

.level-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  gap: 8px;
}

.level-tab {
  min-width: 54px;
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  font-weight: 800;
}

.level-tab:hover,
.level-tab.is-active {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
}

.exam-panel,
.status-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.exam-panel {
  min-height: 690px;
  display: flex;
  flex-direction: column;
}

.mode-bar {
  padding: 18px 30px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: #f8fbff;
  border-bottom: 1px solid var(--line);
}

.subject-bar {
  padding: 14px 30px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.subject-btn {
  min-height: 42px;
  border: 1px solid #c9d5e4;
  background: #f8fbff;
  color: var(--navy);
  cursor: pointer;
  font-weight: 800;
}

.subject-btn:hover,
.subject-btn.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.mode-btn {
  min-height: 64px;
  padding: 10px 12px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid #c9d5e4;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  font-weight: 800;
}

.mode-btn span {
  font-size: 15px;
}

.mode-btn b {
  color: var(--red);
  font-size: 18px;
}

.mode-btn:hover,
.mode-btn.is-active {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.mode-btn:hover b,
.mode-btn.is-active b {
  color: #fff;
}

.exam-top {
  padding: 28px 30px 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.exam-top h2 {
  margin: 8px 0 0;
  font-size: clamp(20px, 2.6vw, 30px);
}

.score-board {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.pill {
  min-width: 56px;
  height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #fff;
}

.pill.correct {
  background: var(--green);
}

.pill.wrong {
  background: var(--red);
}

.progress-track {
  padding: 18px 30px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8px, 1fr));
  gap: 7px;
}

.progress-step {
  height: 6px;
  background: #d9e2ef;
}

.progress-step.is-current {
  background: var(--gold);
}

.progress-step.is-correct {
  background: var(--green);
}

.progress-step.is-wrong {
  background: var(--red);
}

.question-area {
  padding: 42px 30px 22px;
  flex: 1;
}

.question-area h3 {
  margin: 12px 0 28px;
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.6;
}

.media-stage {
  display: none;
  margin: 18px 0 24px;
}

.media-stage.has-media {
  display: grid;
  gap: 14px;
}

.listening-card {
  border: 1px solid #c7d8ec;
  background: #f7fbff;
}

.listening-card {
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.listen-btn {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.listening-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.6;
}

.choices {
  display: grid;
  gap: 14px;
}

.choice {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  padding: 20px 20px 18px;
  min-height: 74px;
}

.choice:hover {
  border-color: #9bb8d8;
  background: #f7fbff;
}

.choice.is-correct {
  border-color: var(--green);
  background: #eefaf4;
}

.choice.is-wrong {
  border-color: var(--red);
  background: #fff1f2;
}

.choice.is-muted {
  opacity: 0.62;
}

.choice-head {
  display: flex;
  gap: 14px;
  align-items: baseline;
  font-weight: 800;
  font-size: 18px;
}

.explanation {
  margin: 14px 0 0 34px;
  color: var(--muted);
  line-height: 1.75;
  font-weight: 700;
}

.choice.is-correct .explanation {
  color: #0e6b42;
}

.exam-actions {
  padding: 20px 30px 30px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.primary-btn,
.ghost-btn {
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid var(--navy);
  cursor: pointer;
  font-weight: 800;
}

.primary-btn {
  background: var(--navy);
  color: #fff;
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ghost-btn {
  background: #fff;
  color: var(--navy);
}

.status-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.status-card {
  padding: 24px;
}

.status-card h2 {
  margin: 8px 0;
  color: var(--navy);
  font-size: 48px;
}

.status-card h3 {
  margin: 10px 0 0;
  color: var(--navy);
  font-size: 26px;
}

.status-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.compact {
  text-align: center;
}

.result-ring {
  width: 132px;
  height: 132px;
  margin: 18px auto 12px;
  display: grid;
  place-items: center;
  color: var(--navy);
  background:
    radial-gradient(circle at center, #fff 58%, transparent 59%),
    conic-gradient(var(--green) 0deg, var(--green) 0deg, #e5ebf2 0deg);
  border-radius: 50%;
  font-size: 28px;
  font-weight: 900;
}

.scope-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.scope-list li {
  padding: 11px 12px;
  background: var(--sky);
  color: var(--navy);
  font-weight: 800;
  border-left: 4px solid var(--navy);
}

.finish-message {
  padding: 30px;
  border: 1px solid #c7d8ec;
  background: #f7fbff;
  line-height: 1.8;
}

.wrong-review {
  padding: 24px;
  border: 1px solid #edd2d3;
  background: #fff7f7;
}

.wrong-review h4 {
  margin: 0 0 16px;
  color: var(--red);
  font-size: 20px;
}

.wrong-review p {
  margin: 8px 0 0;
  line-height: 1.7;
}

.wrong-item {
  padding: 16px 0;
  border-top: 1px solid #edd2d3;
}

.wrong-title {
  color: var(--red);
  font-weight: 900;
}

@media (max-width: 900px) {
  .header-inner,
  .exam-top,
  .exam-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .level-tabs {
    width: 100%;
  }

  .mode-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .subject-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .score-board {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .header-inner,
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .site-header {
    position: static;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .level-tabs {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }

  .level-tab {
    min-width: 0;
    height: 38px;
  }

  .exam-top,
  .question-area,
  .exam-actions {
    padding-left: 18px;
    padding-right: 18px;
  }

  .progress-track {
    padding-left: 18px;
    padding-right: 18px;
    gap: 4px;
  }

  .mode-bar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .subject-bar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .listening-card {
    align-items: stretch;
    flex-direction: column;
  }

  .choice {
    padding: 17px 15px;
  }

  .explanation {
    margin-left: 0;
  }
}
