:root {
  color-scheme: dark;
  --ink-950: #04101f;
  --ink-900: #071a2f;
  --ink-850: #0a2542;
  --ink-800: #103150;
  --panel: rgba(9, 31, 54, 0.94);
  --panel-soft: rgba(15, 48, 77, 0.84);
  --paper: #f5fbff;
  --muted: #a8bfd1;
  --line: rgba(170, 210, 236, 0.2);
  --runway: #4da8ff;
  --orange: #ff8a2a;
  --yellow: #ffd34d;
  --teal: #2fd4c8;
  --green: #4ed58a;
  --red: #ff6c6c;
  --violet: #a88aff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 30px;
  --display: "Arial Rounded MT Bold", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --body: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink-950);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  font-family: var(--body);
  background:
    radial-gradient(circle at 10% 5%, rgba(47, 212, 200, 0.12), transparent 28rem),
    radial-gradient(circle at 88% 12%, rgba(77, 168, 255, 0.14), transparent 30rem),
    linear-gradient(145deg, var(--ink-950), var(--ink-900) 50%, #092744);
  overflow-x: hidden;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
}

button:not(:disabled),
a[href] {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 999;
  padding: 10px 14px;
  color: var(--ink-950);
  background: var(--yellow);
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 48px;
}

.app-shell[data-view="roles"] {
  padding-bottom: 16px;
}

.screen {
  min-height: calc(100vh - 68px);
  animation: screen-in 420ms cubic-bezier(.2, .9, .2, 1) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px 14px 12px 18px;
  background: rgba(5, 22, 39, 0.86);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wing-mark {
  position: relative;
  width: 34px;
  height: 18px;
  flex: 0 0 auto;
}

.wing-mark::before,
.wing-mark::after {
  content: "";
  position: absolute;
  top: 7px;
  width: 15px;
  height: 5px;
  border-radius: 999px;
  background: var(--orange);
}

.wing-mark::before { left: 1px; transform: rotate(16deg); }
.wing-mark::after { right: 1px; transform: rotate(-16deg); }

.brand-mini strong {
  overflow: hidden;
  font-family: var(--display);
  font-size: 0.98rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.top-actions,
.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  color: #dfefff;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill strong {
  color: var(--yellow);
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: background 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: var(--display);
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(2.5rem, 7vw, 5.9rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.75rem, 4vw, 3rem);
  letter-spacing: -0.035em;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

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

.lead {
  max-width: 54ch;
  color: #d7e9f6;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.9;
}

.runway-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(430px, 100%);
  margin: 22px 0;
}

.runway-rule::before,
.runway-rule::after {
  content: "";
  height: 2px;
  flex: 1;
  background: repeating-linear-gradient(90deg, var(--runway) 0 18px, transparent 18px 30px);
}

.runway-rule span {
  width: 12px;
  height: 12px;
  background: var(--orange);
  border: 3px solid #ffd0a8;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(255, 138, 42, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 50px;
  padding: 13px 21px;
  border-radius: 14px;
  font-weight: 900;
  text-decoration: none;
  transition: transform 160ms ease, filter 160ms ease, background 160ms ease;
}

.primary-button {
  color: #241100;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  box-shadow: 0 12px 28px rgba(255, 138, 42, 0.24);
}

.primary-button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.primary-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.5;
}

.secondary-button {
  color: var(--ink-950);
  background: var(--paper);
}

.ghost-button {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--line);
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.82fr);
  min-height: calc(100vh - 88px);
  overflow: hidden;
}

.hero-copy {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(34px, 7vw, 82px);
}

.hero-copy h1 span {
  display: block;
  color: var(--yellow);
}

.hero-visual {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  background-image:
    linear-gradient(90deg, var(--panel) 0%, rgba(9, 31, 54, 0.12) 40%),
    url("assets/airport-map.png");
  background-position: center;
  background-size: cover;
}

.hero-visual::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 40%;
  background: linear-gradient(transparent, rgba(3, 16, 30, 0.9));
}

