:root {
  --bg: #f2ece2;
  --panel: rgba(255, 250, 243, 0.9);
  --text: #1f2933;
  --muted: #5c6773;
  --line: rgba(31, 41, 51, 0.12);
  --warm: #b5523c;
  --cool: #285d8f;
  --dark: #16344a;
  --open: #1f7a5c;
  --open-soft: #dcf3e7;
  --closed: #b74242;
  --closed-soft: #f8e0de;
  --gold: #b8801e;
  --shadow: 0 24px 48px rgba(29, 34, 37, 0.12);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(183, 66, 66, 0.11), transparent 26%),
    radial-gradient(circle at bottom right, rgba(40, 93, 143, 0.14), transparent 22%),
    linear-gradient(180deg, #f6f0e8 0%, #efe3d2 100%);
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent 35%);
  opacity: 0.7;
}

img {
  display: block;
  max-width: 100%;
}

button,
textarea,
select {
  font: inherit;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(290px, 0.92fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 20px;
}

.hero-copy,
.hero-panel,
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 28px;
}

.hero-panel {
  padding: 22px;
  background: rgba(17, 44, 63, 0.92);
  color: #f7fbff;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.panel-warm {
  background:
    linear-gradient(180deg, rgba(255, 247, 242, 0.96), rgba(255, 249, 245, 0.92));
}

.panel-cool {
  background:
    linear-gradient(180deg, rgba(245, 249, 255, 0.96), rgba(250, 252, 255, 0.92));
}

.panel-retrieval {
  background:
    linear-gradient(180deg, rgba(245, 252, 248, 0.96), rgba(251, 255, 253, 0.92));
}

.panel-retrieval .panel-heading {
  margin-bottom: 10px;
}

.panel-retrieval .panel-copy {
  margin: 0 0 12px;
  font-size: 0.92rem;
}

.eyebrow,
.step {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  font-weight: 800;
}

.eyebrow {
  color: var(--warm);
}

.step {
  color: var(--cool);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
  font-family: Georgia, "Avenir Next", serif;
}

h1 {
  font-size: clamp(2rem, 3.6vw, 3.4rem);
  margin-bottom: 14px;
  max-width: none;
}

