@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces.woff2') format('woff2');
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces-italic.woff2') format('woff2');
  font-weight: 400 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Figtree';
  src: url('/fonts/figtree.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #07040a;
  --ink: #fff1e2;
  --ink-2: rgba(255, 236, 214, 0.7);
  --ink-3: rgba(255, 236, 214, 0.44);
  --line: rgba(255, 214, 178, 0.12);
  --card: rgba(30, 17, 14, 0.8);
  --card-2: #1b0f0d;
  --ember: #ff7a1a;
  --ember-hot: #ffb547;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ui: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --my-hue: 24;
  --spring: cubic-bezier(0.3, 1.5, 0.45, 1);
  --ease: cubic-bezier(0.2, 0.85, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100svh;
  overscroll-behavior-y: none;
  background:
    radial-gradient(120% 60% at 50% 0%, #120b18 0%, transparent 60%),
    var(--bg);
}

button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ember-hot); outline-offset: 2px; }
[hidden] { display: none !important; }

.app {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}

/* ------------------------------------------------------------------ scene */

.scene {
  position: relative;
  height: clamp(380px, 60svh, 600px);
  overflow: hidden;
  background: #0b0a1d;
}
.scene canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.scene::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 90px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
  z-index: 1;
}

.topbar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 6;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: calc(var(--safe-top) + 14px) 16px 0;
}
.title { flex: 1; min-width: 0; transition: opacity 0.5s; }
/* The fire's name only arrives with the first state; keep the space, show nothing until then. */
.app[data-view='loading'] .title { opacity: 0; }
.title h1 {
  min-height: 1.1em;
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.count {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}
.pips { display: inline-flex; gap: 4px; }
.pip {
  width: 8px;
  height: 11px;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.5s, box-shadow 0.5s, transform 0.5s var(--spring);
}
.pip.on {
  background: linear-gradient(#ffe08a, #ff6a1a);
  box-shadow: 0 0 9px #ff7a1a;
  transform: scale(1.15);
}

.icon-btn {
  position: relative;
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(16, 9, 10, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: color 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.icon-btn svg { width: 20px; height: 20px; }
.bell[data-state='hidden'] { display: none; }
.bell .slash { display: none; }
.bell[data-state='denied'] .slash, .bell[data-state='unsupported'] .slash { display: block; }
.bell[data-state='on'] {
  color: var(--ember-hot);
  border-color: rgba(255, 170, 90, 0.4);
  box-shadow: 0 0 18px rgba(255, 122, 26, 0.3);
}
.bell-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ember);
  display: none;
}
.bell[data-state='off'] .bell-dot,
.bell[data-state='install'] .bell-dot {
  display: block;
  animation: beacon 2s infinite;
}
@keyframes beacon {
  0% { box-shadow: 0 0 0 0 rgba(255, 122, 26, 0.7); }
  70%, 100% { box-shadow: 0 0 0 9px rgba(255, 122, 26, 0); }
}

/* ------------------------------------------------------------------ seats */

.seats {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.seat {
  --c: hsl(var(--hue) 95% 62%);
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  translate: -50% -24px;
  scale: var(--s, 1);
  transition: left 0.8s var(--ease), top 0.8s var(--ease), scale 0.8s var(--ease);
}
.seat .avatar {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  color: rgba(255, 238, 222, 0.72);
  background:
    radial-gradient(circle at var(--lx, 50%) var(--ly, 10%), rgba(255, 150, 70, calc(0.12 + 0.3 * var(--fire, 0))) 0%, transparent 72%),
    #1b1013;
  border: 2px solid hsl(var(--hue) 45% 42% / 0.55);
  transition: color 0.5s, border-color 0.5s, box-shadow 0.6s, filter 0.6s, background 0.6s;
}
.seat .ring {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  rotate: -90deg;
  opacity: 0;
  transition: opacity 0.5s;
}
.seat .ring circle {
  fill: none;
  stroke: var(--c);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: var(--p, 100) 100;
  transition: stroke-dasharray 1s linear;
}
.seat[data-state='lit'][data-timed] .ring { opacity: 0.85; }
.seat .name {
  max-width: 86px;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-2);
  text-shadow: 0 1px 6px #000, 0 0 2px #000;
  transition: color 0.5s;
}
.seat .tag {
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--c);
  text-shadow: 0 1px 6px #000;
  opacity: 0;
  translate: 0 -4px;
  transition: opacity 0.4s, translate 0.4s;
}
.seat .mini-flame {
  position: absolute;
  top: -20px;
  left: 50%;
  width: 16px;
  height: 24px;
  margin-left: -8px;
  transform-origin: 50% 100%;
  scale: 0;
  transition: scale 0.45s var(--spring);
}
.seat .mini-flame::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 82%, #fff 0 16%, var(--c) 46%, transparent 72%);
  animation: flick 0.8s infinite alternate ease-in-out;
}
.seat .zz {
  position: absolute;
  top: -8px;
  right: 16px;
  font-family: var(--display);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
  opacity: 0;
}
.seat[data-state='lit'] .avatar {
  color: #fff8ee;
  border-color: var(--c);
  background:
    radial-gradient(circle at var(--lx, 50%) var(--ly, 10%), hsl(var(--hue) 95% 68% / 0.6) 0%, transparent 78%),
    #2a1611;
  box-shadow: 0 0 0 4px hsl(var(--hue) 95% 60% / 0.16), 0 0 28px hsl(var(--hue) 95% 58% / 0.55);
}
.seat[data-state='lit'] .name { color: var(--ink); }
.seat[data-state='lit'] .tag:not(:empty) { opacity: 1; translate: 0 0; }
.seat[data-state='lit'] .mini-flame { scale: 1; }
.seat[data-state='asleep'] .avatar { filter: saturate(0.35) brightness(0.7); }
.seat[data-state='asleep'] .zz { animation: zz 3.4s infinite ease-out; }
.seat.me .name { color: var(--ink); }
.seat.me .avatar::after {
  content: '';
  position: absolute;
  bottom: -9px;
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--c);
  opacity: 0.8;
}
.seat.entering .avatar { animation: seat-in 0.9s var(--spring) both; }
.seat.entering .name, .seat.entering .tag { animation: fade-in 0.6s 0.25s both; }
.seat.leaving { animation: seat-out 0.5s both; }
.seats.crowded .seat { translate: -50% -19px; width: 64px; }
.seats.crowded .seat .name { font-size: 10.5px; max-width: 60px; }
.seats.crowded .seat .tag { display: none; }
.seats.crowded .seat .avatar { width: 38px; height: 38px; font-size: 16px; }

