:root {
  --ink: #14213d;
  --muted: rgba(20, 33, 61, .68);
  --soft: #f5f7ff;
  --white: #fff;
  --purple: #6d4cff;
  --teal: #10b7b0;
  --blue: #2388ff;
  --orange: #f97316;
  --pink: #ec4899;
  --green: #22c55e;
  --red: #ef4444;
  --border: rgba(20, 33, 61, .12);
  --shadow: 0 22px 70px rgba(20, 33, 61, .14);
  --radius: 30px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(109, 76, 255, .20), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(16, 183, 176, .22), transparent 28%),
    linear-gradient(135deg, #fbfbff 0%, #eef9ff 50%, #fff7ed 100%);
}

button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }

.pv-app { min-height: 100vh; }

.pv-topbar {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 12px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  color: #fff;
  font-weight: 950;
  box-shadow: 0 12px 24px rgba(249, 115, 22, .24);
}

.brand strong { display: block; font-size: 1.05rem; }
.brand small { color: var(--muted); font-weight: 800; }

.top-actions, .setup-footer, .play-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-btn, .primary-btn, .secondary-btn, .small-btn {
  border: 0;
  min-height: 46px;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 900;
}

.ghost-btn, .secondary-btn, .small-btn {
  background: rgba(255,255,255,.8);
  color: var(--ink);
  border: 1px solid var(--border);
}

.primary-btn {
  background: linear-gradient(135deg, var(--orange), var(--pink));
  color: #fff;
  box-shadow: 0 16px 32px rgba(249, 115, 22, .22);
}

.pv-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding-bottom: 48px;
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 20px;
  align-items: start;
}

.setup-card, .play-card {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.setup-card { padding: clamp(22px, 3vw, 34px); position: sticky; top: 16px; }
.play-card { padding: clamp(18px, 3vw, 28px); }

.eyebrow, .question-type {
  display: inline-flex;
  width: fit-content;
  min-height: 32px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(249, 115, 22, .13);
  color: #b45309;
  font-weight: 950;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: .78rem;
}

.setup-copy h1 {
  margin: 12px 0 10px;
  line-height: .98;
  letter-spacing: -.055em;
  font-size: clamp(2.1rem, 5vw, 4.4rem);
}

.setup-copy p:not(.eyebrow), .teacher-note p {
  color: var(--muted);
  line-height: 1.55;
}

.setup-controls {
  display: grid;
  gap: 12px;
  margin: 22px 0;
}

.setup-controls label { display: grid; gap: 7px; font-weight: 900; }
.setup-controls span { color: var(--muted); font-size: .88rem; }
select {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
}

.teacher-note {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(245,247,255,.85);
  margin-bottom: 18px;
}
.teacher-note summary { font-weight: 950; cursor: pointer; }

.setup-status { align-self: center; font-weight: 900; color: var(--muted); }

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.hud-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 14px;
  box-shadow: 0 8px 18px rgba(20,33,61,.06);
}
.hud-tile span { display: block; color: var(--muted); font-weight: 900; font-size: .82rem; }
.hud-tile strong { display: block; font-size: clamp(1.35rem, 3vw, 2.1rem); line-height: 1.05; }

.question-card {
  border-radius: 26px;
  padding: clamp(18px, 3vw, 28px);
  color: #fff;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.22), transparent 30%),
    linear-gradient(135deg, var(--orange), var(--pink));
  box-shadow: 0 18px 36px rgba(249, 115, 22, .20);
  margin-bottom: 16px;
}
.question-card .question-type { background: rgba(255,255,255,.2); color: #fff; }
.question-card h2 { margin: 12px 0 8px; font-size: clamp(1.9rem, 5vw, 3.8rem); letter-spacing: -.055em; line-height: 1; }
.question-hint { margin: 0; color: rgba(255,255,255,.85); font-weight: 800; }

.builder-panel, .model-panel, .choice-grid {
  margin-top: 16px;
}

.target-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.target-strip span { display: block; color: var(--muted); font-weight: 900; }
.target-strip strong { font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: -.05em; }

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

.place-card, .model-card {
  border-radius: 22px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 14px;
  box-shadow: 0 10px 22px rgba(20, 33, 61, .06);
}

.place-title, .model-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 950;
}
.place-title small, .model-title small { color: var(--muted); font-weight: 900; }

.counter {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  gap: 8px;
  align-items: center;
}
.counter button {
  border: 0;
  border-radius: 14px;
  height: 46px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 950;
  font-size: 1.4rem;
}
.counter strong {
  text-align: center;
  font-size: 2rem;
}
.blocks {
  min-height: 72px;
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}
.block {
  width: 23px;
  height: 23px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 950;
  font-size: .72rem;
  box-shadow: 0 4px 8px rgba(20,33,61,.12);
}
.block.green { background: #22c55e; }
.block.blue { background: #2388ff; }
.block.purple { background: #8b5cf6; }
.block.orange { background: #f97316; }
.block.pink { background: #ec4899; }
.block.teal { background: #10b7b0; }
.block.lime { background: #84cc16; }
.block.gold { background: #f59e0b; }

.check-btn { width: 100%; margin-top: 14px; }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.choice-btn {
  min-height: 86px;
  border: 0;
  border-radius: 22px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 950;
  font-size: clamp(1.25rem, 4vw, 2.2rem);
  box-shadow: 0 10px 20px rgba(20,33,61,.08);
  border: 1px solid var(--border);
}
.choice-btn:hover { transform: translateY(-2px); }
.choice-btn.correct { background: #dcfce7; border-color: rgba(34,197,94,.45); }
.choice-btn.wrong { background: #fee2e2; border-color: rgba(239,68,68,.45); }

.model-card .blocks { min-height: 84px; }
.model-count { font-size: 2.2rem; font-weight: 950; }

.feedback {
  min-height: 52px;
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(245,247,255,.9);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 900;
  margin: 16px 0;
}
.feedback.good { background: #dcfce7; color: #166534; }
.feedback.try { background: #fff7ed; color: #9a3412; }
.feedback.bad { background: #fee2e2; color: #991b1b; }

.end-screen[hidden], [hidden] { display: none !important; }
.end-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20,33,61,.44);
  backdrop-filter: blur(6px);
  z-index: 30;
}
.end-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 32px;
  padding: clamp(28px, 5vw, 46px);
  text-align: center;
  box-shadow: var(--shadow);
}
.end-card h2 { margin: 12px 0; font-size: clamp(2.2rem, 7vw, 4.5rem); letter-spacing: -.06em; }
.end-card p:not(.eyebrow) { color: var(--muted); font-weight: 850; line-height: 1.5; }

@media (max-width: 980px) {
  .pv-shell { grid-template-columns: 1fr; }
  .setup-card { position: static; }
}

@media (max-width: 650px) {
  .pv-topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: stretch; }
  .top-actions button { flex: 1; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: 1fr; }
  .target-strip { align-items: flex-start; flex-direction: column; }
  .small-btn { width: 100%; }
}
