/* ============================================================
   HIGH GUYS — "Psychedelic Speakeasy"  (per docs/DESIGN.md)
   ============================================================ */

:root {
  /* base / atmosphere */
  --bg-void:    #0A0710;
  --bg-haze-1:  #14091F;
  --bg-haze-2:  #07140D;
  --surface:    rgba(18, 12, 28, 0.55);
  --surface-2:  rgba(28, 20, 40, 0.7);

  /* neon brand */
  --acid:       #B6FF3C;
  --acid-soft:  #8FE000;
  --ember:      #FF8A3D;
  --magenta:    #FF4D8D;
  --cyan:       #4DE5FF;

  /* rarity glows */
  --rarity-common:    #7C8B7A;
  --rarity-uncommon:  #4DA6FF;
  --rarity-rare:      #C04DFF;
  --rarity-legendary: #FFC83D;

  /* text */
  --ink:        #F4F0FF;
  --ink-dim:    #A99FC2;
  --ink-faint:  #6A6280;

  /* utility */
  --danger:     #FF5C7A;
  --radius:     20px;
  --radius-lg:  28px;

  --font-display: "Unbounded", sans-serif;
  --font-body:    "Hanken Grotesk", sans-serif;
  --font-mono:    "JetBrains Mono", monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  height: 100%;
  /* Kill horizontal pan / rubber-band on phones — nothing slides sideways. */
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
  /* Vertical scroll only; never a horizontal pan gesture. */
  touch-action: pan-y;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;

  background:
    radial-gradient(circle at 20% 20%, rgba(182, 255, 60, 0.06), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 77, 141, 0.06), transparent 40%),
    linear-gradient(135deg, var(--bg-haze-1), var(--bg-void) 50%, var(--bg-haze-2));
  background-size: 200% 200%;
  background-attachment: fixed;
  animation: drift 22s ease-in-out infinite;
}

@keyframes drift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ---------- Atmosphere layers ---------- */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.blob {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  filter: blur(70px);
  opacity: 0.22;
  border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%;
  will-change: transform, border-radius;
  animation: morph 26s ease-in-out infinite, float 30s ease-in-out infinite;
}
.blob--acid    { top: -14vmax; left: -10vmax; background: radial-gradient(circle, var(--acid), transparent 70%); }
.blob--ember   { bottom: -16vmax; right: -12vmax; background: radial-gradient(circle, var(--ember), transparent 70%); opacity: 0.14; animation-delay: -8s, -5s; }
.blob--magenta { top: 40%; right: 8%; width: 30vmax; height: 30vmax; background: radial-gradient(circle, var(--magenta), transparent 70%); opacity: 0.12; animation-delay: -14s, -12s; }

@keyframes morph {
  0%, 100% { border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%; }
  33%      { border-radius: 68% 32% 38% 62% / 58% 39% 61% 42%; }
  66%      { border-radius: 39% 61% 47% 53% / 62% 56% 44% 38%; }
}
@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(4vmax, -3vmax, 0) scale(1.08); }
}

/* Grain overlay — data-URI SVG noise */
.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Vignette */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(5, 3, 9, 0.6) 100%);
}

/* ---------- Stage / screens ---------- */
.stage {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  /* Honour the notch / home-indicator on phones. */
  padding: calc(clamp(1rem, 4vw, 2.5rem) + env(safe-area-inset-top))
           calc(clamp(1rem, 4vw, 2.5rem) + env(safe-area-inset-right))
           calc(clamp(1rem, 4vw, 2.5rem) + env(safe-area-inset-bottom))
           calc(clamp(1rem, 4vw, 2.5rem) + env(safe-area-inset-left));
  overflow-x: clip;
}

.screen {
  width: 100%;
  max-width: 460px;
  display: grid;
  place-items: center;
}
.screen.hidden { display: none; }

