:root {
  --bg: #f4efe5;
  --bg-2: #f7fafb;
  --panel: rgba(255, 251, 247, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --text: #172026;
  --muted: #5f6a72;
  --line: rgba(23, 32, 38, 0.1);
  --teal: #0f766e;
  --teal-soft: #d3f3f0;
  --amber: #dd6b20;
  --amber-soft: #fff0d9;
  --sky: #1d4ed8;
  --shadow: 0 18px 50px rgba(48, 61, 75, 0.12);
  --radius: 18px;
  --font-body: "Noto Sans JP", "Hiragino Sans", sans-serif;
  --font-head: "Noto Serif JP", "Yu Mincho", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.1), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(29, 78, 216, 0.08), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  line-height: 1.65;
}

.page-noise,
.page-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.page-noise {
  opacity: 0.12;
  background-image:
    radial-gradient(rgba(23, 32, 38, 0.22) 0.4px, transparent 0.4px);
  background-size: 10px 10px;
}

.page-grid {
  opacity: 0.08;
  background-image:
    linear-gradient(rgba(15, 118, 110, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.18) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 92%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

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

.brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, #11867d 0%, #0f766e 38%, #0d4b59 100%);
  color: #fff8f1;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.06em;
  box-shadow: 0 14px 30px rgba(15, 118, 110, 0.28);
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 800;
  color: var(--teal);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-head);
  line-height: 1.3;
}

h1 {
  font-size: clamp(28px, 4vw, 40px);
}

h2 {
  font-size: clamp(24px, 3vw, 36px);
}

h3 {
  font-size: 20px;
}

.index-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(23, 32, 38, 0.08);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.index-link:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(255, 255, 255, 0.9);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel-hero,
.panel-control,
.question-panel,
.finish-panel,
.timer-panel {
  padding: 22px;
}

.panel-hero {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(255, 248, 240, 0.98), rgba(243, 250, 249, 0.92)),
    var(--panel);
}

.lede {
  margin: 16px 0 0;
  color: var(--muted);
}

.hero-meta {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.hero-meta-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(23, 32, 38, 0.08);
}

.hero-meta-item span {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.hero-meta-item strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(23, 32, 38, 0.08);
}

.stat-card span {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.15;
}

.stat-card.accent {
  background: linear-gradient(145deg, #fff5e6 0%, #fef2d8 100%);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field span,
.block-label {
  font-weight: 700;
}

.field input {
  padding: 12px 14px;
  border: 1px solid rgba(23, 32, 38, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  font: inherit;
}

.field small {
  color: var(--muted);
}

.mode-block {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.mode-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(23, 32, 38, 0.1);
  background: rgba(255, 255, 255, 0.72);
}

.mode-option input {
  width: 18px;
  height: 18px;
}

.mode-option strong {
  display: block;
}

.mode-option small {
  color: var(--muted);
}

.resume-block {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0.86));
  border: 1px dashed rgba(15, 118, 110, 0.35);
}

.resume-title {
  margin: 0;
  font-weight: 800;
}

.resume-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, #12776f 0%, #19a092 100%);
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.24);
}

.btn.secondary {
  color: #fff;
  background: linear-gradient(135deg, #dd6b20 0%, #f59e0b 100%);
  box-shadow: 0 14px 28px rgba(221, 107, 32, 0.24);
}

.btn.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(23, 32, 38, 0.12);
}

.btn.giant {
  min-width: 280px;
  min-height: 84px;
  font-size: 20px;
}

.message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
}

.study-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.head-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--teal);
  font-weight: 800;
}

.tag.warm {
  background: rgba(221, 107, 32, 0.12);
  color: var(--amber);
}

.tag.quiet {
  background: rgba(29, 78, 216, 0.08);
  color: var(--sky);
}

.progress {
  font-size: 22px;
  font-weight: 800;
}

.timer-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.timer-label {
  font-weight: 700;
}

