/* =====================================================================
   Lucrit Script — design tokens
   ===================================================================== */

:root {
  --bg:        #05060a;
  --bg-lift:   #0a0d16;
  --ink:       #eef3fb;
  --ink-2:     #a8b6cd;
  --ink-3:     #6f7f99;
  --line:      rgba(140, 175, 225, 0.14);
  --line-2:    rgba(140, 175, 225, 0.28);

  --blue:      #3d9bff;
  --cyan:      #48e5ff;
  --ice:       #cfe8ff;
  --red:       #ff4d5e;
  --violet:    #9a6bff;

  --glass:     rgba(9, 13, 24, 0.94);
  --glass-2:   rgba(12, 17, 30, 0.97);
  --panel:     rgba(10, 14, 25, 0.95);
  --panel-2:   rgba(14, 19, 33, 0.97);
  --gold:      #ffc857;
  --discord:   #5865f2;
  --good:      #35d07f;

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --shell: min(1180px, 92vw);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* =====================================================================
   Base
   ===================================================================== */

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

html { -webkit-text-size-adjust: 100%; scrollbar-width: none; }
html::-webkit-scrollbar { width: 0; height: 0; }

html.is-locked { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -0.035em; line-height: 1.02; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
::selection { background: rgba(61, 155, 255, 0.32); }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =====================================================================
   Canvas + atmosphere
   ===================================================================== */

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  background: var(--bg);
}

/* Fallback backdrop when WebGL is unavailable. */
html.no-webgl body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 55% at 50% -6%, rgba(61, 155, 255, 0.30), transparent 64%),
    radial-gradient(ellipse 62% 46% at 12% 78%, rgba(154, 107, 255, 0.22), transparent 62%),
    radial-gradient(ellipse 64% 46% at 90% 58%, rgba(72, 229, 255, 0.18), transparent 62%),
    radial-gradient(ellipse 120% 70% at 50% 110%, rgba(10, 16, 30, 0.9), transparent 60%),
    var(--bg);
}

#grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.16; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

html.no-webgl #grain { opacity: 0.1; }

/* =====================================================================
   Navigation
   ===================================================================== */

.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; gap: 24px;
  padding: 16px max(22px, calc((100vw - var(--shell)) / 2));
  padding-right: max(210px, calc((100vw - var(--shell)) / 2 + 200px));
  transition: background 0.4s var(--ease), backdrop-filter 0.4s var(--ease),
              border-color 0.4s var(--ease);
  border-bottom: 1px solid transparent;
}

.nav.is-scrolled {
  background: linear-gradient(to bottom, rgba(5, 6, 10, 0.82), rgba(5, 6, 10, 0.42));
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom-color: var(--line);
}

.nav__brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font-weight: 620; font-size: 0.98rem; letter-spacing: -0.03em;
  margin-right: auto;
}
.nav__brand b { font-weight: 620; color: var(--blue); }

/* The artwork carries its own glow and its own transparency. */
.nav__mark { width: auto; height: 32px; display: block; }

.nav__links { display: flex; gap: 4px; }
.nav__links button {
  color: var(--ink-2); font-size: 0.875rem; font-weight: 480;
  padding: 7px 13px; border-radius: 999px;
  transition: color 0.25s, background 0.25s;
}
.nav__links button:hover { color: var(--ink); background: rgba(160, 200, 255, 0.08); }
.nav__links button.is-on { color: var(--ink); background: rgba(61, 155, 255, 0.14); }

.nav__search {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--ink-2);
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.nav__search:hover { color: var(--ink); border-color: var(--line-2); background: rgba(160, 200, 255, 0.07); }
.nav__search svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }

/* =====================================================================
   Chapters
   ===================================================================== */

#content { position: relative; z-index: 10; }

.chapter { position: relative; height: calc(var(--len) * 1vh); }

/* The sticky stage overflows its chapter box, so a later section could sit on
   top of the live one and swallow its clicks. Only the stage is interactive,
   and the choreography turns that on and off per chapter. */
.chapter, .chapter__inner { pointer-events: none; }
.chapter.is-live .chapter__inner { z-index: 2; }

/* Sticky needs travel: the chapter is always taller than its 100vh inner.
   The scale is uniform so chapter heights stay proportional to the camera
   bands — a per-chapter clamp would desync them. */
@media (max-width: 820px) {
  .chapter { height: calc(var(--len) * 0.85vh); }
}

/* A zero-height sticky wrapper stays pinned for the chapter's entire scroll
   length. A full-height one unpins early, which would drag content off screen
   while the camera is still mid-chapter. */
.chapter__inner {
  position: sticky; top: 0; height: 0;
}

.chapter__stage {
  height: 100vh;
  display: flex; flex-direction: column;
  justify-content: center;
  justify-content: safe center;
  width: var(--shell); margin: 0 auto;
  padding: 92px 0 64px;
  will-change: opacity, transform;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none;
}
.chapter__stage::-webkit-scrollbar { width: 0; height: 0; }

.chapter__stage::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 58% 66% at 30% 50%, rgba(3, 5, 9, 0.93), rgba(3, 5, 9, 0.3) 72%, rgba(3, 5, 9, 0) 100%),
    linear-gradient(to bottom, rgba(3, 5, 9, 0.72), rgba(3, 5, 9, 0.06) 30%, rgba(3, 5, 9, 0.42) 100%);
}

.chapter__tag {
  position: absolute; top: 84px; left: 0;
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ink-3);
}
.chapter__tag::before {
  content: ""; display: inline-block; width: 22px; height: 1px;
  background: var(--line-2); vertical-align: middle; margin-right: 10px;
}

/* =====================================================================
   Buttons
   ===================================================================== */

.btn { text-decoration: none; }
a.btn:hover { text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px;
  font-size: 0.86rem; font-weight: 560; letter-spacing: 0.01em;
  border: 1px solid var(--line-2); color: var(--ink);
  background: rgba(160, 200, 255, 0.05);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: transform 0.25s var(--ease), background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.btn:hover { transform: translateY(-1.5px); background: rgba(160, 200, 255, 0.11); border-color: rgba(140, 175, 225, 0.42); }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: linear-gradient(135deg, var(--blue), #2a7fe0);
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 30px rgba(61, 155, 255, 0.32);
}
.btn--primary:hover { box-shadow: 0 12px 38px rgba(61, 155, 255, 0.46); background: linear-gradient(135deg, #4fa8ff, #3387e8); }

.btn--ghost { background: transparent; }
.btn--sm { padding: 8px 15px; font-size: 0.8rem; }
.btn.is-on { border-color: var(--cyan); color: var(--cyan); }
.btn.is-flash { animation: flash 0.7s var(--ease); }

@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(72, 229, 255, 0.55); }
  100% { box-shadow: 0 0 0 18px rgba(72, 229, 255, 0); }
}

/* =====================================================================
   Hero
   ===================================================================== */

.hero { max-width: 940px; }

.hero__logo {
  display: block; width: clamp(230px, 31vw, 360px); height: auto;
  margin: 0 0 14px -18px;   /* the artwork's glow reads as padding */
}

.hero__title {
  font-size: clamp(2.6rem, 7.4vw, 5.6rem);
  font-weight: 660;
  letter-spacing: -0.052em;
  line-height: 0.94;
  text-wrap: balance;
}
.hero__title .line { display: block; }
.hero__title .accent {
  background: linear-gradient(100deg, var(--cyan), var(--blue) 42%, var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.hero__sub {
  margin-top: 26px; max-width: 46ch;
  font-size: clamp(1rem, 1.5vw, 1.2rem); color: var(--ink-2);
}

.hero__cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 38px; }

.scrollcue {
  position: absolute; bottom: 46px; left: 0;
  display: flex; align-items: center; gap: 11px;
  font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-3);
}
.scrollcue svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  animation: bob 2.1s var(--ease) infinite;
}
@keyframes bob { 0%,100% { transform: translateY(-2px); opacity: 0.5; } 50% { transform: translateY(3px); opacity: 1; } }

/* =====================================================================
   Statement
   ===================================================================== */

