:root {
  --cream: #fff9f2;
  --surface: #ffffff;
  --surface-soft: #fff2e3;
  --surface-strong: #ffe1c4;
  --ink: #241b18;
  --muted: #725f58;
  --line: #ead6c5;
  --accent-coral: #e9573f;
  --accent: #e9573f;
  --ember: #ff8a5c;
  --gold-mist: #ffcd8a;
  --terracotta: #c1613f;
  --accent-strong: #c73928;
  --accent-soft: #ffe4dc;
  --green: #16735b;
  --green-soft: #e3f5ec;
  --red: #b12c22;
  --red-soft: #ffe2df;
  --warm-dark: #241b18;
  --dusk-brown: #3a2620;
  --shadow: 0 18px 45px rgba(62, 38, 22, 0.12);
  --radius: 8px;
  --max: 1120px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(115deg, rgba(233, 87, 63, 0.08), transparent 32%),
    linear-gradient(205deg, rgba(255, 205, 138, 0.16), transparent 30%),
    var(--cream);
}

body.world-mode {
  background: radial-gradient(circle at 50% 38%, rgba(255, 138, 92, 0.34), transparent 28%),
    radial-gradient(circle at 50% 60%, rgba(255, 205, 138, 0.18), transparent 32%),
    linear-gradient(180deg, #4a2f24 0%, var(--warm-dark) 68%, #1c1513 100%);
  color: var(--cream);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

button,
.button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 750;
  line-height: 1.1;
  padding: 0.78rem 1rem;
  position: relative;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
  box-shadow: 0 12px 28px rgba(233, 87, 63, 0.18);
  transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(233, 87, 63, 0.38);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.skip-link {
  background: var(--ink);
  color: #fff;
  left: 1rem;
  padding: 0.75rem 1rem;
  position: fixed;
  top: -5rem;
  z-index: 40;
}

.skip-link:focus {
  top: 1rem;
}

.shell {
  min-height: 100vh;
  position: relative;
}

.world-layer {
  background: radial-gradient(circle at 50% 42%, rgba(255, 138, 92, 0.32), transparent 24%),
    radial-gradient(circle at 50% 82%, rgba(255, 205, 138, 0.12), transparent 36%),
    linear-gradient(180deg, #4a2f24 0%, var(--warm-dark) 70%, #1a1412 100%);
  inset: 0;
  overflow: hidden;
  position: fixed;
  z-index: 0;
}

.world-layer:after {
  background: linear-gradient(180deg, rgba(28, 21, 18, 0.28), rgba(28, 21, 18, 0.08) 42%, rgba(20, 15, 13, 0.32));
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.ember-mount,
.ember-mount canvas,
.ember-css-fallback,
.ember-poster {
  height: 100%;
  inset: 0;
  position: absolute;
  width: 100%;
}

.ember-mount canvas {
  display: block;
}

.ember-css-fallback,
.ember-poster {
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.ember-css-fallback:before,
.ember-poster:before {
  animation: emberPulse 4.8s ease-in-out infinite;
  background: radial-gradient(circle, rgba(255, 205, 138, 0.9) 0 4%, rgba(255, 138, 92, 0.55) 10%, rgba(233, 87, 63, 0.18) 22%, transparent 48%);
  border-radius: 50%;
  content: "";
  filter: blur(8px);
  height: 44vmin;
  left: 50%;
  max-height: 420px;
  max-width: 420px;
  min-height: 240px;
  min-width: 240px;
  position: absolute;
  top: 36%;
  transform: translate(-50%, -50%);
  width: 44vmin;
}

.ember-css-fallback:after,
.ember-poster:after {
  animation: gradientDrift 18s ease-in-out infinite alternate;
  background:
    radial-gradient(circle at 42% 35%, rgba(255, 205, 138, 0.18), transparent 18%),
    radial-gradient(circle at 62% 45%, rgba(233, 87, 63, 0.12), transparent 22%),
    repeating-radial-gradient(circle at 50% 48%, rgba(255, 205, 138, 0.12), transparent 1px, transparent 28px);
  content: "";
  inset: -8%;
  position: absolute;
}

.world-layer[data-tier="poster"] .ember-poster,
.world-layer[data-tier="css"] .ember-css-fallback {
  opacity: 1;
}

.world-layer[data-tier="poster"] .ember-mount,
.world-layer[data-tier="css"] .ember-mount {
  display: none;
}

.world-main {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 2rem);
  position: relative;
  z-index: 2;
}

.world-view {
  display: grid;
  gap: clamp(1rem, 3vw, 1.4rem);
  margin: 0 auto;
  max-width: var(--max);
  width: 100%;
}

.arrival-panel,
.world-picker {
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  box-shadow: none;
  color: var(--cream);
  overflow: visible;
  padding: clamp(1.2rem, 4vw, 2.6rem);
  position: relative;
}

.arrival-panel:after,
.world-picker:after {
  background: linear-gradient(90deg, transparent, rgba(255, 205, 138, 0.8), rgba(233, 87, 63, 0.72), transparent);
  bottom: 0;
  content: "";
  height: 3px;
  left: 0;
  position: absolute;
  width: 100%;
  display: none;
  z-index: 2;
}

.arrival-panel > *,
.world-picker > * {
  position: relative;
  z-index: 1;
}

.arrival-panel h1,
.hero-arrival h1 {
  max-width: 920px;
}

.arrival-panel .lead,
.world-picker .subtle,
.arrival-panel .subtle {
  color: rgba(255, 249, 242, 0.9);
}

.name-panel,
.gate-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
  margin: 0 auto;
  max-width: 760px;
  overflow: hidden;
  width: min(100%, 760px);
}

.gate-panel .eyebrow,
.name-panel .eyebrow {
  color: var(--accent-strong);
}

.gate-panel h1,
.name-panel h1,
.gate-panel .lead,
.name-panel .lead,
.name-panel .subtle,
.gate-panel .subtle {
  color: var(--ink);
}

.gate-panel .lead,
.name-panel .lead,
.name-panel .subtle,
.name-wall-placeholder {
  color: var(--muted);
}

.name-wall-wrap {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.2rem;
}

.name-wall,
.compact-name-wall {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.name-chip,
.compact-name-wall span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  min-height: 38px;
  padding: 0.5rem 0.75rem;
}

.name-wall-placeholder {
  margin: 0;
}

.name-chip {
  display: inline-grid;
  gap: 0.05rem;
  justify-items: start;
}

.name-chip small {
  color: var(--muted);
  font-size: 0.72rem;
}

.participant-strip {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.participant-strip span,
.ghost-button {
  background: rgba(255, 249, 242, 0.12);
  border: 1px solid rgba(255, 205, 138, 0.22);
  border-radius: 999px;
  color: var(--cream);
  min-height: 36px;
  padding: 0.45rem 0.7rem;
}

.ghost-button {
  min-height: 36px;
}

.world-card-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr;
  margin-top: 1rem;
}

.world-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  display: grid;
  gap: 0.52rem;
  min-height: 100%;
  overflow: hidden;
  padding: 1rem;
  position: relative;
  text-decoration: none;
  transition: background 220ms ease, border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

.world-card:before {
  background: linear-gradient(90deg, var(--dept-glow, var(--ember)), rgba(255, 205, 138, 0.2));
  content: "";
  height: 3px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.world-card > * {
  position: relative;
  z-index: 1;
}

.world-card:hover,
.world-card:focus-visible {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--dept-glow, var(--accent)) 42%, var(--line));
  box-shadow: 0 18px 42px color-mix(in srgb, var(--dept-glow, var(--ember)) 18%, rgba(62, 38, 22, 0.14));
  transform: translateY(-2px);
}

.world-card p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.hero-arrival {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--cream);
}

.hero-arrival h1 {
  color: var(--cream);
  font-weight: 950;
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.34);
}

