/* Loop Troop — sticker-book styling: chunky borders, hard shadows, bright blocks. */

:root {
  --ink: #1c1440;
  --ink-2: #2b2158;
  --muted: #6a6290;
  --paper: #fffdf6;
  --bg: #f4f1ff;
  --violet: #7c5cff;
  --violet-deep: #5b3ce0;
  --lime: #c3f76b;
  --coral: #ff8a5c;
  --sky: #5ed3ff;
  --sun: #ffd166;
  --radius: 20px;
  --border: 3px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --font-display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 10% 6%, #e6dcff 0, transparent 40%),
    radial-gradient(circle at 92% 10%, #d8f7e7 0, transparent 38%),
    radial-gradient(circle at 50% 102%, #ffe7d5 0, transparent 42%);
  background-attachment: fixed;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.08;
  margin: 0 0 0.35em;
  letter-spacing: -0.4px;
}

h1 {
  font-size: clamp(2rem, 4.4vw, 2.9rem);
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 0.75em;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--violet-deep);
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: #efe9ff;
  padding: 1px 5px;
  border-radius: 6px;
}

pre code {
  background: none;
  padding: 0;
}

.small {
  font-size: 0.86rem;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
}

/* --------------------------------- topbar -------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  padding: 10px clamp(14px, 3vw, 28px);
  background: rgba(255, 253, 246, 0.93);
  backdrop-filter: blur(10px);
  border-bottom: var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--lime);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 1.15rem;
  transform: rotate(-6deg);
}

.brand-name em {
  font-style: normal;
  color: var(--violet-deep);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 3px solid transparent;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.94rem;
  white-space: nowrap;
}

.tab:hover {
  background: #efe9ff;
}

.tab.is-active {
  background: var(--ink);
  color: var(--paper);
}

.tab-count {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--ink);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-toggle {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: var(--border);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.sound-toggle:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.xp-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  border-radius: 999px;
  border: var(--border);
  background: var(--lime);
  box-shadow: var(--shadow-sm);
}

.xp-emoji {
  font-size: 1.1rem;
}

.xp-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.xp-text b {
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.xp-text small {
  font-size: 0.68rem;
  font-weight: 700;
  color: #3f3663;
}

/* --------------------------------- layout -------------------------------- */

.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) clamp(14px, 3vw, 24px) 70px;
}

.page-head {
  margin-bottom: 22px;
}

.lede {
  font-size: 1.05rem;
  color: var(--ink-2);
  max-width: 62ch;
}

.eyebrow {
  display: inline-block;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--violet-deep);
  margin-bottom: 10px;
}

.block {
  margin-top: 28px;
}

.block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 12px;
}

.block-head h2 {
  margin: 0;
}

.footer {
  border-top: var(--border);
  padding: 22px clamp(14px, 3vw, 28px) 34px;
  text-align: center;
  background: rgba(255, 253, 246, 0.75);
}

.footer p {
  margin: 0 0 4px;
}

