* {
  box-sizing: border-box;
}

:root {
  --bg: #eef5f7;
  --panel: #ffffff;
  --text: #18323b;
  --muted: #607780;
  --brand: #167c83;
  --brand-dark: #0d5e64;
  --accent: #ef5b5b;
  --accent-soft: #fff0f0;
  --line: #d7e4e8;
  --success: #2f8f63;
  --shadow: 0 12px 32px rgba(31, 72, 83, 0.10);
  --radius: 18px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f6fafb 0%, var(--bg) 55%, #e8f1f3 100%);
  color: var(--text);
  min-height: 100vh;
}

button, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 24px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-name {
  text-decoration: none;
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.brand-tagline {
  color: var(--muted);
  font-size: 0.9rem;
}

.home-link {
  color: var(--brand-dark);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
}

.page-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 24px 40px;
}

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(211, 226, 230, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  padding: 30px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.15rem;
}

h3 {
  margin-bottom: 6px;
}

.hero-copy {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 0;
}

.status-card {
  min-width: 220px;
  background: #effafa;
  border: 1px solid #cce7e7;
  border-radius: 14px;
  padding: 18px;
}

.status-card strong,
.status-card span {
  display: block;
}

.status-label, .mini-label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.06em;
}

#stageLabel {
  margin: 4px 0 5px;
  font-size: 1.08rem;
}

#stageHint {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.lab-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(420px, 1.45fr);
  gap: 22px;
  margin-top: 22px;
}

.controls-panel,
.visual-panel,
.data-panel,
.teacher-note {
  padding: 26px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-top: 26px;
}

.section-heading p {
  color: var(--muted);
  margin-bottom: 0;
  font-size: 0.92rem;
}

.step-number {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  background: var(--brand);
  color: white;
  border-radius: 10px;
  font-weight: 800;
  flex: 0 0 auto;
}

.controls-panel label {
  display: block;
  font-weight: 750;
  margin: 14px 0 7px;
}

select {
  width: 100%;
  padding: 12px 13px;
  border-radius: 11px;
  border: 1px solid #c9d9dd;
  color: var(--text);
  background: white;
}

select:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  background: #f3f6f7;
  color: #6a7e85;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.small-btn {
  border: none;
  border-radius: 11px;
  font-weight: 800;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn {
  width: 100%;
  margin-top: 10px;
  padding: 13px 15px;
  background: var(--brand);
  color: white;
  box-shadow: 0 6px 14px rgba(22, 124, 131, 0.18);
}

.secondary-btn {
  padding: 11px;
  background: #e9f6f6;
  color: var(--brand-dark);
}

.ghost-btn {
  padding: 11px;
  background: #f3f6f7;
  color: #536a72;
}

.small-btn {
  padding: 9px 12px;
  background: var(--brand);
  color: white;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.timer-card {
  margin-top: 18px;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 15px;
}

.timer-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-weight: 800;
}

.progress-track {
  margin-top: 10px;
  height: 9px;
  background: #dfeaec;
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--brand);
  transition: width 0.12s linear;
}

#timerMessage {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.45;
  margin: 9px 0 0;
}

.legend-box {
  margin-top: 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 13px 14px;
  border-radius: 9px;
}

.legend-box p {
  margin: 4px 0 0;
  color: #6f5050;
  font-size: 0.9rem;
  line-height: 1.45;
}

.visual-panel {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.student-stage {
  min-height: 390px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,255,255,.9), rgba(233,247,248,.85) 50%, rgba(223,239,241,.9) 100%);
  border: 1px solid #d6e6e8;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.pulse-ring {
  width: 230px;
  height: 230px;
  border-radius: 50%;
  border: 2px solid rgba(239, 91, 91, 0.25);
  display: grid;
  place-items: center;
  position: relative;
}

.pulse-ring.active {
  animation: pulseRing 0.9s infinite ease-out;
}

.person {
  width: 110px;
  height: 210px;
  position: relative;
  transform-origin: center bottom;
}

.head {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #d8a47f;
  position: absolute;
  left: 31px;
  top: 6px;
}

.torso {
  width: 58px;
  height: 92px;
  border-radius: 18px 18px 14px 14px;
  background: var(--brand);
  position: absolute;
  left: 26px;
  top: 54px;
}

.arm, .leg {
  position: absolute;
  background: #44656e;
  border-radius: 99px;
  transform-origin: top center;
}

.arm {
  width: 15px;
  height: 82px;
  top: 60px;
}

.arm-left { left: 13px; transform: rotate(11deg); }
.arm-right { right: 13px; transform: rotate(-11deg); }

.leg {
  width: 18px;
  height: 76px;
  top: 139px;
}