.hero-flight-card {
  position: absolute;
  right: 26px;
  bottom: 28px;
  left: 26px;
  z-index: 2;
  padding: 18px;
  background: rgba(4, 22, 40, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  backdrop-filter: blur(14px);
}

.hero-flight-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--yellow);
  font-family: var(--display);
}

.screen-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 34px 4px 24px;
}

.screen-heading p {
  max-width: 55ch;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.role-card {
  --accent: var(--runway);
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 324px;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px 10px;
  overflow: hidden;
  color: var(--paper);
  text-align: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 16%, var(--panel)), var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  transition: transform 180ms ease, border-color 180ms ease;
}

.role-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: var(--accent);
}

.role-card:hover {
  z-index: 2;
  border-color: var(--accent);
  transform: translateY(-5px);
}

.role-card:focus-visible {
  z-index: 3;
  outline-color: var(--accent);
}

.sprite-crop {
  position: relative;
  width: 90px;
  aspect-ratio: 0.25;
  margin: 0 auto 10px;
  overflow: hidden;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.3));
}

.sprite-crop img {
  display: block;
  width: 700%;
  max-width: none;
  transform: translateX(calc(var(--sprite-index) * -14.285714%));
}

.role-card .sprite-crop {
  width: 58px;
  flex: 0 0 auto;
  margin-bottom: 6px;
}

.role-name {
  display: grid;
  min-height: 42px;
  place-items: center;
  color: var(--paper);
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.3;
}

.role-card-action {
  width: 100%;
  margin-top: auto;
  padding: 7px 8px;
  color: var(--paper);
  background: color-mix(in srgb, var(--accent) 18%, rgba(255, 255, 255, 0.04));
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 900;
}

.role-screen .topbar {
  margin-bottom: 10px;
  padding-block: 8px;
}

.role-screen .screen-heading {
  align-items: center;
  margin: 8px 4px 12px;
}

.role-screen .screen-heading .eyebrow {
  margin-bottom: 4px;
}

.role-screen .screen-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3.4vw, 2.65rem);
}

.role-screen .screen-heading > p {
  max-width: 46ch;
  font-size: 0.9rem;
  line-height: 1.5;
}

.story-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.65fr) minmax(0, 1.35fr);
  min-height: 670px;
  overflow: hidden;
}

.story-character {
  --accent: var(--runway);
  display: grid;
  place-items: end center;
  min-height: 500px;
  padding-top: 36px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 46%),
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 12%, var(--ink-850)), var(--ink-900));
}

.story-character .sprite-crop {
  width: min(145px, 65%);
  margin-bottom: -4px;
}

.story-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(34px, 6vw, 76px);
}

.story-bubble {
  position: relative;
  margin: 24px 0 0;
  padding: 22px 24px;
  color: #dff3ff;
  background: rgba(77, 168, 255, 0.1);
  border-left: 4px solid var(--runway);
  border-radius: 0 18px 18px 0;
  line-height: 1.85;
}

.map-shell {
  padding: 18px;
}

.map-canvas {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background-image:
    linear-gradient(rgba(3, 17, 31, 0.05), rgba(3, 17, 31, 0.14)),
    url("assets/airport-map.png");
  background-position: center;
  background-size: cover;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.map-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 70px rgba(3, 17, 31, 0.42);
}

.map-node {
  --node-accent: var(--orange);
  position: absolute;
  z-index: 2;
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  color: var(--ink-950);
  background: var(--yellow);
  border: 5px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--node-accent) 30%, transparent), 0 12px 26px rgba(0, 0, 0, 0.34);
  transform: translate(-50%, -50%);
  transition: transform 160ms ease, filter 160ms ease;
}

.map-node:hover:not(:disabled) {
  z-index: 4;
  filter: brightness(1.08);
  transform: translate(-50%, -50%) scale(1.1);
}

.map-node.completed {
  color: white;
  background: var(--green);
}

.map-node:disabled {
  cursor: default;
}

.map-node-label {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: 150px;
  padding: 7px 9px;
  color: white;
  background: rgba(4, 18, 33, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.level-roster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.level-chip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 10px 12px;
  color: var(--paper);
  text-align: left;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.level-chip:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.level-chip.completed {
  border-color: rgba(78, 213, 138, 0.48);
}

.level-chip-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--ink-950);
  background: var(--yellow);
  border-radius: 50%;
  font-weight: 950;
}