@keyframes seat-in {
  from { opacity: 0; transform: translateY(18px) scale(0.3); }
}
@keyframes seat-out {
  to { opacity: 0; transform: scale(0.6); }
}
@keyframes fade-in {
  from { opacity: 0; }
}
@keyframes zz {
  0% { opacity: 0; transform: translate(0, 4px) scale(0.8); }
  30% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(10px, -14px) scale(1.15); }
}
@keyframes flick {
  0% { transform: scale(1, 1) skewX(-3deg); }
  50% { transform: scale(0.93, 1.07) skewX(2deg); }
  100% { transform: scale(1.05, 0.94) skewX(-1deg); }
}

/* ------------------------------------------------------------------ banner */

.banner {
  position: absolute;
  inset: 24% 0 auto;
  z-index: 5;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}
.banner strong {
  display: block;
  font-family: var(--display);
  font-style: italic;
  font-weight: 600;
  font-size: 46px;
  line-height: 1.1;
  background: linear-gradient(#fff6cf, #ffb547 55%, #ff6a1a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 140, 40, 0.65));
}
.banner span {
  display: block;
  margin-top: 4px;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 1px 10px #000;
}
.banner.show { animation: banner 3.4s var(--ease) both; }
@keyframes banner {
  0% { opacity: 0; transform: translateY(24px) scale(0.6); }
  14% { opacity: 1; transform: none; }
  78% { opacity: 1; transform: translateY(-6px); }
  100% { opacity: 0; transform: translateY(-34px); }
}

/* ------------------------------------------------------------------ panel */

.panel {
  --c: hsl(var(--my-hue) 95% 60%);
  position: relative;
  z-index: 4;
  margin: -34px 12px 0;
  padding: 16px 16px 16px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(40, 22, 17, 0.94), rgba(20, 11, 11, 0.97));
  border: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 220, 190, 0.07);
  transition: border-color 0.6s, box-shadow 0.6s;
}
.panel.lit {
  border-color: hsl(var(--my-hue) 90% 60% / 0.38);
  box-shadow: 0 0 46px hsl(var(--my-hue) 90% 55% / 0.2), 0 -12px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 220, 190, 0.07);
}
.status-line {
  margin: 0 0 12px;
  min-height: 27px;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.panel.lit .status-line { color: #fff6ea; }

.chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}
.chip-label {
  flex: none;
  width: 66px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 16px 2px 2px;
  margin: -2px 0;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.25s var(--spring);
}
.chip:active { transform: scale(0.94); }
.chip[aria-checked='true'] {
  color: #1d0e06;
  border-color: transparent;
  background: linear-gradient(#ffcd7a, #ff8f2e);
  box-shadow: 0 4px 16px rgba(255, 122, 26, 0.32);
}

/* The match: drag (or tap) the matchstick across the striker strip. */
.match {
  --pos: 0;
  position: relative;
  display: block;
  width: 100%;
  height: 78px;
  margin: 14px 0 0;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  container-type: inline-size;
}
.match .strip {
  position: absolute;
  inset: 12px 0;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 40%, rgba(255, 255, 255, 0.07) 0 0.8px, transparent 1.4px) 0 0 / 6px 6px,
    radial-gradient(circle at 70% 70%, rgba(0, 0, 0, 0.35) 0 0.8px, transparent 1.4px) 0 0 / 5px 5px,
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0 2px, transparent 2px 6px),
    linear-gradient(#5e2b1d, #391711);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.65), inset 0 -1px 0 rgba(255, 200, 160, 0.08), 0 1px 0 rgba(255, 220, 190, 0.05);
}
.match .trail {
  position: absolute;
  left: 18px;
  top: 50%;
  height: 8px;
  width: calc((100cqw - 120px) * var(--pos));
  translate: 0 -50%;
  border-radius: 8px;
  background: linear-gradient(90deg, transparent, hsl(var(--my-hue) 95% 60% / 0.55), #ffe2a8);
  filter: blur(3px);
  opacity: 0;
  transition: opacity 0.6s;
}
.match.lit .trail { opacity: 0.75; animation: trail-glow 2.4s infinite alternate ease-in-out; }
@keyframes trail-glow { to { opacity: 0.45; } }
.match .hint {
  position: absolute;
  right: 20px;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 210, 170, 0.5);
  opacity: calc(1 - var(--pos) * 2.2);
  transition: opacity 0.3s;
}
.match .hint span { margin-right: 6px; }
.match .hint i {
  font-style: normal;
  font-size: 18px;
  animation: chevron 1.6s infinite;
}
.match .hint i:nth-child(3) { animation-delay: 0.15s; }
.match .hint i:nth-child(4) { animation-delay: 0.3s; }
@keyframes chevron {
  0%, 100% { opacity: 0.2; }
  40% { opacity: 1; color: #ffcf9a; }
}
.match .stick {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 104px;
  height: 18px;
  translate: calc((100cqw - 124px) * var(--pos)) -50%;
  transition: translate 0.5s var(--spring);
}
.match.dragging .stick, .match.dragging .trail { transition: none; }
.match .wood {
  position: absolute;
  left: 0;
  top: 4px;
  width: 88px;
  height: 10px;
  border-radius: 3px 5px 5px 3px;
  background: linear-gradient(#f7e2b4, #d0a066 70%, #b5864f);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.55);
}
.match .head {
  position: absolute;
  right: 0;
  top: -2px;
  width: 25px;
  height: 22px;
  border-radius: 56% 62% 62% 56%;
  background: radial-gradient(circle at 34% 30%, #ff9c8c 0 10%, #c9301e 42%, #74130a 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  transition: background 0.8s;
}
.match.lit .head {
  background: radial-gradient(circle at 42% 42%, #ffe6a6 0 10%, #ff8a2a 32%, #3d1b10 76%);
}
.match .flame {
  position: absolute;
  right: -6px;
  bottom: 9px;
  width: 36px;
  height: 58px;
  transform-origin: 50% 100%;
  scale: 0;
  transition: scale 0.4s var(--spring);
  pointer-events: none;
}
.match.lit .flame { scale: 1; }
.match .flame i {
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 86%, #fff 0 12%, #ffe08a 22%, var(--c) 50%, transparent 72%);
  animation: flick 0.9s infinite alternate ease-in-out;
  transform-origin: 50% 100%;
}
.match .flame i + i {
  inset: 22% 24% 0;
  animation-duration: 0.55s;
  background: radial-gradient(ellipse at 50% 86%, #fff 0 28%, #ffd36b 52%, transparent 74%);
}
.match .puff {
  position: absolute;
  right: 0;
  bottom: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 190, 185, 0.5), transparent 70%);
  opacity: 0;
  pointer-events: none;
}
.match.dousing .puff { animation: puff 1s ease-out; }
@keyframes puff {
  0% { opacity: 0.9; transform: translateY(0) scale(0.5); }
  100% { opacity: 0; transform: translateY(-40px) scale(2.2); }
}
.match.igniting .head { animation: ignite 0.7s ease-out; }
@keyframes ignite {
  0% { box-shadow: 0 0 0 0 rgba(255, 245, 210, 0.9); }
  25% { box-shadow: 0 0 34px 14px rgba(255, 200, 120, 0.9); }
  100% { box-shadow: 0 0 10px 2px rgba(255, 122, 26, 0); }
}
.match .spark {
  position: absolute;
  right: 8px;
  top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffe2a0;
  box-shadow: 0 0 6px #ffb547;
  pointer-events: none;
  animation: spark 0.7s ease-out forwards;
}
@keyframes spark {
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

.nudge {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 10px 12px 14px;
  border-radius: 16px;
  background: rgba(255, 140, 60, 0.07);
  border: 1px dashed rgba(255, 170, 100, 0.32);
  animation: fade-in 0.6s both;
}
.nudge-text { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2); }
.nudge-text strong { display: block; font-size: 14px; color: var(--ink); }
.nudge-x {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  font-size: 20px;
  cursor: pointer;
}

/* ------------------------------------------------------------------ roster */

.roster { padding: 24px 16px calc(32px + var(--safe-bottom)); }
.roster h2 {
  margin: 0 0 12px 4px;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink-2);
}
.roster ul { list-style: none; margin: 0; padding: 0; }
.friend {
  --c: hsl(var(--hue) 95% 62%);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 11px 14px 11px 11px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card);
  transition: border-color 0.5s, background 0.5s;
}
.friend[data-state='lit'] {
  border-color: hsl(var(--hue) 90% 60% / 0.34);
  background: linear-gradient(90deg, hsl(var(--hue) 90% 50% / 0.15), var(--card) 65%);
}
.friend .dot {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  background: hsl(var(--hue) 35% 17%);
  color: hsl(var(--hue) 85% 76%);
  transition: background 0.5s, color 0.5s, box-shadow 0.5s;
}
.friend[data-state='lit'] .dot {
  background: var(--c);
  color: #170a05;
  box-shadow: 0 0 18px hsl(var(--hue) 90% 55% / 0.6);
}
.friend .online {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #a7e37c;
  border: 2px solid #1e1110;
}
.friend .who { flex: 1; min-width: 0; }
.friend b { font-weight: 700; font-size: 15.5px; }
.friend .you {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 2px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-2);
}
.friend small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--ink-3);
}
.friend[data-state='lit'] small { color: var(--ink-2); }
.friend .lit-flame {
  flex: none;
  width: 14px;
  height: 22px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 82%, #fff 0 16%, var(--c) 48%, transparent 74%);
  animation: flick 0.75s infinite alternate ease-in-out;
  transform-origin: 50% 100%;
}
.empty {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  color: var(--ink-3);
  text-align: center;
  font-size: 14px;
}
.hosted {
  margin: 20px 6px 0;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}