.hero-arrival .lead {
  color: rgba(255, 249, 242, 0.9);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.32);
}

.world-picker h2 {
  color: var(--cream);
}

.world-picker .subtle {
  color: rgba(255, 249, 242, 0.9);
}

.social-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
  overflow: hidden;
}

.social-panel h2,
.social-panel .subtle {
  color: var(--ink);
}

.social-panel .subtle {
  color: var(--muted);
}

.social-panel .progress-track.warm {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  height: 10px;
}

.topbar {
  backdrop-filter: blur(16px);
  background: rgba(255, 249, 242, 0.9);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  align-items: center;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
  margin: 0 auto;
  max-width: var(--max);
  padding: 0.85rem 1rem;
}

.brand-row {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  letter-spacing: 0;
  width: 38px;
}

.brand-name {
  display: block;
  font-weight: 900;
  line-height: 1;
}

.progress-copy {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  margin-top: 0.18rem;
}

.nav-links {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}

.nav-links a {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-weight: 750;
  padding: 0.58rem 0.82rem;
  text-decoration: none;
}

.nav-links a.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.progress-track {
  background: var(--surface-strong);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  width: 100%;
}

.progress-track.warm {
  background: rgba(255, 249, 242, 0.16);
}

.progress-fill {
  background: var(--green);
  border-radius: inherit;
  height: 100%;
  transition: width 220ms ease;
}

