/* Title, HQ, Case Closed, and dialogue boxes. */

/* ---------- Title ---------- */

.title-screen {
  text-align: center;
  padding-top: 3rem;
}
.title-screen__logo {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  color: var(--yellow);
  text-shadow: var(--px) var(--px) 0 var(--magenta), calc(var(--px) * 2) calc(var(--px) * 2) 0 var(--ink);
  margin-bottom: 0.25em;
}
.title-screen__tagline {
  color: var(--teal);
  font-family: var(--font-pixel);
  font-size: 1.3rem;
  margin-bottom: 2.5rem;
}
.title-screen__box {
  max-width: 30rem;
  margin: 0 auto;
  text-align: left;
}
.title-screen__box h2 { font-size: 1.4rem; }
.title-screen__status {
  margin-top: 2rem;
  font-family: var(--font-pixel);
  color: var(--teal);
  font-size: 1rem;
}

.profile-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.profile-row__pick { width: 100%; }

/* ---------- HQ ---------- */

.hq h1 { margin-bottom: 0.75rem; }
.hq__heading { font-size: 1.4rem; margin: 1.5rem 0 0.75rem; }

/* Continue: the one big obvious next step. */
.continue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  background: #fff3c4;
}
.continue__where { flex: 1 1 16rem; }
.continue__label { font-family: var(--font-pixel); color: var(--muted-ink); font-size: 0.95rem; }
.continue__lesson { font-size: 1.25rem; font-weight: 700; }
.continue__btn { font-size: 1.35rem; padding: 0.55em 1.2em; }
.continue--done { background: #e6f8e8; font-weight: 700; }

/* The room: wall with a map board of stamps, and a wooden shelf of rewards. */
.hq-room {
  display: grid;
  grid-template-columns: 3fr 2fr auto;
  gap: 0;
  margin-bottom: 1.25rem;
  border: var(--border);
  box-shadow: var(--shadow);
  background: repeating-linear-gradient(90deg, #3b2f6e 0 46px, #372b66 46px 92px);
}
.hq-room__wall, .hq-room__shelf { padding: 1rem; min-width: 0; }
.hq-room__shelf { background: linear-gradient(#5a3f22, #4a331b); border-left: var(--border); }
.hq-room__mascot { display: flex; align-items: flex-end; padding: 0.75rem; border-left: var(--border); background: #2a2050; }
.hq-room__label {
  font-family: var(--font-pixel);
  color: var(--yellow);
  font-size: 1rem;
  margin-bottom: 0.6rem;
}
.stamp-board {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: #d9c79a;
  border: 4px solid #6b4a24;
  padding: 0.75rem;
  min-height: 6rem;
}
.shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 0.75rem;
  align-items: flex-end;
}
.shelf__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 5.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 6px solid #2f2010;  /* the shelf board */
}
.shelf__name { font-size: 0.85rem; color: #f3e6c4; text-align: center; margin-top: 0.25rem; line-height: 1.2; }

/* Placeholder art (replaced by pixel art in step 8). */
.stamp-art {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  border: 4px double #b3261e;
  color: #b3261e;
  display: grid;
  place-items: center;
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  text-align: center;
  transform: rotate(-8deg);
  background: #f6e9c8;
  overflow: hidden;
}
.stamp-art--empty { border-color: #a89a78; border-style: dashed; color: #a89a78; background: transparent; transform: none; }
.reward-art {
  width: 4rem;
  height: 4rem;
  display: grid;
  place-items: center;
  background: var(--sky);
  border: var(--border);
  font-family: var(--font-pixel);
  font-size: 2rem;
  color: var(--ink);
}
.reward-art--sprite { width: 72px; height: 72px; background: none; border: none; }
.reward-art--sprite img { width: 72px; height: 72px; display: block; }
.stamp-art__icon { width: 24px; height: 24px; image-rendering: pixelated; }
.stamp-art { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.reward-art--empty { background: #00000040; border-style: dashed; border-color: #00000080; color: #ffffff55; }

.rank-card { margin-bottom: 0.5rem; }
.rank-card__rank { font-family: var(--font-pixel); font-size: 1.4rem; }
.rank-card__label { color: var(--muted-ink); font-size: 1rem; text-transform: uppercase; }
.rank-card__bar { height: 18px; background: var(--paper-2); border: 3px solid var(--ink); margin: 0.4rem 0; }
.rank-card__fill { height: 100%; background: repeating-linear-gradient(90deg, var(--yellow) 0 8px, #ffbf00 8px 12px); }
.rank-card__next { color: var(--muted-ink); font-size: 1rem; }

.chapter-card--locked { opacity: 0.75; background: var(--paper-2); }
.chapter-card--closed { border-color: #22863a; }

@media (max-width: 640px) {
  .hq-room { grid-template-columns: 1fr; }
  .hq-room__shelf, .hq-room__mascot { border-left: none; border-top: var(--border); }
  .hq-room__mascot { justify-content: center; }
}

.chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
}
.chapter-card h3 { font-size: 1.2rem; margin-bottom: 0.25rem; }
.chapter-card p { color: var(--muted-ink); font-size: 1rem; }
.chapter-card__label { font-family: var(--font-pixel); color: var(--muted-ink); font-size: 0.95rem; }
.chapter-card__progress { font-family: var(--font-pixel); color: var(--teal); font-size: 0.95rem; margin-bottom: 0.5rem; }
.lesson-links { margin: 0; padding-left: 1.5rem; font-size: 1.05rem; }
.lesson-links a { color: var(--paper-ink); }
.lesson-links--done::marker { content: '✔ '; color: var(--green); }

/* ---------- Dialogue ---------- */

.dialogue {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}
.portrait {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  background: var(--night-2);
  border: var(--border);
  display: grid;
  place-items: center;
}
.portrait { overflow: hidden; }
.portrait__img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.portrait--large { width: 144px; height: 144px; }
.portrait__initial {
  font-family: var(--font-pixel);
  font-size: 2.5rem;
  color: #ffffffcc;
}
.dialogue-list { margin-bottom: 0.25rem; }
.dialogue__bubble {
  flex: 1 1 auto;
  background: #fff;
  color: var(--paper-ink);
  border: var(--border);
  padding: 0.5rem 0.75rem;
}
.dialogue__name {
  font-family: var(--font-pixel);
  font-weight: 700;
  color: var(--magenta);
  font-size: 1rem;
}

/* ---------- Lesson panel sections ---------- */

.lesson-section { margin-bottom: 1.25rem; }
.lesson-section__label {
  font-family: var(--font-pixel);
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--muted-ink);
  border-bottom: 2px dashed var(--paper-2);
  margin-bottom: 0.5rem;
}

/* ---------- Case Closed ---------- */

.case-closed { text-align: center; }
.case-closed__stamp {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: clamp(2rem, 7vw, 3.5rem);
  color: var(--red);
  border: 6px solid var(--red);
  padding: 0.2em 0.6em;
  transform: rotate(-6deg);
  margin: 2rem 0;
}

/* ---------- Lesson panel content ---------- */

.lesson__meta {
  font-family: var(--font-pixel);
  font-size: 0.95rem;
  color: var(--muted-ink);
  margin-bottom: 0.25rem;
}
.lesson__title { font-size: 1.7rem; margin-bottom: 1rem; }

.md p:last-child { margin-bottom: 0; }
/* Inline code only. Code blocks (.code-block) keep their own dark look. */
.md :not(pre) > code, .new-words code, .hint code, .keys code {
  font-family: var(--font-code);
  background: var(--paper-2);
  padding: 0.05em 0.3em;
  border-radius: 2px;
}
.dialogue__bubble .md :not(pre) > code { background: #eee6ff; }
.md ul, .md ol { margin: 0 0 0.75em; padding-left: 1.5rem; }

.example { margin-top: 0.75rem; }
.example__label {
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  color: var(--muted-ink);
  margin-bottom: 0.25rem;
}
.example__output {
  background: var(--console-bg);
  color: #d7ffd9;
  font-family: var(--font-code);
  font-size: var(--code-size);
  padding: 0.5rem 0.85rem;
  margin: 0 0 0.75rem;
  border: 3px solid var(--ink);
  white-space: pre-wrap;
}

.new-words {
  background: #e9f9f7;
  border: 3px dashed var(--teal);
  padding: 0.5rem 0.85rem;
  margin-top: 0.75rem;
}
.new-words__label { font-family: var(--font-pixel); font-size: 0.9rem; color: #1b8c82; }
.new-words dl { margin: 0.25rem 0 0; }
.new-words dt { font-weight: 700; display: inline; }
.new-words dt::after { content: ' — '; font-weight: 400; }
.new-words dd { display: inline; margin: 0; }
.new-words dd::after { content: ''; display: block; margin-bottom: 0.2rem; }

/* The task is the part to act on, so it looks different from everything above it:
   a bright card with a thick border, like a sticky note on the case file. */
.task {
  background: #fff3b0;
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem 1rem;
  scroll-margin-top: 0.75rem;
}
.task__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 3px solid var(--ink);
}
.task__title {
  font-family: var(--font-pixel);
  font-size: 1.3rem;
  text-transform: uppercase;
  color: var(--ink);
}
.task__count { font-family: var(--font-pixel); font-size: 0.95rem; color: var(--muted-ink); }
.task__prompt { font-size: 1.05em; }
.task .md :not(pre) > code { background: #ffe680; }
.task--glow { animation: task-glow 1.6s ease-out 1; }
@keyframes task-glow {
  0%, 30% { box-shadow: var(--shadow), 0 0 0 6px var(--yellow); }
  100% { box-shadow: var(--shadow), 0 0 0 0 rgba(255, 210, 63, 0); }
}

/* "▼ Your task": sticks to the bottom of the lesson panel while the task is out of view. */
.task-jump {
  position: sticky;
  bottom: 0.75rem;
  display: block;
  margin: 0.75rem auto 0;
  font-family: var(--font-pixel);
  font-size: 1.05rem;
  background: var(--yellow);
  color: var(--ink);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 0.35rem 1rem;
  cursor: pointer;
  z-index: 2;
}
.task-jump:hover { transform: translateY(-2px); }
.task-jump[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .task--glow { animation: none; }
}
.task-dots { display: inline-flex; gap: 6px; }
.task-dot { width: 16px; height: 16px; padding: 0; border: 2px solid var(--ink); background: var(--paper); cursor: pointer; }
.task-dot:disabled { cursor: default; }
.task-dot:not(:disabled):hover { transform: translateY(-2px); }
.task-dot--current { background: var(--yellow); }
.task-dot--done { background: var(--green); }

.hints { margin-top: 0.75rem; }
.hints__list { margin: 0 0 0.6rem; padding-left: 1.5rem; }
.hint { background: #fff3c4; border-left: 4px solid var(--yellow); padding: 0.3rem 0.6rem; margin-bottom: 0.4rem; }
.hints__button { color: var(--text-light); }

.success {
  background: #e6f8e8;
  border: 3px solid var(--green);
  padding: 0.6rem 0.85rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}
.success__title { font-family: var(--font-pixel); font-size: 1.3rem; color: #22863a; }
.success__xp { font-family: var(--font-pixel); font-size: 1.2rem; color: #b8860b; }
.success__bonus { font-size: 0.95rem; }
.success .btn { margin-left: auto; }

.debrief__actions { display: flex; justify-content: flex-end; margin-top: 0.5rem; }

/* ---------- Case Closed extras ---------- */

.case-closed__story { max-width: 36rem; margin: 0 auto 1.5rem; text-align: left; }
.case-closed__stamp--slam { animation: stamp-slam 600ms cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes stamp-slam {
  0%   { transform: scale(3) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(0.92) rotate(-5deg); opacity: 1; }
  100% { transform: scale(1) rotate(-6deg); }
}
.earned { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin: 0 auto 1.25rem; }
.earned__card { width: 14rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.earned__label { font-family: var(--font-pixel); color: var(--muted-ink); font-size: 0.95rem; text-transform: uppercase; }
.earned__name { font-family: var(--font-pixel); font-size: 1.3rem; }
.earned__text { font-size: 1rem; margin: 0; }
.stats { list-style: none; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.5rem; font-size: 1.1rem; }
.stats strong { font-family: var(--font-pixel); color: var(--yellow); font-size: 1.3rem; }
.case-closed__actions { justify-content: center; margin: 1rem 0; }
.case-closed__backup { font-size: 1rem; color: #cfc8e8; }
.case-closed__backup .link-button { color: var(--sky); }

/* ---------- Celebrations ---------- */

.xp-pop {
  position: absolute;
  right: 0;
  top: -0.2rem;
  font-family: var(--font-pixel);
  font-weight: 700;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink);
  pointer-events: none;
  animation: xp-pop 1.4s ease-out forwards;
}
@keyframes xp-pop {
  0%   { transform: translateY(0.6rem) scale(0.8); opacity: 0; }
  20%  { transform: translateY(0) scale(1.2); opacity: 1; }
  100% { transform: translateY(1.8rem); opacity: 0; }
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #140f26cc;
}
.promo {
  position: relative;
  text-align: center;
  width: min(32rem, 100%);
  padding: 1.5rem 1.5rem 1.25rem;
  background: radial-gradient(circle at 50% 30%, #fff9e6, var(--paper) 70%);
  animation: promo-in 450ms cubic-bezier(.2, 1.5, .4, 1) both;
}
.promo__title {
  font-size: clamp(2rem, 7vw, 2.75rem);
  color: var(--magenta);
  text-shadow: 3px 3px 0 var(--ink);
  margin: 0 0 1rem;
  -webkit-text-stroke: 1px var(--ink);
}
.promo__speaker { display: flex; gap: 0.75rem; align-items: flex-end; text-align: left; margin-bottom: 1rem; }
.promo__bubble { font-size: 1.15rem; }
.promo__bubble p { margin: 0; }
.promo__text { font-size: 1.25rem; }
.promo__rank {
  display: inline-block;
  background: var(--yellow);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 0.5rem 1.25rem;
  margin-bottom: 0.75rem;
  transform: rotate(-2deg);
}
.promo__rank-label { font-family: var(--font-pixel); font-size: 0.95rem; text-transform: uppercase; color: var(--paper-ink); }
.promo__rank-name { font-family: var(--font-pixel); font-size: 1.8rem; font-weight: 700; color: var(--ink); }
.promo__next { color: var(--muted-ink); font-size: 1.05rem; }
.promo__ok { font-size: 1.3rem; }
/* Stars flying out from the middle */
.promo__burst { position: absolute; left: 50%; top: 2.5rem; width: 0; height: 0; pointer-events: none; }
.promo__star {
  position: absolute;
  left: -0.5em;
  top: -0.5em;
  font-size: 1.6rem;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink);
  opacity: 0;
  animation: promo-star 1.1s ease-out var(--delay, 0ms) forwards;
}
@keyframes promo-in { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes promo-star {
  0%   { transform: rotate(var(--angle)) translateY(0) scale(0.4); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: rotate(var(--angle)) translateY(-11rem) scale(1.2); opacity: 0; }
}
@media (max-width: 480px) { .promo__speaker { flex-direction: column; align-items: center; text-align: center; } }
@keyframes rankup-in { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .case-closed__stamp--slam, .promo, .promo__star, .xp-pop { animation: none; }
  .promo__star { display: none; }
  .xp-pop { display: none; }
}

/* ---------- Author-facing content errors ---------- */

.problem-list { font-size: 1rem; padding-left: 1.25rem; }
.problem-list code { font-size: 0.9rem; }
.problem--warning { color: var(--muted-ink); }

/* ---------- Profiles (title screen) ---------- */

.title-screen__message { font-weight: 700; color: #1b8c82; }
.title-screen__empty { color: var(--muted-ink); }
.profile-row { display: flex; gap: 0.5rem; align-items: stretch; }
.profile-row__pick { flex: 1 1 auto; justify-content: space-between; text-align: left; }
.profile-row__pick--last { background: #ffe680; }
.profile-row__name { font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; }
.profile-row__meta { font-family: var(--font-body); font-weight: 400; font-size: 0.95rem; white-space: nowrap; }
.profile-row__delete { flex: 0 0 auto; }
.profile-row__confirm { flex: 1 1 auto; background: #ffe3e3; border: 3px solid var(--red); padding: 0.5rem 0.75rem; }
.profile-row__confirm p { margin-bottom: 0.5rem; }

.new-profile { margin-top: 0.75rem; }
.new-profile__label { display: block; font-family: var(--font-pixel); font-size: 1rem; margin-bottom: 0.25rem; }
.new-profile__row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.new-profile__open { margin-top: 0.25rem; }
.text-input {
  flex: 1 1 10rem;
  min-width: 0;
  font: inherit;
  font-size: 1.2rem;
  padding: 0.4rem 0.6rem;
  border: var(--border);
  background: #fff;
  color: var(--paper-ink);
}
.form-error { color: #c62828; font-size: 1rem; margin: 0.4rem 0 0; min-height: 1.5em; }

.import-save { margin-top: 1rem; border-top: 2px dashed var(--paper-2); padding-top: 0.75rem; }
.link-button {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 1rem; color: #3b5bdb; text-decoration: underline;
}
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.save-warning { max-width: 30rem; margin: 0 auto 1rem; background: #ffe3e3; border-color: var(--red); text-align: left; }

/* ---------- HQ save panel ---------- */

.save-panel { margin-top: 1.5rem; }
.save-panel h2 { font-size: 1.3rem; color: var(--yellow); }
.save-panel p { font-size: 1.05rem; }
.save-panel__warning { color: #ffb3b5; font-weight: 700; }

/* Dialogue lines appearing one at a time */
.dialogue--waiting { visibility: hidden; }
.dialogue--enter { animation: dialogue-in 220ms ease-out both; }
@keyframes dialogue-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Keyboard tips for new symbols */
.keys {
  background: #fff3c4;
  border: 3px dashed #d4a017;
  padding: 0.5rem 0.85rem;
  margin-top: 0.75rem;
}
.keys__label { font-family: var(--font-pixel); font-size: 0.9rem; color: #8a6d00; }
.keys dl { margin: 0.25rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.75rem; align-items: baseline; }
.keys dt code { font-size: 1.05rem; font-weight: 700; }
.keys dd { margin: 0; }

/* ---------- Case briefing (Star Fox-style comm) ---------- */

.briefing { max-width: 48rem; display: flex; flex-direction: column; gap: 1rem; min-height: calc(100vh - var(--hud-height)); }
.briefing__label { font-family: var(--font-pixel); color: var(--teal); text-transform: uppercase; font-size: 1rem; }
.briefing__title { font-size: clamp(2rem, 6vw, 3rem); color: var(--yellow); text-shadow: 3px 3px 0 var(--ink); margin: 0.1rem 0 0; }
.briefing__log {
  max-height: 14rem;
  overflow-y: auto;
  font-size: 1.05rem;
  color: #cfc8e8;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.briefing__log:empty { display: none; }
.briefing__past strong { color: var(--teal); font-weight: 700; }
.briefing__past .md { display: inline; }
.briefing__comm {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: #120d26;
  border: var(--border);
  box-shadow: var(--shadow), inset 0 0 0 3px #2e2560;
  padding: 1rem;
  cursor: pointer;
  /* faint scanlines, like an old monitor */
  background-image: repeating-linear-gradient(#ffffff08 0 2px, transparent 2px 4px);
}
.briefing__bubble { flex: 1 1 auto; font-size: 1.3rem; line-height: 1.5; min-height: 6.5rem; }
.briefing__controls { display: flex; justify-content: flex-end; gap: 0.75rem; }
@media (max-width: 560px) {
  .briefing__comm { flex-direction: column; align-items: center; }
  .briefing__bubble { width: 100%; }
}

/* ---------- Travel map (trial) ---------- */

.travel { max-width: 60rem; }
.travel__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.travel__label { font-family: var(--font-pixel); font-size: 1.6rem; color: var(--yellow); text-shadow: 2px 2px 0 var(--ink); }
.travel__frame {
  position: relative;
  border: var(--border);
  box-shadow: var(--shadow);
  background: #1d2f5c;
  aspect-ratio: 240 / 89;
}
.travel__map, .travel__route { position: absolute; inset: 0; width: 100%; height: 100%; }
.travel__labels { position: absolute; inset: 0; pointer-events: none; }
.travel__pin {
  position: absolute;
  transform: translate(-50%, -150%);
  font-family: var(--font-pixel);
  font-size: clamp(0.75rem, 1.8vw, 1rem);
  color: #fff;
  background: #140f26cc;
  padding: 0 0.35em;
  white-space: nowrap;
}
.travel__pin--to { color: var(--yellow); }
.travel__card {
  margin: 1rem auto 0;
  max-width: 32rem;
  text-align: center;
  animation: promo-in 350ms cubic-bezier(.2, 1.5, .4, 1) both;
}
.travel__where { font-family: var(--font-pixel); font-size: 1.6rem; margin-bottom: 0.4rem; }
.travel__fact { font-size: 1.15rem; }
.chapter-card__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.chapter-card__actions .btn--quiet { color: var(--text-light); }
@media (prefers-reduced-motion: reduce) { .travel__card { animation: none; } }

/* ---------- Opening cutscene (#/intro) ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #07071a;
  color: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.intro__gate {
  all: unset;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  cursor: pointer;
  text-align: center;
}
.intro__gate:focus-visible { outline: none; }
.intro__gate-title {
  font-family: var(--font-pixel);
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  color: #ffffff55;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.intro__press {
  font-family: var(--font-pixel);
  font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  color: var(--yellow);
  animation: intro-blink 1.1s steps(1) infinite;
}
.intro__gate-hint { font-size: 0.9rem; color: #ffffff88; }
@keyframes intro-blink { 50% { opacity: 0; } }

.intro__stage {
  /* As wide as fits, but short enough that headline + map + console fit the window. */
  width: min(100%, 1100px, calc((100vh - 17rem) * 2.7));
  min-width: min(100%, 520px);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: opacity 450ms;
}
.intro__stage--out { opacity: 0; }
.intro__headline {
  font-family: var(--font-pixel);
  font-size: clamp(0.9rem, 2.4vw, 1.3rem);
  color: var(--red);
  text-align: center;
  letter-spacing: 0.08em;
  animation: intro-blink 0.9s steps(1) 4;
}
.intro__mapwrap { position: relative; }
.intro__frame {
  position: relative;
  border: var(--border);
  background: #0f1838;
  aspect-ratio: 240 / 89;
  animation: intro-fade 700ms ease-out both;
}
@keyframes intro-fade { from { opacity: 0; } }
.intro__map, .intro__route { position: absolute; inset: 0; width: 100%; height: 100%; }
.intro__pins { position: absolute; inset: 0; pointer-events: none; }
.intro__suspect, .intro__hq {
  gap: 3px;
  position: absolute;
  display: flex;
  flex-direction: column-reverse;     /* pin dot at the bottom, card above it */
  align-items: center;
  transform: translate(-50%, calc(-100% + 4px));
  animation: intro-pop 420ms cubic-bezier(.2, 1.6, .4, 1) both;
}
.intro__suspect--below { flex-direction: column; transform: translate(-50%, -4px); }
@keyframes intro-pop { from { transform: translate(-50%, -60%) scale(0); opacity: 0; } }
.intro__suspect--below { animation-name: intro-pop-below; }
@keyframes intro-pop-below { from { transform: translate(-50%, 0) scale(0); opacity: 0; } }
.intro__pin-dot {
  width: 8px;
  height: 8px;
  background: var(--red);
  border: 2px solid #140f26;
}
.intro__pin-dot--hq { background: #4ff0ff; }
.intro__face { line-height: 0; }
.intro__face .portrait {
  width: clamp(40px, 6.5vw, 76px);
  height: clamp(40px, 6.5vw, 76px);
  border-width: 3px;
}
.intro__place {
  font-family: var(--font-pixel);
  font-size: clamp(0.6rem, 1.4vw, 0.85rem);
  background: #140f26dd;
  padding: 0 0.3rem;
  white-space: nowrap;
}
.intro__suspect--revealed .portrait {
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
  animation: intro-flash 0.5s steps(1) 4;
}
@keyframes intro-flash { 50% { outline-color: transparent; } }
.intro__suspect--caught .portrait {
  outline: 4px solid var(--red);
  outline-offset: 2px;
  animation: intro-shake 300ms linear;
}
@keyframes intro-shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* The console overlaps only the bottom strip of the map (ocean and Antarctica, where no
   suspect sits), so it never covers a face. */
.intro__terminal {
  position: relative;
  z-index: 1;
  width: min(100%, 40rem);
  margin: -2.2rem auto 0;
  height: 11.5em;
  overflow: hidden;
  background: #0b0b1fee;
  border: 3px solid #4ff0ff;
  box-shadow: 0 0 0 3px #140f26;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-code);
  font-size: clamp(0.7rem, 1.45vw, 0.95rem);
  line-height: 1.45;
  animation: intro-fade 300ms ease-out both;
}
/* Long lines wrap, and the wrapped part lines up after the ">>> " prompt. */
.intro__line { white-space: pre-wrap; padding-left: 4ch; text-indent: -4ch; }
.intro__prompt { color: #8b84a8; }
.intro__line--in .intro__code { color: #e8f7ff; }
.intro__line--out { color: #ffd23f; }
.intro__line--win { color: #5bf06b; font-weight: bold; font-size: 1.25em; }
.intro__cursor { color: #4ff0ff; animation: intro-blink 0.6s steps(1) infinite; }
.intro__skip { align-self: flex-end; }

.intro__card {
  text-align: center;
  animation: intro-zoom 900ms cubic-bezier(.2, 1.4, .4, 1) both;
}
.intro__logo {
  font-family: var(--font-pixel);
  font-size: clamp(3rem, 13vw, 7rem);
  color: var(--yellow);
  text-shadow: 6px 6px 0 #140f26, 0 0 30px #ffd23f55;
  letter-spacing: 0.05em;
}
.intro__tagline {
  font-family: var(--font-pixel);
  font-size: clamp(1rem, 3vw, 1.5rem);
  color: #fff;
  margin-top: 0.5rem;
}
@keyframes intro-zoom { from { transform: scale(2.5); opacity: 0; } }

@media (max-width: 700px) {
  .intro__terminal { margin-top: 0.5rem; }
}
.watch-intro { margin-top: 0.5rem; }

/* ---------- Blocks view (js/ui/blocks.js): Scratch / SPIKE-app style word blocks ---------- */
.blocks {
  --b-events: #e6a800; --b-control: #ffab19; --b-motion: #4c97ff; --b-sensing: #4cb5d6;
  --b-looks: #9966ff; --b-variables: #ff8c1a; --b-operators: #4fae4f; --b-myblocks: #ff6680;
  --b-python: #7d8299;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: flex-start;
  padding: 0.75rem;
  background: #f4f1fa;
  border: 3px solid var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: #fff;
  overflow-x: auto;
}
.blocks--loading, .blocks--error { color: var(--paper-ink); font-style: italic; }
.block-stack { display: flex; flex-direction: column; align-items: flex-start; }
.block {
  --c: var(--b-python);
  background: var(--c);
  border: 2px solid color-mix(in srgb, var(--c), #000 25%);
  border-radius: 5px;
  margin-top: -2px;
  min-width: 3rem;
  position: relative;
}
.block--events { --c: var(--b-events); }
.block--control { --c: var(--b-control); }
.block--motion { --c: var(--b-motion); }
.block--sensing { --c: var(--b-sensing); }
.block--looks { --c: var(--b-looks); }
.block--variables { --c: var(--b-variables); }
.block--operators { --c: var(--b-operators); }
.block--myblocks { --c: var(--b-myblocks); }
/* the little notch tab on top of a stack block */
.block::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 14px;
  width: 16px;
  height: 5px;
  background: color-mix(in srgb, var(--c), #000 25%);
  border-radius: 0 0 4px 4px;
}
.block--hat { border-radius: 18px 18px 5px 5px; padding-top: 0.25rem; margin-top: 0; }
.block--hat::before { display: none; }
.block__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.55rem;
  min-height: 2rem;
}
.block__word { font-weight: 700; white-space: nowrap; }
.block__field {
  background: color-mix(in srgb, var(--c), #000 18%);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  font-weight: 700;
}
.block__field::after { content: " ▾"; font-size: 0.7em; opacity: 0.8; }
/* C-blocks (repeat, if, forever): a mouth on the left for the blocks inside */
.block--c { background: transparent; border: none; }
.block--c::before { display: none; }
.block--c > .block__row {
  background: var(--c);
  border: 2px solid color-mix(in srgb, var(--c), #000 25%);
  border-radius: 5px 5px 5px 0;
}
.block--c > .block__row--label { border-radius: 0 5px 5px 0; min-height: 1.6rem; }
.block__mouth {
  border-left: 14px solid var(--c);
  padding: 2px 0 2px 0;
  min-height: 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.block__empty { height: 1.2rem; }
.block__foot {
  height: 0.8rem;
  width: 4.5rem;
  background: var(--c);
  border: 2px solid color-mix(in srgb, var(--c), #000 25%);
  border-radius: 0 0 5px 5px;
}
.block--cap > .block__foot { border-radius: 0 0 8px 8px; }
/* reporters (values) and booleans (questions) inside blocks */
.rep {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 2px solid #00000033;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}
.rep--hex { border-radius: 4px; clip-path: polygon(0.5rem 0, calc(100% - 0.5rem) 0, 100% 50%, calc(100% - 0.5rem) 100%, 0.5rem 100%, 0 50%); padding: 0.1rem 0.75rem; }
.rep--literal { background: #fff; color: #3a3a4a; font-weight: 600; }
.rep--literal.rep--text { border-radius: 4px; }
.rep--variables { background: var(--b-variables); }
.rep--operators { background: var(--b-operators); }
.rep--sensing { background: var(--b-sensing); }
.rep--myblocks { background: var(--b-myblocks); }
.rep--python { background: var(--b-python); font-family: var(--font-code); font-weight: 400; }
.rep--motion { background: var(--b-motion); }
.block--python .rep--literal { font-family: var(--font-code); }

/* code and blocks side by side */
.compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 0.75rem;
}
.compare__side { min-width: 0; }
.compare__label {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.compare .code-block { margin: 0; }

/* the 🧩 Blocks panel under the Run button */
.blocks-panel { flex: 0 1 auto; max-height: 45%; overflow: auto; }
.blocks-panel[hidden] { display: none; }
.blocks-panel .blocks { border-width: 3px; }

/* "Your code from earlier" in a briefing */
.recall { margin-top: 0.75rem; }

/* ---------- End credits (#/credits) ---------- */
.credits {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #07071a;
  color: #fff;
  overflow: hidden;
  text-align: center;
}
.credits__window { position: absolute; inset: 0; overflow: hidden; }
.credits__roll { padding: 2rem 1rem 6rem; }
.credits__roll--moving { animation: credits-roll var(--roll-seconds, 30s) linear both; }
@keyframes credits-roll { from { transform: translateY(100vh); } to { transform: translateY(-100%); } }
.credits__roll--still { position: absolute; inset: 0; overflow-y: auto; padding-bottom: 12rem; }
.credits__title {
  font-family: var(--font-pixel);
  font-size: clamp(2rem, 7vw, 4rem);
  color: var(--yellow);
  text-shadow: 4px 4px 0 #140f26;
  margin-bottom: 2.5rem;
}
.credits__block { margin: 0 auto 3rem; max-width: 40rem; }
.credits__label {
  font-family: var(--font-pixel);
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.75rem;
}
.credits__star { font-family: var(--font-pixel); font-size: clamp(1.6rem, 5vw, 2.6rem); }
.credits__rank { color: #ffffffaa; margin-top: 0.25rem; }
.credits__cast { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; justify-items: center; }
.credits__member { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.credits__name { font-family: var(--font-pixel); font-size: 1.1rem; }
.credits__line { font-size: 1.15rem; line-height: 1.5; margin: 0.25rem 0; }
.credits__ending {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.5rem 1rem 2rem;
  background: linear-gradient(transparent, #07071a 35%);
}
.credits__ending[hidden] { display: none; }
.credits__the-end { font-family: var(--font-pixel); font-size: 2rem; color: var(--yellow); margin-bottom: 1rem; }
.credits__ending .button-row { justify-content: center; }
.credits__skip { position: absolute; right: 1rem; bottom: 1rem; }

/* ---------- Team support (support.js): quiet, for grown-ups ---------- */
.support-line {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #6b6182;
  text-align: center;
}
.support-line__link { color: #8a3d00; font-weight: 600; white-space: nowrap; }
.support-card {
  position: relative;
  margin-top: 1.25rem;
  padding: 1rem 1.25rem 1.1rem;
  background: var(--paper);
  color: var(--paper-ink);
  border: var(--border);
  border-left-width: 8px;
  border-left-color: var(--yellow);
  box-shadow: var(--shadow);
  max-width: 46rem;
}
.support-card__tag {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--paper-2);
  padding: 0.1rem 0.45rem;
  margin-bottom: 0.4rem;
}
.support-card__title { font-family: var(--font-pixel); font-size: 1.2rem; margin: 0.1rem 0 0.4rem; }
.support-card .md p { margin: 0 0 0.75rem; line-height: 1.5; }
.support-card__stamp {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: #c8323c;
  border: 3px solid #c8323c;
  padding: 0.1rem 0.5rem;
  transform: rotate(-8deg);
  opacity: 0.75;
  pointer-events: none;
}
.credits .support-card { margin: 0 auto; text-align: left; }
@media (max-width: 480px) { .support-card__stamp { display: none; } }