/* ------------------------------------------------------------------ views */

.app[data-view='loading'] .panel,
.app[data-view='loading'] .roster,
.app[data-view='gate'] .panel,
.app[data-view='gate'] .roster,
.app[data-view='gate'] .topbar,
.app[data-view='onboard'] .panel,
.app[data-view='onboard'] .roster { display: none; }
.app[data-view='gate'] .scene, .app[data-view='onboard'] .scene { height: 100svh; max-height: none; }

/* ------------------------------------------------------------------ overlays */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 16px 12px calc(14px + var(--safe-bottom));
  background: linear-gradient(transparent 35%, rgba(7, 4, 10, 0.72) 70%, rgba(7, 4, 10, 0.92));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.overlay .card {
  width: min(520px, 100%);
  padding: 22px 20px 20px;
  border-radius: 28px;
  background: rgba(27, 15, 13, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  translate: 0 28px;
  transition: translate 0.7s var(--ease);
}
.overlay.open .card { translate: 0 0; }
.overlay h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
}
.overlay p { margin: 0 0 4px; color: var(--ink-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.ember-badge {
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 122, 26, 0.1);
  border: 1px solid rgba(255, 150, 80, 0.25);
}
.ember-badge i {
  width: 14px;
  height: 20px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 82%, #ffd9a0 0 14%, #ff6a1a 50%, transparent 74%);
  animation: flick 1.2s infinite alternate ease-in-out;
  transform-origin: 50% 100%;
}
.overlay .btn-primary { margin-top: 16px; }

.label {
  display: block;
  margin: 14px 0 8px;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink-2);
}
.field {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.32);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field:focus { border-color: rgba(255, 170, 90, 0.6); box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.15); }
.field::placeholder { color: var(--ink-3); }

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.swatch {
  --c: hsl(var(--hue) 95% 62%);
  position: relative;
  height: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s, transform 0.25s var(--spring);
}
.swatch:active { transform: scale(0.94); }
.swatch .f {
  width: 18px;
  height: 27px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 82%, #fff 0 14%, var(--c) 48%, transparent 74%);
  opacity: 0.55;
  transform-origin: 50% 100%;
  transition: opacity 0.3s;
}
.swatch small { font-size: 10.5px; font-weight: 650; color: var(--ink-3); }
.swatch[aria-checked='true'] {
  border-color: var(--c);
  background: hsl(var(--hue) 90% 50% / 0.13);
  box-shadow: 0 0 22px hsl(var(--hue) 90% 50% / 0.28);
}
.swatch[aria-checked='true'] .f { opacity: 1; animation: flick 0.7s infinite alternate ease-in-out; }
.swatch[aria-checked='true'] small { color: var(--ink); }
.swatches.compact .swatch { height: 52px; }
.swatches.compact .swatch small { display: none; }

