/* ==========================================================
   WizardXP — theme tokens
   ========================================================== */
:root {
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Accent palette. The admin dashboard overrides --blue-1/2/3 and --a1-rgb/--a2-rgb at runtime. */
  --blue-1: #d58bff;   /* WizardXP purple */
  --blue-2: #9b5cff;
  --blue-3: #6a2cff;
  --a1-rgb: 213, 139, 255;
  --a2-rgb: 155, 92, 255;
  --blue-mid: color-mix(in srgb, var(--blue-1) 40%, var(--blue-2));
  --blue-deep: color-mix(in srgb, var(--blue-3) 85%, #000);
  --blue-dim: color-mix(in srgb, var(--blue-3) 60%, #000);
  --blue-soft: color-mix(in srgb, var(--blue-2) 55%, #fff);
  --accent-shift: 57deg; /* hue rotation applied to the pixel-art cube/portal to follow the accent */
  --brand-grad: linear-gradient(135deg, var(--blue-1), var(--blue-3));
  --btn-grad: linear-gradient(180deg, var(--blue-mid) 0%, var(--blue-2) 55%, var(--blue-3) 100%);
  --gold-grad: linear-gradient(180deg, #ffd84d, #f5b301);
  --star: #ffb21e;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --gutter: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #03060c;
  --bg-glow: radial-gradient(120% 60% at 0% 0%, rgba(20, 70, 160, .18), transparent 60%),
             radial-gradient(90% 50% at 100% 30%, rgba(var(--a2-rgb), .08), transparent 60%);
  --text: #ffffff;
  --text-2: #d7dce6;
  --text-3: #aeb6c4;
  --accent-text: var(--blue-mid);
  --beta-bg: #1d2a40;
  --beta-text: #c6d4ea;
  --pill-bg: rgba(14, 26, 48, .85);
  --pill-border: var(--blue-dim);
  --pill-glow: 0 0 12px rgba(var(--a2-rgb), .35), inset 0 0 8px rgba(var(--a2-rgb), .15);
  --card-bg: linear-gradient(180deg, rgba(20, 28, 42, .92), rgba(10, 15, 25, .92));
  --card-border: rgba(120, 150, 200, .22);
  --card-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 8px 24px rgba(0, 0, 0, .45);
  --outline-border: var(--blue-2);
  --outline-bg: rgba(6, 12, 24, .6);
  --outline-text: #ffffff;
  --discord: #ffffff;
  --heart-fill: none;
  --heart-stroke: var(--blue-mid);
  --heart-glow: drop-shadow(0 0 6px rgba(var(--a2-rgb), .9));
  --game-border: var(--blue-mid);
  --game-glow: 0 0 0 1px rgba(var(--a1-rgb), .25), 0 0 18px rgba(var(--a2-rgb), .55), inset 0 0 16px rgba(var(--a2-rgb), .35);
  --game-glow-hover: 0 0 0 1px rgba(var(--a1-rgb), .45), 0 0 28px rgba(var(--a2-rgb), .8), inset 0 0 20px rgba(var(--a2-rgb), .45);
  --game-overlay: linear-gradient(90deg, rgba(5, 10, 24, .95) 0%, rgba(5, 10, 24, .82) 30%, rgba(5, 10, 24, .25) 62%, rgba(5, 10, 24, 0) 80%),
                  linear-gradient(0deg, rgba(5, 10, 24, .9) 0%, rgba(5, 10, 24, .35) 48%, rgba(5, 10, 24, 0) 70%);
  --tag-bg: rgba(40, 46, 58, .78);
  --tag-text: #e7ebf2;
  --divider: rgba(255, 255, 255, .35);
  --nav-bg: rgba(8, 12, 20, .92);
  --nav-border: rgba(255, 255, 255, .09);
  --nav-shadow: 0 10px 30px rgba(0, 0, 0, .6);
  --nav-active-bg: linear-gradient(180deg, color-mix(in srgb, var(--blue-3) 30%, #060b16), color-mix(in srgb, var(--blue-3) 20%, #060b16));
  --nav-active-border: rgba(var(--a2-rgb), .45);
  --nav-text: #e6eaf1;
  --nav-icon: #e6eaf1;
  --avatar-ring: 0 0 0 3px var(--blue-mid), 0 0 0 6px rgba(3, 6, 12, 1), 0 0 22px 6px rgba(var(--a1-rgb), .55);
  --drawer-bg: rgba(10, 16, 28, .82);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fc;
  --bg-glow: linear-gradient(180deg, #ffffff 0%, #f3f6fb 40%, #eef2f8 100%);
  --text: #0b1222;
  --text-2: #1f2735;
  --text-3: #3c4555;
  --accent-text: var(--blue-deep);
  --beta-bg: #e6ebf3;
  --beta-text: #2b3446;
  --pill-bg: #ffffff;
  --pill-border: #e1e6ee;
  --pill-glow: 0 2px 8px rgba(20, 40, 80, .08);
  --card-bg: linear-gradient(180deg, #ffffff, #f7f9fc);
  --card-border: rgba(15, 30, 60, .06);
  --card-shadow: 0 6px 18px rgba(20, 40, 80, .09), 0 1px 2px rgba(20, 40, 80, .05);
  --outline-border: var(--blue-2);
  --outline-bg: #ffffff;
  --outline-text: #0b1222;
  --discord: #3d6cff;
  --heart-fill: url(#g-heart);
  --heart-stroke: none;
  --heart-glow: drop-shadow(0 4px 6px rgba(30, 90, 230, .3));
  --game-border: var(--blue-soft);
  --game-glow: 0 6px 22px rgba(var(--a2-rgb), .16), 0 0 10px rgba(var(--a2-rgb), .25);
  --game-glow-hover: 0 10px 28px rgba(var(--a2-rgb), .26), 0 0 16px rgba(var(--a2-rgb), .4);
  --game-overlay: linear-gradient(90deg, rgba(255, 255, 255, .96) 0%, rgba(255, 255, 255, .85) 30%, rgba(255, 255, 255, .3) 62%, rgba(255, 255, 255, 0) 80%),
                  linear-gradient(0deg, rgba(255, 255, 255, .95) 0%, rgba(255, 255, 255, .45) 48%, rgba(255, 255, 255, 0) 70%);
  --tag-bg: rgba(233, 237, 243, .92);
  --tag-text: #1d2433;
  --divider: rgba(10, 20, 40, .35);
  --nav-bg: rgba(255, 255, 255, .95);
  --nav-border: rgba(15, 30, 60, .05);
  --nav-shadow: 0 8px 28px rgba(20, 40, 80, .12);
  --nav-active-bg: color-mix(in srgb, var(--blue-2) 11%, #fff);
  --nav-active-border: transparent;
  --nav-text: #1a2232;
  --nav-icon: #1a2232;
  --avatar-ring: 0 0 0 3px var(--blue-mid), 0 0 0 6px #ffffff, 0 0 18px 6px rgba(var(--a2-rgb), .4);
  --drawer-bg: rgba(255, 255, 255, .88);
}

/* ==========================================================
   Base
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;          /* keep the scrollbar's space so pages don't shift sideways */
  scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom));
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color .4s var(--ease), color .4s var(--ease);
  overflow-x: hidden;
  overflow-x: clip;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
img { display: block; max-width: 100%; }
.ic { flex: none; }
:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 3px; border-radius: 8px; }

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  /* Clear the floating bottom nav so CTAs stay tappable */
  padding: 0 0 calc(112px + env(safe-area-inset-bottom));
}

/* ==========================================================
   Header
   ========================================================== */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: calc(env(safe-area-inset-top) + 4px) 18px 0;
  box-sizing: content-box;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--text);
  border-radius: 10px;
  transition: transform .2s var(--ease), background .2s;
}
.icon-btn:hover { background: rgba(127, 160, 220, .12); }
.icon-btn:active { transform: scale(.92); }
.theme-btn { width: 44px; }
.icon-btn.theme-btn:hover,
.icon-btn.theme-btn:active { background: none; transform: none; }
.theme-btn .switch { filter: drop-shadow(0 1px 0 rgba(23, 13, 43, .4)); }

.brand { display: flex; align-items: center; gap: 6px; flex: none; }
/* WizardXP pixel logo: scaled by clean multiples so pixels stay square (1.5x phones, 2x desktop). */
.brand__mark, .brand__word { display: block; flex: none; max-width: none; image-rendering: pixelated; }
.brand__mark { width: 36px; height: 36px; filter: drop-shadow(0 0 6px rgba(var(--a1-rgb), .45)); }
.brand__word { width: 117px; height: auto; margin-top: 3px; }
@media (max-width: 429px) { .header .brand__beta { display: none; } }
@media (min-width: 1024px) {
  .header .brand__mark { width: 48px; height: 48px; }
  .header .brand__word { width: 156px; }
}
.brand__beta {
  flex: none;
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--beta-bg);
  color: var(--beta-text);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.header__right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.coin-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 31px;
  padding: 0 14px 0 6px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  box-shadow: var(--pill-glow);
}
/* WizardXP coin: pixel art (art/coin.px.js), 11px drawn at 2x. Any text inside is hidden. */
.coin {
  display: inline-block;
  flex: none;
  width: 22px;
  height: 22px;
  background: url('/assets/coin/sprites/coin.png') 0 0 / 22px 22px no-repeat;
  image-rendering: pixelated;
  font-size: 0;
  color: transparent;
  vertical-align: middle;
}
/* header / drawer / menu: coin shines every couple of seconds */
.coin-pill .coin,
.drawer__link .coin,
.menu .coin {
  background: url('/assets/coin/anims/coin_shine.png') 0 0 / 176px 22px no-repeat;
  animation: coinShine 1.6s steps(8) infinite;
}
@keyframes coinShine { to { background-position: -176px 0; } }
@media (prefers-reduced-motion: reduce) {
  .coin-pill .coin,
  .drawer__link .coin,
  .menu .coin { animation: none; }
}
.coin-pill__value { font-size: 15px; font-weight: 700; }

.bell { position: relative; }
.bell__dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue-mid);
  box-shadow: 0 0 0 2px var(--bg), 0 0 8px var(--blue-mid);
  animation: pulse 2.2s ease-in-out infinite;
}

/* ==========================================================
   Hero
   ========================================================== */
.hero { position: relative; padding: 10px 18px 0; }
.hero__art {
  position: absolute;
  top: -14px;
  right: -4px;
  width: 55%;
  max-width: 300px;
  aspect-ratio: 320 / 300;
  pointer-events: none;
  z-index: 0;
}

/* Pixel-art hero scene: 104x96 stage scaled by a whole number (--s, set in JS) */
.px-scene { position: absolute; inset: 0; --s: 2; }
.px-stage {
  position: absolute;
  top: 0;
  right: 0;
  width: calc(104px * var(--s));
  height: calc(96px * var(--s));
}
.px {
  position: absolute;
  left: calc(var(--x) * var(--s) * 1px);
  top: calc(var(--y) * var(--s) * 1px);
  width: calc(var(--w) * var(--s) * 1px);
  height: calc(var(--h) * var(--s) * 1px);
  background: no-repeat 0 0 / 100% 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}
/* Sprite strips: --f frames over --t seconds */
.px-stars, .px-castle, .px-portal, .px-cube, .px-spark {
  background-size: calc(var(--w) * var(--f) * var(--s) * 1px) 100%;
  animation: px-play var(--t) steps(var(--f)) infinite;
}
@keyframes px-play { to { background-position-x: calc(var(--w) * var(--f) * var(--s) * -1px); } }

.px-stars {
  background-image: url(../assets/pixel/anims/stars.png);
  transition: opacity .4s, filter .25s;
  pointer-events: auto;
  cursor: crosshair;
}
.px-stars.is-flare {
  animation-duration: .28s;
  filter: brightness(1.75) drop-shadow(0 0 calc(var(--s) * 2px) rgba(180, 220, 255, .55));
}
.px-moon { background-image: url(../assets/pixel/sprites/moon.png); animation: px-moon 6s ease-in-out infinite; }
.px-castle { background-image: url(../assets/pixel/anims/castle.png); }
.px-portal { background-image: url(../assets/pixel/anims/portal.png); transition: filter .3s; }
.px-portal { filter: hue-rotate(var(--accent-shift)); }
.px-portal.is-flash { filter: hue-rotate(var(--accent-shift)) brightness(1.8) saturate(1.3); }
.px-fx { filter: hue-rotate(var(--accent-shift)); }
.px-cloud i {
  position: absolute;
  inset: 0;
  background: no-repeat 0 0 / 100% 100%;
  animation: px-drift var(--dur, 9s) ease-in-out infinite alternate;
}
.px-cloud--a i { background-image: url(../assets/pixel/sprites/cloud_a.png); --dur: 11s; opacity: .85; }
.px-cloud--b i { background-image: url(../assets/pixel/sprites/cloud_b.png); --dur: 8s; opacity: .7; animation-direction: alternate-reverse; }
.px-cloud--c i { background-image: url(../assets/pixel/sprites/cloud_c.png); --dur: 13s; opacity: .9; }
[data-theme="light"] .px-stars { opacity: 0; }
[data-theme="light"] .px-moon { background-image: url(../assets/pixel/sprites/moon_light.png); }
[data-theme="light"] .px-castle { background-image: url(../assets/pixel/anims/castle_light.png); }
[data-theme="light"] .px-cloud--a i { background-image: url(../assets/pixel/sprites/cloud_a_light.png); }
[data-theme="light"] .px-cloud--b i { background-image: url(../assets/pixel/sprites/cloud_b_light.png); }
[data-theme="light"] .px-cloud--c i { background-image: url(../assets/pixel/sprites/cloud_c_light.png); }

.px-cube-wrap {
  pointer-events: auto;
  cursor: pointer;
  perspective: calc(var(--s) * 90px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.px-cube-wrap:focus-visible { outline-offset: 4px; }
.px-cube {
  position: absolute;
  inset: 0;
  background-image: url(../assets/pixel/anims/cube.png);
  background-repeat: no-repeat;
  image-rendering: pixelated;
  filter: hue-rotate(var(--accent-shift)) drop-shadow(0 0 calc(var(--s) * 3px) rgba(var(--a1-rgb), .7));
  will-change: transform;
}

/* Particles */
.px-fx { position: absolute; inset: 0; pointer-events: none; }
.px-mote {
  position: absolute;
  width: calc(var(--s) * 1px);
  height: calc(var(--s) * 1px);
  background: var(--c);
  box-shadow: 0 0 calc(var(--s) * 2px) var(--c);
  animation: px-mote var(--dur) linear forwards;
}
.px-spark {
  --w: 7; --h: 7; --f: 6;
  position: absolute;
  width: calc(7px * var(--s));
  height: calc(7px * var(--s));
  margin: calc(-3.5px * var(--s)) 0 0 calc(-3.5px * var(--s));
  background-image: url(../assets/pixel/anims/sparkle.png);
  background-repeat: no-repeat;
  image-rendering: pixelated;
  animation: px-play .5s steps(6) 1 forwards, px-fly var(--dur, .5s) ease-out forwards;
}
.px-shoot {
  position: absolute;
  width: calc(var(--s) * 12px);
  height: calc(var(--s) * 1px);
  margin: 0 0 0 calc(var(--s) * -6px);
  background: linear-gradient(90deg, transparent 0%, #ffffff 45%, #b4f0ff 100%);
  box-shadow: 0 0 calc(var(--s) * 2px) rgba(140, 220, 255, .8);
  transform-origin: left center;
  animation: px-shoot var(--dur, .55s) ease-out forwards;
  image-rendering: pixelated;
}
@keyframes px-mote {
  0% { opacity: 0; transform: none; }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(var(--dx) * var(--s) * 1px), calc(var(--dy) * var(--s) * 1px)); }
}
@keyframes px-fly { to { transform: translate(calc(var(--dx, 0) * var(--s) * 1px), calc(var(--dy, 0) * var(--s) * 1px)); } }
@keyframes px-shoot {
  0% { opacity: 0; transform: rotate(var(--rot, -32deg)) translate(0, 0) scaleX(.25); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--rot, -32deg)) translate(calc(var(--dx) * var(--s) * 1px), calc(var(--dy) * var(--s) * 1px)) scaleX(1.35); }
}
@keyframes px-drift { to { transform: translateX(calc(var(--s) * 8px)); } }
@keyframes px-moon { 50% { filter: brightness(1.12); } }