/* ---------- Glass card ---------- */
.card {
  position: relative;
  width: 100%;
  padding: clamp(1.6rem, 5vw, 2.6rem);
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(182, 255, 60, 0.18);
  border-radius: var(--radius-lg);
  box-shadow:
    0 0 60px rgba(182, 255, 60, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 0 80px rgba(182, 255, 60, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.card--center { text-align: center; }

/* ---------- Typography ---------- */
.eyebrow {
  margin: 0 0 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--acid);
  opacity: 0.85;
}

.title {
  margin: 0 0 0.8rem;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.title--logo {
  font-size: clamp(2.6rem, 11vw, 3.8rem);
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  gap: 0.05em;
}
.title--logo.title--sm { font-size: clamp(2rem, 8vw, 2.6rem); }
.card--center .title--logo { align-items: center; }

.title__guys {
  color: var(--acid);
  text-shadow:
    0 0 14px rgba(182, 255, 60, 0.55),
    0 0 38px rgba(182, 255, 60, 0.35);
  animation: pulseGlow 3.4s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { text-shadow: 0 0 14px rgba(182, 255, 60, 0.45), 0 0 34px rgba(182, 255, 60, 0.25); }
  50%      { text-shadow: 0 0 22px rgba(182, 255, 60, 0.75), 0 0 60px rgba(182, 255, 60, 0.45); }
}

.title--md { font-size: clamp(1.7rem, 6vw, 2.2rem); }

.lede {
  margin: 0 0 1.5rem;
  color: var(--ink-dim);
  font-size: 1rem;
  max-width: 38ch;
}
.card--center .lede { margin-inline: auto; }

.accent { color: var(--acid); }

.fineprint {
  margin: 1.1rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* ---------- Age callout ---------- */
.age-callout {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.6rem;
  padding: 1rem 1.2rem;
  background: var(--surface-2);
  border: 1px solid rgba(182, 255, 60, 0.12);
  border-radius: var(--radius);
}
.age-callout p { margin: 0; color: var(--ink-dim); font-size: 0.94rem; }
.age-callout strong { color: var(--ink); }
.age-callout__num {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--acid);
  padding: 0.35rem 0.6rem;
  border: 1px solid rgba(182, 255, 60, 0.4);
  border-radius: 12px;
  text-shadow: 0 0 12px rgba(182, 255, 60, 0.5);
}

/* ---------- Bud mascot ---------- */
.bud {
  display: inline-grid;
  place-items: center;
  margin: 0 auto 1rem;
  filter: drop-shadow(0 0 28px rgba(182, 255, 60, 0.4));
  animation: bob 5s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-8px) rotate(2deg); }
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--bg-void);
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn--block { width: 100%; }

.btn--primary {
  background: linear-gradient(180deg, var(--acid), var(--acid-soft));
  box-shadow: 0 0 0 rgba(182, 255, 60, 0), 0 8px 24px rgba(143, 224, 0, 0.25);
}
.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 28px var(--acid), 0 10px 28px rgba(143, 224, 0, 0.3);
}
.btn--primary:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn--google {
  background: linear-gradient(180deg, #1d1430, #14091f);
  color: var(--ink);
  border: 1px solid rgba(182, 255, 60, 0.3);
}
.btn--google:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 26px rgba(182, 255, 60, 0.35);
  border-color: rgba(182, 255, 60, 0.55);
}
.btn--google .g-icon { flex: 0 0 auto; }

.btn--ghost {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid rgba(169, 159, 194, 0.3);
}
.btn--ghost:hover {
  color: var(--ink);
  border-color: rgba(182, 255, 60, 0.4);
  box-shadow: 0 0 20px rgba(182, 255, 60, 0.18);
  transform: translateY(-2px);
}
.btn--ghost:active { transform: scale(0.97); }

/* ---------- Input field ---------- */
.field {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 0 0.4rem;
  background: var(--surface-2);
  border: 1px solid rgba(169, 159, 194, 0.18);
  border-radius: var(--radius);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}