.statement { max-width: 800px; }
.statement__title { font-size: clamp(2.4rem, 6.4vw, 5rem); letter-spacing: -0.048em; }
.statement__sub { margin-top: 22px; max-width: 48ch; font-size: 1.06rem; color: var(--ink-2); }

.statement__stats { display: flex; flex-wrap: wrap; gap: 46px; margin-top: 48px; }
.statement__stats div { display: flex; flex-direction: column; }
.statement__stats strong {
  font-size: 2.1rem; font-weight: 620; letter-spacing: -0.04em;
  background: linear-gradient(120deg, var(--ice), var(--blue));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.statement__stats span {
  font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3);
}

/* =====================================================================
   Glass panels
   ===================================================================== */

.panel {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  backdrop-filter: blur(26px) saturate(1.2);
  -webkit-backdrop-filter: blur(26px) saturate(1.2);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 26px;
}

.panel__head { margin-bottom: 20px; }
.panel__head h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
.panel__head p { margin-top: 7px; color: var(--ink-2); font-size: 0.92rem; }

/* =====================================================================
   Library
   ===================================================================== */

.library__search {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: rgba(6, 10, 20, 0.7);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.library__search:focus-within {
  border-color: rgba(72, 229, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(72, 229, 255, 0.1);
}
.library__icon { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 1.9; stroke-linecap: round; }
.library__input {
  flex: 1; min-width: 0; padding: 14px 0;
  background: none; border: 0; outline: none; font-size: 0.98rem;
}
.library__input::placeholder { color: var(--ink-3); }
.library__input::-webkit-search-cancel-button { filter: invert(0.6); }
.library__kbd {
  font-family: var(--mono); font-size: 0.7rem; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
}

.library__controls {
  display: flex; align-items: flex-start; gap: 16px;
  margin-top: 16px; flex-wrap: wrap;
}

.filters { display: flex; flex-wrap: wrap; gap: 7px; flex: 1; min-width: 0; }
.filter {
  --cat: var(--blue);
  padding: 6px 13px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 480; color: var(--ink-2);
  border: 1px solid var(--line);
  transition: color 0.22s, border-color 0.22s, background 0.22s;
}
.filter:hover { color: var(--ink); border-color: var(--line-2); }
.filter.is-on {
  color: #061019; background: var(--cat); border-color: var(--cat);
  font-weight: 560;
}

.sort { display: inline-flex; align-items: center; gap: 9px; margin-left: auto; flex: none; }
.sort__label { font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.sort__select {
  appearance: none; -webkit-appearance: none;
  padding: 7px 30px 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(6, 10, 20, 0.8);
  font-size: 0.8rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f7f99' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 13px;
}
.sort__select option { background: #0a0f1a; }

.library__count {
  margin-top: 16px; font-family: var(--mono);
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}

.library__results {
  margin-top: 12px;
  max-height: min(46vh, 430px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 3px 10px 3px 3px;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.library__results::-webkit-scrollbar { width: 8px; }
.library__results::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }

.empty {
  grid-column: 1 / -1; padding: 34px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r);
  display: grid; gap: 6px; color: var(--ink-2);
}
.empty strong { color: var(--ink); font-weight: 560; }

/* =====================================================================
   Cards
   ===================================================================== */

.card {
  --cat: var(--blue);
  position: relative;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: linear-gradient(168deg, rgba(20, 28, 47, 0.985), rgba(10, 14, 25, 0.995));
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.45s var(--ease), border-color 0.3s, box-shadow 0.4s;
  will-change: transform;
}
.card.is-tilt {
  transform: perspective(900px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)) translateZ(6px);
  transition: transform 0.09s linear, border-color 0.3s, box-shadow 0.4s;
}
.card:hover {
  border-color: color-mix(in srgb, var(--cat) 55%, transparent);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.5), 0 0 0 1px color-mix(in srgb, var(--cat) 22%, transparent);
}

.card__glow {
  position: absolute; inset: -1px; pointer-events: none; opacity: 0;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%),
              color-mix(in srgb, var(--cat) 22%, transparent), transparent 62%);
  transition: opacity 0.35s;
}
.card:hover .card__glow { opacity: 1; }

.card__body { position: relative; padding: 17px 18px 16px; display: flex; flex-direction: column; gap: 9px; height: 100%; }
.card__top { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  --cat: var(--blue);
  font-size: 0.66rem; font-weight: 560; letter-spacing: 0.09em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat) 32%, transparent);
}
.chip--hot { --cat: var(--red); }
.chip--soft { --cat: var(--ink-3); color: var(--ink-2); text-transform: none; letter-spacing: 0.02em; }

.card__title { font-size: 1.06rem; letter-spacing: -0.026em; }
.card--lg .card__title { font-size: 1.32rem; }
.card__desc { font-size: 0.85rem; line-height: 1.52; color: var(--ink-2); flex: 1; }

.card__meta { display: flex; align-items: center; gap: 9px; font-size: 0.78rem; color: var(--ink-2); }
.stars { letter-spacing: 1px; color: rgba(150, 170, 200, 0.3); font-size: 0.8rem; }
.star.is-full, .star.is-half { color: #ffc857; }
.rating-num { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 520; }
.by { color: var(--ink-2); }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); display: inline-block; }

.card__stats {
  display: flex; gap: 14px; font-family: var(--mono);
  font-size: 0.7rem; color: var(--ink-3); letter-spacing: 0.03em;
}

.card__actions { display: flex; gap: 8px; margin-top: 3px; }

/* =====================================================================
   Vault + featured
   ===================================================================== */

.vault__head, .featured__head, .community__head, .submit__head { margin-bottom: 26px; max-width: 52ch; }
.submit__head { margin-bottom: 18px; }
.submit__head h2 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); }
.vault__head h2, .featured__head h2, .community__head h2, .submit__head h2 { font-size: clamp(2rem, 4.4vw, 3.3rem); }
.vault__head p, .featured__head p, .community__head p, .submit__head p { margin-top: 10px; color: var(--ink-2); }

.vault__grid, .featured__grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
}
.featured__grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

/* =====================================================================
   Category worlds
   ===================================================================== */

.worlds { display: grid; grid-template-columns: 150px 1fr; gap: 46px; align-items: center; }

.worlds__rail { display: grid; gap: 11px; border-left: 1px solid var(--line); padding-left: 20px; }
.worlds__rail span {
  font-size: 0.76rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3); transition: color 0.4s, transform 0.4s var(--ease);
}
.worlds__rail span.is-on { color: var(--ink); transform: translateX(5px); }

.worlds__stage { position: relative; min-height: 320px; }
.world {
  --cat: var(--blue);
  position: absolute; inset: 0; max-width: 620px;
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  opacity: 0; transition: opacity 0.5s var(--ease);
  pointer-events: none;
}
.world.is-on { pointer-events: auto; }
.world__idx {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.2em; color: var(--cat);
}
.world h3 {
  font-size: clamp(2.6rem, 6vw, 4.4rem); letter-spacing: -0.05em;
  color: var(--ink);
}
.world h3::after {
  content: ""; display: block; width: 72px; height: 2px; margin-top: 14px;
  background: linear-gradient(to right, var(--cat), transparent);
}
.world p { color: var(--ink-2); max-width: 44ch; font-size: 1.02rem; }
.world .btn { align-self: flex-start; }

/* =====================================================================
   Community
   ===================================================================== */

.community__people {
  display: grid; gap: 9px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}
.person {
  display: grid; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(12, 18, 32, 0.55);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.3s, transform 0.3s var(--ease);
}
.person:hover { border-color: var(--line-2); transform: translateY(-2px); }
.person__avatar {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 620; letter-spacing: 0.04em; color: #05070c;
  background: linear-gradient(140deg, hsl(var(--h) 90% 72%), hsl(calc(var(--h) + 40) 85% 58%));
  margin-bottom: 6px;
}
.person__name { font-weight: 560; font-size: 0.9rem; }
.person__stats { font-size: 0.76rem; color: var(--ink-3); }
.person__rep { font-family: var(--mono); font-size: 0.7rem; color: var(--cyan); letter-spacing: 0.05em; }