.progress-track.warm .progress-fill {
  background: linear-gradient(90deg, var(--gold-mist), var(--ember), var(--accent));
}

main:not(.world-main) {
  margin: 0 auto;
  max-width: var(--max);
  padding: 1rem 1rem 3rem;
}

.view {
  display: grid;
  gap: 1.25rem;
}

.hero,
.role-hero,
.status-panel,
.badge-panel {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 242, 227, 0.9)),
    repeating-linear-gradient(90deg, rgba(233, 87, 63, 0.07), rgba(233, 87, 63, 0.07) 1px, transparent 1px, transparent 22px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: clamp(1.35rem, 5vw, 3rem);
  position: relative;
}

.horizon-strip {
  min-height: 160px;
}

.horizon-strip:before {
  background:
    radial-gradient(circle at 78% 35%, color-mix(in srgb, var(--dept-glow, var(--ember)) 44%, transparent), transparent 22%),
    radial-gradient(circle at 42% 15%, rgba(255, 205, 138, 0.26), transparent 24%),
    linear-gradient(180deg, rgba(58, 38, 32, 0.2), transparent);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.horizon-strip > * {
  position: relative;
}

.hero:after,
.role-hero:after {
  background: linear-gradient(90deg, var(--accent), var(--gold-mist), var(--terracotta));
  bottom: 0;
  content: "";
  height: 5px;
  left: 0;
  position: absolute;
  width: 100%;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  margin: 0 0 0.55rem;
  text-transform: uppercase;
}

.world-mode .eyebrow,
.arrival-panel .eyebrow,
.world-card .card-topline {
  color: var(--gold-mist);
}

.gate-panel .eyebrow,
.name-panel .eyebrow {
  color: var(--accent-strong);
}

.gate-panel .card-topline,
.name-panel .card-topline {
  color: var(--muted);
}

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

h1 {
  font-size: clamp(2.15rem, 10vw, 4.7rem);
  line-height: 0.96;
  margin-bottom: 1rem;
  max-width: 880px;
}

.role-hero h1,
.status-panel h1,
.gate-panel h1,
.name-panel h1 {
  font-size: clamp(2rem, 8vw, 4rem);
}

h2 {
  font-size: clamp(1.45rem, 4vw, 2.25rem);
  line-height: 1.08;
  margin-bottom: 0.3rem;
}

h3 {
  font-size: 1.1rem;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.lead {
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.25rem);
  line-height: 1.55;
  max-width: 820px;
}

.stats-grid,
.card-grid,
.tool-grid,
.pains-grid,
.rules-grid,
.prompt-grid {
  display: grid;
  gap: 0.85rem;
}

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

.stat,
.card,
.tool-card,
.pain-card,
.rule-card,
.prompt-card,
.toolkit-block,
.game-panel,
.quiz-panel,
.assignment-panel,
.video-box,
.leaderboard-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(62, 38, 22, 0.06);
}