/* --------------------------------- buttons ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: var(--border);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.98rem;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 90ms ease, box-shadow 90ms ease, background 120ms ease;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn.primary {
  background: var(--violet);
  color: #fff;
}

.btn.ghost {
  background: var(--paper);
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
  box-shadow: var(--shadow-sm);
}

.chip-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: var(--border);
  background: var(--paper);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.86rem;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}

.chip-btn:hover {
  background: var(--sun);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #efe9ff;
  font-size: 0.76rem;
  font-weight: 800;
  font-family: var(--font-body);
  white-space: nowrap;
}

.pill-good {
  background: var(--lime);
}

/* ---------------------------------- hero --------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 30px;
  align-items: center;
  padding: 8px 0 4px;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  margin-bottom: 14px;
}

.marker {
  background: linear-gradient(180deg, transparent 58%, var(--lime) 58%, var(--lime) 92%, transparent 92%);
  padding: 0 6px;
}

.hero .lede {
  font-size: 1.1rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px 0 10px;
}

.hero-note {
  color: var(--muted);
  margin: 0;
}

.hero-art {
  position: relative;
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 10px;
}

.code-card {
  width: min(100%, 340px);
  background: var(--ink);
  color: #efeaff;
  border: var(--border);
  border-radius: 18px;
  box-shadow: 8px 8px 0 var(--coral);
  transform: rotate(-2.5deg);
  overflow: hidden;
}

.code-dots {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: var(--ink-2);
}

.code-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
}

.code-dots i:nth-child(2) {
  background: var(--sun);
}

.code-dots i:nth-child(3) {
  background: var(--lime);
}

.code-card pre {
  margin: 0;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.c-key {
  color: var(--sky);
}

.c-fn {
  color: var(--lime);
}

.c-num {
  color: var(--sun);
}

.c-com {
  color: #9a90c9;
}

.sticker {
  position: absolute;
  padding: 5px 12px;
  border-radius: 999px;
  border: var(--border);
  background: var(--paper);
  font-weight: 800;
  font-size: 0.82rem;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.sticker.s1 {
  top: 4%;
  left: 2%;
  background: var(--lime);
  transform: rotate(-7deg);
}

.sticker.s2 {
  top: 16%;
  right: 0;
  background: var(--sky);
  transform: rotate(6deg);
  font-family: var(--font-mono);
}

.sticker.s3 {
  bottom: 12%;
  right: 6%;
  background: var(--sun);
  transform: rotate(-4deg);
}

.sticker.s4 {
  bottom: 2%;
  left: 10%;
  background: var(--coral);
  transform: rotate(8deg);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 0;
}

.stat {
  background: var(--paper);
  border: var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.stat span {
  display: block;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.7rem;
  line-height: 1.2;
}

.stat b em {
  font-style: normal;
  font-size: 1rem;
  color: var(--muted);
}

.stat b.stat-small {
  font-size: 1.05rem;
  padding-top: 6px;
}

.panel {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.crew {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.crew-name label,
.crew-level-top b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

#crew-name {
  width: 100%;
  padding: 10px 12px;
  border: var(--border);
  border-radius: 12px;
  background: #fff;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.crew-level-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.crew-level-top span {
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--muted);
}

.bar {
  height: 16px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #eee8ff;
  overflow: hidden;
  margin: 4px 0 6px;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--sky));
  border-radius: 999px;
  transition: width 400ms ease;
}

/* --------------------------------- tracks -------------------------------- */

.track-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.track-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px 14px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 110ms ease, box-shadow 110ms ease;
}

.track-card:hover {
  transform: translate(-2px, -2px) rotate(-0.4deg);
  box-shadow: 6px 6px 0 var(--ink);
}

.track-card h3 {
  margin: 0;
}

.track-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.track-emoji {
  font-size: 2rem;
  line-height: 1;
}

.track-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-weight: 800;
}

.track-violet {
  background: linear-gradient(180deg, #ede7ff, var(--paper) 60%);
}

.track-sky {
  background: linear-gradient(180deg, #e2f6ff, var(--paper) 60%);
}

.track-lime {
  background: linear-gradient(180deg, #efffdc, var(--paper) 60%);
}

/* --------------------------------- badges -------------------------------- */

.badge-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px dashed #c9c0ec;
  border-radius: 14px;
  background: #faf7ff;
}

.badge.is-earned {
  border: var(--border);
  border-style: solid;
  background: #f4ffe4;
  box-shadow: 2px 2px 0 var(--ink);
}

.badge-emoji {
  font-size: 1.5rem;
}

.badge div {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.badge small {
  font-size: 0.74rem;
  color: var(--muted);
}

.badge.is-locked {
  opacity: 0.75;
}

/* ---------------------------------- how ---------------------------------- */

.how {
  margin-top: 30px;
}

.how-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.how-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  background: var(--paper);
  border: var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.how-list li > span {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--sun);
  font-family: var(--font-display);
  font-weight: 800;
}

.how-list p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* --------------------------------- quests -------------------------------- */

.trail {
  border-left: none;
}

.quest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 10px;
}

.quest-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: var(--border);
  border-radius: 16px;
  background: var(--paper);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 100ms ease, box-shadow 100ms ease, background 120ms ease;
}

.quest-card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
  background: #fbf8ff;
}

.quest-card.is-done {
  background: #f3ffe1;
}

.quest-emoji {
  font-size: 1.6rem;
  line-height: 1;
}

.quest-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.quest-text b {
  font-size: 0.98rem;
}

.quest-text small {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 700;
}

.quest-state {
  margin-left: auto;
  font-size: 1.1rem;
  font-weight: 800;
}

