:root {
  --ice-night: #07151c;
  --panel: #10262f;
  --panel-2: #16323c;
  --tape: #ff6a1a;
  --tape-dark: #c4470a;
  --gold: #f5d76e;
  --mint: #9ee6d4;
  --chalk: #e8f1ef;
  --ink: #0b1c24;
  --danger: #ff6b5a;
  --ok: #3dd68c;
  --line: rgba(255, 255, 255, 0.08);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(255, 106, 26, 0.12), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(158, 230, 212, 0.08), transparent 45%),
    var(--ice-night);
  color: var(--chalk);
  font-family: "Nunito", "Trebuchet MS", sans-serif;
}

body {
  height: 100vh;
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
  opacity: 0.7;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  max-width: none;
  margin: 0;
  padding: 10px 12px 12px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

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

.brand h1 {
  font-family: "Bungee", Impact, sans-serif;
  font-size: 22px;
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
}

.brand .sub {
  font-size: 13px;
  color: var(--mint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.day-pips {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.day-pip {
  appearance: none;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--chalk);
  font-family: inherit;
  font-weight: 800;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
}

.day-pip.active {
  background: var(--tape);
  border-color: var(--tape);
  color: var(--ink);
  transform: translateY(-1px);
}

.day-pip.done {
  box-shadow: inset 0 -3px 0 var(--ok);
}

.meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.names {
  font-weight: 800;
  font-size: 14px;
  color: var(--mint);
}

.timer {
  font-family: "Martian Mono", ui-monospace, monospace;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 6px 8px;
  border-radius: 8px;
}

.timer.hot { color: var(--tape); }

button, .btn {
  font-family: inherit;
  cursor: pointer;
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--chalk);
  border-radius: 8px;
  padding: 6px 8px;
  font-weight: 700;
  font-size: 13px;
}

.lesson-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  background: linear-gradient(90deg, #1a3d32, var(--panel));
  border: 1px solid var(--line);
  border-left: 8px solid var(--tape);
  border-radius: 10px;
  padding: 6px 12px;
  box-shadow: none;
}

.lesson-bar h2 {
  margin: 0;
  font-size: 16px;
}

.lesson-bar p {
  margin: 0;
  color: rgba(232, 241, 239, 0.86);
}

.stage {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(260px, 1fr) minmax(300px, 1.15fr);
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card h3 {
  margin: 0;
  padding: 8px 12px 4px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
}

.missions {
  overflow: hidden;
  padding: 0 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mission {
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: inherit;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
}

.mission.active {
  border-color: var(--tape);
  box-shadow: 0 0 0 1px var(--tape);
}

.mission.done {
  border-color: rgba(61, 214, 140, 0.5);
}

.tick {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  margin-top: 2px;
}

.mission.done .tick {
  background: var(--ok);
  border-color: var(--ok);
}

.mission strong { display: block; font-size: 15px; }

.why {
  padding: 0 12px 10px;
  font-size: 14px;
  color: rgba(232,241,239,0.85);
}

.editor-wrap {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  min-height: 0;
}

.palette {
  display: flex;
  gap: 8px;
  padding: 0 12px 6px;
}

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

.speed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 6px;
  font-weight: 800;
  font-size: 14px;
}

.chip-btn, .helper {
  background: var(--panel-2);
  color: var(--chalk);
  border: 2px solid var(--line);
  border-radius: 999px;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 12px;
  min-height: 36px;
  cursor: pointer;
}

.helpers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 6px;
}

.helpers:empty {
  display: none;
}

.hidden {
  display: none !important;
}

.helper {
  background: #1e4a3c;
  border-color: rgba(158, 230, 212, 0.35);
}

.codebox {
  display: grid;
  grid-template-columns: 32px 1fr;
  margin: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
  height: 100%;
  background: #0a1a20;
}

.gutter {
  margin: 0;
  padding: 8px 6px;
  background: #071217;
  color: #5d7a82;
  font-family: "Martian Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.55;
  text-align: right;
  overflow: hidden;
  user-select: none;
}

#code {
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: #d7f3ea;
  font-family: "Martian Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.55;
  padding: 8px 10px;
  tab-size: 2;
  min-height: 0;
  height: 100%;
}

.editor-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px 10px;
}

.error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 800;
  min-height: 1.2em;
  flex: 1;
}

.run-btn {
  background: var(--tape);
  color: var(--ink);
  border: 0;
  border-bottom: 4px solid var(--tape-dark);
  font-family: "Bungee", Impact, sans-serif;
  font-size: 18px;
  padding: 8px 16px;
  border-radius: 10px;
  min-width: 110px;
}

.run-btn:active { border-bottom-width: 2px; transform: translateY(2px); }

.show-btn {
  background: var(--gold);
  color: var(--ink);
  border: 0;
  font-weight: 800;
  border-radius: 8px;
  padding: 8px 10px;
}

.rink-card { padding-bottom: 8px; }

.screen {
  margin: 0 10px;
  background: #041014;
  border-radius: 12px;
  padding: 8px;
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(245, 215, 110, 0.15);
  flex: 1 1 auto;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#rink {
  display: block;
  width: min(100%, 560px);
  height: auto;
  aspect-ratio: 560 / 380;
  max-height: calc(100vh - 170px);
  min-height: 200px;
  border-radius: 8px;
  background: #0b3a32;
  outline: none;
}

.scan {
  pointer-events: none;
  position: absolute;
  inset: 10px;
  border-radius: 8px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.03),
    rgba(255,255,255,0.03) 1px,
    transparent 1px,
    transparent 4px
  );
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px 0;
  font-size: 11px;
  color: rgba(232,241,239,0.7);
}

.keys kbd {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Martian Mono", ui-monospace, monospace;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 21, 28, 0.82);
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.overlay.hidden { display: none; }

.modal {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 8px solid var(--tape);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal h2 {
  font-family: "Bungee", Impact, sans-serif;
  color: var(--gold);
  margin: 0 0 8px;
}

.modal p { margin: 0 0 14px; color: rgba(232,241,239,0.85); }

.fields {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.fields label { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mint); }
.fields input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0a1a20;
  color: var(--chalk);
  font-family: inherit;
  font-size: 16px;
}

.celebrate {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(160px, 200px) 1fr 1fr; }
}
