:root {
  --gold-1: #fff1c7;
  --gold-2: #f0c66a;
  --gold-3: #b9852f;
  --ink: #f6ecd8;
  --ink-dim: rgba(246, 236, 216, 0.62);
  --glass: rgba(18, 16, 28, 0.42);
  --glass-line: rgba(255, 226, 160, 0.18);
  --bg: #070a17;
  --script: "Snell Roundhand", "Apple Chancery", "Segoe Script", "Brush Script MT", "Lucida Handwriting", cursive;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

/* ---------- loader ---------- */
.loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: radial-gradient(ellipse at 50% 40%, #151a33 0%, var(--bg) 70%);
  z-index: 20;
  transition: opacity 0.9s ease, visibility 0.9s;
}
.loader p {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
}
.loader-star {
  width: 44px;
  height: 44px;
  fill: var(--gold-2);
  filter: drop-shadow(0 0 14px rgba(255, 200, 100, 0.8));
  animation: pulse 1.6s ease-in-out infinite;
}
.loader.done { opacity: 0; visibility: hidden; }
@keyframes pulse {
  0%, 100% { transform: scale(0.9) rotate(0deg); opacity: 0.75; }
  50% { transform: scale(1.08) rotate(18deg); opacity: 1; }
}

/* ---------- hero ---------- */
.hero {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 5;
  padding: 0 16px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 1.6s ease 0.4s, transform 1.6s ease 0.4s;
}
.ready .hero { opacity: 1; transform: none; }
.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.title {
  margin: 2px 0 0;
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(40px, 7.2vw, 78px);
  line-height: 1.15;
  background: linear-gradient(180deg, var(--gold-1) 10%, var(--gold-2) 55%, var(--gold-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 190, 90, 0.35));
}
.countdown {
  margin: 4px 0 0;
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
}
.countdown b {
  color: var(--gold-1);
  font-weight: 600;
  font-size: 18px;
  margin: 0 0.25em;
  font-variant-numeric: tabular-nums;
}

/* ---------- controls ---------- */
.controls {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  z-index: 6;
  opacity: 0;
  transition: opacity 1.2s ease 1s, transform 1.2s ease 1s;
  max-width: calc(100vw - 32px);
}
.ready .controls { opacity: 1; transform: translateX(-50%); }
.controls button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.25s ease, color 0.25s ease;
}
.controls button:hover { background: rgba(255, 220, 150, 0.1); }
.controls button:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 1px; }
.controls button[aria-pressed="true"],
.controls button.on {
  background: linear-gradient(180deg, rgba(255, 214, 130, 0.24), rgba(255, 190, 90, 0.12));
  color: var(--gold-1);
}
.controls svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- hint ---------- */
.hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 62px);
  margin: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
  z-index: 5;
}
.hint.show { opacity: 1; }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
}

/* part-preview mode (?part=...) */
.part-mode .hero,
.part-mode .controls,
.part-mode .hint,
.part-mode .online-pill { display: none; }

@media (max-width: 560px) {
  .controls { gap: 2px; padding: 5px; }
  .controls button { padding: 9px 10px; gap: 0; }
  .controls button span { display: none; }
  .controls svg { width: 20px; height: 20px; }
  .eyebrow { font-size: 10px; letter-spacing: 0.32em; }
  .countdown { font-size: 13px; }
  .hint { font-size: 11px; letter-spacing: 0.12em; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-star { animation: none; }
  .hero, .controls { transition: none; }
}

/* ---------- festive events ---------- */
.sky-show .hero { opacity: 0.18; transition: opacity 2s ease; }
.seated .hero { opacity: 0; }
.banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 34%;
  text-align: center;
  pointer-events: none;
  z-index: 7;
  font-family: var(--script);
  font-size: clamp(54px, 14vw, 140px);
  line-height: 1;
  color: var(--gold-1);
  text-shadow: 0 0 30px rgba(255, 190, 90, 0.75), 0 0 80px rgba(255, 150, 60, 0.45);
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.banner.show { opacity: 1; transform: none; }
.banner.num { font-family: var(--sans); font-weight: 200; font-variant-numeric: tabular-nums; }
.toast {
  position: fixed;
  left: 50%;
  top: calc(max(18px, env(safe-area-inset-top)) + 150px);
  transform: translate(-50%, -8px);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 13px;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 8;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- plaza ---------- */
.online-pill {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.online-pill[hidden] { display: none; }
.online-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5be08a;
  box-shadow: 0 0 8px #5be08a;
}
.online-pill b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.controls button[hidden] { display: none; }

.tags { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.tag {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: #fff;
  background: rgba(10, 10, 20, 0.55);
  border: 1px solid color-mix(in srgb, var(--c, #e0a63a) 70%, transparent);
  transition: opacity 0.3s ease;
  will-change: transform;
}
.emoji-float {
  position: absolute;
  font-size: 26px;
  transform: translate(-50%, -50%);
  animation: floatUp 2.1s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -420%) scale(1); }
}
.emotes {
  position: fixed;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 62px);
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 6;
}
.emotes[hidden] { display: none; }
.emotes button {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.emotes button:hover { background: rgba(255, 220, 150, 0.12); }
.emotes button:active { transform: scale(0.88); }
.emotes .stand { font-size: 12px; width: auto; padding: 0 12px; color: var(--ink); border-radius: 999px; letter-spacing: 0.1em; }

.sheet {
  border: 1px solid var(--glass-line);
  border-radius: 20px;
  padding: 22px 22px 18px;
  width: min(360px, calc(100vw - 32px));
  color: var(--ink);
  background: rgba(16, 15, 26, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.sheet.wide { width: min(460px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(4, 6, 14, 0.45); }
.sheet h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.08em; }
.sheet .sub { margin: 6px 0 14px; font-size: 13px; line-height: 1.6; color: var(--ink-dim); }
.field { display: grid; gap: 8px; margin: 0 0 14px; font-size: 13px; color: var(--ink-dim); }
.field input {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 226, 160, 0.22);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
.field input:focus { border-color: var(--gold-2); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.25);
}
.swatch[aria-pressed="true"] { border-color: var(--gold-1); box-shadow: 0 0 0 2px rgba(255, 220, 150, 0.35); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.actions button {
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.1em;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--glass-line);
}
.actions .ghost { background: transparent; color: var(--ink); }
.actions .primary {
  border: 0;
  color: #2a1a05;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  font-weight: 600;
}
.actions button[hidden] { display: none; }
.seat-map svg { width: 100%; height: auto; display: block; }
.seat-map .seat { stroke-width: 1.6; cursor: pointer; transition: fill 0.2s ease; }
.seat-map .seat.free { fill: rgba(255, 220, 150, 0.06); stroke: rgba(255, 220, 150, 0.6); }
.seat-map .seat.free:hover { fill: rgba(255, 220, 150, 0.35); }
.seat-map .seat.taken { stroke: rgba(255, 255, 255, 0.5); cursor: not-allowed; }
.seat-map .seat.mine { fill: var(--gold-2); stroke: #fff; stroke-width: 2.4; }
.map-sky, .map-front { fill: var(--ink-dim); font-size: 11px; text-anchor: middle; letter-spacing: 0.2em; }
.map-tree { font-size: 18px; text-anchor: middle; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--ink-dim); margin: 10px 0 4px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-left: 6px; }
.legend .dot.free { border: 1.5px solid rgba(255, 220, 150, 0.7); }
.legend .dot.taken { background: #3a73d6; }
.legend .dot.mine { background: var(--gold-2); }