.level-chip.completed .level-chip-icon {
  color: white;
  background: var(--green);
}

.level-chip strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.stars {
  color: var(--yellow);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
}

.quiz-card {
  padding: clamp(24px, 5vw, 54px);
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.progress-track {
  height: 8px;
  margin-bottom: 30px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.progress-track span {
  display: block;
  width: var(--progress);
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--runway));
  border-radius: inherit;
  transition: width 300ms ease;
}

.question-text {
  max-width: 29ch;
  margin-bottom: 28px;
  font-size: clamp(1.45rem, 3.2vw, 2.35rem);
  line-height: 1.35;
}

.answer-list {
  display: grid;
  gap: 12px;
}

.answer-option {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 68px;
  padding: 12px 16px;
  color: var(--paper);
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.answer-option:hover:not(:disabled) {
  background: rgba(77, 168, 255, 0.11);
  border-color: rgba(77, 168, 255, 0.5);
  transform: translateX(3px);
}

.answer-option.selected {
  background: rgba(255, 211, 77, 0.12);
  border-color: var(--yellow);
}

.answer-option.correct {
  background: rgba(78, 213, 138, 0.14);
  border-color: var(--green);
}

.answer-key {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--ink-950);
  background: var(--paper);
  border-radius: 12px;
  font-family: var(--display);
  font-weight: 950;
}

.answer-option.selected .answer-key { background: var(--yellow); }
.answer-option.correct .answer-key { color: white; background: var(--green); }

.answer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

.quiz-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.side-card {
  padding: 20px;
}

.side-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--yellow);
}

.life-dots {
  display: flex;
  gap: 8px;
  margin-top: 13px;
}

.life-dot {
  width: 15px;
  height: 15px;
  background: var(--orange);
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 138, 42, 0.13);
}

.life-dot.used {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.feedback-box {
  margin-top: 24px;
  padding: 22px;
  border-radius: 18px;
  line-height: 1.8;
}

.feedback-box.correct {
  background: rgba(78, 213, 138, 0.11);
  border: 1px solid rgba(78, 213, 138, 0.42);
}

.feedback-box.wrong {
  background: rgba(255, 108, 108, 0.1);
  border: 1px solid rgba(255, 108, 108, 0.4);
}

.feedback-box h3 {
  color: var(--green);
}

.feedback-box.wrong h3 {
  color: #ff9b9b;
}

.source-link {
  display: inline-flex;
  margin-top: 8px;
  color: #9ed2ff;
  font-weight: 800;
}

.badge-crop {
  position: relative;
  width: 130px;
  aspect-ratio: 0.5;
  overflow: hidden;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.34));
}

.badge-crop img {
  display: block;
  width: 600%;
  max-width: none;
  transform: translateX(calc(var(--badge-index) * -16.666667%));
}

.badge-crop.small {
  width: 72px;
}

.celebration,
.end-screen {
  display: grid;
  min-height: calc(100vh - 88px);
  place-items: center;
  padding: 30px;
  text-align: center;
}

.celebration-card,
.end-card {
  width: min(760px, 100%);
  padding: clamp(32px, 7vw, 72px);
}

.celebration .badge-crop {
  width: 190px;
  margin: 0 auto 20px;
  animation: badge-land 800ms cubic-bezier(.16, 1.3, .3, 1) both;
}