.community__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.community__cols > div {
  padding: 14px 14px 10px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(8, 12, 22, 0.52);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.community__cols h3 {
  font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 12px;
}
.minilist { display: grid; gap: 2px; }
.mini {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 9px 12px; border-radius: var(--r-sm); text-align: left;
  border: 1px solid transparent;
  transition: background 0.25s, border-color 0.25s;
}
.mini:hover { background: rgba(160, 200, 255, 0.06); border-color: var(--line); }
.mini__title { font-size: 0.9rem; font-weight: 500; }
.mini__cat { font-size: 0.7rem; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.mini__stat { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); }

/* =====================================================================
   Submit
   ===================================================================== */

.submit { display: grid; grid-template-columns: 1.35fr 0.85fr; gap: 28px; align-items: start; }
.submit__head { grid-column: 1 / -1; }

.submit__form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.submit__form label {
  display: grid; gap: 6px;
  font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-3);
}
.submit__form label.wide { grid-column: 1 / -1; }
.submit__form input, .submit__form select, .submit__form textarea {
  padding: 11px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(6, 10, 20, 0.72);
  font-size: 0.92rem; letter-spacing: normal; text-transform: none; color: var(--ink);
  outline: none; transition: border-color 0.25s, box-shadow 0.25s;
  resize: vertical;
}
.submit__form textarea[name="code"] { font-family: var(--mono); font-size: 0.82rem; line-height: 1.6; }
.submit__form input:focus, .submit__form select:focus, .submit__form textarea:focus {
  border-color: rgba(72, 229, 255, 0.55); box-shadow: 0 0 0 3px rgba(72, 229, 255, 0.1);
}
.submit__actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.submit__note { font-size: 0.78rem; color: var(--ink-3); }

.submit__preview { position: sticky; top: 110px; display: grid; gap: 10px; }
.submit__previewlabel {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-3);
}

/* =====================================================================
   Finale
   ===================================================================== */

