/* =====================================================================
   Twinkle Land — design system
   Sky archipelago · candy-glass UI · Persian-first (RTL)
   ===================================================================== */

/* ---------- 1. Fonts (all local, no CDN) ---------- */
@font-face {
  font-family: "VazirRD";
  src: url("../fonts/vazirmatn-rd-nl-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Lalezar";
  src: url("../fonts/lalezar-arabic-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka-latin-500.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka-latin-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka-latin-700.woff2") format("woff2");
  font-weight: 700 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}

/* ---------- 2. Tokens ---------- */
:root {
  --ink: #3B2257;          /* twilight plum: all text */
  --ink-soft: #77609A;
  --ink-faint: #A898C2;
  --candy: #FF6FAE;        /* cotton candy: primary actions */
  --candy-deep: #E2448C;
  --candy-edge: #B92F6E;
  --lilac: #B79CFF;        /* lilac mist: secondary */
  --lilac-deep: #8B6CF0;
  --lilac-edge: #6A4BD0;
  --mint: #4FDDBB;         /* mint fizz: success / go */
  --mint-deep: #23B392;
  --mint-edge: #158A70;
  --butter: #FFD45E;       /* butter star: coins, highlights */
  --butter-deep: #F4AE2E;
  --butter-edge: #C9831A;
  --cloud: #FFFFFF;
  --cloud-tint: #F7F2FF;
  --field: #F4EEFF;
  --danger: #F0507E;

  --font-body: "VazirRD", "Fredoka", Tahoma, "Segoe UI", sans-serif;
  --font-display: "Lalezar", "Fredoka", "VazirRD", Tahoma, sans-serif;
  --font-latin: "Fredoka", "VazirRD", sans-serif;

  --r-xl: 36px;
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --r-pill: 999px;

  --lift: 0 18px 40px -14px rgba(84, 48, 160, .45);
  --lift-sm: 0 10px 22px -10px rgba(84, 48, 160, .45);
  --ring: 0 0 0 4px rgba(183, 156, 255, .55);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- 3. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.9;
  color: var(--ink);
  background: linear-gradient(180deg, #9DB6FF 0%, #BCA9FF 34%, #F7B6DD 70%, #FFDDC4 100%) fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--lilac-edge); text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover { color: var(--candy-deep); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 12px; }
[hidden] { display: none !important; }
.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; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.icon { width: 1.25em; height: 1.25em; flex: none; display: inline-block; vertical-align: -0.22em; }

#sky {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
}

/* ---------- 4. Typography ---------- */
h1, h2, h3, .title-xl, .title-lg, .title-md, .title-sm {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.35;
  margin: 0 0 .4em;
  color: var(--ink);
}
.title-xl { font-size: clamp(2.2rem, 5.5vw, 3.6rem); }
.title-lg { font-size: clamp(1.8rem, 4vw, 2.5rem); }
.title-md { font-size: 1.75rem; }
.title-sm { font-size: 1.2rem; color: var(--lilac-edge); margin-top: 1.2em; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-soft); }
small { font-size: .82em; }

/* Sticker logo */
.logo {
  --logo-size: 3.2rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: .1em;
  text-decoration: none;
  line-height: 1;
  user-select: none;
  position: relative;
}
.logo-sm { --logo-size: 1.7rem; }
.logo-md { --logo-size: 2.4rem; }
.logo-xl { --logo-size: clamp(3.4rem, 10vw, 6.4rem); }
.logo-en {
  position: relative;
  direction: ltr;
  font-family: var(--font-latin);
  font-weight: 700;
  font-size: var(--logo-size);
  letter-spacing: -.01em;
  white-space: nowrap;
  color: #FF6FAE;
  background: linear-gradient(180deg, #FF8CC6 0%, #FF4FA3 48%, #A250F0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  padding: 0 .08em;
}
.logo-en::before, .logo-en::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  padding: inherit;
  background: none;
}
/* sticker: white inner outline + plum outer outline */
.logo-en::before { z-index: -1; -webkit-text-fill-color: #fff; -webkit-text-stroke: .16em #fff; }
.logo-en::after {
  z-index: -2;
  -webkit-text-fill-color: #6A3FC8;
  -webkit-text-stroke: .3em #6A3FC8;
  filter: drop-shadow(0 .07em 0 #4A2B9A) drop-shadow(0 .2em .28em rgba(74, 43, 154, .35));
}
.logo-star {
  position: absolute;
  top: calc(var(--logo-size) * -.2);
  right: calc(var(--logo-size) * -.34);
  width: calc(var(--logo-size) * .6);
  height: calc(var(--logo-size) * .6);
  color: var(--butter);
  filter: drop-shadow(0 0 .12em #fff) drop-shadow(0 .05em 0 var(--butter-edge));
  animation: twinkle 2.6s ease-in-out infinite;
}
.logo-fa {
  font-family: var(--font-display);
  font-size: calc(var(--logo-size) * .42);
  color: #5B35B5;
  text-shadow: 0 2px 0 #fff, 0 -2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff, 2px 2px 0 #fff, -2px 2px 0 #fff, 0 6px 14px rgba(84, 48, 160, .3);
  margin-top: .05em;
}
@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(.72) rotate(18deg); opacity: .75; }
}

/* ---------- 5. Buttons ---------- */
.btn {
  --c1: var(--candy);
  --c2: var(--candy-deep);
  --edge: var(--candy-edge);
  --tx: #fff;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  min-height: 52px;
  padding: .3em 1.5em .4em;
  border: 0;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1.2;
  color: var(--tx);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c1) 70%, #fff) 0%, var(--c1) 48%, var(--c2) 100%);
  box-shadow: 0 6px 0 var(--edge), 0 16px 22px -10px color-mix(in srgb, var(--edge) 70%, transparent), inset 0 -3px 0 rgba(0, 0, 0, .06);
  text-shadow: 0 2px 0 color-mix(in srgb, var(--edge) 55%, transparent);
  transform: translateY(0);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn::before {
  content: "";
  position: absolute;
  inset: 5px 14% auto;
  height: 38%;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, .75), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn:hover { color: var(--tx); transform: translateY(-2px); filter: brightness(1.04) saturate(1.06); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--edge), 0 6px 12px -8px color-mix(in srgb, var(--edge) 70%, transparent), inset 0 -2px 0 rgba(0, 0, 0, .06); }
.btn:focus-visible { box-shadow: 0 6px 0 var(--edge), var(--ring); border-radius: var(--r-pill); }
.btn[disabled], .btn.is-disabled { filter: grayscale(.65) opacity(.6); cursor: not-allowed; transform: none; }
.btn .icon { width: 1.15em; height: 1.15em; filter: drop-shadow(0 2px 0 color-mix(in srgb, var(--edge) 50%, transparent)); }

.btn-mint { --c1: var(--mint); --c2: var(--mint-deep); --edge: var(--mint-edge); }
.btn-lilac { --c1: var(--lilac); --c2: var(--lilac-deep); --edge: var(--lilac-edge); }
.btn-butter { --c1: var(--butter); --c2: var(--butter-deep); --edge: var(--butter-edge); --tx: #5A3410; }
.btn-ghost {
  --edge: #D9CCF6;
  --tx: var(--ink);
  background: linear-gradient(180deg, #fff 0%, #F6F1FF 100%);
  text-shadow: none;
}
.btn-ghost:hover { --tx: var(--lilac-edge); }
.btn-sm { min-height: 42px; font-size: 1rem; padding: .2em 1.1em .3em; }
.btn-lg { min-height: 58px; font-size: 1.3rem; }
.btn-xl { min-height: 66px; font-size: 1.5rem; padding-inline: 2em; }
.btn-block { width: 100%; }
.btn-icon { min-height: 48px; width: 48px; padding: 0; }
.btn-icon.btn-sm { width: 42px; }
.btn.is-busy { color: transparent; text-shadow: none; pointer-events: none; }
.btn.is-busy .icon { opacity: 0; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .5);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-ghost.is-busy::after, .btn-butter.is-busy::after { border-color: rgba(59, 34, 87, .25); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--lilac-edge);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* ---------- 6. Forms ---------- */
.form-stack { display: grid; gap: 1.05rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.05rem; }
.field { display: grid; gap: .35rem; }
.field > label { font-weight: 700; font-size: .95rem; }
.field-box { position: relative; display: flex; align-items: center; }
.field-box input {
  width: 100%;
  min-height: 54px;
  padding: .55rem 3rem .55rem 1rem;
  border: 2.5px solid transparent;
  border-radius: var(--r-md);
  background: var(--field);
  box-shadow: inset 0 3px 0 rgba(84, 48, 160, .07);
  font-size: 1.02rem;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field-box input[dir="ltr"] { text-align: left; font-family: var(--font-latin); }
.field-box input[dir="ltr"]::placeholder { text-align: right; font-family: var(--font-body); }
.field-box input:hover { background: #EFE6FF; }
.field-box input:focus { outline: none; border-color: var(--lilac); background: #fff; box-shadow: var(--ring); }
.field-icon { position: absolute; inset-inline-start: 1rem; color: var(--lilac-deep); pointer-events: none; }
.field-eye {
  position: absolute;
  inset-inline-end: .5rem;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.field-eye:hover { background: rgba(183, 156, 255, .2); color: var(--lilac-edge); }
.field-box input[type="password"], .field-box input[data-has-eye] { padding-inline-end: 3.2rem; }
.field-hint { margin: 0; font-size: .84rem; color: var(--ink-soft); line-height: 1.7; }
.field-error { margin: 0; font-size: .86rem; color: var(--danger); font-weight: 700; line-height: 1.7; }
.field.has-error .field-box input { border-color: #FF9EBB; background: #FFF2F6; }
.hp { position: absolute !important; inset-inline-start: -10000px; width: 1px; height: 1px; overflow: hidden; }

.check {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--field);
  box-shadow: inset 0 2px 0 rgba(84, 48, 160, .1);
  display: grid;
  place-items: center;
  color: transparent;
  transition: background .15s, transform .15s;
}
.check input:checked + .check-box { background: var(--mint); color: #fff; transform: rotate(-6deg) scale(1.05); box-shadow: 0 3px 0 var(--mint-edge); }
.check input:focus-visible + .check-box { box-shadow: var(--ring); }

.switch { display: inline-flex; align-items: center; gap: .7rem; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative;
  width: 58px;
  height: 32px;
  border-radius: var(--r-pill);
  background: #E4DAF8;
  box-shadow: inset 0 2px 0 rgba(84, 48, 160, .12);
  transition: background .2s;
  flex: none;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  inset-inline-start: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 6px rgba(84, 48, 160, .3);
  transition: inset-inline-start .2s cubic-bezier(.3, 1.6, .5, 1);
}
.switch input:checked + .switch-track { background: var(--candy); }
.switch input:checked + .switch-track::after { inset-inline-start: 30px; }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

.meter { display: flex; gap: 5px; margin-top: .35rem; }
.meter span { flex: 1; height: 7px; border-radius: 9px; background: #E9E1F8; transition: background .2s; }
.meter[data-level="1"] span:nth-child(-n+1) { background: #FF8DAF; }
.meter[data-level="2"] span:nth-child(-n+2) { background: var(--butter); }
.meter[data-level="3"] span:nth-child(-n+3) { background: #8FE3C9; }
.meter[data-level="4"] span:nth-child(-n+4) { background: var(--mint-deep); }

/* ---------- 7. Cloud card, alerts, lists ---------- */
.page-center {
  display: grid;
  place-items: center;
  padding: calc(4.5rem + var(--safe-top)) 1rem calc(2.5rem + var(--safe-bottom));
}
.cloud-card {
  position: relative;
  width: min(100%, 460px);
  padding: 2.6rem clamp(1.3rem, 4vw, 2.4rem) 2.2rem;
  border-radius: var(--r-xl);
  background: var(--cloud);
  filter: drop-shadow(0 20px 30px rgba(84, 48, 160, .28));
  animation: card-in .55s cubic-bezier(.2, 1.4, .4, 1) both;
}
.cloud-card.wide { width: min(100%, 720px); }
.cloud-card.narrow { width: min(100%, 420px); text-align: center; }
/* the cloud bumps that sit on the top edge */
.cloud-card::before {
  content: "";
  position: absolute;
  top: -50px;
  left: 50%;
  width: 290px;
  height: 100px;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 21% 74%, var(--cloud) 36px, transparent 37px),
    radial-gradient(circle at 50% 52%, var(--cloud) 50px, transparent 51px),
    radial-gradient(circle at 79% 72%, var(--cloud) 38px, transparent 39px);
  pointer-events: none;
}
.cloud-badge {
  position: absolute;
  top: -40px;
  left: 50%;
  width: 64px;
  height: 64px;
  transform: translateX(-50%) rotate(-6deg);
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(180deg, #FFA0CB, var(--candy));
  color: #fff;
  font-family: var(--font-display);
  font-size: 2rem;
  box-shadow: 0 5px 0 var(--candy-edge);
  z-index: 1;
}
.cloud-badge .icon { width: 34px; height: 34px; }
.cloud-card > .logo { display: flex; margin: .2rem auto 1rem; width: max-content; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to { opacity: 1; transform: none; }
}

.alert {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  padding: .8rem 1rem;
  border-radius: var(--r-md);
  font-weight: 600;
  line-height: 1.8;
  margin-bottom: 1rem;
}
.alert .icon { margin-top: .25em; }
.alert-error { background: #FFE8EF; color: #B5245A; }
.alert-success { background: #E2FBF3; color: #11735C; }
.alert-info { background: #EFE8FF; color: var(--lilac-edge); }

.checklist { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .35rem; }
.checklist li { display: flex; gap: .55rem; align-items: flex-start; font-weight: 600; }
.checklist li .icon { margin-top: .3em; }
.checklist li.ok .icon { color: var(--mint-deep); }
.checklist li.bad { color: #B5245A; }
.checklist small { display: block; font-weight: 400; color: var(--ink-soft); }

.actions-row { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: 1.2rem; }
.auth-foot { margin: 1.4rem 0 0; text-align: center; color: var(--ink-soft); }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.auth-title { text-align: center; }
.auth-sub { text-align: center; margin-top: -.3rem; }
.error-detail { white-space: pre-wrap; direction: ltr; text-align: left; background: var(--cloud-tint); padding: .8rem; border-radius: 12px; font-size: .8rem; }

/* ---------- 8. Toasts & modal ---------- */
.toasts {
  position: fixed;
  top: calc(.9rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: .5rem;
  width: min(92vw, 440px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem 1.1rem .7rem;
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.6;
  box-shadow: 0 5px 0 #DCCFF7, var(--lift-sm);
  pointer-events: auto;
  animation: toast-in .45s cubic-bezier(.2, 1.5, .4, 1) both;
}
.toast .toast-dot { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; background: var(--lilac-deep); }
.toast .toast-dot .icon { width: 18px; height: 18px; }
.toast.success .toast-dot { background: var(--mint-deep); }
.toast.error .toast-dot { background: var(--candy-deep); }
.toast.leaving { animation: toast-out .3s ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px) scale(.95); } }

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 4.5rem 1rem 1.5rem;
  background: rgba(59, 34, 87, .35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in .2s ease both;
}
.modal .cloud-card { width: min(100%, 440px); }
.modal-close { position: absolute; top: 1rem; inset-inline-end: 1rem; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* DOM sparkles (button feedback) */
.spark {
  position: fixed;
  z-index: 120;
  width: 14px;
  height: 14px;
  pointer-events: none;
  color: var(--butter);
  animation: spark-fly .7s cubic-bezier(.2, .8, .3, 1) forwards;
}
@keyframes spark-fly {
  from { transform: translate(-50%, -50%) scale(.4) rotate(0); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(160deg); opacity: 0; }
}

/* ---------- 9. Landing ---------- */
.landing {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  justify-items: center;
  padding: calc(1.6rem + var(--safe-top)) 1rem calc(1.4rem + var(--safe-bottom));
  text-align: center;
}
.landing-head { display: grid; justify-items: center; gap: .6rem; animation: drop-in .9s cubic-bezier(.2, 1.5, .4, 1) both; }
.landing-tag {
  max-width: 34ch;
  margin: .4rem auto 0;
  font-size: clamp(1.02rem, 2.4vw, 1.2rem);
  font-weight: 600;
  color: var(--ink);
  font-weight: 700;
  text-shadow: 0 0 14px rgba(255, 255, 255, .95), 0 1px 0 rgba(255, 255, 255, .8);
}
/* full-bleed so 3D clouds leave at the screen edge, not at a hard canvas edge */
.hero-stage {
  position: relative;
  width: 100vw;
  height: clamp(340px, 54vh, 600px);
  margin: -.5rem 0 0;
}
.hero-stage canvas { width: 100%; height: 100%; }
.hero-fallback { position: absolute; inset: 0; display: grid; place-items: center; }
.hero-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-top: -.6rem; position: relative; z-index: 2; }
.hero-facts {
  list-style: none;
  text-shadow: 0 2px 8px rgba(84, 48, 160, .6);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .6rem 1.4rem;
  padding: 0;
  margin: 1.6rem 0 0;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(84, 48, 160, .5);
}
.hero-facts li { display: inline-flex; align-items: center; gap: .45rem; }
.hero-facts .icon { color: var(--butter); filter: drop-shadow(0 2px 0 rgba(84, 48, 160, .35)); }
.landing-foot { margin-top: 1.4rem; font-size: .85rem; color: rgba(255, 255, 255, .85); }
@keyframes drop-in { from { opacity: 0; transform: translateY(-40px) scale(.9); } to { opacity: 1; transform: none; } }

/* ---------- 10. Character maker ---------- */
.page-maker { overflow: hidden; }
.maker {
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  height: 100vh;
  height: 100dvh;
}
.maker-panel {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  margin: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--lift);
  overflow: hidden;
}
.maker-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.4rem .4rem; }
.maker-head h1 { margin: 0; font-size: 1.65rem; }
.maker-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .35rem;
  padding: .4rem 1rem .8rem;
}
.maker-tab {
  display: grid;
  justify-items: center;
  gap: .1rem;
  padding: .55rem .2rem .45rem;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.maker-tab .icon { width: 26px; height: 26px; }
.maker-tab:hover { background: var(--cloud-tint); color: var(--ink); }
.maker-tab[aria-selected="true"] { background: #FFE6F2; color: var(--candy-deep); transform: translateY(-2px); box-shadow: 0 4px 0 #FFC2DD; }
.maker-body { overflow-y: auto; padding: .2rem 1.4rem 1.2rem; overscroll-behavior: contain; }
.maker-section { margin-bottom: 1.3rem; }
.maker-section h2 { font-size: 1.08rem; margin: 0 0 .6rem; color: var(--ink); }
.maker-section .note { font-size: .85rem; color: var(--ink-soft); margin: -.3rem 0 .7rem; line-height: 1.7; }
.maker-foot { padding: 1rem 1.4rem 1.3rem; background: var(--cloud-tint); display: grid; gap: .85rem; }

.gender-pick { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.gender-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: .2rem;
  padding: .5rem .5rem .7rem;
  border: 3px solid transparent;
  border-radius: var(--r-lg);
  background: var(--cloud-tint);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1.15rem;
  transition: transform .15s, border-color .15s, background .15s;
}
.gender-card img { width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #fff, #EDE4FF); }
.gender-card .icon { position: absolute; top: .55rem; inset-inline-start: .65rem; color: var(--ink-faint); }
.gender-card:hover { transform: translateY(-2px); }
.gender-card[aria-checked="true"] { border-color: var(--candy); background: #FFF0F7; }
.gender-card[aria-checked="true"] .icon { color: var(--candy-deep); }

.swatches { display: flex; flex-wrap: wrap; gap: .55rem; }
.swatch {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: var(--sw);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12), inset 0 4px 0 rgba(255, 255, 255, .35), 0 3px 0 rgba(84, 48, 160, .18);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1);
}
.swatch:hover { transform: translateY(-3px) scale(1.06); }
.swatch[aria-checked="true"] { transform: scale(1.12); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12), 0 0 0 4px #fff, 0 0 0 7px var(--candy); }
.swatch-duo { background: linear-gradient(135deg, var(--sw) 50%, var(--sw2) 50%); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .55rem; }
.tile {
  display: grid;
  justify-items: center;
  gap: .1rem;
  padding: .3rem .2rem .45rem;
  border: 3px solid transparent;
  border-radius: var(--r-md);
  background: var(--cloud-tint);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink-soft);
  transition: transform .15s, border-color .15s;
}
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: radial-gradient(circle at 50% 35%, #fff, #EDE4FF); }
.tile:hover { transform: translateY(-2px); }
.tile[aria-checked="true"] { border-color: var(--candy); color: var(--candy-deep); background: #FFF0F7; }
.tile .ph { width: 100%; aspect-ratio: 1; border-radius: 14px; background: linear-gradient(110deg, #EFE7FF 30%, #FBF8FF 50%, #EFE7FF 70%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.maker-stage { position: relative; min-width: 0; }
.maker-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.maker-stage canvas:active { cursor: grabbing; }
.stage-hint {
  position: absolute;
  top: calc(1.2rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .9rem .35rem;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .7);
  font-size: .85rem;
  font-weight: 700;
  color: var(--ink-soft);
  pointer-events: none;
  transition: opacity .6s;
}
.stage-name {
  position: absolute;
  top: calc(3.6rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  color: #fff;
  text-shadow: 0 3px 0 #9468E6, 0 6px 18px rgba(84, 48, 160, .45);
  white-space: nowrap;
  pointer-events: none;
}
.stage-actions {
  position: absolute;
  bottom: calc(1.4rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .7rem;
}
.maker-stage > canvas { z-index: 0; }
.maker-stage > .stage-hint, .maker-stage > .stage-name, .maker-stage > .stage-actions, .maker-stage > .body-preview { z-index: 2; }
.body-preview {
  position: absolute;
  bottom: calc(1.4rem + var(--safe-bottom));
  inset-inline-end: 1.4rem;
  width: 272px;
  padding: .9rem 1rem 1rem;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--lift-sm);
}
.body-preview h2 { font-size: 1.05rem; margin: 0 0 .1rem; }
.body-preview p { font-size: .78rem; line-height: 1.7; color: var(--ink-soft); margin: 0 0 .5rem; }
.slider-row { display: grid; grid-template-columns: 3.4rem 1fr; align-items: center; gap: .5rem; font-weight: 700; font-size: .9rem; }
.slider-row + .slider-row { margin-top: .35rem; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 10px; border-radius: 9px; background: linear-gradient(90deg, #FFD3E8, #C9B3FF); }
input[type="range"]::-moz-range-track { height: 10px; border-radius: 9px; background: linear-gradient(90deg, #FFD3E8, #C9B3FF); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -7px; border-radius: 50%; background: #fff; border: 4px solid var(--candy); box-shadow: 0 2px 0 var(--candy-edge); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--candy); box-shadow: 0 2px 0 var(--candy-edge); }
input[type="range"]:focus-visible { box-shadow: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }

/* ---------- 11. Lobby ---------- */
.page-lobby { padding-bottom: 3rem; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(.6rem + var(--safe-top)) clamp(1rem, 3vw, 2rem) .6rem;
}
.topbar .logo { --logo-size: 1.55rem; }
.player-chip {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .3rem .4rem .3rem 1rem;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--lift-sm);
}
.avatar {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #fff, #E9DEFF);
  box-shadow: 0 0 0 3px #fff, 0 3px 0 4px #E2D5FA;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.level-badge {
  position: absolute;
  bottom: -6px;
  inset-inline-start: -6px;
  min-width: 24px;
  height: 24px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--butter);
  color: #5A3410;
  font-size: .8rem;
  font-weight: 800;
  box-shadow: 0 2px 0 var(--butter-edge);
}
.player-chip-wrap { position: relative; }
.player-meta { display: grid; line-height: 1.35; }
.player-meta strong { font-family: var(--font-display); font-weight: 400; font-size: 1.1rem; }
.coins { display: inline-flex; align-items: center; gap: .3rem; font-weight: 800; color: #9A6212; font-size: .92rem; }
.coins .icon { color: var(--butter-deep); width: 1.1em; height: 1.1em; }
.topbar-actions { display: flex; gap: .6rem; align-items: center; }
.topbar-actions form { margin: 0; }

.lobby { width: min(100% - 2rem, 1180px); margin: 1rem auto 0; }
.lobby-hero {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1.2rem;
  align-items: stretch;
  animation: card-in .6s cubic-bezier(.2, 1.4, .4, 1) both;
}
.portal-btn {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1.1rem;
  padding: 1.3rem 1.6rem;
  border: 0;
  border-radius: var(--r-xl);
  cursor: pointer;
  text-align: start;
  color: #fff;
  background: radial-gradient(120% 140% at 85% 0%, #FFB2D8 0%, #FF6FAE 40%, #A65BF0 100%);
  box-shadow: 0 8px 0 #8A3FC8, var(--lift);
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.portal-btn::after {
  content: "";
  position: absolute;
  inset: -40% -10% auto auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%);
  pointer-events: none;
}
.portal-btn:hover { transform: translateY(-3px); }
.portal-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #8A3FC8, var(--lift-sm); }
.portal-ring {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(from 0deg, #FFE27A, #FF9AD0, #B79CFF, #8FE3FF, #FFE27A);
  animation: spin 6s linear infinite;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .35);
}
.portal-ring > span { width: 64px; height: 64px; border-radius: 50%; background: #fff; display: grid; place-items: center; animation: spin 6s linear infinite reverse; }
.portal-ring .icon { width: 34px; height: 34px; color: var(--candy-deep); }
.portal-text strong { display: block; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.7rem, 3vw, 2.2rem); line-height: 1.3; text-shadow: 0 3px 0 rgba(138, 63, 200, .55); }
.portal-text span { font-weight: 600; opacity: .95; }

.lobby-side {
  display: grid;
  gap: .9rem;
  padding: 1.1rem 1.2rem 1.2rem;
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--lift-sm);
}
.code-row { display: flex; gap: .6rem; }
.code-row input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: .4rem 1rem;
  border: 2.5px solid transparent;
  border-radius: var(--r-md);
  background: var(--field);
  font-family: var(--font-latin);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: .3em;
  text-align: center;
  text-transform: uppercase;
  direction: ltr;
}
.code-row input::placeholder { letter-spacing: 0; font-family: var(--font-body); font-weight: 600; font-size: 1rem; text-transform: none; color: var(--ink-faint); }
.code-row input:focus { outline: none; border-color: var(--lilac); background: #fff; box-shadow: var(--ring); }
.side-label { font-weight: 700; font-size: .92rem; color: var(--ink-soft); margin: 0 0 -.3rem; }

.current-room {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.2rem;
  padding: .8rem 1rem .8rem 1.2rem;
  border-radius: var(--r-lg);
  background: #E2FBF3;
  color: #11735C;
  font-weight: 700;
  box-shadow: var(--lift-sm);
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 2.2rem 0 .6rem; }
.section-head h2 { margin: 0; color: #fff; font-size: clamp(1.5rem, 3vw, 1.9rem); text-shadow: 0 3px 0 #9468E6, 0 6px 16px rgba(84, 48, 160, .35); }
.section-head .muted { color: rgba(255, 255, 255, .92); font-weight: 600; text-shadow: 0 2px 6px rgba(84, 48, 160, .45); }

.islands {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.6rem 1.3rem;
  padding-top: .6rem;
}
.island-card {
  position: relative;
  display: grid;
  justify-items: center;
  padding-bottom: .4rem;
  animation: float-in .7s cubic-bezier(.2, 1.4, .4, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.island-art { position: relative; width: 100%; max-width: 280px; aspect-ratio: 240 / 165; animation: bob 5s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -700ms); }
.island-art svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.island-folk {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 2%;
  height: 34%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  direction: ltr;
}
.folk {
  width: 17%;
  max-width: 44px;
  aspect-ratio: 1;
  margin-inline: -1.2%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #fff, #EFE6FF);
  box-shadow: 0 0 0 2.5px #fff, 0 4px 6px rgba(84, 48, 160, .25);
  overflow: hidden;
  animation: hop 2.8s ease-in-out infinite;
  animation-delay: calc(var(--j, 0) * -400ms);
}
.folk img { width: 100%; height: 100%; object-fit: cover; }
.folk.empty {
  background: rgba(255, 255, 255, .35);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8);
  animation: none;
  transform: scale(.55);
}
.island-label {
  margin-top: -.3rem;
  display: grid;
  justify-items: center;
  gap: .25rem;
  text-align: center;
}
.island-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: #fff;
  line-height: 1.4;
  text-shadow: 0 2px 0 #8F62E2, 0 4px 12px rgba(84, 48, 160, .4);
}
.island-meta { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; justify-content: center; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .05rem .65rem .15rem;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .88);
  font-size: .82rem;
  font-weight: 800;
  color: var(--ink-soft);
}
.tag .icon { width: 1em; height: 1em; }
.tag.count { color: var(--ink); }
.tag.full { background: #FFE1EC; color: #B5245A; }
.tag.perm .icon { color: var(--butter-deep); }
.island-card .btn { margin-top: .55rem; }
.empty-sky {
  grid-column: 1 / -1;
  padding: 2.4rem 1rem;
  text-align: center;
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, .5);
  border: 3px dashed rgba(255, 255, 255, .9);
  color: var(--ink);
  font-weight: 700;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes hop { 0%, 82%, 100% { transform: translateY(0); } 88% { transform: translateY(-14%); } 94% { transform: translateY(0); } }
@keyframes float-in { from { opacity: 0; transform: translateY(30px) scale(.9); } to { opacity: 1; transform: none; } }

/* ---------- 12. Room (stage + HUD) ---------- */
.page-room { overflow: hidden; }
.room-stage { position: fixed; inset: 0; }
.room-stage canvas { width: 100%; height: 100%; touch-action: none; }
.nametags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.nametag {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .1rem .7rem .2rem .25rem;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .92);
  font-weight: 800;
  font-size: .92rem;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(84, 48, 160, .18);
  will-change: transform;
  transition: opacity .3s;
}
.nametag .lv { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px; background: var(--butter); color: #5A3410; font-size: .75rem; }
.nametag.me { background: var(--candy); color: #fff; box-shadow: 0 3px 0 var(--candy-edge); }
.bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 11px);
  translate: -50% 0;
  padding: .2rem .75rem .3rem;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: .95rem;
  white-space: nowrap;
  box-shadow: var(--lift-sm);
  animation: bubble-in .35s cubic-bezier(.2, 1.5, .4, 1) both;
}
.bubble::after { content: ""; position: absolute; left: 50%; top: 100%; translate: -50% -1px; border: 7px solid transparent; border-top-color: #fff; }
@keyframes bubble-in { from { opacity: 0; scale: .6; } to { opacity: 1; scale: 1; } }
.hud { position: fixed; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top {
  position: absolute;
  top: calc(.9rem + var(--safe-top));
  inset-inline: clamp(.8rem, 2.5vw, 1.6rem);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.room-card {
  display: grid;
  gap: .3rem;
  padding: .7rem 1.2rem .8rem;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--lift-sm);
}
.room-card h1 { margin: 0; font-size: 1.45rem; line-height: 1.3; }
.pips { display: flex; gap: 5px; align-items: center; }
.pip { width: 15px; height: 15px; color: #E4DAF8; }
.pip.on { color: var(--butter); filter: drop-shadow(0 1px 0 var(--butter-edge)); }
.pips-label { font-weight: 800; font-size: .88rem; color: var(--ink-soft); margin-inline-start: .3rem; }
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  width: max-content;
  padding: .1rem .3rem .1rem .8rem;
  border-radius: var(--r-pill);
  background: #F1EAFF;
  font-weight: 800;
}
.code-chip code { font-family: var(--font-latin); font-size: 1.05rem; letter-spacing: .18em; direction: ltr; }
.code-chip button { border: 0; background: #fff; color: var(--lilac-edge); width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.hud-bottom {
  position: absolute;
  bottom: calc(1.2rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .7rem;
  flex-wrap: wrap;
  justify-content: center;
  width: max-content;
  max-width: calc(100vw - 2rem);
}
.roster {
  position: absolute;
  top: calc(8.6rem + var(--safe-top));
  inset-inline-start: clamp(.8rem, 2.5vw, 1.6rem);
  width: 220px;
  padding: .7rem .8rem;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--lift-sm);
}
.roster h2 { font-size: 1rem; margin: 0 0 .4rem; }
.roster ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.roster li { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: .92rem; line-height: 1.4; animation: card-in .4s ease both; }
.roster li img { width: 34px; height: 34px; border-radius: 50%; background: #F1EAFF; }
.roster li.me { color: var(--candy-deep); }
.portal-label {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  justify-items: center;
  gap: .1rem;
  padding: .3rem .9rem .4rem;
  border-radius: var(--r-md);
  background: rgba(59, 34, 87, .55);
  color: #fff;
  text-align: center;
  font-weight: 700;
  font-size: .82rem;
  line-height: 1.5;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.portal-label strong { font-family: var(--font-display); font-weight: 400; font-size: 1.05rem; }
.conn-lost {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1rem 1.4rem;
  border-radius: var(--r-lg);
  background: #fff;
  font-weight: 800;
  box-shadow: var(--lift);
  z-index: 50;
}

.loading-veil {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  background: linear-gradient(180deg, #9DB6FF 0%, #BCA9FF 40%, #F7B6DD 100%);
  transition: opacity .6s ease, visibility .6s;
}
.loading-veil.done { opacity: 0; visibility: hidden; }
.loader-stars { display: flex; gap: .5rem; }
.loader-stars .icon { width: 28px; height: 28px; color: #fff; animation: loader-hop 1s ease-in-out infinite; filter: drop-shadow(0 3px 0 rgba(138, 85, 224, .5)); }
.loader-stars .icon:nth-child(2) { animation-delay: .15s; color: var(--butter); }
.loader-stars .icon:nth-child(3) { animation-delay: .3s; }
.loading-veil p { color: #fff; font-weight: 700; text-shadow: 0 2px 8px rgba(84, 48, 160, .5); }
@keyframes loader-hop { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-14px) scale(1.1); } }

/* ---------- 13. Responsive ---------- */
@media (max-width: 960px) {
  .page-maker { overflow: auto; }
  .maker { grid-template-columns: 1fr; grid-template-rows: 54vh auto; height: auto; min-height: 100dvh; }
  .maker-stage { grid-row: 1; height: 54vh; position: sticky; top: 0; z-index: 1; }
  .maker-panel { grid-row: 2; margin: -1.5rem .6rem 1rem; z-index: 2; }
  .maker-body { overflow: visible; }
  .body-preview { display: none; }
  .stage-actions { bottom: 2.2rem; }
  .lobby-hero { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .topbar .logo { display: none; }
  .player-chip { flex: 1; }
  .portal-ring { width: 70px; height: 70px; }
  .portal-ring > span { width: 52px; height: 52px; }
  .roster { display: none; }
  .room-card h1 { font-size: 1.2rem; }
  .btn-xl { font-size: 1.3rem; min-height: 60px; }
  .tiles { grid-template-columns: repeat(4, 1fr); gap: .4rem; }
  .stage-name { top: calc(3rem + var(--safe-top)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* body preview quick presets */
.presets { display: flex; gap: .35rem; margin: .1rem 0 .55rem; }
.preset {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: .35rem .2rem .4rem;
  background: var(--cloud-tint);
  color: var(--ink-soft);
  font-weight: 800;
  font-size: .78rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.preset:hover { transform: translateY(-1px); color: var(--ink); }
.preset[aria-pressed="true"] { background: #FFE6F2; color: var(--candy-deep); box-shadow: 0 3px 0 #FFC2DD; }

.hero-caption {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  padding: .25rem 1.1rem .35rem;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .88);
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
  box-shadow: var(--lift-sm);
  transition: opacity .35s ease;
  pointer-events: none;
}
.hero-caption:empty { display: none; }
.hero-stage canvas { position: absolute; inset: 0; }
@media (max-width: 640px) { .hero-caption { white-space: normal; width: 86vw; text-align: center; font-size: .9rem; } }

/* lobby: readable labels over white clouds */
.island-name { color: var(--ink); text-shadow: 0 0 10px rgba(255, 255, 255, .95), 0 0 3px #fff, 0 2px 0 rgba(255, 255, 255, .85); }
.section-head .muted { color: var(--ink); text-shadow: none; background: rgba(255, 255, 255, .82); padding: .1rem .85rem .2rem; border-radius: var(--r-pill); font-size: .9rem; }

/* ---------- Phase 2 ---------- */
/* password eye sits on the left, where LTR text starts: keep text clear of it */
.field-box input[data-has-eye] { padding-left: 3.4rem; }
.field-eye { inset-inline-end: auto; left: .5rem; }

/* auth links as small candy pills */
.auth-foot a, .auth-row > a {
  display: inline-flex;
  align-items: center;
  padding: .1rem .95rem .22rem;
  border-radius: var(--r-pill);
  background: #FFE6F2;
  color: var(--candy-deep);
  font-family: var(--font-display);
  font-size: 1.05rem;
  text-decoration: none;
  box-shadow: 0 3px 0 #FFC2DD;
  transition: transform .12s ease, box-shadow .12s ease;
}
.auth-row > a { background: #F1EAFF; color: var(--lilac-edge); box-shadow: 0 3px 0 #DCCFF7; font-size: .98rem; }
.auth-foot a:hover, .auth-row > a:hover { transform: translateY(-2px); }
.auth-foot a:active, .auth-row > a:active { transform: translateY(2px); box-shadow: none; }

/* world HUD */
.page-world .hud-top { align-items: flex-start; }
.hud-stack { display: grid; gap: .6rem; justify-items: start; }
.xp-chip {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-width: 260px;
  padding: .4rem .9rem .4rem .55rem;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--lift-sm);
}
.xp-chip.pulse { animation: chip-pulse .55s ease 2; }
@keyframes chip-pulse { 50% { scale: 1.07; } }
.lvl-star {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding-top: 4px;
  background: linear-gradient(180deg, #FFE48A, var(--butter-deep));
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 57%, 79% 92%, 50% 71%, 21% 92%, 32% 57%, 2% 35%, 39% 34%);
  color: #5A3410;
  font-weight: 900;
  font-size: .95rem;
}
.xp-main { flex: 1; display: grid; gap: .15rem; }
.xp-bar { height: 12px; border-radius: 99px; background: #EFE7FF; overflow: hidden; box-shadow: inset 0 2px 0 rgba(84, 48, 160, .12); }
.xp-bar span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #FF8FC0, #B79CFF); transition: width .9s cubic-bezier(.2, 1.2, .4, 1); }
.xp-main small { font-size: .75rem; font-weight: 800; color: var(--ink-soft); line-height: 1.2; }
.page-world .roster { position: static; width: 230px; }
.minimap {
  position: absolute;
  bottom: calc(1.2rem + var(--safe-bottom));
  inset-inline-end: 1.2rem;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  background: #E8DEFF;
  box-shadow: 0 0 0 4px #fff, var(--lift-sm);
}
.zone-banner {
  position: absolute;
  top: 17%;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: .1rem;
  padding: .45rem 1.6rem .65rem;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--lift);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
.zone-banner strong { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; line-height: 1.4; color: var(--ink); }
.zone-banner span { font-weight: 800; color: var(--candy-deep); }
.zone-banner.big strong { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.zone-banner.show { animation: zone-in 2.4s ease both; }
.zone-banner.big.show { animation-duration: 3.6s; }
@keyframes zone-in {
  0% { opacity: 0; translate: 0 -14px; scale: .9; }
  10% { opacity: 1; translate: 0 0; scale: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; translate: 0 -8px; }
}
.controls-hint {
  position: absolute;
  bottom: calc(5.6rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .35rem .9rem;
  width: max-content;
  max-width: min(92vw, 820px);
  margin: 0;
  padding: .5rem 1.1rem;
  border-radius: var(--r-lg);
  background: rgba(59, 34, 87, .62);
  color: #fff;
  font-weight: 700;
  font-size: .86rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity .6s ease;
  pointer-events: none;
}
.controls-hint.gone { opacity: 0; }
.controls-hint kbd {
  display: inline-block;
  min-width: 1.6em;
  margin-inline-end: .25rem;
  padding: 0 .4em;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-latin);
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.page-world .hud-bottom .btn { min-height: 46px; font-size: 1.05rem; }
.nametag .nm { line-height: 1.5; }

/* touch controls */
.joy {
  position: fixed;
  left: calc(1.3rem + env(safe-area-inset-left, 0px));
  bottom: calc(1.5rem + var(--safe-bottom));
  z-index: 30;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .85);
  touch-action: none;
}
.joy-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: #fff; box-shadow: 0 4px 0 #DCCFF7, var(--lift-sm); }
.touch-btns { position: fixed; right: calc(1.3rem + env(safe-area-inset-right, 0px)); bottom: calc(1.5rem + var(--safe-bottom)); z-index: 30; display: flex; align-items: flex-end; gap: .7rem; }
.tbtn { width: 74px; height: 74px; border: 0; border-radius: 50%; color: #fff; font-family: var(--font-display); font-size: 1.15rem; background: var(--candy); box-shadow: 0 5px 0 var(--candy-edge); touch-action: none; }
.tbtn-run { width: 60px; height: 60px; font-size: 1rem; background: var(--lilac-deep); box-shadow: 0 5px 0 var(--lilac-edge); }
.tbtn-run[aria-pressed="true"] { background: var(--mint-deep); box-shadow: 0 5px 0 var(--mint-edge); }
@media (pointer: coarse) {
  .page-world .minimap { top: calc(4.6rem + var(--safe-top)); bottom: auto; width: 116px; height: 116px; }
  .page-world .hud-bottom { bottom: calc(9.6rem + var(--safe-bottom)); }
  .page-world .roster { display: none; }
  .controls-hint { bottom: calc(13rem + var(--safe-bottom)); }
}
@media (max-width: 640px) { .xp-chip { min-width: 0; } }

/* admin */
.page-admin { padding-bottom: 3rem; }
.admin { width: min(100% - 2rem, 1240px); margin: .6rem auto 0; display: grid; gap: 1.3rem; }
.admin-head h1 { margin: 0; color: #fff; display: flex; align-items: center; gap: .5rem; text-shadow: 0 3px 0 #9468E6, 0 6px 16px rgba(84, 48, 160, .35); }
.admin-head h1 .icon { color: var(--butter); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat { padding: .9rem 1.2rem; border-radius: var(--r-lg); background: rgba(255, 255, 255, .92); box-shadow: var(--lift-sm); }
.stat b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 2.1rem; line-height: 1.25; color: var(--ink); }
.stat span { font-weight: 700; font-size: .9rem; color: var(--ink-soft); }
.panel { padding: 1.2rem 1.3rem; border-radius: var(--r-xl); background: rgba(255, 255, 255, .95); box-shadow: var(--lift); }
.panel h2 { margin: 0 0 .7rem; font-size: 1.4rem; }
.panel-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .7rem; }
.search { display: flex; gap: .5rem; }
.search input { min-width: min(320px, 60vw); min-height: 44px; padding: .3rem 1rem; border: 2px solid transparent; border-radius: var(--r-md); background: var(--field); }
.search input:focus { outline: none; border-color: var(--lilac); box-shadow: var(--ring); background: #fff; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.table th { padding: .5rem .6rem; border-bottom: 2px solid #EEE6FF; color: var(--ink-soft); font-weight: 800; text-align: start; white-space: nowrap; }
.table td { padding: .55rem .6rem; border-bottom: 1px solid #F3EEFF; vertical-align: middle; }
.table tbody tr:hover td { background: #FBF8FF; }
.who { display: grid; line-height: 1.4; }
.who b { font-weight: 800; }
.who small { color: var(--ink-soft); }
.pill { display: inline-flex; align-items: center; padding: .05rem .6rem .12rem; border-radius: 99px; font-size: .8rem; font-weight: 800; white-space: nowrap; }
.pill.on { background: #E2FBF3; color: #11735C; }
.pill.off { background: #F3EEFF; color: var(--ink-soft); }
.pill.ban { background: #FFE1EC; color: #B5245A; }
.pill.admin { background: #FFF3C9; color: #8A5A0B; margin-inline-end: .25rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.row-actions form { margin: 0; }
.mini { padding: .22rem .65rem .3rem; border: 0; border-radius: 10px; background: #F1EAFF; color: var(--lilac-edge); font-size: .8rem; font-weight: 800; cursor: pointer; box-shadow: 0 2px 0 #DCCFF7; white-space: nowrap; }
.mini:active { transform: translateY(2px); box-shadow: none; }
.mini.danger { background: #FFE1EC; color: #B5245A; box-shadow: 0 2px 0 #F8B9CF; }
.mini.good { background: #E2FBF3; color: #11735C; box-shadow: 0 2px 0 #B6EBD9; }
.mini.gold { background: #FFF3C9; color: #8A5A0B; box-shadow: 0 2px 0 #F2DB8C; }
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-top: .9rem; }
.pager a, .pager span { padding: .15rem .75rem; border-radius: 10px; background: #F1EAFF; color: var(--lilac-edge); font-weight: 800; text-decoration: none; }
.pager span { background: var(--candy); color: #fff; }