.field:focus-within {
  border-color: var(--acid);
  box-shadow: 0 0 0 3px rgba(182, 255, 60, 0.25);
}
.field__prefix {
  padding-left: 1rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--acid);
  opacity: 0.8;
}
.input {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  padding: 0.95rem 1rem 0.95rem 0.4rem;
}
.input::placeholder { color: var(--ink-faint); }

.error {
  min-height: 1.2rem;
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  color: var(--danger);
  font-weight: 500;
}

/* ---------- Home / balance ---------- */
.card--home { text-align: left; }

.balance {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 1.5rem;
  padding: 1.2rem 1.4rem;
  background: var(--surface-2);
  border: 1px solid rgba(182, 255, 60, 0.14);
  border-radius: var(--radius);
}
.balance__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.balance__value {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.mono {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 2.4rem;
  color: var(--acid);
  text-shadow: 0 0 18px rgba(182, 255, 60, 0.4);
  line-height: 1;
}
.balance__unit {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink-dim);
}

/* ============================================================
   PHASE 2 — Character builder + main menu
   ============================================================ */

.balance--center { align-items: center; text-align: center; }
.balance--center .balance__value { justify-content: center; }

/* Wider stage for the builder + menu layouts. */
.screen--wide { max-width: 720px; }

/* ---------- Reusable bud renderer ---------- */
.bud-svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 8px 26px rgba(0, 0, 0, 0.45));
}

/* ---------- Layered character compositor ---------- */
/* Square stage: base bud + cosmetic PNG layers, all absolutely full-size. */
.char-stage {
  position: relative;
  aspect-ratio: 1 / 1;
  max-width: 100%;
}
.char-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.char-layer--cosmetic {
  object-fit: contain;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.char-layer--bud {
  display: grid;
  place-items: center;
}
.char-layer--bud .bud-svg { width: 100%; height: 100%; }

/* ---------- Builder ---------- */
.card--builder { text-align: left; }

.builder-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(1rem, 3vw, 2rem);
  margin: 1.4rem 0 0.6rem;
  align-items: start;
}

.builder-stage {
  position: relative;
  display: grid;
  place-items: center;
  gap: 1rem;
  padding: 1.2rem;
  background: var(--surface-2);
  border: 1px solid rgba(182, 255, 60, 0.14);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.builder-stage__halo {
  position: absolute;
  inset: -20% 10% auto 10%;
  height: 70%;
  background: radial-gradient(ellipse at center, rgba(182, 255, 60, 0.28), transparent 70%);
  filter: blur(26px);
  pointer-events: none;
}
.builder-preview {
  position: relative;
  z-index: 2;
  width: min(220px, 60vw);
  animation: breathe 5.5s ease-in-out infinite;
  will-change: transform;
}

/* ---------- Premium pedestal stage ---------- */
/* Reactive glow tracks the chosen body color via --stage-glow (set in JS). */
.builder-stage--pedestal {
  --stage-glow: var(--acid);
  gap: 0.6rem;
  padding: 1.6rem 1.2rem 1.3rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% 38%, rgba(255, 255, 255, 0.05), transparent 70%),
    linear-gradient(180deg, rgba(28, 20, 40, 0.85), rgba(12, 8, 20, 0.92));
  border-color: color-mix(in srgb, var(--stage-glow) 22%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -40px 60px -30px color-mix(in srgb, var(--stage-glow) 30%, transparent);
  isolation: isolate;
}
/* Reactive halo behind the bud — its color follows --stage-glow. */
.builder-stage--pedestal .builder-stage__halo {
  inset: -8% 8% auto 8%;
  height: 78%;
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--stage-glow) 45%, transparent), transparent 68%);
  filter: blur(34px);
  z-index: 0;
  transition: background 0.4s ease;
  animation: haloBreathe 5.5s ease-in-out infinite;
}
@keyframes haloBreathe {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.06); }
}
/* Soft volumetric light cone from above. */
.stage-light {
  position: absolute;
  top: -12%;
  left: 50%;
  width: 70%;
  height: 80%;
  transform: translateX(-50%);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--stage-glow) 16%, transparent), transparent 72%);
  clip-path: polygon(34% 0, 66% 0, 92% 100%, 8% 100%);
  filter: blur(6px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}