.stat,
.card,
.tool-card,
.pain-card,
.rule-card,
.prompt-card {
  padding: 1rem;
}

.stat strong {
  color: var(--accent-strong);
  display: block;
  font-size: clamp(1.7rem, 8vw, 3rem);
  line-height: 1;
  margin-bottom: 0.45rem;
}

.stat p,
.card p,
.tool-card p,
.pain-card p,
.rule-card p,
.prompt-card p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0;
}

.section {
  display: grid;
  gap: 0.9rem;
  padding-top: 0.65rem;
}

.section-head {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: space-between;
}

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

.card {
  color: inherit;
  display: grid;
  gap: 0.5rem;
  min-height: 100%;
  text-decoration: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.card:hover,
.tool-card:hover,
.pain-card:hover,
.prompt-card:hover {
  border-color: rgba(233, 87, 63, 0.45);
  box-shadow: 0 12px 32px rgba(233, 87, 63, 0.1);
  transform: translateY(-2px);
}

.card-topline {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tick {
  background: var(--green-soft);
  border: 1px solid rgba(22, 115, 91, 0.2);
  border-radius: 999px;
  color: var(--green);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 850;
  justify-self: start;
  padding: 0.28rem 0.55rem;
}

.quote {
  border-left: 4px solid var(--accent);
  color: var(--ink);
  margin-top: 0.8rem;
  padding-left: 0.85rem;
}

.quote blockquote {
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 0.35rem;
}

.quote cite {
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
}

.toolkit-block,
.game-panel,
.quiz-panel,
.assignment-panel {
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 1.45rem);
}

.toolkit-top {
  display: grid;
  gap: 0.8rem;
}

.tool-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.button.secondary,
button.secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}

.button.secondary:hover,
button.secondary:hover {
  background: var(--surface-soft);
}

.example {
  display: grid;
  gap: 0.75rem;
}