.btn-primary, .btn-secondary, .btn-ghost, .btn-small {
  border: 0;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.2s var(--spring), opacity 0.2s, box-shadow 0.2s;
}
.btn-primary:active, .btn-secondary:active, .btn-ghost:active, .btn-small:active { transform: scale(0.97); }
.btn-primary {
  width: 100%;
  padding: 15px;
  border-radius: 18px;
  font-size: 17px;
  color: #1d0e06;
  background: linear-gradient(#ffcd7a, #ff7a1a);
  box-shadow: 0 10px 30px rgba(255, 122, 26, 0.34);
}
.btn-primary:disabled { opacity: 0.55; }
.btn-secondary {
  padding: 12px 18px;
  border-radius: 14px;
  color: #1d0e06;
  background: linear-gradient(#ffcd7a, #ff8f2e);
}
.btn-ghost {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}
.btn-small {
  flex: none;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 14px;
  color: #1d0e06;
  background: linear-gradient(#ffcd7a, #ff8f2e);
}

/* ------------------------------------------------------------------ sheets */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 3, 6, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 51;
  width: min(560px, 100%);
  max-height: 90svh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 18px calc(24px + var(--safe-bottom));
  border-radius: 28px 28px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #170d0c;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  translate: -50% 105%;
  visibility: hidden;
  transition: translate 0.5s var(--ease), visibility 0s 0.5s;
}
.sheet.open { translate: -50% 0; visibility: visible; transition: translate 0.5s var(--ease); }
.grab { width: 42px; height: 5px; margin: 0 auto 10px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 700; }
.sheet h3 {
  margin: 24px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.stack { display: grid; gap: 10px; }
.note { margin: 0 0 6px; font-size: 13.5px; color: var(--ink-2); }
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  cursor: pointer;
}
.toggle input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 48px;
  height: 29px;
  margin: 0;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.13);
  cursor: pointer;
  transition: background 0.25s;
}
.toggle input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #f3e6da;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: translate 0.3s var(--spring);
}
.toggle input:checked { background: linear-gradient(90deg, #ff7a1a, #ffb547); }
.toggle input:checked::after { translate: 19px 0; }
.toggle input:disabled { opacity: 0.4; }
.steps { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 12px; color: var(--ink); font-weight: 600; }
.steps svg { width: 18px; height: 18px; vertical-align: -3px; color: #6cb4ff; }

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

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  z-index: 60;
  width: min(92vw, 420px);
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  --c: var(--ember);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 16px 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(26, 14, 12, 0.94);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  font-size: 14px;
  font-weight: 650;
  animation: toast-in 0.5s var(--spring) both;
}
.toast .dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}
.toast.muted .dot { background: #8a7f7a; box-shadow: none; }
.toast.out { animation: toast-out 0.4s both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.92); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* The full-fire banner still has to be seen: fade it, no movement. */
  .banner.show {
    animation: banner-still 3.4s linear both !important;
  }
  @keyframes banner-still {
    0%, 100% { opacity: 0; }
    8%, 85% { opacity: 1; }
  }
}