/* Floating ambient particles (subtle). */
.stage-particles {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20% 30%, color-mix(in srgb, var(--stage-glow) 70%, transparent), transparent),
    radial-gradient(1.5px 1.5px at 70% 20%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(2px 2px at 80% 60%, color-mix(in srgb, var(--stage-glow) 60%, transparent), transparent),
    radial-gradient(1.5px 1.5px at 35% 75%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 55% 50%, color-mix(in srgb, var(--stage-glow) 50%, transparent), transparent);
  opacity: 0.55;
  animation: particleDrift 9s ease-in-out infinite;
}
@keyframes particleDrift {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50%      { transform: translateY(-10px); opacity: 0.7; }
}
/* The glowing pedestal disc the bud stands on. */
.pedestal {
  position: relative;
  z-index: 1;
  width: min(190px, 56vw);
  height: 34px;
  margin-top: -10px;
  display: grid;
  place-items: center;
}
.pedestal__top {
  position: absolute;
  top: 4px;
  width: 100%;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--stage-glow) 55%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(40, 30, 56, 0.95), rgba(16, 11, 26, 0.95));
  border: 1px solid color-mix(in srgb, var(--stage-glow) 40%, transparent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--stage-glow) 40%, transparent);
}
.pedestal__glow {
  position: absolute;
  top: -2px;
  width: 78%;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--stage-glow) 60%, transparent), transparent 70%);
  filter: blur(12px);
  animation: haloBreathe 5.5s ease-in-out infinite;
}
.pedestal__shadow {
  position: absolute;
  top: 16px;
  width: 60%;
  height: 14px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  filter: blur(8px);
}
@keyframes breathe {
  0%, 100% { transform: translateY(0) rotate(-1.5deg) scale(1); }
  50%      { transform: translateY(-10px) rotate(1.5deg) scale(1.03); }
}
.btn--dice {
  position: relative;
  padding: 0.6rem 1.1rem;
  font-size: 0.86rem;
}