.back {
  display: inline-block;
  margin-bottom: 12px;
  font-weight: 800;
  text-decoration: none;
  color: var(--ink-2);
}

.back:hover {
  color: var(--violet-deep);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.track-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.76rem;
  font-weight: 800;
}

.quest-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* --------------------------------- editors ------------------------------- */

.editor-panel {
  min-width: 0;
}

.editor {
  border: var(--border);
  border-radius: 18px;
  background: #171033;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.editor:focus-within {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  background: var(--ink-2);
  border-bottom: 2px solid #3a2f6b;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #b9afe6;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.red {
  background: #ff6b6b;
}

.dot.yellow {
  background: var(--sun);
}

.dot.green {
  background: var(--lime);
}

.editor-bar .filename {
  margin-left: 6px;
  font-weight: 600;
}

.editor-tip {
  margin-left: auto;
  color: #8a7fc0;
  font-size: 0.68rem;
}

.editor-body {
  display: flex;
  align-items: stretch;
  background: #171033;
}

.gutter {
  padding: 14px 8px 14px 12px;
  min-width: 42px;
  text-align: right;
  color: #5c5291;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.62;
  white-space: pre;
  user-select: none;
  overflow: hidden;
}

#editor,
#play-editor {
  flex: 1;
  min-width: 0;
  min-height: 300px;
  padding: 14px 14px 18px 4px;
  border: 0;
  resize: vertical;
  background: transparent;
  color: #f6f2ff;
  caret-color: var(--lime);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.62;
  tab-size: 2;
  outline: none;
}

#play-editor {
  min-height: 340px;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.run-status {
  margin-left: auto;
}

/* -------------------------------- results -------------------------------- */

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

.result-block h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.console-out {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: #171033;
  color: #cbff9e;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-out span {
  display: block;
}

.console-out span::before {
  content: "› ";
  color: #6f63a8;
}

.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.checks li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 11px;
  background: #f2eeff;
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.4;
}

.checks li::before {
  content: "•";
  color: var(--violet);
  font-weight: 800;
}

.result-checks li::before {
  content: none;
}

.checks li.pass {
  background: #ecffd6;
}

.checks li.fail {
  background: #ffece2;
}

.checks li small {
  display: block;
  font-weight: 600;
  font-size: 0.74rem;
  color: #8a4a32;
}

.mark {
  font-weight: 800;
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px;
  border: var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.banner p {
  margin: 0;
}

.banner-warn {
  background: #ffe9df;
}

.banner-good {
  background: #ecffd6;
}

.success-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: var(--border);
  border-radius: 16px;
  background: var(--lime);
  box-shadow: var(--shadow);
  animation: pop-in 260ms ease;
}

.success-emoji {
  font-size: 1.8rem;
  line-height: 1;
}