.hero__title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(25px, 7.2vw, 30px);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -.8px;
}
.hero__accent {
  position: relative;
  display: inline-block;
  background: linear-gradient(90deg, var(--blue-1) 0%, var(--blue-2) 60%, var(--blue-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__accent::after {
  content: "";
  position: absolute;
  left: 2%;
  right: -4%;
  bottom: -5px;
  height: 4px;
  border-radius: 50% / 100% 100% 0 0;
  border-top: 2.5px solid var(--blue-2);
  transform: rotate(-1.5deg);
  transform-origin: left;
  animation: swoosh .9s .5s var(--ease) both;
}
.hero__text {
  position: relative;
  z-index: 1;
  max-width: min(62%, 198px);
  margin: 16px 0 0;
  font-size: clamp(12px, 3.5vw, 13.6px);
  line-height: 1.58;
  color: var(--text-2);
}
.hero__cta {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1.13fr;
  gap: 13px;
  margin: 20px -3px 0;
}
/* Hero primary: flat pixel frame instead of the chunky 3D purple key */
.hero__cta .btn--primary {
  --edge: color-mix(in srgb, var(--blue-2) 70%, #fff);
  --face: color-mix(in srgb, var(--blue-3) 28%, transparent);
  --ink: #fff;
  --ledge: transparent;
  --lift: 0px; --lift-hover: 0px; --lift-press: 0px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hero__cta .btn--primary:hover {
  --edge: var(--blue-1);
  --face: color-mix(in srgb, var(--blue-2) 42%, transparent);
}
.hero__cta .btn--primary:active { transform: translateY(1px); }

/* Buttons — simple pixel blocks that follow the WizardXP pixel identity.
   One flat colour, 2px stair-step corners and (for solid buttons) a darker key strip along the bottom
   that sinks when pressed. Outline buttons are a flat 2px pixel frame. No glows, gradients or highlights.
   The button paints the frame and the key strip; ::before paints the face inside it. */
.btn {
  --edge: var(--card-border);                 /* frame */
  --face: transparent;                        /* fill */
  --ink: var(--text);                         /* label */
  --ledge: transparent;                       /* key strip */
  --lift: 0px; --lift-hover: 0px; --lift-press: 0px;
  --notch: polygon(0 4px, 2px 4px, 2px 2px, 4px 2px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px));
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  font-size: clamp(13px, 3.6vw, 14.5px);
  font-weight: 700;
  white-space: nowrap;
  color: var(--ink);
  background: linear-gradient(to top, var(--ledge) var(--lift), var(--edge) var(--lift));
  clip-path: var(--notch);
  overflow: hidden;
  transition: transform .08s linear;
}
.btn::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 2px 2px max(2px, var(--lift)) 2px;
  background: var(--face);
  transition: background-color .15s;
}
.btn:hover { --lift: var(--lift-hover); }
.btn:active { --lift: var(--lift-press); transform: translateY(calc(var(--lift-hover) - var(--lift-press))); }
.btn:focus-visible { outline: none; --edge: var(--blue-1); }

/* solid key */
.btn--primary {
  --edge: var(--blue-2); --face: var(--blue-2); --ink: #fff;
  --ledge: color-mix(in srgb, var(--blue-3) 72%, #000);
  --lift: 4px; --lift-hover: 4px; --lift-press: 1px;
}
.btn--primary:hover { --edge: color-mix(in srgb, var(--blue-2) 86%, #fff); --face: var(--edge); }
/* pixel frame */
.btn--outline {
  --edge: var(--outline-border); --face: var(--outline-bg); --ink: var(--outline-text);
}
.btn--outline:hover { --face: color-mix(in srgb, var(--outline-bg) 80%, var(--blue-2)); }
.btn--outline:active { transform: translateY(1px); }
.btn__discord { color: var(--discord); }

/* Hero Discord CTA: pixel Discord mark + animated pixel backdrop (no float) */
.btn--discord {
  --edge: #5865f2;
  --face: transparent;
  --ink: #fff;
  position: relative;
  gap: 10px;
  overflow: hidden;
  isolation: isolate;
}
.btn--discord::before {
  /* pixel spark field behind the label (125% height crops the sprite’s bottom bar) */
  content: "";
  position: absolute;
  z-index: -1;
  inset: 2px;
  background: url('/assets/ui/anims/discord_bg.png') 0 0 / 1200% 125% no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: discordBg 1.5s steps(12, jump-none) infinite;
}
.btn.btn--outline.btn--discord:hover {
  --edge: #5865f2; /* Discord blurple, not site purple */
  --face: color-mix(in srgb, #5865f2 18%, transparent);
  filter: brightness(1.06);
}
.btn--discord:active { transform: translateY(1px); }
.btn__discord-px {
  flex: none;
  width: 36px;
  height: 30px;
  background: url('/assets/ui/anims/discord_blink.png') 0 0 / 144px 30px no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: discordBlink 2.4s steps(4) infinite;
  filter: drop-shadow(0 2px 0 rgba(13, 8, 24, .55));
}
@keyframes discordBlink { to { background-position: -144px 0; } }
@keyframes discordBg { to { background-position: 100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .btn--discord::before,
  .btn__discord-px { animation: none; }
}

/* ==========================================================
   Action cards (Get Coins / Support)
   ========================================================== */
.actions {
  display: grid;
  grid-template-columns: 1fr 1.03fr;
  gap: 11px;
  margin: 16px var(--gutter) 0 calc(var(--gutter) - 3px);
}
.action-card {
  --px-card: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 88px;
  padding: 12px 10px 12px 12px;
  border-radius: 0;
  border: 0;
  clip-path: var(--px-card);
  color: #f2ecff;
  background-color: #170d2b;
  background-repeat: no-repeat;
  background-position: right center;
  background-size: auto 100%;
  image-rendering: pixelated;
  box-shadow: 0 4px 0 #0d0818;
  overflow: hidden;
  isolation: isolate;
  transition: transform .18s steps(3), filter .2s;
}
.action-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, #170d2b 0%, #170d2bcc 42%, transparent 78%);
  pointer-events: none;
}
.action-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  box-shadow: inset 0 0 0 2px #3f1c86, inset 0 0 0 3px #0d0818;
  pointer-events: none;
}
.action-card:hover { transform: translateY(-3px); filter: brightness(1.08); }
.action-card:active { transform: translateY(1px); box-shadow: 0 1px 0 #0d0818; }
/* animated pixel scene: 16-frame strip, one frame fills the card height, anchored right, fades in from the left */
.action-card__bg {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  aspect-ratio: 288 / 52;
  z-index: -2;
  background: 0 0 / 1600% 100% no-repeat;
  image-rendering: pixelated;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%);
  mask-image: linear-gradient(90deg, transparent, #000 22%);
  opacity: .7;
  animation: actionCardScene 2s steps(16, jump-none) infinite;
  pointer-events: none;
}
@keyframes actionCardScene { to { background-position: 100% 0; } }
.action-card--coins .action-card__bg { background-image: url('/assets/ui/anims/card_coins.png'); }
.action-card--share .action-card__bg { background-image: url('/assets/ui/anims/card_share.png'); }
@media (max-width: 599px) { .action-card__bg { top: auto; bottom: 0; height: 64%; } }
.action-card__art { flex: none; position: relative; z-index: 1; }
.action-card__coins.coin {
  --coin-s: 42px;
  width: var(--coin-s);
  height: var(--coin-s);
  background: url('/assets/coin/anims/coin_shine.png') 0 0 / calc(var(--coin-s) * 8) var(--coin-s) no-repeat;
  animation: coinShineCard 1.6s steps(8) infinite;
  filter: drop-shadow(0 3px 0 rgba(63, 28, 134, .55));
}
@keyframes coinShineCard { to { background-position: calc(var(--coin-s, 42px) * -8) 0; } }
@media (prefers-reduced-motion: reduce) {
  .action-card__coins.coin {
    animation: none;
    background: url('/assets/coin/sprites/coin.png') 0 0 / var(--coin-s) var(--coin-s) no-repeat;
  }
  .action-card { transition: none; }
  .action-card__bg { animation: none; }
}
button.action-card {
  width: 100%;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.action-card__share {
  width: 42px;
  height: 42px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 3px 0 rgba(63, 28, 134, .55));
}
.action-card__body { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; position: relative; z-index: 1; }
.action-card__title {
  font-size: clamp(13px, 3.75vw, 16px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.2px;
  text-shadow: 0 2px 0 #0d0818;
}
.action-card__text {
  font-size: clamp(9.5px, 2.75vw, 11.5px);
  line-height: 1.3;
  color: #c9b8e8;
  text-shadow: 0 1px 0 #0d0818;
}
.action-card__chev {
  width: 15px; height: 15px; margin-left: -4px;
  color: #d9b8ff; position: relative; z-index: 1;
  transition: transform .18s steps(2);
  filter: drop-shadow(0 2px 0 #0d0818);
}
.action-card:hover .action-card__chev { transform: translateX(3px); }

/* ==========================================================
   Section header
   ========================================================== */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px var(--gutter) 13px calc(var(--gutter) - 2px);
}
.section-head__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: clamp(16.5px, 4.7vw, 19px);
  font-weight: 700;
  letter-spacing: -.3px;
}
.section-head__icon { width: 24px; height: 24px; color: var(--accent-text); filter: drop-shadow(0 0 6px rgba(var(--a1-rgb), .4)); }
[data-theme="light"] .section-head__count span { color: var(--accent-text); }
.section-head__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-text);
  font-size: 13.5px;
  font-weight: 600;
}
.section-head__link .ic { transition: transform .25s var(--ease); width: 16px; height: 16px; }
.section-head__link:hover .ic { transform: translateX(4px); }

/* ==========================================================
   Game card
   ========================================================== */
.game-list { display: grid; gap: 14px; margin: 0 var(--gutter) 0 calc(var(--gutter) - 3px); }
.game-card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 140px;
  padding: 11px 10px 12px 15px;
  border-radius: 6px;
  border: 1.5px solid var(--game-border);
  box-shadow: var(--game-glow);
  overflow: hidden;
  transition: transform .3s var(--ease), box-shadow .35s var(--ease);
}
.game-card:hover { transform: translateY(-3px); box-shadow: var(--game-glow-hover); }
.game-card__banner {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
  transition: transform .6s var(--ease);
}
.game-card:hover .game-card__banner { transform: scale(1.04); }
.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--game-overlay);
}
.badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 9px 0 8px;
  border-radius: 999px;
  background: var(--gold-grad);
  color: #1a1405;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .2px;
  box-shadow: 0 2px 8px rgba(245, 180, 0, .35);
}
.badge .ic { width: 12px; height: 12px; }
.game-card__content {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  column-gap: 8px;
}
.game-card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 7px;
  font-size: clamp(19px, 5.5vw, 22px);
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
[data-theme="light"] .game-card__title { text-shadow: none; }
.game-card__logo { width: 28px; height: 28px; flex: none; }
.game-card__logo--compass { color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 21px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 11px;
  font-weight: 500;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  --pad-cut: var(--tag-bg);
}
.tag .ic { width: 14px; height: 14px; }
.stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
}
.stats__item { display: inline-flex; align-items: center; gap: 5px; }
.stats__item .ic { width: 15px; height: 15px; }
.stats__star { color: var(--star); filter: drop-shadow(0 0 3px rgba(255, 180, 30, .5)); }
.stats__sep { width: 1px; height: 11px; background: var(--divider); transform: skewX(-12deg); }
.btn--play {
  height: 34px;
  min-width: 104px;
  margin-bottom: 15px;
  padding: 0 14px;
  gap: 8px;
  font-size: 12.5px;
}
.btn--play .ic { width: 15px; height: 15px; }