.builder-options {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}
.picker__label {
  display: block;
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.picker__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- Selectable chips ---------- */
.chip {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.84rem;
  color: var(--ink-dim);
  background: var(--surface);
  border: 1px solid rgba(169, 159, 194, 0.22);
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.16s ease,
              border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover {
  color: var(--ink);
  border-color: rgba(182, 255, 60, 0.4);
  transform: translateY(-1px);
}
.chip:active { transform: scale(0.95); }
.chip--on {
  color: var(--bg-void);
  background: linear-gradient(180deg, var(--acid), var(--acid-soft));
  border-color: var(--acid);
  box-shadow: 0 0 20px rgba(182, 255, 60, 0.5);
}

/* color swatches */
.chip--swatch {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid rgba(255, 255, 255, 0.18);
  position: relative;
}
.chip--swatch:hover { transform: translateY(-2px) scale(1.06); }
.chip--swatch.chip--on {
  border-color: var(--acid);
  box-shadow: 0 0 0 3px rgba(10, 7, 16, 0.9), 0 0 0 5px var(--acid),
              0 0 24px rgba(182, 255, 60, 0.6);
}

/* ---------- Owned cosmetics (builder) ---------- */
.picker--cosmetics { margin-top: 0.2rem; }
.cos-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}
.cos-tab {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--ink-dim);
  background: var(--surface);
  border: 1px solid rgba(169, 159, 194, 0.2);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.cos-tab:hover { color: var(--ink); border-color: rgba(182, 255, 60, 0.4); }
.cos-tab--on {
  color: var(--bg-void);
  background: linear-gradient(180deg, var(--acid), var(--acid-soft));
  border-color: var(--acid);
  box-shadow: 0 0 16px rgba(182, 255, 60, 0.4);
}
.cos-tab__n {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.66rem;
  line-height: 1;
  color: inherit;
  text-shadow: none;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: rgba(10, 7, 16, 0.25);
}
.cos-tab--on .cos-tab__n { background: rgba(10, 7, 16, 0.3); color: var(--bg-void); }

.cos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 0.55rem;
}
.cos-empty {
  grid-column: 1 / -1;
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-faint);
}
.cos-tile {
  position: relative;
  display: grid;
  place-items: center;
  gap: 0.25rem;
  aspect-ratio: 1 / 1;
  padding: 0.4rem;
  background: var(--surface);
  border: 1.5px solid rgba(169, 159, 194, 0.2);
  border-radius: 16px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.14s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.cos-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.cos-tile--broken img { display: none; }
.cos-tile__name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.15rem 0.2rem;
  font-size: 0.6rem;
  line-height: 1.1;
  text-align: center;
  color: var(--ink-dim);
  background: linear-gradient(180deg, transparent, rgba(10, 7, 16, 0.85));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cos-tile:hover { transform: translateY(-2px); border-color: rgba(182, 255, 60, 0.45); }
.cos-tile:active { transform: scale(0.95); }
.cos-tile--on {
  border-color: var(--acid);
  box-shadow: 0 0 0 1px var(--acid), 0 0 18px rgba(182, 255, 60, 0.45);
}
.cos-tile--none .cos-tile__none-x {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--ink-faint);
  position: relative;
}
.cos-tile--none .cos-tile__none-x::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 2px; height: 30px;
  background: var(--ink-faint);
  transform: rotate(45deg);
}
.cos-tile--none .cos-tile__name { position: static; background: none; padding-top: 0.2rem; }

/* ---------- Rarity (chips + borders), shared store + builder ---------- */
.rarity-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 6px;
  color: var(--bg-void);
}
.rarity-chip.rarity--common    { background: var(--rarity-common); color: #0a0710; }
.rarity-chip.rarity--uncommon  { background: var(--rarity-uncommon); }
.rarity-chip.rarity--rare      { background: var(--rarity-rare); color: var(--ink); }
.rarity-chip.rarity--legendary {
  background: var(--rarity-legendary);
  box-shadow: 0 0 12px rgba(255, 200, 61, 0.7);
}
.rarity-chip.rarity--mythic {
  background: linear-gradient(100deg, var(--magenta), var(--cyan), var(--rarity-rare));
  background-size: 200% 100%;
  color: var(--ink);
  animation: mythicShimmer 3s linear infinite;
  box-shadow: 0 0 14px rgba(255, 77, 141, 0.6);
}
@keyframes mythicShimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.rarity-border--common    { border-color: rgba(124, 139, 122, 0.5); }
.rarity-border--uncommon  { border-color: rgba(77, 166, 255, 0.55); }
.rarity-border--rare      { border-color: rgba(192, 77, 255, 0.6); }
.rarity-border--legendary { border-color: rgba(255, 200, 61, 0.7); }
.rarity-border--mythic    { border-color: rgba(255, 77, 141, 0.7); }

/* ---------- Headshop CTA button ---------- */
.btn--shop-cta {
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  padding: 0.95rem 1.4rem;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.18), rgba(255, 77, 141, 0.16));
  border: 1px solid rgba(255, 138, 61, 0.45);
}
.btn--shop-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 26px rgba(255, 138, 61, 0.3);
  border-color: rgba(255, 138, 61, 0.7);
}
.btn--shop-cta:active { transform: scale(0.97); }
.btn--shop-cta .btn__sub { color: var(--ink-dim); }

/* ---------- Main menu ---------- */
.card--menu { text-align: center; }