.finale { text-align: center; display: grid; gap: 18px; justify-items: center; }
.finale__title {
  font-size: clamp(2.6rem, 7.6vw, 6rem); letter-spacing: -0.055em;
  background: linear-gradient(180deg, #ffffff, #9fc4f0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.finale__sub { font-size: clamp(1rem, 2vw, 1.35rem); color: var(--ink-2); }
.finale__cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

/* =====================================================================
   Code
   ===================================================================== */

.code {
  display: grid; grid-template-columns: auto 1fr;
  border: 1px solid var(--line); border-radius: var(--r);
  background: #060911;
  overflow: hidden;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.75;
}
.code__gutter {
  display: grid; padding: 16px 12px 16px 16px; text-align: right;
  color: rgba(120, 140, 170, 0.34); user-select: none;
  background: rgba(255, 255, 255, 0.014);
  border-right: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.code__body {
  margin: 0; padding: 16px 18px; overflow-x: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.code__body code { display: grid; }
.code .ln { white-space: pre; }

.t-comment   { color: #55697f; font-style: italic; }
.t-directive { color: #7a8ba0; font-weight: 600; }
.t-keyword   { color: #ff7b93; }
.t-string    { color: #9ce8a8; }
.t-number    { color: #ffc266; }
.t-fn        { color: #6fc3ff; }
.t-method    { color: #6fc3ff; }
.t-global    { color: #c9a6ff; }
.t-type      { color: #56e0c8; }
.t-op        { color: #8fa3bd; }
.t-punct     { color: #63758c; }

/* =====================================================================
   Toast
   ===================================================================== */

.toast {
  position: fixed; left: 50%; bottom: 34px; z-index: 300;
  transform: translate(-50%, 130%);
  padding: 12px 22px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 560; letter-spacing: 0.09em; text-transform: uppercase;
  background: rgba(10, 16, 28, 0.95);
  border: 1px solid rgba(72, 229, 255, 0.45);
  color: var(--cyan);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6), 0 0 34px rgba(72, 229, 255, 0.16);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform 0.45s var(--ease), opacity 0.45s;
  opacity: 0; pointer-events: none;
}
.toast.is-in { transform: translate(-50%, 0); opacity: 1; }
.toast[data-tone="warn"] { border-color: rgba(255, 190, 90, 0.5); color: #ffbe5a; box-shadow: 0 16px 44px rgba(0,0,0,0.6), 0 0 34px rgba(255,190,90,0.14); }

/* =====================================================================
   Responsive
   ===================================================================== */

@media (max-width: 1080px) {
  .worlds { grid-template-columns: 1fr; gap: 26px; }
  .worlds__rail { display: flex; flex-wrap: wrap; gap: 14px; border-left: 0; border-top: 1px solid var(--line); padding: 16px 0 0; }
  .worlds__stage { min-height: 300px; }
  .submit { grid-template-columns: 1fr; }
  .submit__preview { position: static; max-width: 340px; }
}

@media (max-width: 820px) {
  body { font-size: 15px; }
  .nav { padding: 12px 18px; gap: 12px; }
  .nav__links { display: none; }
  .chapter__stage { width: min(92vw, 620px); padding: 84px 0 56px; }
  .chapter__tag { top: 74px; }
  .community__cols { grid-template-columns: 1fr; gap: 22px; }
  .submit__form { grid-template-columns: 1fr; }
  .library__results { max-height: 52vh; }
  .results__grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; border-radius: var(--r); }
  .statement__stats { gap: 26px; }
  .reader__panel { padding: 22px 18px; max-height: 94vh; }
  .code { font-size: 0.74rem; }
}

@media (max-width: 520px) {
  .hero__cta, .finale__cta { flex-direction: column; align-items: stretch; }
  .btn { justify-content: center; }
  .scrollcue { bottom: 30px; }
}


/* =====================================================================
   Mobile: chapters stay pinned, so their content must fit one screen.
   Card grids become swipeable rows instead of tall stacks.
   ===================================================================== */

@media (max-width: 820px) {
  html.no-webgl .chapter__stage::before { display: none; }

  .vault__grid, .featured__grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 78%;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    padding-bottom: 6px;
    scrollbar-width: none;
  }
  .vault__grid::-webkit-scrollbar, .featured__grid::-webkit-scrollbar { height: 0; }
  .vault__grid .card, .featured__grid .card { scroll-snap-align: start; }

  .vault__head, .featured__head, .community__head, .submit__head { margin-bottom: 18px; }

  .community__people { grid-template-columns: repeat(2, 1fr); }
  .community__people .person:nth-child(n+5) { display: none; }
  .minilist .mini:nth-child(n+3) { display: none; }

  .submit { gap: 14px; }
  .submit__preview { display: none; }
  .submit__form { gap: 8px; }
  .submit__note { display: none; }

  /* One swipeable row of filters beats four wrapped lines. */
  .filters {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none; padding-bottom: 2px;
  }
  .filters::-webkit-scrollbar { height: 0; }
  .filter { flex: none; }
  .library__controls { flex-wrap: nowrap; gap: 10px; align-items: center; }
  .sort__label { display: none; }
  .panel__head p { display: none; }
  .panel__head { margin-bottom: 14px; }
  .library__results { max-height: 42vh; }
  .library__count { margin-top: 10px; }
  .hero__logo { width: min(74vw, 300px); margin-bottom: 16px; }

  .community__people { margin-bottom: 16px; }
  .community__cols h3 { margin-bottom: 8px; }
  .statement__stats { gap: 20px; margin-top: 30px; }
  .statement__stats strong { font-size: 1.7rem; }
}

@media (max-width: 820px) and (max-height: 720px) {
  .library__results { max-height: 38vh; }
}

/* =====================================================================
   Reduced motion
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card.is-tilt { transform: none; }
  .chapter__stage { opacity: 1 !important; transform: none !important; }
}

html.reduced-motion .chapter__stage { opacity: 1 !important; transform: none !important; pointer-events: auto !important; }
html.reduced-motion .world { opacity: 1 !important; position: relative; inset: auto; }
html.reduced-motion .worlds__stage { display: grid; gap: 34px; min-height: 0; }

/* Non-WebGL: no world to travel through, so shorten the journey. */
html.no-webgl .chapter { height: calc(var(--len) * 0.45vh); min-height: 112vh; }
html.no-webgl .chapter__stage { background: none; }
html.no-webgl .chapter__stage::before { opacity: 0.55; }
html.no-webgl .panel { background: rgba(10, 15, 26, 0.86); }

/* =====================================================================
   Top scroll indicator — replaces the side rail
   ===================================================================== */

.progress {
  position: absolute; left: 50%; bottom: -1px;
  transform: translateX(-50%);
  width: min(560px, 62vw); height: 3px;
  background: rgba(140, 175, 225, 0.16);
  border-radius: 999px;
  overflow: visible;
}
.progress__fill {
  display: block; height: 100%; width: 100%;
  transform-origin: left; transform: scaleX(0);
  border-radius: 999px;
  background: linear-gradient(to right, var(--cyan), var(--blue) 55%, var(--violet));
  box-shadow: 0 0 14px rgba(72, 229, 255, 0.55);
  transition: transform 0.08s linear;
}
.progress__label {
  position: absolute; left: 50%; top: -17px; transform: translateX(-50%);
  font-size: 0.6rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.35s var(--ease);
}
.nav.is-scrolled .progress__label { opacity: 1; }

/* =====================================================================
   Floating dashboard button — top right, always visible
   ===================================================================== */

.dashbtn {
  position: fixed; top: 14px; right: 18px; z-index: 70;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 15px 7px 8px; border-radius: 999px;
  font-size: 0.84rem; font-weight: 560; color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}
.dashbtn:hover {
  transform: translateY(-1px);
  border-color: rgba(61, 155, 255, 0.6);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(61, 155, 255, 0.12);
}
.dashbtn__icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(61,155,255,.16); }
.dashbtn__icon svg { width: 16px; height: 16px; fill: none; stroke: var(--blue); stroke-width: 1.9; stroke-linecap: round; }

.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.03em; color: #04070d;
  background: linear-gradient(140deg,
    hsl(calc(var(--seed, 200) * 1deg) 88% 68%),
    hsl(calc(var(--seed, 200) * 1deg + 45deg) 82% 52%));
  flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 62px; height: 62px; font-size: 1.15rem; border-radius: 18px; }

/* =====================================================================
   Buttons — extra variants
   ===================================================================== */

.btn--full { width: 100%; justify-content: center; }
.btn--discord { background: var(--discord); border-color: transparent; color: #fff; box-shadow: 0 8px 26px rgba(88, 101, 242, 0.34); }
.btn--discord:hover { background: #6b77f5; box-shadow: 0 12px 34px rgba(88, 101, 242, 0.46); }
.btn--discord svg { width: 17px; height: 17px; fill: currentColor; }
.btn--gold { background: linear-gradient(135deg, var(--gold), #f0a93c); border-color: transparent; color: #1a1200; box-shadow: 0 8px 26px rgba(255, 200, 87, 0.3); }
.btn--gold:hover { filter: brightness(1.06); box-shadow: 0 12px 34px rgba(255, 200, 87, 0.42); }
.btn--alt { background: linear-gradient(135deg, #2fe0a6, #16b183); box-shadow: 0 8px 26px rgba(47, 224, 166, 0.3); }

/* =====================================================================
   Sheets — auth, dashboard, info, script page
   ===================================================================== */

.sheet { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 4vh 16px; }
.sheet[hidden] { display: none; }

.sheet__scrim {
  position: absolute; inset: 0; opacity: 1;
  background: rgba(2, 4, 8, 0.86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: fade 0.24s var(--ease);
}
@keyframes fade { from { backdrop-filter: blur(0); } }

.sheet__panel {
  position: relative; opacity: 1; width: min(560px, 100%); max-height: 92vh;
  overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(15, 21, 36, 0.99), rgba(8, 11, 20, 1));
  box-shadow: 0 50px 130px rgba(0, 0, 0, 0.8);
  padding: 30px;
  animation: pop 0.3s var(--ease);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.sheet--wide .sheet__panel { width: min(940px, 100%); }
.sheet__panel::-webkit-scrollbar { width: 9px; }
.sheet__panel::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }
@keyframes pop { from { transform: translateY(16px) scale(.985); } }

.sheet__close {
  position: absolute; top: 16px; right: 18px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 1.35rem; line-height: 1; color: var(--ink-3);
  border: 1px solid var(--line);
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.sheet__close:hover { color: var(--ink); border-color: var(--line-2); background: rgba(160, 200, 255, 0.08); }

.sheet__head { margin-bottom: 22px; padding-right: 40px; }
.sheet__head h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.sheet__head p { margin-top: 9px; color: var(--ink-2); }
.sheet__head--row { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; }
.sheet__eyebrow {
  display: block; margin-bottom: 6px;
  font-family: var(--mono); font-size: 0.66rem;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3);
}
.sheet__sub { margin: 26px 0 12px; font-size: 1.05rem; }
.sheet__meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 14px; font-size: 0.82rem; color: var(--ink-3); }
.sheet__alt { margin-top: 18px; display: grid; gap: 8px; text-align: center; }
.sheet__alt button { font-size: 0.86rem; color: var(--ink-2); }
.sheet__alt b { color: var(--blue); }
.sheet__alt button:hover b { text-decoration: underline; }

/* =====================================================================
   Forms
   ===================================================================== */

.form { display: grid; gap: 13px; }
.form--grid { grid-template-columns: 1fr 1fr; }
.form label, .publish__form label {
  display: grid; gap: 6px;
  font-size: 0.68rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-3);
}
.form label.wide, .publish__form label.wide, .form .wide { grid-column: 1 / -1; }
.form input, .form select, .form textarea,
.publish__form input, .publish__form select, .publish__form textarea {
  padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: rgba(4, 7, 14, 0.9);
  font-size: 0.94rem; letter-spacing: normal; text-transform: none; color: var(--ink);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical; width: 100%;
}
.form textarea[name="code"], .publish__form textarea[name="code"] { font-family: var(--mono); font-size: 0.82rem; line-height: 1.6; }
.form input:focus, .form select:focus, .form textarea:focus,
.publish__form input:focus, .publish__form textarea:focus, .publish__form select:focus {
  border-color: rgba(72, 229, 255, 0.6); box-shadow: 0 0 0 3px rgba(72, 229, 255, 0.12);
}
.opt { text-transform: none; letter-spacing: normal; color: var(--ink-3); font-size: 0.72rem; }
.note { font-size: 0.78rem; color: var(--ink-3); letter-spacing: normal; text-transform: none; }
.formerror {
  padding: 11px 14px; border-radius: var(--r-sm); margin-bottom: 14px;
  background: rgba(255, 77, 94, 0.12); border: 1px solid rgba(255, 77, 94, 0.4);
  color: #ffb3ba; font-size: 0.87rem;
}
.counter { font-size: 0.72rem; color: var(--ink-3); letter-spacing: normal; text-transform: none; }
.counter.is-ok { color: var(--good); }

.keyless { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; display: flex; gap: 18px; flex-wrap: wrap; }
.keyless legend { font-size: 0.68rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-3); padding: 0 6px; }
.radio { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 8px; text-transform: none !important; letter-spacing: normal !important; font-size: 0.92rem !important; color: var(--ink) !important; }
.radio input { width: auto; }

.publish__actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.thumbpick, .avatarpick { display: flex; align-items: center; gap: 14px; }
.thumbpick__preview {
  display: grid; place-items: center; overflow: hidden;
  width: 150px; height: 84px; flex: none;
  border: 1px dashed var(--line-2); border-radius: var(--r-sm);
  font-size: 0.72rem; color: var(--ink-3); text-transform: none; letter-spacing: normal;
  background: rgba(4, 7, 14, 0.7);
}
.thumbpick__preview img { width: 100%; height: 100%; object-fit: cover; }
.thumbpick input[type=file], .avatarpick input[type=file] { font-size: 0.8rem; text-transform: none; letter-spacing: normal; }

/* Human check */
.hcheck {
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: rgba(4, 7, 14, 0.86); overflow: hidden;
  transition: border-color 0.25s;
}
.hcheck[data-state="ok"] { border-color: rgba(53, 208, 127, 0.55); background: rgba(53, 208, 127, 0.06); }
.hcheck.is-shake { animation: shake 0.42s var(--ease); border-color: rgba(255, 77, 94, 0.6); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
}

.hcheck__main { display: flex; align-items: center; gap: 13px; padding: 14px 15px; }

.hcheck__box {
  position: relative; flex: none;
  width: 26px; height: 26px; border-radius: 7px;
  border: 2px solid var(--line-2); background: rgba(8, 12, 22, 0.9);
  transition: border-color 0.25s, background 0.25s;
}
.hcheck__box:hover { border-color: rgba(61, 155, 255, 0.7); }
.hcheck[data-state="ok"] .hcheck__box { border-color: var(--good); background: var(--good); }

.hcheck__tick {
  position: absolute; inset: 0; margin: auto; width: 17px; height: 17px;
  fill: none; stroke: #04120a; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 26; stroke-dashoffset: 26; opacity: 0;
  transition: stroke-dashoffset 0.32s var(--ease) 0.05s, opacity 0.1s;
}
.hcheck[data-state="ok"] .hcheck__tick { stroke-dashoffset: 0; opacity: 1; }

.hcheck__spin {
  position: absolute; inset: 2px; border-radius: 50%; opacity: 0;
  border: 2px solid rgba(61, 155, 255, 0.25); border-top-color: var(--blue);
}
.hcheck[data-state="checking"] .hcheck__spin { opacity: 1; animation: hcspin 0.7s linear infinite; }
.hcheck[data-state="checking"] .hcheck__box { border-color: transparent; }
@keyframes hcspin { to { transform: rotate(360deg); } }

.hcheck__label { display: grid; gap: 1px; flex: 1; min-width: 0;
  text-transform: none !important; letter-spacing: normal !important; }
.hcheck__label b { font-size: 0.92rem; font-weight: 550; color: var(--ink); }
.hcheck__sub { font-size: 0.76rem; color: var(--ink-3); }
.hcheck[data-state="ok"] .hcheck__sub { color: var(--good); }

.hcheck__brand {
  display: grid; justify-items: center; gap: 2px; flex: none;
  font-size: 0.58rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.hcheck__brand svg { width: 17px; height: 17px; fill: none; stroke: var(--ink-3); stroke-width: 1.6; stroke-linejoin: round; }

.hcheck__slide { padding: 0 15px 15px; display: grid; gap: 9px; }
.hcheck__slide[hidden] { display: none; }
.hcheck__slidehint { font-size: 0.76rem; color: var(--ink-3); text-transform: none; letter-spacing: normal; }
.hcheck__track {
  position: relative; height: 42px; border-radius: 999px;
  background: rgba(8, 12, 22, 0.9); border: 1px solid var(--line-2); overflow: hidden;
}
.hcheck__fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(to right, rgba(61,155,255,.35), rgba(53,208,127,.4)); }
.hcheck__handle {
  position: absolute; left: 3px; top: 3px;
  width: 50px; height: 34px; border-radius: 999px;
  display: grid; place-items: center; touch-action: none;
  background: var(--blue); box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
  cursor: grab;
}
.hcheck__handle:active { cursor: grabbing; }
.hcheck__handle svg { width: 19px; height: 19px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.hcheck__hp {
  position: absolute !important; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* =====================================================================
   Dashboard
   ===================================================================== */

.dash__head {
  display: grid; grid-template-columns: auto 1fr auto; gap: 18px;
  align-items: center; margin-bottom: 22px; padding-right: 40px;
}
.dash__who h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
.dash__who p { margin-top: 6px; color: var(--ink-2); font-size: 0.92rem; }
.dash__links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.dash__meta { font-size: 0.74rem; color: var(--ink-3); letter-spacing: 0.04em; }
.sociallink {
  font-size: 0.74rem; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2); text-decoration: none;
}
.sociallink:hover { color: var(--ink); border-color: var(--blue); }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab { padding: 9px 15px; font-size: 0.88rem; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink-2); }
.tab.is-on { color: var(--ink); border-bottom-color: var(--blue); }

.pane { display: grid; gap: 16px; }
.pane[hidden] { display: none; }
.pane h3 { font-size: 1.05rem; }
.pane__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.segmented button { padding: 6px 13px; font-size: 0.78rem; color: var(--ink-3); }
.segmented button:hover { color: var(--ink-2); }
.segmented button.is-on { background: rgba(61, 155, 255, 0.2); color: var(--ink); }

.stats { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat {
  padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(6, 10, 19, 0.85); display: grid; gap: 5px; align-content: start;
}
.stat__v { font-size: 1.75rem; font-weight: 620; letter-spacing: -0.035em; line-height: 1; }
.stat__l { font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }

.trend { display: inline-flex; align-items: center; gap: 3px; font-size: 0.72rem; font-weight: 540; }
.trend svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.trend--up { color: var(--good); }
.trend--down { color: var(--red); }
.trend--flat { color: var(--ink-3); }

.chartbox { border: 1px solid var(--line); border-radius: var(--r); background: rgba(6, 10, 19, 0.8); padding: 16px; }
.chartbox__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.chartbox__head b { font-size: 0.9rem; }
.chartbox__head span { font-size: 0.74rem; color: var(--ink-3); }

.ch { width: 100%; height: 170px; display: block; overflow: visible; }
.ch__grid { stroke: rgba(140, 175, 225, 0.12); stroke-width: 1; }
.ch__ytick { fill: var(--ink-3); font-size: 10px; text-anchor: end; font-family: var(--mono); }
.ch__line { fill: none; stroke: var(--blue); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ch__dot { fill: var(--cyan); stroke: #05070d; stroke-width: 2; }

.chart__empty { display: grid; gap: 5px; justify-items: center; text-align: center; padding: 34px 16px; }
.chart__empty strong { color: var(--ink); font-weight: 550; }
.chart__empty span { color: var(--ink-3); font-size: 0.86rem; max-width: 44ch; }

/* publishes table */
.ptable { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ptable th {
  text-align: left; padding: 9px 10px; font-size: 0.64rem;
  letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.ptable td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ptable tr:last-child td { border-bottom: 0; }
.ptable tbody tr:hover { background: rgba(160, 200, 255, 0.045); }
.ptable .num { font-family: var(--mono); font-size: 0.82rem; text-align: right; }
.ptable th:nth-child(n+3) { text-align: right; }
.ptable__name { display: block; font-weight: 540; color: var(--ink); text-align: left; }
.ptable__name:hover { color: var(--blue); }
.ptable__game { display: block; font-size: 0.74rem; color: var(--ink-3); }
.ptable__del {
  width: 26px; height: 26px; border-radius: 7px; font-size: 1.1rem; line-height: 1;
  color: var(--ink-3); border: 1px solid transparent;
}
.ptable__del:hover { color: var(--red); border-color: rgba(255, 77, 94, 0.45); background: rgba(255, 77, 94, 0.1); }

.avatarpick__controls { display: grid; gap: 8px; }

/* password strength */
.meter { display: block; height: 4px; border-radius: 999px; background: rgba(140,175,225,.16); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; width: 0; border-radius: 999px; transition: width 0.3s var(--ease), background 0.3s; }
.meter[data-score="1"] i { width: 25%; background: var(--red); }
.meter[data-score="2"] i { width: 50%; background: var(--gold); }
.meter[data-score="3"] i { width: 75%; background: #7ee787; }
.meter[data-score="4"] i { width: 100%; background: var(--good); }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

/* =====================================================================
   Info tab
   ===================================================================== */

.steps { display: grid; gap: 12px; padding-left: 20px; color: var(--ink-2); }
.steps li { line-height: 1.6; }
.steps b { color: var(--ink); }
.infogrid { display: grid; gap: 13px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 24px 0; }
.infogrid > div { padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(6, 10, 19, 0.75); }
.infogrid h3 { font-size: 0.95rem; margin-bottom: 6px; }
.infogrid p { font-size: 0.87rem; color: var(--ink-2); }
.callout { padding: 15px 18px; border-radius: var(--r); border-left: 3px solid var(--gold); background: rgba(255, 200, 87, 0.09); color: var(--ink-2); font-size: 0.9rem; }
.rules { display: grid; gap: 9px; padding-left: 20px; color: var(--ink-2); font-size: 0.9rem; }

/* =====================================================================
   Script page
   ===================================================================== */

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 13px; }
.chip--ok { --cat: var(--good); }
.chip--warn { --cat: var(--gold); }
.script__game { color: var(--ink-2); margin-top: 6px; }
.script__thumb { width: 100%; border-radius: var(--r); border: 1px solid var(--line); margin-bottom: 20px; display: block; }
.script__desc { color: var(--ink-2); display: grid; gap: 12px; margin-bottom: 22px; }
.script__toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; padding-top: 18px; border-top: 1px solid var(--line); }
.script__code { margin-top: 4px; }

.gate {
  text-align: center; padding: 40px 26px; border-radius: var(--r-lg);
  border: 1px solid var(--line-2);
  background: radial-gradient(ellipse 70% 90% at 50% 0%, rgba(61, 155, 255, 0.12), transparent 70%), rgba(6, 10, 19, 0.9);
}
.gate__lock { width: 54px; height: 54px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; background: rgba(61, 155, 255, 0.14); }
.gate__lock svg { width: 26px; height: 26px; fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gate h3 { font-size: 1.4rem; }
.gate p { margin-top: 9px; color: var(--ink-2); max-width: 44ch; margin-inline: auto; }
.gate__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.gate__note { font-size: 0.8rem; color: var(--ink-3); margin-top: 14px; }

/* =====================================================================
   Leaderboard
   ===================================================================== */

.board__tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 18px; }
.board__tabs button {
  padding: 8px 15px; border-radius: 999px; font-size: 0.83rem;
  color: var(--ink-2); border: 1px solid var(--line);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.board__tabs button:hover { color: var(--ink); border-color: var(--line-2); }
.board__tabs button.is-on { background: rgba(61, 155, 255, 0.18); border-color: rgba(61, 155, 255, 0.5); color: var(--ink); }

.board__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board__row {
  display: grid; grid-template-columns: 34px auto 1fr auto; gap: 13px; align-items: center;
  padding: 11px 14px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: rgba(6, 10, 19, 0.6);
}
.board__row.is-top { border-color: rgba(255, 200, 87, 0.28); background: rgba(255, 200, 87, 0.05); }
.board__rank { font-family: var(--mono); font-size: 0.9rem; color: var(--ink-3); text-align: center; }
.board__row.is-top .board__rank { color: var(--gold); font-weight: 700; }
.board__name { font-weight: 520; }
.board__value { font-family: var(--mono); font-size: 0.85rem; }
.board__value small { color: var(--ink-3); }

/* =====================================================================
   Empty states
   ===================================================================== */

.empty {
  grid-column: 1 / -1; padding: 30px; text-align: center;
  border: 1px dashed var(--line-2); border-radius: var(--r);
  display: grid; gap: 8px; justify-items: center; color: var(--ink-2);
  background: rgba(6, 10, 19, 0.55);
}
.empty strong { color: var(--ink); font-weight: 580; font-size: 1.02rem; }
.empty span { max-width: 46ch; font-size: 0.9rem; }
.empty--lg { padding: 44px 30px; }

/* =====================================================================
   Cards — thumbnails and game line
   ===================================================================== */

.card__thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border-bottom: 1px solid var(--line); }
.card__game { font-size: 0.78rem; color: var(--blue); font-weight: 500; }

/* =====================================================================
   Assistant — bottom left
   ===================================================================== */

.assistant { position: fixed; left: 18px; bottom: 18px; z-index: 150; }

.assistant__toggle {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 17px 10px 11px; border-radius: 999px;
  font-size: 0.86rem; font-weight: 560; color: var(--ink);
  background: linear-gradient(135deg, rgba(61, 155, 255, 0.22), rgba(154, 107, 255, 0.22)), var(--panel-2);
  border: 1px solid rgba(61, 155, 255, 0.42);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55), 0 0 0 0 rgba(61, 155, 255, 0.4);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform 0.25s var(--ease), box-shadow 0.3s;
}
.assistant__toggle:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(0,0,0,.6), 0 0 0 4px rgba(61,155,255,.14); }
.assistant.is-open .assistant__toggle { opacity: 0; pointer-events: none; }
.assistant__spark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(61, 155, 255, 0.25); }
.assistant__spark svg { width: 16px; height: 16px; fill: var(--cyan); }

.assistant__panel[hidden] { display: none; }

.assistant__panel {
  position: absolute; left: 0; bottom: 0;
  width: min(370px, calc(100vw - 36px)); height: min(520px, 72vh);
  display: flex; flex-direction: column;
  border: 1px solid var(--line-2); border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 21, 36, 0.995), rgba(8, 11, 20, 1));
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  animation: pop 0.26s var(--ease);
}

.assistant__head { display: flex; align-items: center; gap: 9px; padding: 13px 15px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.assistant__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px var(--good); }
.assistant__x { margin-left: auto; font-size: 1.3rem; line-height: 1; color: var(--ink-3); }
.assistant__x:hover { color: var(--ink); }

.assistant__log { flex: 1; overflow-y: auto; padding: 15px; display: grid; gap: 11px; align-content: start; scrollbar-width: thin; }
.assistant__log::-webkit-scrollbar { width: 6px; }
.assistant__log::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }

.bubble { padding: 11px 14px; border-radius: 14px; font-size: 0.875rem; line-height: 1.55; max-width: 92%; }
.bubble--bot { background: rgba(61, 155, 255, 0.11); border: 1px solid rgba(61, 155, 255, 0.22); border-bottom-left-radius: 5px; justify-self: start; color: var(--ink); }
.bubble--me { background: rgba(160, 200, 255, 0.09); border: 1px solid var(--line); border-bottom-right-radius: 5px; justify-self: end; color: var(--ink-2); }
.bubble b { color: var(--ink); }
.bubble__steps { margin: 9px 0 0; padding-left: 18px; display: grid; gap: 6px; color: var(--ink-2); }
.bubble__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; }
.bubble__actions button {
  padding: 6px 12px; border-radius: 999px; font-size: 0.78rem;
  border: 1px solid rgba(61, 155, 255, 0.45); color: var(--cyan);
  background: rgba(61, 155, 255, 0.1); transition: background 0.2s;
}
.bubble__actions button:hover { background: rgba(61, 155, 255, 0.2); }

.bubble__results { display: grid; gap: 6px; margin: 10px 0; }
.miniscript {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 9px; text-align: left;
  padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(6, 10, 19, 0.7);
  transition: border-color 0.2s, background 0.2s;
}
.miniscript:hover { border-color: rgba(61, 155, 255, 0.5); background: rgba(61, 155, 255, 0.08); }
.miniscript__cat { --cat: var(--blue); grid-row: span 2; align-self: center;
  font-size: 0.6rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--cat); padding: 3px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--cat) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat) 34%, transparent); }
.miniscript__title { font-size: 0.85rem; font-weight: 540; color: var(--ink); }
.miniscript__game { font-size: 0.74rem; color: var(--ink-3); }

.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.assistant__chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 15px 10px; }
.assistant__chips button {
  padding: 6px 11px; border-radius: 999px; font-size: 0.75rem;
  border: 1px solid var(--line); color: var(--ink-2); background: rgba(6, 10, 19, 0.6);
}
.assistant__chips button:hover { color: var(--ink); border-color: var(--line-2); }

.assistant__form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.assistant__input {
  flex: 1; min-width: 0; padding: 10px 13px; border-radius: 999px;
  border: 1px solid var(--line-2); background: rgba(4, 7, 14, 0.9);
  font-size: 0.87rem; outline: none;
}
.assistant__input:focus { border-color: rgba(72, 229, 255, 0.55); }
.assistant__send { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--blue); flex: none; }
.assistant__send svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* =====================================================================
   Responsive
   ===================================================================== */

@media (max-width: 820px) {
  .progress { width: 46vw; }
  .dashbtn { top: auto; bottom: 18px; right: 14px; padding: 8px 14px 8px 9px; }
  .dashbtn span:last-child { display: none; }
  .assistant { left: 14px; bottom: 18px; }
  .assistant__label { display: none; }
  .assistant__toggle { padding: 11px; }
  .form--grid { grid-template-columns: 1fr; }
  .sheet__panel { padding: 22px 18px; max-height: 94vh; }
  .sheet__head--row { grid-template-columns: auto 1fr; }
  .sheet__head--row .btn { grid-column: 1 / -1; justify-self: start; }
  .infogrid { grid-template-columns: 1fr; }
  .board__row { grid-template-columns: 26px auto 1fr; row-gap: 4px; }
  .board__value { grid-column: 2 / -1; }
  .dash__head { grid-template-columns: auto 1fr; }
  .dash__head > .btn { grid-column: 1 / -1; justify-self: start; }
  .ptable th:nth-child(2), .ptable td:nth-child(2) { display: none; }
  .ptable { font-size: 0.82rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* =====================================================================
   Roblox game picker
   ===================================================================== */

.gpick { position: relative; }

.gpick__field {
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: rgba(4, 7, 14, 0.9);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gpick__field:focus-within { border-color: rgba(72, 229, 255, 0.6); box-shadow: 0 0 0 3px rgba(72, 229, 255, 0.12); }
.gpick__icon { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
.gpick__input {
  flex: 1; min-width: 0; padding: 12px 0 !important;
  border: 0 !important; background: none !important; box-shadow: none !important;
  font-size: 0.94rem; outline: none; color: var(--ink);
  text-transform: none; letter-spacing: normal;
}
.gpick__clear { font-size: 1.2rem; line-height: 1; color: var(--ink-3); padding: 0 4px; }
.gpick__clear:hover { color: var(--ink); }
.gpick__caret { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.gpick__list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  margin: 0; padding: 6px; list-style: none;
  max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: rgba(10, 14, 25, 0.99);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.7);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.gpick__list[hidden] { display: none; }
.gpick__list::-webkit-scrollbar { width: 7px; }
.gpick__list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }

.gpick__opt {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 8px; cursor: pointer;
  font-size: 0.89rem; color: var(--ink-2);
  text-transform: none; letter-spacing: normal;
}
.gpick__opt:hover, .gpick__opt.is-active { background: rgba(61, 155, 255, 0.16); color: var(--ink); }
.gpick__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); flex: none; opacity: 0.7; }
.gpick__opt--custom { color: var(--cyan); border-top: 1px solid var(--line); margin-top: 4px; padding-top: 11px; }
.gpick__opt--custom b { color: var(--ink); }
.gpick__none { padding: 12px; font-size: 0.85rem; color: var(--ink-3); text-align: center; }

/* ============================================================
   Games — tiles, rows, and the game page
   ============================================================ */

.results__grid {
  display: grid; gap: 13px;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
}
.results__head {
  margin: 18px 0 10px; font-family: var(--mono);
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.results__head:first-child { margin-top: 2px; }

.library__pinned {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px;
}
.library__pinnote {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-3);
}
.library__all { margin-left: auto; }
.btn--xs { padding: 7px 13px; font-size: 0.74rem; }

.filter--pin { border-color: var(--line-2); }
.filter--pin.is-on {
  background: color-mix(in srgb, var(--cat) 22%, transparent);
  border-color: var(--cat); color: var(--ink);
}

.library__clear {
  border: 0; background: none; color: var(--ink-3); font-size: 1.25rem; line-height: 1;
  cursor: pointer; padding: 0 4px; flex: none;
}
.library__clear:hover { color: var(--ink); }

.library__undo {
  margin-left: 8px; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--blue); text-transform: none; letter-spacing: 0;
}
.library__undo:hover { text-decoration: underline; }

.library__search--inline { margin-top: 18px; }

/* ------------------------------------------------------------- tiles */

.games {
  display: grid; gap: 11px;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}
.games--compact { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }

.gtile {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  padding: 11px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink);
  transition: transform 0.18s var(--ease), border-color 0.18s, background 0.18s;
}
.gtile:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, hsl(var(--h, 210) 80% 62%) 55%, var(--line-2));
  background: color-mix(in srgb, hsl(var(--h, 210) 80% 55%) 8%, var(--panel));
}
.gtile:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.gtile__art {
  position: relative; display: grid; place-items: center; overflow: hidden;
  aspect-ratio: 16 / 9; border-radius: 9px;
  background:
    radial-gradient(120% 120% at 20% 0%, hsl(var(--h, 210) 70% 42% / 0.55), transparent 65%),
    linear-gradient(140deg, hsl(var(--h, 210) 65% 24%), hsl(calc(var(--h, 210) + 40) 60% 14%));
  border: 1px solid var(--line);
}
.gtile__art img { width: 100%; height: 100%; object-fit: cover; }
.gtile__art--lg { width: 132px; flex: none; aspect-ratio: 16 / 10; }
.gtile__mono {
  font-family: var(--mono); font-weight: 700; font-size: 1.25rem;
  letter-spacing: 0.04em; color: rgba(255, 255, 255, 0.86);
}

.gtile__name {
  font-weight: 620; font-size: 0.86rem; line-height: 1.25;
  /* Two lines reserved either way, so every tile's count sits on one line. */
  min-height: 2.5em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gtile--more .gtile__name { min-height: 0; }
.gtile__count {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.06em; color: var(--ink-3);
}

.gtile--more {
  align-items: center; justify-content: center; text-align: center;
  border-style: dashed; border-color: var(--line-2);
  background: color-mix(in srgb, var(--blue) 7%, var(--panel));
}
.gtile--more:hover { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 13%, var(--panel)); }
.gtile__bubble {
  display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(150deg, var(--blue), var(--cyan));
  color: #05070d; font-weight: 750; font-size: 1rem; letter-spacing: -0.02em;
  box-shadow: 0 8px 22px rgba(61, 155, 255, 0.32);
}
.gtile--more .gtile__name { text-align: center; }

/* -------------------------------------------------------------- rows */

.grows { display: grid; gap: 8px; margin-top: 14px; }

.grow {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 9px 13px 9px 9px; cursor: pointer; text-align: left;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink);
  transition: border-color 0.16s, background 0.16s, transform 0.16s var(--ease);
}
.grow:hover {
  transform: translateX(3px);
  border-color: color-mix(in srgb, hsl(var(--h, 210) 80% 62%) 50%, var(--line-2));
  background: color-mix(in srgb, hsl(var(--h, 210) 80% 55%) 7%, var(--panel));
}
.grow:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.grow .gtile__art { width: 78px; flex: none; }
.grow__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.grow__name { font-weight: 620; font-size: 0.94rem; }
.grow__meta { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-3); }
.grow__chev {
  width: 18px; height: 18px; margin-left: auto; flex: none;
  fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.grow:hover .grow__chev { stroke: var(--ink-2); }

/* ---------------------------------------------------------- game page */

.gamehead {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
}
.gamehead__text { min-width: 0; flex: 1; }
.gamehead__text .sheet__title { margin: 2px 0 8px; }
.gamehead__meta {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 0.74rem; color: var(--ink-3);
}
.gamehead__meta b { color: var(--ink); font-weight: 650; }
.gamehead__back { flex: none; }

@media (max-width: 820px) {
  .games { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 9px; }
  .gtile__art--lg { width: 96px; }
  .gamehead { gap: 13px; }
  .library__all { margin-left: 0; }
}

/* ============================================================
   Assistant — model answers
   ============================================================ */

.assistant .bubble p { margin: 0 0 9px; }
.assistant .bubble p:last-child { margin-bottom: 0; }
.assistant .bubble code {
  font-family: var(--mono); font-size: 0.82em;
  background: rgba(255, 255, 255, 0.07); border-radius: 5px; padding: 1px 5px;
}

.acode {
  position: relative; margin: 10px 0;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(2, 4, 9, 0.72); overflow: hidden;
}
.acode pre {
  margin: 0; padding: 12px 13px; overflow-x: auto;
  font-family: var(--mono); font-size: 0.76rem; line-height: 1.6;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.acode code { background: none; padding: 0; font-size: inherit; }

.acode__copy {
  position: absolute; top: 7px; right: 7px; z-index: 1;
  padding: 4px 9px; cursor: pointer;
  font-family: var(--mono); font-size: 0.64rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2); background: rgba(9, 13, 24, 0.92);
  border: 1px solid var(--line-2); border-radius: 6px;
  opacity: 0; transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.acode:hover .acode__copy, .acode__copy:focus-visible { opacity: 1; }
.acode__copy:hover { color: var(--ink); border-color: var(--blue); }

/* A fence still being streamed gets a live edge, so a half-written script
   reads as "still coming" rather than as the finished answer. */
.acode.is-open::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  animation: acodeflow 1.1s linear infinite;
}
@keyframes acodeflow {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

@media (pointer: coarse) {
  .acode__copy { opacity: 1; }
}

/* ============================================================
   AI generator, hearts and the shelf
   ============================================================ */

.btn--ai {
  background: linear-gradient(120deg, var(--violet, #8b5cf6), var(--blue));
  color: #fff; border: 0;
}
.btn--ai svg { width: 17px; height: 17px; fill: currentColor; }
.btn--ai:hover { filter: brightness(1.08); }

/* ------------------------------------------------------------- heart */

.card { position: relative; }
.card__heart {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: grid; place-items: center; width: 32px; height: 32px;
  cursor: pointer; border-radius: 50%;
  background: rgba(6, 9, 16, 0.72); border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  transition: transform 0.16s var(--ease), border-color 0.16s, background 0.16s;
}
.card__heart svg { width: 17px; height: 17px; fill: none; stroke: var(--ink-2); stroke-width: 1.8; }
.card__heart:hover { transform: scale(1.1); border-color: var(--red, #ff4d5e); }
.card__heart:hover svg { stroke: var(--red, #ff4d5e); }
.card__heart.is-on { border-color: var(--red, #ff4d5e); background: rgba(255, 77, 94, 0.16); }
.card__heart.is-on svg { fill: var(--red, #ff4d5e); stroke: var(--red, #ff4d5e); }
.card__heart:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* --------------------------------------------------------- generator */

.gen__label {
  display: block; margin: 22px 0 8px;
  font-family: var(--mono); font-size: 0.7rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.gen__prompt {
  width: 100%; resize: vertical; padding: 13px 15px;
  font: inherit; line-height: 1.55; color: var(--ink);
  background: rgba(4, 7, 13, 0.6);
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
.gen__prompt:focus { outline: none; border-color: var(--blue); }

.gen__examples { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.gen__eg {
  padding: 6px 11px; cursor: pointer; text-align: left;
  font-size: 0.76rem; color: var(--ink-2);
  background: none; border: 1px dashed var(--line-2); border-radius: 99px;
}
.gen__eg:hover { color: var(--ink); border-color: var(--blue); border-style: solid; }

.gen__bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; }
.gen__quota { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); }

.gen__out { margin-top: 26px; }
.gen__outhead {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-bottom: 9px; font-weight: 620;
}
.gen__hint { font-family: var(--mono); font-size: 0.68rem; color: var(--ink-3); font-weight: 400; }

/* The textarea sits transparent on top of a highlighted copy of the same
   text, so people edit real code and still see it coloured. Both layers must
   use identical metrics or the two drift apart as you type. */
.gen__editor {
  position: relative; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(2, 4, 9, 0.72); overflow: hidden;
}
.gen__ghost, .gen__code {
  margin: 0; padding: 14px 16px;
  font-family: var(--mono); font-size: 0.78rem; line-height: 1.65;
  white-space: pre; tab-size: 2;
}
.gen__ghost {
  position: absolute; inset: 0; overflow: auto;
  pointer-events: none; color: var(--ink);
}
.gen__code {
  position: relative; display: block; width: 100%; height: 340px;
  resize: vertical; border: 0; background: none;
  color: transparent; caret-color: var(--blue);
  overflow: auto;
}
.gen__code:focus { outline: none; }
.gen__code::selection { background: rgba(61, 155, 255, 0.32); color: transparent; }

.gen__save { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-top: 16px; }
.gen__note { font-family: var(--mono); font-size: 0.7rem; color: var(--good, #4ade80); }

.ptable__acts { display: flex; gap: 6px; flex: none; }

@media (max-width: 820px) {
  .gen__code { height: 260px; }
  .gen__examples .gen__eg:nth-child(n+3) { display: none; }
}

/* ============================================================
   First-visit bot check
   ============================================================ */

html.is-gated { overflow: hidden; }

.botgate {
  position: fixed; inset: 0; z-index: 999;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, #0b1020, #04060c 70%);
  animation: gatein 0.35s var(--ease) both;
}
.botgate.is-going {
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s var(--ease);
}
@keyframes gatein { from { opacity: 0; } to { opacity: 1; } }

.botgate__panel {
  width: min(480px, 100%); text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.botgate__logo { width: min(300px, 74vw); height: auto; margin-bottom: 6px; }
.botgate__title {
  font-size: clamp(1.7rem, 4vw, 2.3rem); letter-spacing: -0.03em; margin: 0 0 8px;
}
.botgate__sub { color: var(--ink-2); max-width: 34ch; margin: 0 0 24px; }
.botgate .hcheck { width: 100%; text-align: left; }
.botgate__note {
  margin-top: 20px; max-width: 38ch;
  font-family: var(--mono); font-size: 0.68rem; line-height: 1.6; color: var(--ink-3);
}

@media (prefers-reduced-motion: reduce) {
  .botgate, .botgate.is-going { animation: none; transition: none; }
}

/* Continue with Google -------------------------------------------------- */

/* Google's brand guidelines want their mark on a light, plain surface, so
   this button deliberately breaks the dark theme rather than tinting it. */
.btn--google {
  background: #fff;
  color: #1f1f1f;
  border-color: #dadce0;
  gap: 10px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}
.btn--google:hover { background: #f5f6f7; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.34); }
.btn--google:disabled { opacity: 0.6; cursor: default; }
.btn--google svg { flex: none; }

.sheet__or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 4px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3, var(--ink-2));
}
.sheet__or::before,
.sheet__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line, rgba(255, 255, 255, 0.12));
}

/* The AI conversation ---------------------------------------------------- */

.chat {
  list-style: none;
  margin: 0 0 18px;
  padding: 14px;
  display: grid;
  gap: 12px;
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
  border-radius: 16px;
}
.chat__row { display: grid; gap: 4px; }
.chat__row--you { justify-items: end; }
.chat__who {
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3, var(--ink-2));
}
.chat__bubble {
  margin: 0;
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  background: var(--blue, #3f8cff);
  color: #fff;
}
.chat__bubble--ai {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink-1, #eef2f7);
}
.chat__bubble--busy { opacity: 0.7; font-style: italic; }

.gen__warn {
  margin: 10px 0 0;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 0.86rem;
  line-height: 1.5;
  background: rgba(255, 200, 87, 0.11);
  border: 1px solid rgba(255, 200, 87, 0.32);
  color: var(--gold, #ffc857);
}

/* My Scripts ------------------------------------------------------------- */

.mine__grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  margin-top: 16px;
}
.mine__card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
}
.mine__card--live { border-color: rgba(255, 200, 87, 0.32); }
.mine__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mine__title { margin: 0; font-size: 1rem; line-height: 1.3; }
.mine__meta { flex: none; font-size: 0.74rem; color: var(--ink-3, var(--ink-2)); white-space: nowrap; }
.mine__meta--live { color: var(--gold, #ffc857); }
.mine__ask {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mine__code {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.34);
  font-size: 0.76rem;
  line-height: 1.5;
  overflow: hidden;
  white-space: pre;
  text-overflow: ellipsis;
  color: var(--ink-2);
}
.mine__acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.mine__del:hover { color: #ff6b6b; border-color: rgba(255, 107, 107, 0.5); }

.mine__empty {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-2);
}

/* Turnstile ------------------------------------------------------------- */

.turnstile { margin: 4px 0 2px; min-height: 65px; }