/* ==========================================================
   Bottom navigation
   ========================================================== */
.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: 470px;
  height: 60px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  padding: 0 6px;
  border-radius: 16px;
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  box-shadow: var(--nav-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: navIn .7s .35s var(--ease) both;
}
.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 48px;
  margin: 0;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--nav-text);
  font-size: 11px;
  font-weight: 500;
  transition: background .2s var(--ease), color .2s, transform .15s var(--ease);
}
.nav-item:active { transform: scale(.96); }
.nav-item__icon { color: var(--nav-icon); width: 22px; height: 22px; transition: color .2s; }
.nav-item.is-active { background: var(--nav-active-bg); border-color: transparent; }
.nav-item.is-active .nav-item__icon { color: var(--blue-2); --icon-fill: url(#g-brand); }
.nav-item__badge-wrap { position: relative; display: inline-flex; }
.nav-item__badge {
  position: absolute;
  top: -4px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue-2);
}
.nav-item__badge::before {
  content: "";
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: -3.5px 0 #fff, 3.5px 0 #fff;
}
.nav-avatar {
  justify-self: center;
  position: relative;
  width: 48px;
  height: 48px;
  margin-top: -4px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--blue-mid), 0 0 0 4px var(--bg);
  transition: transform .2s var(--ease);
}
.nav-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.nav-avatar::after { content: none; display: none; }
.nav-avatar:hover { transform: translateY(-1px); }