.leg-left { left: 31px; transform: rotate(4deg); }
.leg-right { right: 31px; transform: rotate(-4deg); }

.person.moving .arm-left { animation: armMoveLeft 0.65s infinite alternate ease-in-out; }
.person.moving .arm-right { animation: armMoveRight 0.65s infinite alternate ease-in-out; }
.person.moving .leg-left { animation: legMoveLeft 0.65s infinite alternate ease-in-out; }
.person.moving .leg-right { animation: legMoveRight 0.65s infinite alternate ease-in-out; }
.person.moving { animation: bodyBounce 0.65s infinite alternate ease-in-out; }

.heart-readout {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: white;
  border: 1px solid #ead6d6;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 20px rgba(91, 56, 56, 0.08);
}

.heart-readout span,
.heart-readout strong {
  display: block;
}

.heart-readout strong {
  font-size: 1.35rem;
}

.heart-icon {
  color: var(--accent);
  font-size: 1.85rem;
  animation: heartbeat 1.1s infinite;
}

.body-response {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.body-response > div {
  background: rgba(255,255,255,.9);
  border: 1px solid #d9e6e8;
  border-radius: 11px;
  padding: 10px 12px;
}

.body-response strong {
  display: block;
  margin-top: 3px;
}

.explanation-card {
  margin-top: 16px;
  padding: 17px 18px;
  border-radius: 14px;
  background: #f5fbfb;
  border: 1px solid #d8eaea;
}

.explanation-card p {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

.data-panel {
  margin-top: 22px;
}

.data-layout {
  display: grid;
  grid-template-columns: minmax(300px, .78fr) minmax(480px, 1.45fr);
  gap: 20px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fbfdfd;
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  padding: 12px 11px;
  border-bottom: 1px solid #e0eaec;
  text-align: left;
  font-size: 0.92rem;
}

th {
  background: #eff7f7;
  color: var(--brand-dark);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.graph-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbfdfd;
}

.graph-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.graph-header p {
  color: var(--muted);
  margin-bottom: 0;
  font-size: 0.88rem;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.analysis-box {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.analysis-box > p {
  color: var(--muted);
}

.prompt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.prompt-grid label {
  font-weight: 750;
  font-size: 0.92rem;
}

.prompt-grid .wide {
  grid-column: 1 / -1;
}

textarea {
  width: 100%;
  min-height: 105px;
  resize: vertical;
  margin-top: 8px;
  border-radius: 11px;
  border: 1px solid #cbdadd;
  padding: 12px;
  color: var(--text);
  background: white;
  line-height: 1.45;
}

.completion-message {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #edf8f2;
  border: 1px solid #cce7d8;
  color: #2c694c;
}

.hidden {
  display: none;
}

.teacher-note {
  margin-top: 22px;
}

.teacher-note p {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 36px;
  display: flex;
  justify-content: space-between;
  color: #6a7e85;
  font-size: 0.86rem;
}

@keyframes heartbeat {
  0%, 70%, 100% { transform: scale(1); }
  12% { transform: scale(1.14); }
  24% { transform: scale(1); }
  34% { transform: scale(1.08); }
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(239,91,91,.28); }
  100% { box-shadow: 0 0 0 28px rgba(239,91,91,0); }
}

@keyframes armMoveLeft {
  from { transform: rotate(28deg); }
  to { transform: rotate(-20deg); }
}
@keyframes armMoveRight {
  from { transform: rotate(-28deg); }
  to { transform: rotate(20deg); }
}
@keyframes legMoveLeft {
  from { transform: rotate(13deg); }
  to { transform: rotate(-10deg); }
}
@keyframes legMoveRight {
  from { transform: rotate(-13deg); }
  to { transform: rotate(10deg); }
}
@keyframes bodyBounce {
  from { transform: translateY(0); }
  to { transform: translateY(-7px); }
}

@media (max-width: 900px) {
  .hero,
  .lab-grid,
  .data-layout {
    grid-template-columns: 1fr;
  }

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

  .status-card {
    min-width: 0;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .prompt-grid .wide {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-shell,
  .site-header,
  footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .controls-panel,
  .visual-panel,
  .data-panel,
  .teacher-note,
  .hero {
    padding: 18px;
  }

  .visual-panel {
    min-height: 480px;
  }

  .student-stage {
    min-height: 360px;
  }

  .pulse-ring {
    width: 190px;
    height: 190px;
  }

  .heart-readout {
    right: 10px;
    top: 10px;
  }

  .body-response {
    grid-template-columns: 1fr;
  }

  .graph-header,
  footer {
    flex-direction: column;
  }
}