.success-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.success-text b {
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.success-text small {
  font-size: 0.8rem;
  color: #3c4f16;
}

.success-banner .btn {
  margin-left: auto;
}

.pending {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 2px dashed #bfb4e6;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 700;
}

.pending p {
  margin: 0;
}

.loader {
  display: inline-block;
  font-size: 1.3rem;
  animation: spin 1.4s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pop-in {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* -------------------------------- mission -------------------------------- */

.mission .panel + .panel {
  margin-top: 12px;
}

.mission h2 {
  font-size: 1.05rem;
  margin-bottom: 0.4em;
}

.mission p {
  font-size: 0.93rem;
}

.hint {
  border: 2px solid #e2dcf6;
  border-radius: 12px;
  padding: 8px 12px;
  background: #faf8ff;
  margin-top: 8px;
}

.hint summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 0.88rem;
  list-style: none;
}

.hint summary::-webkit-details-marker {
  display: none;
}

.hint summary::before {
  content: "▸ ";
  color: var(--violet);
}

.hint[open] summary::before {
  content: "▾ ";
}

.hint p {
  margin: 8px 0 2px;
  font-size: 0.88rem;
}

.hint.reveal {
  border-style: dashed;
  background: #fff7ec;
}

.solution {
  margin: 8px 0 6px;
  padding: 10px 12px;
  background: #171033;
  color: #cbff9e;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
}

.next-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 16px;
  border: var(--border);
  border-radius: 16px;
  background: var(--sun);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.next-card small {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.next-card b {
  font-family: var(--font-display);
  font-size: 1rem;
}

.next-card span {
  margin-left: auto;
  font-size: 1.2rem;
}

/* ------------------------------- playground ------------------------------ */

.snippets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tip {
  margin-top: 16px;
  background: #eef7ff;
}

.tip p {
  font-size: 0.9rem;
  margin-top: 4px;
}

/* --------------------------------- arcade -------------------------------- */

.arcade-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.scoreboard {
  display: flex;
  gap: 10px;
}

.scoreboard > div {
  min-width: 74px;
  padding: 8px 12px;
  border: var(--border);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.scoreboard small {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.scoreboard b {
  font-family: var(--font-display);
  font-size: 1.3rem;
}

.progress-strip {
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #e9e2ff;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-strip i {
  display: block;
  height: 100%;
  background: var(--coral);
  transition: width 300ms ease;
}

.arcade-card {
  padding: 20px 22px 22px;
}

.arcade-card .kind {
  background: var(--sky);
  margin-bottom: 10px;
}

.arcade-code {
  margin: 0 0 14px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: #171033;
  color: #f6f2ff;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre-wrap;
}

.arcade-card h2 {
  font-size: 1.2rem;
}

.options {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 90ms ease, background 120ms ease;
}

.option:hover:not(:disabled) {
  background: #f4efff;
  transform: translate(-1px, -1px);
}

.option:disabled {
  cursor: default;
}

.option-key {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: #efe9ff;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.option.is-correct {
  background: var(--lime);
}

.option.is-wrong {
  background: #ffd9c9;
}

.verdict {
  padding: 12px 14px;
  border: var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.verdict.good {
  background: #ecffd6;
}

.verdict.bad {
  background: #ffece2;
}

.verdict p {
  margin: 4px 0 0;
  font-size: 0.92rem;
}

.arcade-result {
  text-align: center;
  padding: 30px 22px;
}

.big-score {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 4rem;
  line-height: 1;
  color: var(--violet-deep);
}

.big-score small {
  font-size: 1.5rem;
  color: var(--muted);
}

.center-panel {
  max-width: 560px;
  margin: 40px auto;
  text-align: center;
}

.loading {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  padding: 60px 0;
}

.loading .loader {
  display: block;
  font-size: 2.4rem;
  margin-bottom: 10px;
}

/* --------------------------------- toasts -------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(0);
  z-index: 60;
  padding: 11px 20px;
  border: var(--border);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 4px 4px 0 rgba(28, 20, 64, 0.35);
  animation: toast-in 240ms ease;
  max-width: calc(100vw - 32px);
}

.toast.is-leaving {
  opacity: 0;
  transition: opacity 500ms ease;
}

@keyframes toast-in {
  from {
    transform: translateX(-50%) translateY(14px);
    opacity: 0;
  }
}

/* -------------------------------- confetti -------------------------------- */

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  animation: confetti-fall var(--dur, 1.6s) ease-in var(--delay, 0s) forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--dx, 0), 105vh, 0) rotate(var(--rot, 360deg));
    opacity: 0.85;
  }
}

/* ------------------------------- responsive ------------------------------ */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .hero-art {
    padding: 20px 8px 26px;
    order: 2;
  }

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

  .track-grid,
  .how-list {
    grid-template-columns: 1fr;
  }

  .crew,
  .quest-layout {
    grid-template-columns: 1fr;
  }

  .mission {
    order: -1;
  }

  .tabs {
    order: 3;
    width: 100%;
    margin-left: 0;
    padding-bottom: 2px;
  }

  .topbar-right {
    margin-left: auto;
  }
}

@media (max-width: 560px) {
  .brand-name {
    font-size: 1.1rem;
  }

  .xp-text small {
    display: none;
  }

  .editor-bar .editor-tip {
    display: none;
  }

  #editor,
  #play-editor {
    min-height: 240px;
    font-size: 0.8rem;
  }

  .stat b {
    font-size: 1.4rem;
  }

  .scoreboard {
    width: 100%;
  }

  .scoreboard > div {
    flex: 1;
    min-width: 0;
  }

  .success-banner .btn,
  .next-card span {
    margin-left: 0;
  }

  .arcade-result .big-score {
    font-size: 3.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
