:root {
  --bg: #eef2ec;
  --surface: #fbfcf7;
  --surface-soft: #f5f8f1;
  --text: #17231f;
  --muted: #65746f;
  --line: #dfe7dd;
  --primary: #14746f;
  --primary-dark: #0b4f4c;
  --accent: #d4542f;
  --good: #16835d;
  --bad: #b9352c;
  --warning: #b7791f;
  --shadow: 0 18px 42px rgba(21, 34, 30, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(20, 116, 111, 0.12), transparent 30%),
    linear-gradient(240deg, rgba(212, 84, 47, 0.1), transparent 28%),
    var(--bg);
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-header,
.exam-layout,
.resources {
  width: min(1280px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-family: "Bahnschrift", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-title,
.brand-subtitle,
.panel-label,
.eyebrow,
.notice,
.mini-summary p,
#result-summary {
  margin: 0;
}

.brand-title {
  font-weight: 800;
  font-size: 1.08rem;
}

.brand-subtitle,
.mini-summary p,
.notice,
#result-summary {
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.text-link {
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
}

.exam-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.status-panel,
.question-panel,
.resources {
  background: rgba(251, 252, 247, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.status-panel {
  position: sticky;
  top: 16px;
  border-radius: 8px;
  padding: 18px;
}

.question-panel {
  border-radius: 8px;
  padding: 22px;
}

.panel-label,
.eyebrow {
  color: var(--accent);
  font-family: "Bahnschrift", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.timer-card {
  padding: 18px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

#timer {
  display: block;
  margin-top: 8px;
  font-family: "Bahnschrift", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 2.55rem;
  line-height: 1;
}

.timer-bar {
  height: 8px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e4dd;
}

.timer-bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 250ms ease;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.status-grid div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

dt {
  color: var(--muted);
  font-size: 0.82rem;
}

dd {
  margin: 6px 0 0;
  font-family: "Bahnschrift", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
}

.control-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.wrongbook-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.wrongbook-meta {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.wrongbook-meta strong {
  color: var(--primary-dark);
  font-family: "Bahnschrift", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.45rem;
}

.wrongbook-meta span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.wrongbook-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.study-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.study-label {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.study-select {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.study-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 10px 20px rgba(20, 116, 111, 0.18);
}

.secondary-button {
  color: var(--primary-dark);
  background: #fff;
  border: 1px solid var(--line);
}

.ghost-button {
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.mini-summary {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.mini-summary p:last-child {
  margin-top: 8px;
  font-size: 0.92rem;
  line-height: 1.7;
}

.chapter-summary {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.chapter-summary-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
}

.exam-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  margin-top: 6px;
  font-size: clamp(1.55rem, 3vw, 2.45rem);
}

h2 {
  font-size: 1.35rem;
}

.chip {
  flex: 0 0 auto;
  padding: 9px 12px;
  border-radius: 8px;
  background: #e6f2ee;
  color: var(--primary-dark);
  font-weight: 800;
}

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  background: #edf7f4;
  line-height: 1.65;
}

.chapter-board {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.chapter-guide {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.site-note {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px dashed #b8d2c9;
  border-radius: 8px;
  background: #f8fcfa;
}

.site-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.chapter-board-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
}

.chapter-map-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.chapter-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.chapter-guides {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.chapter-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chapter-card h3 {
  font-size: 0.98rem;
}

.chapter-card .chapter-official {
  margin-top: 8px;
  color: var(--primary-dark);
  font-size: 0.84rem;
  font-weight: 700;
}

.chapter-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.chapter-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.6;
}

.chapter-card strong {
  display: inline-block;
  margin-top: 10px;
  color: var(--primary-dark);
  font-family: "Bahnschrift", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
}

.guide-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.guide-card h3 {
  font-size: 0.98rem;
}

.guide-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.guide-chip {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #fff3eb;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.notice.warning {
  border-left-color: var(--warning);
  background: #fff7e6;
  color: #6b4a10;
}

.question-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.question-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.question-title {
  margin-top: 8px;
  font-size: 1.03rem;
  line-height: 1.7;
}

.option-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.option-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  line-height: 1.55;
}

.option-item:has(input:checked) {
  border-color: var(--primary);
  background: #eef8f5;
}

.option-item input {
  margin-top: 5px;
}

.question-feedback {
  margin-top: 12px;
  padding: 12px 13px;
  border-radius: 8px;
  line-height: 1.65;
  font-size: 0.94rem;
}

.question-feedback.correct {
  color: var(--good);
  background: #eaf7f0;
}

.question-feedback.wrong {
  color: var(--bad);
  background: #fff0ee;
}

.result-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.result-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.breakdown-item {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.resources {
  margin-top: 22px;
  margin-bottom: 38px;
  border-radius: 8px;
  padding: 22px;
}

.resource-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.resource-list a {
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-dark);
  background: #fff;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

@media (max-width: 980px) {
  .exam-layout {
    grid-template-columns: 1fr;
  }

  .status-panel {
    position: static;
  }

  .resource-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header,
  .exam-layout,
  .resources {
    width: min(100% - 20px, 1280px);
  }

  .app-header,
  .exam-toolbar,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-grid,
  .result-breakdown,
  .resource-list,
  .chapter-cards,
  .chapter-guides {
    grid-template-columns: 1fr;
  }

  .question-panel,
  .status-panel,
  .resources {
    padding: 14px;
  }
}
