:root {
  --blue-900: #0f172a;
  --blue-600: #2563eb;
  --blue-050: #eff6ff;
  --slate-050: #f8fafc;
  --border: #e5e7eb;
  --green: #16a34a;
  --yellow: #fefce8;
  --text: #1f2937;
  --muted: #64748b;
  --white: #ffffff;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--blue-050) 0%, var(--slate-050) 42%, #ffffff 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.38;
  display: grid;
  place-items: center;
}

button,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  padding: clamp(8px, 1.3vmin, 18px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: clamp(6px, 1vmin, 12px);
  overflow: hidden;
}

.topbar {
  background: var(--blue-900);
  color: var(--white);
  border-radius: 8px;
  padding: clamp(12px, 2vmin, 22px);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow);
}

.course-label,
.section-kicker {
  margin: 0 0 clamp(3px, 0.6vmin, 8px);
  color: #bfdbfe;
  font-size: clamp(0.58rem, 1.25vmin, 0.86rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.25rem, 4.4vmin, 3.1rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.subtitle {
  max-width: 760px;
  margin: clamp(5px, 0.8vmin, 10px) 0 0;
  color: #dbeafe;
  font-size: clamp(0.72rem, 1.55vmin, 1rem);
}

.time-chip {
  flex: 0 0 auto;
  align-self: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: clamp(8px, 1.2vmin, 12px) clamp(10px, 1.5vmin, 14px);
  min-width: clamp(112px, 15vmin, 150px);
  background: rgba(255, 255, 255, 0.08);
}

.time-chip span {
  display: block;
  color: #bfdbfe;
  font-size: clamp(0.58rem, 1.1vmin, 0.78rem);
}

.time-chip strong {
  display: block;
  margin-top: 4px;
  color: var(--white);
}

.progress-wrap {
  margin: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(7px, 1vmin, 11px);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(4px, 0.6vmin, 7px);
  color: var(--muted);
  font-size: clamp(0.62rem, 1.15vmin, 0.86rem);
}

.progress-track {
  height: clamp(6px, 0.9vmin, 9px);
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue-600), var(--green));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.module-frame {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.module {
  display: none;
  height: 100%;
  overflow: hidden;
  padding: clamp(12px, 2vmin, 26px);
}

.module.active {
  display: block;
}

.module-heading {
  max-width: 900px;
  margin-bottom: clamp(8px, 1.3vmin, 18px);
}

.module-heading .section-kicker,
.hero-copy .section-kicker,
.final-panel .section-kicker {
  color: var(--blue-600);
}

.module h2,
.hero-copy h2,
.final-panel h2 {
  color: var(--blue-900);
  margin: 0 0 clamp(5px, 0.8vmin, 10px);
  font-size: clamp(1.15rem, 3vmin, 2.15rem);
  line-height: 1.12;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: clamp(16px, 3vmin, 30px);
  align-items: center;
}

.hero-copy p {
  font-size: clamp(0.72rem, 1.55vmin, 1rem);
}

.instruction-note {
  background: var(--yellow);
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: clamp(9px, 1.3vmin, 14px);
}

.hero-visual {
  min-height: 0;
  height: clamp(210px, 42vmin, 360px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    radial-gradient(circle at 28% 25%, rgba(37, 99, 235, 0.18), transparent 32%),
    radial-gradient(circle at 70% 72%, rgba(22, 163, 74, 0.18), transparent 34%),
    var(--slate-050);
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.visual-node {
  width: clamp(72px, 13vmin, 118px);
  height: clamp(72px, 13vmin, 118px);
  border-radius: 50%;
  background: var(--white);
  border: 2px solid #bfdbfe;
  color: var(--blue-900);
  display: grid;
  place-items: center;
  font-weight: 800;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  position: absolute;
}

.node-large {
  width: clamp(86px, 15vmin, 142px);
  height: clamp(86px, 15vmin, 142px);
  left: 12%;
  top: 18%;
}

.hero-visual .visual-node:nth-of-type(3) {
  right: 12%;
  top: 18%;
}

.hero-visual .visual-node:nth-of-type(4) {
  left: 18%;
  bottom: 14%;
}

.node-accent {
  right: 12%;
  bottom: 14%;
  border-color: #bbf7d0;
}

.visual-link {
  width: 64%;
  height: 3px;
  background: linear-gradient(90deg, var(--blue-600), var(--green));
  transform: rotate(-8deg);
  opacity: 0.35;
}

.concept-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(6px, 0.8vmin, 10px);
}

.concept-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--slate-050);
  overflow: hidden;
}

.concept-card button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  min-height: clamp(34px, 5.6vmin, 52px);
  padding: clamp(6px, 0.9vmin, 10px) clamp(7px, 1vmin, 11px);
  font-weight: 800;
  color: var(--blue-900);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: clamp(0.58rem, 1.15vmin, 0.9rem);
}

.concept-card button:hover,
.concept-card button:focus-visible {
  background: var(--blue-050);
  outline: none;
}

.concept-body {
  display: none;
  padding: 0 16px 16px;
}

.concept-card.open .concept-body {
  display: block;
}

.concept-example {
  margin-top: clamp(5px, 0.8vmin, 9px);
  padding: clamp(7px, 1vmin, 10px);
  border-left: 4px solid var(--blue-600);
  background: var(--white);
  border-radius: 0 8px 8px 0;
}

.flow-map {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(6px, 0.8vmin, 10px);
}

.flow-step {
  border: 1px solid #bfdbfe;
  background: var(--blue-050);
  color: var(--blue-900);
  border-radius: 8px;
  min-height: clamp(48px, 7.2vmin, 74px);
  padding: clamp(7px, 1vmin, 11px);
  cursor: pointer;
  text-align: left;
  font-weight: 800;
  font-size: clamp(0.58rem, 1.15vmin, 0.9rem);
}