/* ==========================================================
   Drawer
   ========================================================== */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .3s;
}
.scrim.is-open { opacity: 1; }
.drawer {
  position: fixed;
  z-index: 50;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(280px, 80vw);
  padding: calc(env(safe-area-inset-top) + 22px) 18px 24px;
  background: var(--drawer-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 10px 0 40px rgba(0, 0, 0, .35);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform .35s var(--ease), visibility 0s .35s;
}
.drawer.is-open { transform: none; visibility: visible; transition: transform .35s var(--ease); }
.drawer > * {
  opacity: 0;
  transform: translateX(-14px);
  transition: opacity .28s var(--ease), transform .32s var(--ease);
}
.drawer.is-open > * {
  opacity: 1;
  transform: none;
}
.drawer.is-open > *:nth-child(1) { transition-delay: .04s; }
.drawer.is-open > *:nth-child(2) { transition-delay: .08s; }
.drawer.is-open > *:nth-child(3) { transition-delay: .12s; }
.drawer.is-open > *:nth-child(4) { transition-delay: .16s; }
.drawer.is-open > *:nth-child(5) { transition-delay: .2s; }
.drawer.is-open > *:nth-child(6) { transition-delay: .24s; }
.drawer.is-open > *:nth-child(7) { transition-delay: .28s; }
.drawer.is-open > *:nth-child(8) { transition-delay: .32s; }
.drawer.is-open > *:nth-child(9) { transition-delay: .36s; }
.drawer.is-open > *:nth-child(10) { transition-delay: .4s; }
.drawer.is-open > *:nth-child(n+11) { transition-delay: .44s; }
.drawer__head { display: flex; align-items: center; gap: 6px; margin-bottom: 18px; min-width: 0; }
.drawer__head .brand { min-width: 0; }
.drawer__head .brand__mark { width: 32px; height: 32px; }
.drawer__head .brand__word { width: 104px; }
.drawer__link { padding: 12px 10px; border-radius: 10px; font-weight: 600; }
.drawer__link:hover { background: rgba(127, 160, 220, .12); }
.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 12px 10px;
  border-top: 1px solid var(--card-border);
  font-weight: 600;
  cursor: pointer;
}
.menu-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 24px;
  border-radius: 0;
  background: url('/assets/ui/sprites/switch_track_off.png') center / 100% 100% no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 2px 0 rgba(23, 13, 43, .45));
  transition: background-image .01s linear .1s;
}
.switch::after { content: none; }
.switch__knob {
  /* 10x10 knob art at 2x; slightly bigger than the track so the sun/moon read clearly */
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: url('/assets/ui/sprites/switch_knob_sun.png') center / 100% 100% no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition:
    transform .22s steps(5),
    background-image .01s linear .1s;
  will-change: transform;
}
/* On = dark theme. One rule for every slider on the site (header button, menu toggle, ...). */
:root[data-theme="dark"] .switch {
  background-image: url('/assets/ui/sprites/switch_track_on.png');
  transition: background-image .01s linear .05s;
}
:root[data-theme="dark"] .switch__knob {
  transform: translateX(20px);
  background-image: url('/assets/ui/sprites/switch_knob_moon.png');
}
.menu-toggle input:focus-visible + .switch { outline: 2px solid var(--blue-2); outline-offset: 3px; outline-style: dashed; }
@media (prefers-reduced-motion: reduce) {
  .switch,
  .switch__knob { transition: none; }
}
/* Theme switch spell (js/shell.js switchTheme): the new theme is revealed by a wave spreading from the
   switch; .spell draws the glowing wave front and pixel sparkles on top. --vt-x/--vt-y/--vt-r are set
   just before the switch. Wave and ring share duration and linear timing so the glow rides the edge. */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: themeReveal .9s linear both; }