@keyframes badge-land {
  from { opacity: 0; transform: translateY(-30px) scale(.7) rotate(-7deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

.earned-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 26px 0;
}

.completion-role {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 26px;
  max-width: 570px;
  margin: 24px auto;
  padding: 18px 24px;
  text-align: left;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.completion-role .sprite-crop {
  width: 68px;
  margin-bottom: 0;
}

.app-shell[data-view="complete"] .end-card {
  width: min(1120px, 100%);
}

.completion-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: start;
  gap: clamp(22px, 4vw, 48px);
  text-align: left;
}

.completion-summary h1 {
  margin-bottom: 14px;
  font-size: clamp(2.7rem, 7vw, 5.2rem);
}

.completion-summary .completion-role {
  margin-inline: 0;
}

.completion-summary .earned-badges {
  justify-content: flex-start;
  margin-bottom: 0;
}

.completion-actions .passcode-panel {
  margin-top: 0;
}

.completion-actions > .primary-button {
  width: 100%;
}

.completion-note {
  margin: 12px 0 0;
  text-align: center;
}

.passcode-panel {
  margin: 26px auto;
  padding: clamp(20px, 4vw, 30px);
  text-align: left;
  background: rgba(7, 26, 47, 0.72);
  border: 1px solid rgba(255, 211, 77, 0.36);
  border-left: 5px solid var(--yellow);
  border-radius: 18px;
}

.passcode-panel h2 {
  margin-top: 4px;
}

.field-label {
  display: block;
  margin: 18px 0 8px;
  font-weight: 800;
}

.text-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(2, 13, 26, 0.9);
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
}

.text-input:focus {
  outline: 3px solid rgba(255, 211, 77, 0.34);
  border-color: var(--yellow);
}

.text-input[aria-invalid="true"] {
  border-color: #ff6b6b;
}

.field-hint {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.passcode-display {
  margin: 16px 0;
  padding: 16px;
  overflow-wrap: anywhere;
  color: var(--yellow);
  background: rgba(2, 13, 26, 0.9);
  border: 1px dashed rgba(255, 211, 77, 0.62);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(0.92rem, 2.6vw, 1.15rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-align: center;
}

.passcode-panel .secondary-button {
  width: 100%;
  justify-content: center;
}

.validator-shell {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(34px, 7vw, 78px) 0;
}

.validator-card {
  padding: clamp(26px, 6vw, 58px);
}

.validator-card h1 {
  margin-bottom: 18px;
  font-size: clamp(2rem, 7vw, 4rem);
}

.validator-form {
  margin-top: 28px;
}

.validator-back-link {
  width: 100%;
  margin-top: 20px;
  justify-content: center;
}

.validator-form .primary-button {
  width: 100%;
  margin-top: 22px;
  justify-content: center;
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.validation-result {
  margin-top: 24px;
  padding: 20px;
  border-radius: 16px;
}

.validation-result p {
  margin: 8px 0 0;
}

.validation-result.valid {
  color: #dfffea;
  background: rgba(78, 213, 138, 0.13);
  border: 1px solid rgba(78, 213, 138, 0.54);
}

.validation-result.invalid {
  color: #ffe3e3;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.5);
}

.validation-result.redeemed {
  color: #fff4c4;
  background: rgba(255, 211, 77, 0.12);
  border: 1px solid rgba(255, 211, 77, 0.5);
}

.validation-result .secondary-button {
  width: 100%;
  margin-top: 16px;
  justify-content: center;
}

.security-note {
  margin-top: 26px;
  padding: 18px 20px;
  color: var(--muted);
  background: rgba(2, 13, 26, 0.66);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.security-note p {
  margin: 8px 0 0;
}

.game-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  overflow: auto;
  color: var(--paper);
  background: var(--ink-900);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.game-dialog::backdrop {
  background: rgba(1, 9, 17, 0.78);
  backdrop-filter: blur(8px);
}

.dialog-body {
  padding: clamp(24px, 6vw, 42px);
}

.dialog-body ul {
  padding-left: 1.3em;
  color: #d8ebf8;
  line-height: 1.9;
}

.dialog-badge-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  max-width: min(380px, calc(100% - 36px));
  padding: 12px 16px;
  color: var(--ink-950);
  background: var(--yellow);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.loading,
.error-state,
.noscript {
  display: grid;
  min-height: 70vh;
  place-items: center;
  padding: 30px;
  text-align: center;
}

.loader {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border: 5px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

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

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

  .hero-copy {
    min-height: 520px;
  }

  .hero-visual {
    min-height: 430px;
  }

  .role-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quiz-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 18px, 620px);
    padding-top: 9px;
  }

  .screen {
    min-height: calc(100vh - 30px);
  }

  .topbar {
    position: sticky;
    top: 7px;
    z-index: 20;
  }

  .status-strip .status-pill:first-child {
    display: none;
  }

  .hero-copy {
    min-height: 500px;
    padding: 34px 24px;
  }

  .hero-visual {
    min-height: 310px;
  }

  .screen-heading {
    display: block;
    margin-top: 24px;
  }

  .role-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .role-card {
    min-height: 420px;
    padding: 16px 12px 12px;
  }

  .sprite-crop {
    width: 76px;
  }

  .story-layout {
    grid-template-columns: 1fr;
  }

  .story-character {
    min-height: 360px;
  }

  .story-character .sprite-crop {
    width: 110px;
  }

  .story-copy {
    padding: 28px 22px 34px;
  }

  .map-shell {
    padding: 8px;
  }

  .map-node {
    width: 44px;
    height: 44px;
    border-width: 3px;
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--node-accent) 28%, transparent), 0 8px 18px rgba(0, 0, 0, 0.3);
  }

  .map-node-label {
    display: none;
  }

  .level-roster {
    grid-template-columns: 1fr;
  }

  .quiz-card {
    padding: 22px 16px;
  }

  .quiz-meta {
    display: grid;
    gap: 4px;
  }

  .question-text {
    font-size: 1.42rem;
  }

  .answer-option {
    min-height: 64px;
    padding: 10px 12px;
  }

  .quiz-side {
    grid-template-columns: 1fr;
    grid-row: auto;
  }

  .completion-role {
    grid-template-columns: 100px minmax(0, 1fr);
    padding: 14px;
  }

  .completion-role .sprite-crop {
    width: 58px;
  }

  .completion-layout {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .completion-summary .completion-role {
    margin-inline: auto;
  }

  .completion-summary .earned-badges {
    justify-content: center;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 2.6rem;
  }

  .brand-mini strong {
    max-width: 150px;
  }

  .status-pill {
    padding-inline: 9px;
  }

  .role-grid {
    grid-template-columns: 1fr;
  }

  .role-card {
    min-height: 420px;
  }

  .role-card .sprite-crop {
    width: 80px;
  }

  .map-canvas {
    aspect-ratio: 4 / 3;
  }

  .button-row > * {
    width: 100%;
  }
}

@media (min-width: 721px) and (max-height: 700px) {
  .app-shell {
    width: min(1280px, calc(100% - 20px));
    padding: 10px 0;
  }

  .screen {
    min-height: calc(100dvh - 20px);
  }

  .topbar {
    min-height: 54px;
    margin-bottom: 8px;
    padding: 7px 12px 7px 16px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    min-height: 44px;
    padding: 10px 17px;
  }

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

  .hero {
    min-height: calc(100dvh - 20px);
  }

  .hero-copy {
    padding: 24px 36px;
  }

  .hero-copy h1 {
    margin-bottom: 12px;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
  }

  .hero-copy .lead {
    font-size: 1rem;
    line-height: 1.6;
  }

  .runway-rule {
    margin: 12px 0;
  }

  .hero-visual {
    min-height: 0;
  }

  .hero-flight-card {
    right: 18px;
    bottom: 18px;
    left: 18px;
    padding: 14px;
  }

  .role-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .role-card {
    min-height: 0;
    height: calc(100dvh - 218px);
    padding-top: 10px;
  }

  .role-card .sprite-crop {
    width: min(58px, calc((100dvh - 245px) / 4));
  }

  .role-screen .screen-heading {
    margin: 6px 4px 10px;
  }

  .story-layout {
    height: calc(100dvh - 82px);
    min-height: 0;
  }

  .story-character {
    min-height: 0;
    padding-top: 12px;
  }

  .story-character .sprite-crop {
    width: min(108px, calc((100dvh - 100px) / 4));
  }

  .story-copy {
    padding: 20px 34px;
  }

  .story-copy h2 {
    margin-bottom: 7px;
    font-size: clamp(1.8rem, 3.6vw, 2.7rem);
  }

  .story-copy .lead {
    margin-bottom: 0;
    font-size: 1rem;
    line-height: 1.6;
  }

  .story-bubble {
    margin-top: 12px;
    padding: 13px 17px;
    line-height: 1.55;
  }

  .app-shell[data-view="map"] .screen-heading {
    align-items: center;
    margin: 4px 4px 8px;
  }

  .app-shell[data-view="map"] .screen-heading h2 {
    margin-bottom: 0;
    font-size: clamp(1.6rem, 3vw, 2.25rem);
  }

  .app-shell[data-view="map"] .screen-heading .eyebrow {
    margin-bottom: 3px;
  }

  .app-shell[data-view="map"] .screen-heading > p {
    line-height: 1.4;
  }

  .map-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(300px, 0.75fr);
    gap: 10px;
    height: calc(100dvh - 185px);
    min-height: 320px;
    padding: 10px;
  }

  .map-canvas {
    height: 100%;
    aspect-ratio: auto;
  }

  .level-roster {
    grid-template-columns: 1fr;
    align-content: stretch;
    gap: 6px;
    margin-top: 0;
  }

  .level-chip {
    min-height: 0;
    padding: 6px 8px;
  }

  .level-chip-icon {
    width: 30px;
    height: 30px;
  }

  .quiz-layout {
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 10px;
  }

  .quiz-card {
    padding: 18px 24px;
  }

  .quiz-meta {
    margin-bottom: 9px;
  }

  .progress-track {
    height: 6px;
    margin-bottom: 14px;
  }

  .question-text {
    margin-bottom: 14px;
    font-size: clamp(1.35rem, 2.7vw, 1.9rem);
    line-height: 1.28;
  }

  .answer-list {
    gap: 8px;
  }

  .answer-option {
    grid-template-columns: 38px 1fr;
    min-height: 54px;
    padding: 8px 12px;
  }

  .answer-key {
    width: 36px;
    height: 36px;
  }

  .answer-actions {
    margin-top: 12px;
  }

  .quiz-side {
    gap: 9px;
  }

  .side-card {
    padding: 14px;
  }

  .feedback-box {
    margin-top: 12px;
    padding: 13px 16px;
    line-height: 1.5;
  }

  .feedback-box h3,
  .feedback-box p {
    margin-bottom: 7px;
  }

  .feedback-box .button-row {
    margin-top: 9px;
  }

  .app-shell[data-view="quiz"] .answer-option:disabled:not(.selected):not(.correct) {
    display: none;
  }

  .celebration,
  .end-screen {
    min-height: calc(100dvh - 20px);
    padding: 8px;
  }

  .celebration-card,
  .end-card {
    padding: 20px 28px;
  }

  .celebration .badge-crop {
    width: 118px;
    margin-bottom: 8px;
  }

  .earned-badges {
    margin: 12px 0;
  }

  .game-dialog {
    max-height: calc(100dvh - 16px);
  }

  .dialog-body {
    padding: 18px 24px;
  }

  .dialog-body ul {
    line-height: 1.55;
  }

  .app-shell[data-view="complete"] .end-card {
    padding: 16px 22px;
  }

  .completion-layout {
    gap: 24px;
  }

  .completion-summary h1 {
    margin-bottom: 8px;
    font-size: clamp(2.6rem, 5vw, 4rem);
  }

  .completion-summary .lead {
    margin-bottom: 8px;
    font-size: 0.96rem;
    line-height: 1.55;
  }

  .completion-role {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 14px;
    margin-block: 10px;
    padding: 10px 14px;
  }

  .completion-role .sprite-crop {
    width: 48px;
  }

  .completion-role h2 {
    margin-bottom: 0;
    font-size: 1.65rem;
  }

  .badge-crop.small {
    width: 50px;
  }

  .passcode-panel {
    margin-bottom: 10px;
    padding: 14px 18px;
  }

  .passcode-panel h2 {
    margin-bottom: 7px;
    font-size: 1.65rem;
  }

  .passcode-panel .muted {
    margin-bottom: 8px;
    line-height: 1.45;
  }

  .field-label {
    margin: 8px 0 5px;
  }

  .text-input {
    min-height: 42px;
    padding: 8px 12px;
  }

  .field-hint {
    margin: 5px 0 9px;
  }

  .completion-note {
    margin-top: 7px;
    font-size: 0.85rem;
  }
}

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