/* A dark warehouse rave. One green; type and glow are the trip's (trip.js), turned down. */
:root {
  --green: #39ff14;
  --green-ink: #39ff14;
  --white: #f2f5ef;
  --ink: #f2f5ef;
  --dim: rgba(242, 245, 239, 0.55);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, Consolas, monospace;
  --glow: 0 0 14px rgba(57, 255, 20, 0.45);
  --glow-big: 0 0 30px rgba(57, 255, 20, 0.55);
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #0a0612;
  color: var(--ink);
  font: 800 13px/1.4 var(--font);
  letter-spacing: 0.02em;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.link {
  appearance: none;
  background: none;
  border: 0;
  padding: 4px 0;
  margin: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.link:hover, .link:focus-visible { color: var(--green-ink); text-shadow: var(--glow); outline: none; }
.dim { color: var(--dim); }

/* ---------- Stage ---------- */

.stage { position: fixed; inset: 0; }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }

/* ---------- HUD (corners only) ---------- */

.hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.hud > * { pointer-events: auto; position: absolute; }
.hud-tl { top: max(16px, env(safe-area-inset-top)); left: var(--gutter); color: var(--green-ink); text-shadow: var(--glow); text-transform: none; font-size: 14px; letter-spacing: 0.06em; }
.hud-tr {
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.hud-bl { bottom: max(16px, env(safe-area-inset-bottom)); left: var(--gutter); }
.hud-br {
  bottom: max(16px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  max-width: min(60vw, 420px);
  text-align: right;
}
.feed { display: inline-block; color: var(--dim); transition: opacity 0.5s ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.feed.out { opacity: 0; }
.feed .win { color: var(--green-ink); text-shadow: var(--glow); }

.sound-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 6px;
  margin: -6px;
  color: var(--dim);
  cursor: pointer;
  display: grid;
}
.sound-btn .on { display: none; }
.sound-btn.playing { color: var(--green-ink); filter: drop-shadow(0 0 6px rgba(57, 255, 20, 0.6)); cursor: default; }
.sound-btn.playing .on { display: block; }
.sound-btn.playing .off { display: none; }

.message {
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 40px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  color: var(--dim);
  transition: opacity 0.4s ease;
  text-transform: none;
}
.message.error { color: #ff8fa3; }
.message.out { opacity: 0; }

.step-back {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 21;
  color: var(--dim);
  font-size: 12px;
}

/* ---------- Labels pinned into the room ---------- */

.anchors { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.anchor { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); white-space: nowrap; }
/* These sit over the dark table top, so they use light text. */
.anchor.link { pointer-events: auto; color: rgba(242, 245, 239, 0.75); font-size: 12px; }
.anchor.link:hover { color: var(--green); }
.anchor.link:disabled { cursor: default; color: rgba(242, 245, 239, 0.75); text-shadow: none; }
.say {
  margin-top: -10px;
  padding: 6px 12px;
  border-radius: 14px 14px 14px 2px;
  background: rgba(5, 3, 10, 0.72);
  color: var(--white);
  font-size: 14px;
  font-style: italic;
  text-shadow: none;
  box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.35), var(--glow);
}
.win-lock { font-size: 14px; }
.marker { color: var(--green); text-shadow: 0 0 2px #0b3d00, 0 0 2px #0b3d00, var(--glow); font-size: 13px; }
.spot-label {
  transform-origin: center;
  margin-top: -18px;
  color: var(--green-ink);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-shadow: var(--glow);
  animation: bob 1.8s ease-in-out infinite;
}
.spot-label::after { content: ""; display: block; margin: 6px auto 0; width: 0; height: 0; border: 7px solid transparent; border-top-color: var(--green-ink); }
@keyframes bob { 0%, 100% { margin-top: -18px; } 50% { margin-top: -26px; } }
.comedown { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.comedown-label { color: rgba(242, 245, 239, 0.8); font-size: 12px; }
.comedown-timer { font: 900 clamp(40px, 9vw, 72px)/1 var(--mono); color: var(--green); text-shadow: var(--glow-big); }

/* ---------- Troll (non-holders) ---------- */

.troll {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 18;
  width: min(92vw, 900px);
  text-align: center;
  pointer-events: none;
}
.troll-title {
  margin: 0;
  font: 900 clamp(34px, 7vw, 80px)/0.98 var(--font);
  letter-spacing: -0.01em;
  color: var(--ink);
  text-shadow: 3px 0 rgba(255, 0, 200, 0.45), -3px 0 rgba(0, 200, 255, 0.45), var(--glow-big);
}
.troll-title .sym { color: var(--green-ink); }
.troll-sub { margin: 14px 0 0; min-height: 1.4em; color: var(--ink); font-weight: 700; font-size: clamp(15px, 2.2vw, 20px); transition: opacity 0.3s ease; }
.buy-btn {
  pointer-events: auto;
  display: inline-block;
  margin-top: 22px;
  padding: 14px 30px;
  border-radius: 999px;
  background: var(--green);
  color: #031400;
  font: 900 clamp(16px, 2.6vw, 22px)/1 var(--font);
  letter-spacing: 0.04em;
  text-decoration: none;
  box-shadow: var(--glow-big);
}
.buy-btn:hover, .buy-btn:focus-visible { filter: brightness(1.12); outline: none; }

/* ---------- Win result + global moment ---------- */

.result, .moment {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  z-index: 19;
  width: min(94vw, 1000px);
  text-align: center;
  pointer-events: none;
}
.result-amount {
  margin: 0;
  font: 900 clamp(56px, 13vw, 150px)/0.95 var(--font);
  color: var(--green-ink);
  text-shadow: 5px 0 rgba(255, 0, 200, 0.45), -5px 0 rgba(0, 200, 255, 0.45), 0 0 40px rgba(57, 255, 20, 0.7);
  animation: rise 0.7s cubic-bezier(0.2, 1.3, 0.3, 1) both;
}
.result-tx, .moment-tx { margin: 12px 0 0; pointer-events: auto; font-size: 16px; text-shadow: 0 0 4px #000, 0 0 10px #000, 0 0 18px #000; }
.result-tx a, .moment-tx a { color: var(--ink); }
.result-tx a:hover, .moment-tx a:hover { color: var(--green-ink); }
.result-lock { margin: 8px 0 0; color: var(--dim); font-variant-numeric: tabular-nums; }

.moment { top: 42%; z-index: 22; }
.moment-title, .moment-sub { margin: 0; font-weight: 900; color: var(--ink); text-shadow: 5px 0 #ff00c8, -5px 0 #00f0ff, 0 0 30px var(--green); }
.moment-title { font-size: clamp(32px, 8vw, 104px); line-height: 0.95; }
.moment-sub { margin-top: 14px; font-size: clamp(20px, 4vw, 44px); color: var(--green-ink); }
.moment-title.in, .moment-sub.in { animation: phrase-in 0.45s cubic-bezier(0.2, 1.4, 0.3, 1) both; }
.moment.out { opacity: 0; transition: opacity 0.6s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(20px) scale(0.9); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes phrase-in { from { opacity: 0; scale: 1.5; filter: blur(8px); } to { opacity: 1; scale: 1; filter: blur(0); } }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 19; }

/* Green flood that hands the room over to the trip. One fade, no flashing. */
.flood {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 45%, #d9ffd0 0%, var(--green) 30%, #0c3a00 75%, #021000 100%);
  transition: opacity 0.9s ease;
}
.flood.on { opacity: 1; }

/* ---------- No-WebGL fallback ---------- */

.fallback {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 16px;
}
.fallback-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px 22px; max-width: 640px; }
.glyph {
  letter-spacing: -0.12em;
  appearance: none;
  border: 0;
  background: none;
  padding: 6px;
  font: 900 34px/1 var(--font);
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.4s ease;
}
.glyph .g { color: var(--green-ink); text-shadow: var(--glow); }
.glyph .w { color: var(--white); }
.warn-fallback { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 30; margin: 0; text-align: center; font: 900 clamp(28px, 7vw, 72px)/1 var(--font); color: var(--green); -webkit-text-stroke: 2px #0b3d00; text-shadow: var(--glow-big); }
.glyph:disabled { opacity: 0.25; cursor: default; }
.glyph.gone { visibility: hidden; }
.glyph.pulling { animation: hover-pulse 1.2s ease-in-out infinite; }
.glyph:not(:disabled):hover { transform: translateY(-4px); }
@keyframes hover-pulse { 0%, 100% { transform: translateY(-6px) scale(1.2); } 50% { transform: translateY(-10px) scale(1.3); } }

/* ---------- Trip (visuals in trip.js) ---------- */

.trip {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: none;
}
.trip-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
html.tripping, html.tripping body { overflow: hidden; overscroll-behavior: none; }
.trip-text {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: 92vw;
  text-align: center;
  font: 900 clamp(30px, 8vw, 110px)/0.95 var(--font);
  letter-spacing: -0.01em;
  pointer-events: none;
  text-shadow: 5px 0 #ff00c8, -5px 0 #00f0ff, 0 0 30px currentColor;
  transform: translate(calc(-50% + var(--x, 0px)), calc(-50% + var(--y, 0px))) rotate(var(--rot, 0deg));
}
/* Fades in and out (no strobing). */
.trip-text.punch { animation: phrase 1.5s ease-in-out both; }
@keyframes phrase {
  0%   { opacity: 0; scale: 1.5; filter: blur(8px); }
  25%  { opacity: 1; scale: 1; filter: blur(0); }
  75%  { opacity: 1; scale: 1.08; filter: blur(0); }
  100% { opacity: 0; scale: 0.85; filter: blur(6px); }
}
.trip.fading { opacity: 0; transition: opacity 1.2s ease; }
.trip-hint {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 14px;
  color: var(--white);
  font-size: 13px;
  text-shadow: 0 0 8px #000;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .trip-text.punch { animation-duration: 2.5s; }
  .result-amount, .moment-title.in, .moment-sub.in { animation-duration: 0.01s; }
  .flood { transition-duration: 1.6s; }
}

@media (max-width: 600px) {
  body { font-size: 12px; }
  .hud-br { max-width: 58vw; }
  .troll { top: 34%; }
  .result, .moment { top: 28%; }
  .step-back { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 30px); }
  .message { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 62px); }
}