@keyframes themeReveal {
  from { clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0)); }
  to { clip-path: circle(var(--vt-r, 150%) at var(--vt-x, 100%) var(--vt-y, 0)); }
}
.spell { position: fixed; inset: 0; z-index: 9999; pointer-events: none; overflow: hidden; view-transition-name: spell; }
::view-transition-old(spell),
::view-transition-new(spell) { animation: none; mix-blend-mode: normal; }
/* keeps the transition open until the last sparkles finish */
::view-transition-group(spell) { animation: spellHold 1.35s linear both; }
@keyframes spellHold { from { opacity: 1; } to { opacity: 1; } }
/* The ring is a small 400px disc painted once (a radial gradient, no blur filters) and stretched by the
   GPU up to the wave size (--vt-k, set in JS), so no frame has to repaint a screen-sized glow. */
.spell__ring {
  position: absolute;
  left: var(--vt-x); top: var(--vt-y);
  width: 400px; height: 400px;
  margin: -200px 0 0 -200px;
  border-radius: 50%;
  transform: scale(0);
  will-change: transform, opacity;
  background: radial-gradient(closest-side,
    transparent 78%,
    rgba(155, 92, 255, .28) 88%,
    rgba(205, 110, 255, .8) 95.5%,
    #f3d4ff 97%,
    rgba(205, 110, 255, .55) 98.5%,
    transparent 100%);
}
.spell.is-cast .spell__ring { animation: spellRing .9s linear both; }
@keyframes spellRing {
  from { transform: scale(0); opacity: 1; }
  80% { opacity: 1; }
  to { transform: scale(var(--vt-k, 4)); opacity: 0; }
}
.spell__spark {
  position: absolute;
  width: var(--size); height: var(--size);
  margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2);
  background: url('/assets/scenery/sprites/spark.png') center / 100% 100% no-repeat;
  image-rendering: pixelated;
  will-change: scale, opacity;
  opacity: 0;
}
.spell.is-cast .spell__spark { animation: spellSpark .45s steps(6) var(--delay) both; }
@keyframes spellSpark {
  0% { opacity: 0; scale: 0; }
  35% { opacity: 1; scale: 1.25; }
  65% { opacity: 1; scale: .9; }
  100% { opacity: 0; scale: 0; }
}