.timer-count {
  font-weight: 800;
  font-size: 20px;
  color: var(--teal);
}

.timer-bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(23, 32, 38, 0.08);
}

.timer-bar div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #19a092 0%, #f59e0b 100%);
  transition: width 0.1s linear;
}

.question-panel {
  margin-top: 14px;
  background:
    linear-gradient(180deg, rgba(255, 252, 249, 0.98), rgba(246, 251, 250, 0.94));
}

.question-meta {
  margin-bottom: 18px;
}

.study-title {
  margin-top: 2px;
  font-size: clamp(24px, 3.5vw, 34px);
}

.study-sub {
  margin: 10px 0 0;
  color: var(--muted);
}

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

.choice-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(23, 32, 38, 0.08);
}

.choice-key {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(15, 118, 110, 0.12);
  color: var(--teal);
  font-weight: 800;
}

.choice-text {
  font-size: 17px;
}

.choice-option {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(23, 32, 38, 0.1);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.choice-option:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.38);
}

.choice-option:disabled {
  cursor: default;
  opacity: 1;
}

.choice-option.correct {
  border-color: #16a34a;
  background: rgba(34, 197, 94, 0.14);
}

.choice-option.wrong {
  border-color: #dc2626;
  background: rgba(248, 113, 113, 0.15);
}

.choice-option-key {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--teal);
  font-weight: 800;
}

.choice-option-text {
  font-size: 17px;
}

.answer-feedback {
  min-height: 24px;
  margin: 12px 0 0;
  font-weight: 800;
}

.answer-feedback.correct {
  color: #15803d;
}

.answer-feedback.wrong {
  color: #b91c1c;
}

.answer-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255, 243, 222, 0.88), rgba(243, 252, 251, 0.92));
  border: 1px solid rgba(23, 32, 38, 0.08);
}

.answer-panel.is-hidden {
  display: none;
}

.answer-head {
  display: grid;
  gap: 6px;
}

.answer-label {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: var(--muted);
}

.answer-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--amber);
}

.explain-block,
.ref-block {
  margin-top: 16px;
}

.explain-text {
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.ref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.ref-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--sky);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(29, 78, 216, 0.14);
}

.study-actions {
  align-items: stretch;
}

.finish-panel {
  background:
    linear-gradient(135deg, rgba(255, 248, 240, 0.98), rgba(243, 250, 249, 0.94));
}

.finish-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.review {
  margin-top: 26px;
}

.review-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.review-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.review-item {
  padding: 16px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid rgba(23, 32, 38, 0.08);
}

.review-item[data-result="wrong"] {
  border-color: rgba(221, 107, 32, 0.22);
  background: linear-gradient(135deg, rgba(255, 245, 229, 0.98), rgba(255, 255, 255, 0.98));
}

.review-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.review-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.review-badge.ok {
  background: rgba(15, 118, 110, 0.12);
  color: var(--teal);
}

.review-badge.ng {
  background: rgba(221, 107, 32, 0.14);
  color: var(--amber);
}

.review-q {
  margin: 0;
  font-weight: 800;
}

.review-a,
.review-e {
  margin: 10px 0 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(24px);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(23, 32, 38, 0.92);
  color: #fff;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 920px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .study-head,
  .timer-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .progress {
    font-size: 18px;
  }

  .btn.giant {
    min-width: 0;
    width: 100%;
  }

  .resume-block {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 56px;
    height: 56px;
    font-size: 19px;
  }

  .panel-hero,
  .panel-control,
  .question-panel,
  .finish-panel,
  .timer-panel {
    padding: 18px;
  }

  .choice-item {
    grid-template-columns: 1fr;
  }

  .choice-option {
    grid-template-columns: 1fr;
  }

  .choice-key {
    width: 28px;
    height: 28px;
  }

  .choice-option-key {
    width: 28px;
    height: 28px;
  }
}