.example-label {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.copy-box {
  background: #1f1b18;
  border-radius: var(--radius);
  color: var(--cream);
  overflow: hidden;
}

.copy-box-head {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.7rem 0.8rem;
}

.copy-box pre {
  margin: 0;
  overflow-x: auto;
  padding: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.copy-box code {
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.mini-copy {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  min-height: 36px;
  padding: 0.45rem 0.7rem;
}

.video-box {
  overflow: hidden;
}

.video-frame {
  aspect-ratio: 16 / 9;
  background: var(--warm-dark);
}

.video-frame iframe {
  border: 0;
  height: 100%;
  width: 100%;
}

.video-placeholder {
  align-items: center;
  aspect-ratio: 16 / 9;
  background: var(--surface-soft);
  color: var(--terracotta);
  display: grid;
  font-weight: 850;
  justify-items: center;
  padding: 1rem;
  text-align: center;
}

.video-caption {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
  padding: 0.75rem 0.9rem;
}

.filter-bar {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 1fr;
}

.filter-bar input,
.filter-bar select,
.gate-form input {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  min-height: 46px;
  padding: 0.75rem 0.85rem;
  width: 100%;
}

.gate-form input::placeholder {
  color: color-mix(in srgb, var(--muted) 74%, #fff);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
  padding: 0.3rem 0.55rem;
}

.game-tiles,
.tool-buttons,
.task-list,
.quiz-options {
  display: grid;
  gap: 0.55rem;
}

.tile,
.tool-choice,
.task-choice,
.quiz-option {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  justify-content: flex-start;
  min-height: 50px;
  padding: 0.8rem;
  text-align: left;
}

.tile.selected,
.task-choice.selected,
.tool-choice.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tile.good {
  border-color: rgba(22, 115, 91, 0.55);
}

.tile.bad {
  border-color: rgba(177, 44, 34, 0.55);
}

.preview {
  background: var(--surface-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  line-height: 1.55;
  min-height: 76px;
  padding: 0.9rem;
}

.feedback {
  border-radius: var(--radius);
  color: var(--muted);
  display: none;
  line-height: 1.5;
  padding: 0.9rem;
}

.feedback.show {
  display: block;
}

.feedback.good {
  background: var(--green-soft);
  color: var(--green);
}

.feedback.bad {
  background: var(--red-soft);
  color: var(--red);
}

.match-board {
  display: grid;
  gap: 0.8rem;
}

.assignment-steps {
  color: var(--muted);
  line-height: 1.55;
  padding-left: 1.25rem;
}

.checklist {
  display: grid;
  gap: 0.55rem;
}

.checkline {
  align-items: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 0.6rem;
  grid-template-columns: auto 1fr;
  line-height: 1.45;
  padding: 0.75rem;
}

.checkline input {
  height: 20px;
  margin-top: 0.08rem;
  width: 20px;
}

.quiz-question {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.7rem;
  padding-top: 1rem;
}

.quiz-question:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.quiz-option.correct {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}

.quiz-option.wrong {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}

.gate-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.2rem;
}

.gate-error {
  color: var(--red-soft);
  font-weight: 750;
  min-height: 1.3rem;
}

.room-mode .gate-error {
  color: var(--red);
}

.gate-panel .gate-error,
.name-panel .gate-error {
  color: var(--red);
}

.toast {
  background: var(--ink);
  border-radius: 999px;
  bottom: 1rem;
  color: #fff;
  left: 50%;
  opacity: 0;
  padding: 0.7rem 1rem;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 1rem);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.empty {
  background: var(--surface-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 1rem;
}

.dark-empty {
  background: rgba(255, 249, 242, 0.1);
  border-color: rgba(255, 205, 138, 0.2);
  color: rgba(255, 249, 242, 0.75);
}

.spot-output {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  line-height: 1.65;
  padding: 1rem;
  white-space: pre-wrap;
}

.spot-error {
  background: var(--red-soft);
  border-bottom: 2px solid var(--red);
  color: var(--red);
}

.ember-divider {
  background: linear-gradient(90deg, transparent, var(--gold-mist), var(--ember), transparent);
  height: 2px;
  opacity: 0.72;
}

.threshold {
  background: radial-gradient(circle at 50% 50%, rgba(255, 205, 138, 0.95), rgba(255, 138, 92, 0.72) 28%, rgba(233, 87, 63, 0.28) 48%, transparent 72%);
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transform: scale(0.2);
  transition: opacity 560ms cubic-bezier(0.22, 1, 0.36, 1), transform 560ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 25;
}

.threshold.show {
  opacity: 1;
  transform: scale(2.2);
}

.burst:after {
  animation: particleBurst 620ms ease-out;
  background:
    radial-gradient(circle, var(--gold-mist) 0 2px, transparent 3px) 0 0 / 18px 18px,
    radial-gradient(circle, var(--ember) 0 2px, transparent 3px) 9px 9px / 22px 22px;
  content: "";
  inset: -18px;
  pointer-events: none;
  position: absolute;
}

.leaderboard-list {
  display: grid;
  gap: 0.75rem;
}

.leaderboard-row {
  align-items: center;
  display: grid;
  gap: 0.85rem;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  padding: 0.9rem;
}

.rank {
  align-items: center;
  background: var(--ink);
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  width: 38px;
}

@keyframes emberPulse {
  0%,
  100% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(0.96);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.04);
  }
}

@keyframes gradientDrift {
  from {
    transform: translate3d(-1%, -1%, 0);
  }
  to {
    transform: translate3d(1%, 1%, 0);
  }
}

@keyframes particleBurst {
  from {
    opacity: 0.75;
    transform: scale(0.55);
  }
  to {
    opacity: 0;
    transform: scale(1.45);
  }
}

@media (min-width: 720px) {
  .topbar-inner {
    grid-template-columns: minmax(250px, 1fr) auto minmax(160px, 220px);
  }

  main:not(.world-main) {
    padding-top: 1.5rem;
  }

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

  .card-grid,
  .pains-grid,
  .rules-grid,
  .prompt-grid,
  .world-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .toolkit-top {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .filter-bar {
    grid-template-columns: minmax(0, 1fr) 230px;
  }

  .match-board {
    grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  }

  .gate-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (min-width: 980px) {
  .card-grid.role-grid,
  .world-card-grid.role-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 520px) {
  .leaderboard-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .leaderboard-row > strong {
    justify-self: start;
  }

  .world-main {
    align-items: start;
    padding-top: 1rem;
  }

  h1 {
    font-size: clamp(2rem, 13vw, 3rem);
  }

  .world-layer:after {
    background:
      radial-gradient(ellipse at 46% 34%, rgba(20, 15, 13, 0.86) 0%, rgba(20, 15, 13, 0.76) 38%, transparent 62%),
      linear-gradient(180deg, rgba(28, 21, 18, 0.76), rgba(28, 21, 18, 0.52) 42%, rgba(20, 15, 13, 0.72));
  }
}

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

  .world-layer .ember-poster {
    opacity: 1;
  }
}

/* ===== BRIEF-ARCADE styles (warm palette) ===== */
.arcade-container { display: block; }
.arcade-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.arcade-head h3 { margin: 0.1rem 0 0.2rem; }
.arcade-meta { text-align: right; font-size: 0.9rem; color: var(--muted); }
.arcade-timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.arcade-score { font-weight: 600; }

.colour-stage { display: grid; gap: 0.5rem; justify-items: center; }
#ct-canvas { background: #fff9f2; border: 1px solid var(--line); border-radius: 6px; touch-action: none; max-width: 100%; height: auto; }
.colour-legend { font-size: 0.8rem; color: var(--muted); }
.colour-regions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.region-chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.region-chip.selected { border-color: var(--accent-coral); background: var(--accent-soft); }
.region-chip.good { border-color: var(--green); background: var(--green-soft); }
.region-chip.bad { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.colour-palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.4rem; margin-top: 0.4rem; }
.palette-label { font-size: 0.72rem; color: var(--accent-strong); grid-column: 1 / -1; }
.palette-btn { background: #fff; border: 1px solid var(--line); padding: 0.55rem 0.7rem; text-align: left; font-size: 0.85rem; border-radius: 6px; }
.colour-explain { min-height: 1.4rem; font-size: 0.85rem; }
.colour-explain .good { color: var(--green); }
.colour-explain .bad { color: var(--red); }

.thela-patience { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.patience-fill { height: 100%; width: 100%; background: var(--gold-mist); transition: width 120ms linear; }
.thela-chit { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; }
.chit-label { font-size: 0.72rem; color: var(--accent-strong); }
.chit-text { font-weight: 600; }
.thela-counter { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.55rem; }
.counter-col { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem; }
.counter-label { font-size: 0.65rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-strong); margin-bottom: 0.2rem; }
.ingreds { display: flex; flex-direction: column; gap: 0.25rem; }
.ingred { font-size: 0.82rem; background: var(--surface); border: 1px solid var(--line); padding: 0.35rem 0.5rem; text-align: left; border-radius: 4px; }
.ingred.junk { border-style: dashed; color: var(--muted); }
.thela-plate { background: var(--surface-soft); border: 1px dashed var(--line); padding: 0.55rem; border-radius: 6px; min-height: 42px; }
.plate-items { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.plate-item { display: inline-flex; align-items: center; gap: 0.25rem; background: #fff; border: 1px solid var(--accent); padding: 0.2rem 0.45rem; border-radius: 4px; font-size: 0.82rem; }
.plate-item.junk { border-color: var(--red); background: var(--red-soft); }
.thela-status { font-size: 0.82rem; min-height: 1rem; color: var(--muted); }

#ar-canvas { background: #f9f2e9; border: 1px solid var(--line); border-radius: 6px; width: 100%; max-width: 100%; height: auto; touch-action: none; display: block; }
.rush-legend { font-size: 0.78rem; color: var(--muted); }
.rush-status { min-height: 2.1rem; font-size: 0.88rem; background: var(--surface-soft); padding: 0.45rem 0.6rem; border-radius: 6px; }

.arcade-end { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 0.9rem; margin-top: 0.6rem; }
.end-head { font-weight: 700; }
.end-score { margin: 0.3rem 0; }
.end-best { color: var(--muted); font-size: 0.9rem; }
.lesson { margin-top: 0.5rem; font-size: 0.85rem; color: var(--ink); background: var(--surface-soft); padding: 0.5rem; border-radius: 6px; }

/* Library phone-chat UI */
.filter-bar { display: grid; gap: 0.65rem; grid-template-columns: 1fr; }
.role-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.role-chip { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 0.32rem 0.7rem; font-size: 0.78rem; font-weight: 700; }
.role-chip.active { background: var(--accent-coral); color: #fff; border-color: var(--accent-coral); }

.phone-frame {
  background: #111;
  border-radius: 28px;
  padding: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  max-width: 420px;
  margin: 0 auto;
  border: 1px solid #222;
}
.phone-head { background: #222; color: var(--cream); text-align: center; font-size: 0.72rem; padding: 0.35rem; border-radius: 16px 16px 0 0; letter-spacing: .08em; }
.chat-scroll { background: #f7f1e8; min-height: 280px; max-height: 420px; overflow: auto; padding: 10px 8px; border-radius: 4px; display: grid; gap: 0.65rem; }
.phone-foot { font-size: 0.65rem; text-align: center; color: #bba48f; padding: 0.3rem 0 0; }

.chat-turn { display: grid; gap: 0.35rem; }
.bubble { max-width: 82%; padding: 0.55rem 0.75rem; border-radius: 14px; font-size: 0.88rem; line-height: 1.35; }
.bubble.incoming { background: #e8e1d6; color: var(--ink); align-self: start; border-bottom-left-radius: 4px; }
.bubble.outgoing { background: var(--accent-coral); color: #fff; align-self: end; border-bottom-right-radius: 4px; }
.bubble-label { display: block; font-size: 0.66rem; opacity: 0.85; margin-bottom: 0.15rem; text-transform: uppercase; letter-spacing: 0.06em; }
.bubble-body { white-space: pre-wrap; word-break: break-word; }
.bubble.outgoing .mini-copy { background: rgba(255,255,255,0.22); color: #fff; border: 1px solid rgba(255,255,255,0.35); margin-top: 0.35rem; min-height: 32px; padding: 0.2rem 0.55rem; font-size: 0.78rem; }

.typing-dots { align-self: end; display: inline-flex; gap: 3px; padding: 0 6px; }
.typing-dots span { width: 5px; height: 5px; background: var(--accent-coral); border-radius: 50%; opacity: 0.6; display: inline-block; animation: typing 900ms infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: 140ms; }
.typing-dots span:nth-child(3) { animation-delay: 280ms; }
@keyframes typing { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-3px)} }

/* breathing room for role sections + ember dividers already present */
.view > .section { gap: 1.05rem; }
.view > .ember-divider { margin: 0.25rem 0 0.15rem; }

/* ensure copy buttons in chat legible */
.phone-frame button.mini-copy { cursor: pointer; }