/* ==========================================================
   Animations
   ========================================================== */
.reveal { animation: fadeUp .7s var(--d, 0s) var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes navIn { from { opacity: 0; transform: translate(-50%, 30px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: .75; } }
@keyframes beat { 0%, 70%, 100% { transform: scale(1); } 78% { transform: scale(1.1); } 86% { transform: scale(.97); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes swoosh { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 359px) {
  .header { gap: 8px; padding-inline: 12px; }
  .brand__mark { width: 24px; height: 24px; }
  .brand__word { width: 78px; }
  .header__right { gap: 8px; }
  .hero { padding-inline: 12px; }
  .btn { gap: 6px; }
  .actions { grid-template-columns: 1fr; }
}

@media (min-width: 768px) {
  .app { max-width: 1080px; padding-inline: 24px; }
  .header { padding-inline: 8px; height: 72px; }
  .hero { padding: 36px 8px 0; min-height: 360px; }
  .hero__art { width: 46%; max-width: 460px; top: -10px; right: 2%; }
  .hero__title { font-size: clamp(44px, 5.4vw, 60px); letter-spacing: -1.5px; }
  .hero__accent::after { bottom: -8px; border-top-width: 4px; }
  .hero__text { max-width: 470px; font-size: 17px; margin-top: 24px; }
  .hero__cta { grid-template-columns: auto auto; justify-content: start; gap: 16px; margin: 32px 0 0; }
  .hero__cta .btn { height: 48px; padding: 0 26px; font-size: 16px; }
  .actions { grid-template-columns: 1fr 1fr; gap: 18px; margin: 44px 0 0; }
  .action-card { min-height: 104px; padding: 16px 18px; gap: 16px; }
  .action-card__share { width: 60px; height: 60px; }
  .action-card__coins.coin { --coin-s: 60px; }
  .action-card__title { font-size: 19px; }
  .action-card__text { font-size: 13.5px; }
  .section-head { margin: 40px 0 18px; }
  .section-head__title { font-size: 24px; }
  .game-list { grid-template-columns: 1fr 1fr; gap: 20px; margin: 0; }
  .game-card { min-height: 190px; padding: 16px 16px 16px 20px; }
  .btn--play { height: 40px; padding: 0 20px; font-size: 14px; }
  .bottom-nav { max-width: 520px; }
}