h2 {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

h3 {
  font-size: 1.26rem;
}

.intro,
.panel-copy,
.feedback-line,
.hero-feedback,
.download-status,
.game-status,
.resource-card figcaption,
.statement-note {
  color: var(--muted);
  line-height: 1.65;
}

.panel-copy-list {
  margin: 0 0 22px 0;
  padding-left: 1.2rem;
}

.intro-list {
  margin: 0 0 18px;
  padding-left: 1.2rem;
}

.dual-coding-card {
  margin-top: 14px;
}

.dual-diagram {
  width: min(100%, 680px);
  margin: 0 auto;
  border-radius: 20px;
  background:
    radial-gradient(circle at top, rgba(255, 203, 119, 0.16), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(248, 240, 228, 0.94));
  border: 1px solid rgba(29, 41, 57, 0.08);
  overflow: hidden;
}

.diagram-svg {
  display: block;
  width: 100%;
  height: auto;
}

.diagram-lines line {
  stroke-width: 3;
  stroke-linecap: round;
}

.diagram-lines-gold line {
  stroke: rgba(184, 128, 30, 0.9);
}

.diagram-lines-blue line {
  stroke: rgba(63, 102, 180, 0.9);
}

.diagram-node rect {
  stroke: rgba(255, 255, 255, 0.56);
  stroke-width: 1.5;
  filter: drop-shadow(0 14px 22px rgba(23, 35, 49, 0.12));
}

.diagram-node text {
  fill: #fff;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 20px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  alignment-baseline: middle;
}

.diagram-node tspan {
  text-anchor: middle;
  dominant-baseline: middle;
  alignment-baseline: middle;
}

.diagram-node-root rect {
  fill: url(#rootFill);
}

.diagram-node-closed rect {
  fill: url(#closedFill);
}

.diagram-node-open rect {
  fill: url(#openFill);
}

.diagram-node-feature rect {
  fill: url(#featureFill);
}

.hero-label,
.hero-feedback,
.download-status {
  color: #dae6ef;
}

.hero-stats {
  display: grid;
  gap: 14px;
  margin: 16px 0;
}

.hero-stats div {
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.hero-stats div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.hero-stats span {
  display: block;
  font-size: 0.92rem;
  opacity: 0.88;
}

.hero-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
}

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

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-2px);
}

.button.primary {
  background: linear-gradient(135deg, #b44b3a, #962f28);
  color: #fff7f4;
  box-shadow: 0 14px 28px rgba(150, 47, 40, 0.18);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.82);
  color: var(--dark);
  border: 1px solid rgba(22, 52, 74, 0.16);
}

.hero .button.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #f7fbff;
  border-color: rgba(255, 255, 255, 0.2);
}

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

.definition-grid,
.sorting-grid,
.game-board,
.resource-strip {
  display: grid;
  gap: 16px;
}

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

.definition-card,
.sort-card,
.resource-card,
.statement-row {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.definition-card,
.sort-card {
  padding: 16px;
}

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

.status-pill,
.result-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(31, 41, 51, 0.08);
  color: var(--muted);
}

.status-pill.is-complete,
.result-pill.is-correct {
  background: var(--open-soft);
  color: var(--open);
}

.result-pill.is-wrong {
  background: var(--closed-soft);
  color: var(--closed);
}

textarea,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(31, 41, 51, 0.14);
  padding: 14px 16px;
  background: #fff;
}

textarea {
  min-height: 176px;
  resize: vertical;
}

.model-answer {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(40, 93, 143, 0.08);
  border: 1px dashed rgba(40, 93, 143, 0.2);
  line-height: 1.6;
}

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

.statement-row {
  padding: 14px;
}

.statement-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.is-correct-row {
  border-color: rgba(31, 122, 92, 0.38);
  background: rgba(220, 243, 231, 0.72);
}

.is-wrong-row {
  border-color: rgba(183, 66, 66, 0.34);
  background: rgba(248, 224, 222, 0.78);
}

.resource-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.resource-card {
  margin: 0;
  padding: 16px;
}

.resource-card figcaption {
  margin-top: 12px;
  font-size: 0.94rem;
}

.game-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.game-board {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(48px, 7vw, 96px);
}

.game-board > div {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.connector-board {
  position: relative;
}

.connector-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.connector-line {
  stroke-width: 4;
  stroke-linecap: round;
}

.connector-line-active {
  stroke: rgba(181, 82, 60, 0.65);
  stroke-dasharray: 10 8;
}

.game-board {
  justify-items: center;
  position: relative;
  z-index: 1;
}

.game-grid {
  display: grid;
  gap: 6px;
  width: min(100%, 230px);
  margin-top: 8px;
  grid-auto-rows: 1fr;
  flex: 1;
}

.game-card {
  width: 100%;
  height: 100%;
  max-width: 230px;
  border-radius: 14px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.game-card strong {
  display: block;
  line-height: 1.25;
  font-size: 0.9rem;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(34, 50, 66, 0.1);
}

.game-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.28;
  font-size: 0.78rem;
}

.game-card.is-selected {
  border-color: rgba(40, 93, 143, 0.38);
  background: rgba(40, 93, 143, 0.08);
}

.game-card.is-dragging {
  border-color: rgba(181, 82, 60, 0.42);
  background: rgba(181, 82, 60, 0.08);
  box-shadow: 0 14px 28px rgba(181, 82, 60, 0.12);
}

.game-card.is-matched {
  color: #fff;
  border-color: transparent;
}

.game-card.is-matched small {
  color: rgba(255, 255, 255, 0.9);
}

.game-card.is-matched[data-format="open"] {
  background: linear-gradient(135deg, #29906b, #195b46);
}

.game-card.is-matched[data-format="closed"] {
  background: linear-gradient(135deg, #c55353, #912f39);
}

.legend-chip {
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 700;
  align-self: center;
}

.legend-chip-open {
  background: var(--open-soft);
  color: var(--open);
}

.legend-chip-closed {
  background: var(--closed-soft);
  color: var(--closed);
}

.feedback-line {
  min-height: 28px;
  margin: 14px 0 0;
  font-weight: 700;
}

.download-panel {
  width: fit-content;
  max-width: 100%;
  margin: 8px auto 0;
  padding: 10px 0 0;
  border-radius: 24px;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  text-align: center;
}

.download-button {
  min-width: 180px;
}

.download-status-panel {
  margin: 10px 0 0;
  color: var(--muted);
}

.feedback-line.is-good {
  color: var(--open);
}

.feedback-line.is-warn {
  color: var(--closed);
}

@media (max-width: 940px) {
  .hero,
  .definition-grid,
  .sorting-grid,
  .game-board,
  .resource-strip {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .game-status {
    display: block;
  }

  .button-row {
    margin-top: 12px;
  }

  .backdrop {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent 35%);
  }
}

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

  .hero-copy,
  .hero-panel,
  .panel {
    padding: 18px;
  }

  .statement-controls {
    grid-template-columns: 1fr;
  }
}