.flow-step span {
  display: block;
  color: var(--blue-600);
  font-size: clamp(0.52rem, 0.95vmin, 0.74rem);
  margin-bottom: clamp(2px, 0.4vmin, 5px);
}

.flow-step.active,
.flow-step:hover,
.flow-step:focus-visible {
  background: var(--blue-600);
  color: var(--white);
  outline: none;
}

.flow-step.active span,
.flow-step:hover span,
.flow-step:focus-visible span {
  color: #dbeafe;
}

.detail-panel,
.feedback-box,
.case-card,
.score-card {
  margin-top: clamp(7px, 1vmin, 12px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--slate-050);
  padding: clamp(8px, 1.2vmin, 14px);
  font-size: clamp(0.64rem, 1.2vmin, 0.9rem);
}

.compact-detail {
  min-height: clamp(72px, 10vmin, 100px);
}

.matching-list,
.quiz-list,
.order-list,
.case-form {
  display: grid;
  gap: clamp(6px, 0.8vmin, 10px);
}

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

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

.match-row,
.tf-row,
.order-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(130px, 1fr);
  gap: clamp(6px, 0.8vmin, 10px);
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(7px, 0.95vmin, 11px);
  font-size: clamp(0.58rem, 1.08vmin, 0.86rem);
  background: var(--slate-050);
}

.match-row strong,
.order-row strong {
  color: var(--blue-900);
}

select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  padding: clamp(6px, 0.8vmin, 9px) clamp(7px, 1vmin, 10px);
  min-height: clamp(30px, 4vmin, 40px);
}

textarea {
  min-height: clamp(44px, 7.5vmin, 72px);
  resize: vertical;
  margin-top: 6px;
}

.tf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(5px, 0.7vmin, 8px);
}

.tf-row {
  grid-template-columns: 1fr auto;
}

.inline-feedback {
  grid-column: 1 / -1;
  font-size: clamp(0.55rem, 1vmin, 0.78rem);
  color: var(--muted);
}

.correct {
  border-color: #86efac !important;
  background: #f0fdf4 !important;
}

.incorrect {
  border-color: #fecaca !important;
  background: #fef2f2 !important;
}

.module-actions,
.nav-controls {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.9vmin, 10px);
  margin-top: clamp(7px, 1vmin, 12px);
}

.nav-controls {
  justify-content: space-between;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(7px, 1vmin, 11px);
  margin-top: 0;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.tf-btn {
  border: 0;
  border-radius: 8px;
  padding: clamp(7px, 1vmin, 10px) clamp(10px, 1.4vmin, 14px);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-size: clamp(0.62rem, 1.15vmin, 0.9rem);
}

.primary-btn {
  background: var(--blue-600);
  color: var(--white);
}

.secondary-btn {
  background: var(--blue-900);
  color: var(--white);
}

.ghost-btn {
  background: var(--blue-050);
  color: var(--blue-900);
  border: 1px solid #bfdbfe;
}

.tf-btn {
  background: var(--white);
  color: var(--blue-900);
  border: 1px solid #cbd5e1;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.tf-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.dot {
  width: clamp(6px, 0.9vmin, 9px);
  height: clamp(6px, 0.9vmin, 9px);
  border-radius: 50%;
  background: #cbd5e1;
}

.dot.active {
  background: var(--blue-600);
}

.case-card {
  background: var(--yellow);
  border-color: #fde68a;
}

.case-card h3 {
  margin-top: 0;
  color: var(--blue-900);
}

.case-form label {
  display: block;
  font-weight: 700;
  color: var(--blue-900);
  font-size: clamp(0.62rem, 1.12vmin, 0.88rem);
}

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

.case-form label:last-child {
  grid-column: 1 / -1;
}

.final-panel {
  max-width: 860px;
  margin: 0 auto;
  text-align: left;
}

.achievement-list {
  display: grid;
  gap: clamp(6px, 0.8vmin, 9px);
  padding: 0;
  list-style: none;
}

.achievement-list li {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: clamp(8px, 1vmin, 11px) clamp(9px, 1.2vmin, 13px);
  font-size: clamp(0.65rem, 1.2vmin, 0.92rem);
}

.achievement-list li::before {
  content: "✓";
  color: var(--green);
  font-weight: 900;
  margin-right: 8px;
}

.score-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--blue-050);
  border-color: #bfdbfe;
}

.score-card strong {
  color: var(--blue-600);
  font-size: clamp(1.2rem, 2.4vmin, 1.8rem);
}

blockquote {
  margin: clamp(8px, 1.2vmin, 16px) 0 0;
  padding: clamp(9px, 1.3vmin, 15px);
  border-left: 6px solid var(--blue-600);
  background: var(--slate-050);
  color: var(--blue-900);
  font-weight: 800;
  font-size: clamp(0.68rem, 1.25vmin, 0.98rem);
}

@media (max-width: 880px) {
  .topbar { gap: 10px; }
  .concept-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .flow-map { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw, calc(100vh * 16 / 9));
    height: min(100vh, calc(100vw * 9 / 16));
    padding: 6px;
  }

  .topbar,
  .module,
  .nav-controls {
    border-radius: 6px;
  }

  .concept-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .flow-map { grid-template-columns: repeat(6, minmax(0, 1fr)); }

  .hero-visual {
    height: 170px;
  }

  .visual-node {
    width: 54px;
    height: 54px;
    font-size: 0.9rem;
  }

  .node-large {
    width: 64px;
    height: 64px;
  }

  .nav-controls {
    display: flex;
  }

  .dots {
    order: 0;
  }
}