.menu-hero {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding-bottom: 0.6rem;
}
.menu-hero__halo {
  position: absolute;
  top: -8%;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(182, 255, 60, 0.22), transparent 68%);
  filter: blur(30px);
  pointer-events: none;
}
.menu-bud {
  position: relative;
  width: min(200px, 56vw);
  margin-bottom: 0.4rem;
  animation: breathe 5.5s ease-in-out infinite;
  will-change: transform;
}
.wordmark { margin-bottom: 0; }
.wordmark__tag {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.menu-handle {
  margin: 0.5rem 0 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--ink-dim);
}

.menu-actions {
  display: grid;
  gap: 0.9rem;
  margin: 1.6rem 0 0.6rem;
}
.btn--action {
  flex-direction: column;
  gap: 0.1rem;
  padding: 1.1rem 1.4rem;
}
.btn__big { font-size: 1.15rem; line-height: 1.1; }
.btn__sub {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.75rem;
  opacity: 0.8;
}
.btn--outline {
  background: transparent;
  color: var(--acid);
  border: 1.5px solid rgba(182, 255, 60, 0.55);
}
.btn--outline:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(182, 255, 60, 0.08);
  box-shadow: 0 0 24px rgba(182, 255, 60, 0.3);
}
.btn--outline:active:not(:disabled) { transform: scale(0.97); }

.join {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  align-items: stretch;
}
.field--code { margin: 0; }
.input--code {
  text-align: center;
  letter-spacing: 0.5em;
  font-size: 1.3rem;
  font-weight: 700;
  padding-right: 0.4rem;
}
.input--code::placeholder { letter-spacing: 0.5em; opacity: 0.4; }
.join .btn--action { white-space: nowrap; }

/* toast */
.toast {
  margin: 0.9rem auto 0.4rem;
  max-width: 32ch;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid rgba(255, 138, 61, 0.4);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast--show {
  opacity: 1;
  transform: translateY(0);
  box-shadow: 0 0 22px rgba(255, 138, 61, 0.18);
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .builder-grid { grid-template-columns: 1fr; }
  .builder-stage { padding: 1rem; }
}

@media (max-width: 420px) {
  body { font-size: 15px; }
  .age-callout { flex-direction: column; text-align: center; }
  .join { grid-template-columns: 1fr; }
}

/* ---------- Branded loader (join/create/game-mount) ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(circle at 50% 42%, rgba(182, 255, 60, 0.08), transparent 55%),
    rgba(8, 5, 13, 0.86);
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  opacity: 1;
  transition: opacity 0.4s ease;
}
.loader.hidden { display: none; }
.loader.is-fading { opacity: 0; pointer-events: none; }
.loader__inner { display: grid; justify-items: center; gap: 1rem; }
.loader__bud {
  position: relative;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
}
.loader__bud svg {
  animation: loaderPulse 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 22px rgba(182, 255, 60, 0.5));
}
@keyframes loaderPulse {
  0%, 100% { transform: scale(0.94); filter: drop-shadow(0 0 14px rgba(182, 255, 60, 0.35)); }
  50%      { transform: scale(1.04); filter: drop-shadow(0 0 30px rgba(182, 255, 60, 0.7)); }
}
/* Spinning acid ring around the bud. */
.loader__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--acid);
  border-right-color: rgba(182, 255, 60, 0.35);
  animation: loaderSpin 1s linear infinite;
}
@keyframes loaderSpin { to { transform: rotate(360deg); } }
.loader__word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.16em;
  color: var(--ink);
}
.loader__word span { color: var(--acid); text-shadow: 0 0 18px rgba(182, 255, 60, 0.5); }
.loader__msg {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  animation: loaderBreathe 1.8s ease-in-out infinite;
}
@keyframes loaderBreathe {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  body { animation: none; background-position: 0% 50%; }
  .blob, .title__guys, .bud,
  .builder-preview, .menu-bud { animation: none; }
  .builder-stage__halo, .stage-particles, .pedestal__glow,
  .rarity-chip.rarity--mythic { animation: none; }
  .loader__bud svg, .loader__ring, .loader__msg { animation: none; }
}
