/* Yalla Maths! shell: screens, HUD, menus, shop, grown-ups. Uses only tokens.css variables. */

[hidden] { display: none !important; }

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

html {
  /* 20px at 1024 x 768, up to 26px on a big screen: everything below is in rem */
  font-size: clamp(16px, min(2.6vh, 1.95vw), 26px);
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--blush);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.3;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

input { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; user-drag: none; }
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
svg { display: block; }

#app { position: absolute; inset: 0; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- backdrop for the menu screens ---------- */

.screen-pretty {
  background:
    radial-gradient(ellipse 34rem 11rem at 12% 104%, rgba(255, 179, 138, 0.85) 0 99%, transparent 100%),
    radial-gradient(ellipse 40rem 13rem at 92% 108%, rgba(255, 111, 165, 0.45) 0 99%, transparent 100%),
    linear-gradient(180deg, var(--lilac) 0%, var(--blush) 55%, #ffd9c2 100%);
}

/* ---------- header decoration: stars, crescent, lanterns, scalloped edge ---------- */

.banner {
  position: relative;
  flex: none;
  height: calc(6.5rem + env(safe-area-inset-top, 0px));
  margin-bottom: 1.5rem;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.2) 0.1rem, transparent 0.13rem) 0 0 / 1.2rem 1.2rem,
    linear-gradient(180deg, var(--orchid-deep), var(--orchid));
  border-bottom: var(--outline);
}
.banner-short { height: calc(3.8rem + env(safe-area-inset-top, 0px)); }

.scallop {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  height: 1.3rem;
  background: radial-gradient(circle at 50% 0, var(--orchid) 0 1rem, var(--ink) calc(1rem + 0.5px) 1.25rem, transparent calc(1.25rem + 0.5px)) 0 0 / 2.5rem 1.3rem repeat-x;
}

.deco { position: absolute; overflow: visible; }
.d-star { width: 1.8rem; height: 1.8rem; color: var(--gold); animation: twinkle 3.2s ease-in-out infinite; }
.d-star.s1 { left: 6%; top: 45%; }
.d-star.s2 { left: 31%; top: 22%; width: 1.3rem; height: 1.3rem; color: var(--peach); animation-delay: 0.8s; }
.d-star.s3 { right: 30%; top: 50%; width: 1.5rem; height: 1.5rem; color: #fff6c9; animation-delay: 1.6s; }
.d-star.s4 { right: 6%; top: 55%; width: 1.2rem; height: 1.2rem; color: var(--turquoise); animation-delay: 2.2s; }
.d-moon { right: 14%; top: 12%; width: 3.2rem; height: 3.2rem; color: var(--gold); }
.banner-short .d-moon { width: 2.3rem; height: 2.3rem; top: 18%; }
.banner-short .d-star { top: 40%; }
.d-lantern { top: 0; width: 2.4rem; height: 4.8rem; transform-origin: 50% 0; animation: sway 4.5s ease-in-out infinite; }
.d-lantern.l1 { left: 17%; color: var(--rose); }
.d-lantern.l2 { right: 22%; color: var(--turquoise); animation-delay: 1.2s; height: 4rem; width: 2rem; }
.banner-short .d-lantern { height: 3rem; width: 1.5rem; }
.banner-short .d-lantern.l2 { height: 2.6rem; width: 1.3rem; }

@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; } 50% { transform: scale(0.72) rotate(12deg); opacity: 0.75; } }
@keyframes sway { 0%, 100% { transform: rotate(5deg); } 50% { transform: rotate(-5deg); } }

/* ---------- type ---------- */

.title {
  font-size: 4rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--rose);
  -webkit-text-stroke: 0.17em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 0.07em 0 var(--ink);
  transform: rotate(-2deg);
  transform-origin: left center;
}
.title-small { font-size: 2.4rem; }
.lead { font-size: var(--size-body); font-weight: 700; color: var(--ink-soft); }

/* ---------- sticker buttons ---------- */

.btn {
  --c: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: var(--tap);
  padding: 0.5em 1.25em;
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--ink);
  background: var(--c);
  border: var(--outline);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-sticker);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn:focus-visible, .link-btn:focus-visible, .who-card:focus-visible, .seg button:focus-visible, .icon-btn:focus-visible {
  outline: 4px solid var(--turquoise);
  outline-offset: 3px;
}
.btn-rose { --c: var(--rose); }
.btn-turq { --c: var(--turquoise); }
.btn-orchid { --c: var(--orchid); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn-gold { --c: var(--gold); }
.btn-cream { --c: var(--cream); }
.btn-big { min-height: 4.4rem; font-size: 1.7rem; border-radius: var(--radius-l); padding: 0.4em 1.4em; }
.btn-small { min-height: var(--tap); font-size: 1rem; padding: 0.3em 1em; }
.btn-round { width: 3.6rem; height: 3.6rem; padding: 0; font-size: 2rem; border-radius: 50%; }
.btn-emoji { font-size: 1.15em; }

.link-btn {
  min-height: var(--tap);
  padding: 0.3em 1em;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  border: 3px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
}
.link-btn:active { background: var(--butter); }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--cream);
  border: var(--outline);
  border-radius: 50%;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.icon-btn svg { width: 1.5rem; height: 1.5rem; }
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }

.panel {
  background: var(--cream);
  border: var(--outline);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-sticker), var(--shadow-soft);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 3rem;
  padding: 0.2rem 1rem 0.2rem 0.5rem;
  font-size: 1.2rem;
  font-weight: 900;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}
.coin-ico { width: 2.1rem; height: 2.1rem; flex: none; }
.pill-coins { background: var(--butter); }
.pill-coins b { min-width: 1.5ch; font-variant-numeric: tabular-nums; }
.pill-level { padding-left: 0.9rem; font-size: 1rem; }
.pill-level > span:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.pill-level small { font-size: 0.68rem; font-weight: 700; color: var(--ink-soft); max-width: 11rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-sign { font-size: 1.5rem; font-weight: 900; color: var(--rose-deep); }

.bump { animation: bump 0.45s var(--pop); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.3) rotate(-3deg); } 100% { transform: scale(1); } }

/* ---------- segmented switch ---------- */

.seg {
  display: inline-flex;
  overflow: hidden;
  background: var(--paper);
  border: var(--outline);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}
.seg button {
  min-width: var(--tap);
  min-height: calc(var(--tap) - 8px);
  padding: 0 0.9rem;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.seg button + button { border-left: 3px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--gold); }
.seg-big button { font-size: 1.3rem; padding: 0 1.4rem; min-height: 3.6rem; }

/* ---------- who's playing ---------- */

.who-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 0.5rem 2rem 1.5rem; }
.who-body .title { transform: rotate(-2deg); transform-origin: center; }
.who-list { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 1.2rem; max-width: 62rem; overflow-y: auto; padding: 0.5rem 0.5rem 1rem; }
.who-card {
  width: 10.5rem;
  min-height: 11.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 0.6rem;
  color: var(--ink);
  background: var(--cream);
  border: var(--outline);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-sticker);
  cursor: pointer;
  transition: transform 0.1s;
}
.who-card:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.who-card.loading { opacity: 0.6; }
.avatar { width: 5rem; height: 5rem; display: grid; place-items: center; font-size: 2.6rem; font-weight: 900; color: #fff; text-shadow: 0 3px 0 var(--ink); border: var(--outline); border-radius: 50%; }
.avatar-plus { background: var(--mint); color: var(--ink); text-shadow: none; }
.who-name { font-size: 1.35rem; font-weight: 900; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-coins { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.95rem; font-weight: 800; color: var(--ink-soft); }
.who-coins .coin-ico { width: 1.3rem; height: 1.3rem; }
.who-new { display: flex; flex-direction: column; align-items: center; gap: 1rem; width: min(38rem, 90%); padding: 1.6rem; }
.who-new-row { display: flex; gap: 0.8rem; width: 100%; }
.text-input {
  flex: 1;
  min-width: 0;
  min-height: 3.6rem;
  padding: 0.3em 0.9em;
  font: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--paper);
  border: var(--outline);
  border-radius: var(--radius-m);
}
.text-input:focus { outline: 4px solid var(--turquoise); outline-offset: 2px; }

/* ---------- home ---------- */

.home-body { flex: 1; min-height: 0; display: flex; gap: 2rem; padding: 0.5rem 3rem 1rem; padding-left: max(3rem, env(safe-area-inset-left)); padding-right: max(3rem, env(safe-area-inset-right)); }
.home-hero { position: relative; flex: 0 0 34%; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.hero-img { position: relative; max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 10px 0 rgba(59, 30, 84, 0.18)); animation: floaty 3.6s ease-in-out infinite; }
.hero-glow { position: absolute; inset: 0; pointer-events: none; }
.hero-glow .h1 { left: 6%; top: 10%; width: 2.4rem; height: 2.4rem; color: var(--gold); }
.hero-glow .h2 { right: 4%; top: 32%; width: 1.7rem; height: 1.7rem; color: var(--rose); animation-delay: 1s; }
.hero-fallback { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.fb-star { position: absolute; width: 78%; max-height: 80%; color: var(--gold); animation: spin-slow 40s linear infinite; }
.fb-moon { position: absolute; width: 36%; right: 6%; top: 6%; color: var(--peach); }
.fb-lamp { position: relative; font-size: 6.5rem; filter: drop-shadow(0 6px 0 rgba(59, 30, 84, 0.25)); animation: floaty 3.6s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-0.6rem); } }
@keyframes spin-slow { to { transform: rotate(360deg); } }

.home-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 0.9rem; }
.stat-row { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-bottom: 0.3rem; }
.home-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.home-buttons #btn-adventure { grid-column: 1 / -1; min-height: 5.6rem; font-size: 2.1rem; }
.home-buttons .btn-big { width: 100%; }
.home-links { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 0.4rem; }

/* ---------- sub screens (practice, pets, grown-ups) ---------- */

.sub-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 2.5rem 1.5rem;
  padding-left: max(2.5rem, env(safe-area-inset-left));
  padding-right: max(2.5rem, env(safe-area-inset-right));
}
.back-btn { position: absolute; left: max(1.2rem, env(safe-area-inset-left)); top: 0; z-index: 2; }
.screen-scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.screen-scroll .sub-body { flex: none; min-height: 100%; padding-top: 4.2rem; padding-bottom: 3rem; }

.practice-card { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; width: min(40rem, 92%); padding: 1.6rem 2rem; margin-top: 0.3rem; text-align: center; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 1.2rem; width: 100%; }
.stepper-mid { flex: 1; min-width: 0; }
.stepper-level { font-size: 2.2rem; font-weight: 900; color: var(--rose-deep); }
.stepper-name { font-size: 1.15rem; font-weight: 900; }
.stepper-blurb { font-size: 0.9rem; font-weight: 700; color: var(--ink-soft); min-height: 2.4em; }

.pets-head { display: flex; align-items: center; gap: 1.5rem; margin-top: 0.2rem; }
.pets-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 1.2rem; width: min(52rem, 100%); }
.pet-card { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.7rem 0.6rem 0.9rem; text-align: center; }
.pet-card.following { background: var(--butter); }
.pet-pic { width: 5rem; height: 5rem; display: grid; place-items: center; }
.pet-pic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pet-emoji { font-size: 3.6rem; line-height: 1; }
.pet-name { font-size: 1.25rem; font-weight: 900; }
.pet-price { font-size: 0.9rem; font-weight: 800; color: var(--ink-soft); margin-bottom: 0.3rem; }
.pet-card .btn { min-height: 3rem; font-size: 0.95rem; width: 100%; }

/* ---------- grown-ups ---------- */

.gate-card { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; padding: 2rem 3rem; margin-top: 2rem; text-align: center; }
.hold-btn { position: relative; overflow: hidden; min-width: 14rem; }
.hold-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--gold); }
.hold-btn.holding .hold-fill { width: 100%; transition: width 2s linear; }
.hold-text { position: relative; color: var(--ink); text-shadow: none; }
.hold-btn { user-select: none; touch-action: none; }

.gu-content { display: flex; flex-direction: column; align-items: stretch; gap: 1.1rem; width: min(52rem, 100%); }
.gu-content .title { align-self: center; }
.gu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.gu-card { position: relative; padding: 1.1rem 1.4rem; }
.gu-card h3 { font-size: 1.25rem; font-weight: 900; margin-bottom: 0.4rem; }
.gu-sign { position: absolute; right: 1rem; top: 0.4rem; font-size: 3rem; font-weight: 900; color: var(--rose); opacity: 0.5; }
.gu-big { font-size: 1.9rem; font-weight: 900; color: var(--orchid-deep); }
.gu-sub { font-size: 0.95rem; font-weight: 700; color: var(--ink-soft); }
.gu-dl { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1rem; margin: 0.6rem 0 0; font-size: 1rem; }
.gu-dl dt { font-weight: 700; color: var(--ink-soft); }
.gu-dl dd { margin: 0; font-weight: 900; text-align: right; }
.tricky { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tricky-chip { padding: 0.25rem 0.8rem; font-size: 1.1rem; font-weight: 900; background: var(--butter); border: 3px solid var(--ink); border-radius: 999px; }
.gu-url { font-size: 1.4rem; font-weight: 900; color: var(--orchid-deep); -webkit-user-select: text; user-select: text; word-break: break-all; }
.gu-danger { background: var(--blush); }

/* ---------- adventure and the puzzle host ---------- */

.screen-game { background: var(--night); touch-action: none; }
.game-stage { position: absolute; inset: 0; overflow: hidden; }
.game-canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

.hud {
  position: absolute;
  z-index: 30;
  left: max(0.8rem, env(safe-area-inset-left));
  right: max(0.8rem, env(safe-area-inset-right));
  top: calc(0.6rem + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  pointer-events: none;
}
.hud > *, .hud .hud-mid > *, .hud .hud-right > * { pointer-events: auto; }
.hud-mid, .hud-right { display: flex; align-items: center; gap: 0.7rem; }
.hud .pill { min-height: var(--tap); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.6rem;
  padding: 0 0.9rem;
  font-size: 1.15rem;
  font-weight: 900;
  background: var(--blush);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
}
.chip-div { background: var(--lilac); }
.chip .lv-sign { font-size: 1.3rem; }

.puzzle-host { position: absolute; inset: 0; z-index: 20; }
/* While a puzzle is open the HUD shrinks to the pause (or Done) button, so it never covers the card. */
.puzzle-open .hud-fade, .puzzle-open .hud-right, .puzzle-open .hud-mid { display: none; }
.hud-practice { z-index: 30; justify-content: flex-start; }
.hud-practice .pill { display: none; }
.gain { font-size: 1rem; color: var(--rose-deep); }
.gain-pop { animation: bump 0.6s var(--pop); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 30, 84, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.pause-card { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1.8rem 2.6rem; min-width: 22rem; }
.pause-card .btn { width: 100%; }

.levelup { position: fixed; z-index: 60; }
.levelup-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.7rem; width: min(34rem, 90%); padding: 2rem 2rem 2.2rem; text-align: center; background: linear-gradient(180deg, var(--butter), var(--cream)); animation: card-in 0.6s var(--pop); }
.lu-kicker { font-size: 3.2rem; font-weight: 900; line-height: 1; color: var(--rose); -webkit-text-stroke: 0.16em var(--ink); paint-order: stroke fill; text-shadow: 0 0.07em 0 var(--ink); }
.lu-skill { font-size: 1.15rem; font-weight: 900; color: var(--orchid-deep); }
.lu-name { font-size: 1.7rem; font-weight: 900; }
.lu-blurb { font-size: 1.05rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 0.6rem; }
.lu-star { position: absolute; color: var(--gold); animation: twinkle 2.4s ease-in-out infinite; }
.lu-a { width: 3.2rem; height: 3.2rem; left: -1.4rem; top: -1.4rem; }
.lu-b { width: 2.2rem; height: 2.2rem; right: -0.9rem; top: 2rem; animation-delay: 0.7s; color: var(--turquoise); }
.lu-c { width: 2.6rem; height: 2.6rem; right: 1.5rem; bottom: -1.2rem; animation-delay: 1.3s; color: var(--rose); }
@keyframes card-in { 0% { transform: scale(0.4) rotate(-6deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  z-index: 100;
  left: 0;
  right: 0;
  top: calc(5.2rem + env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  pointer-events: none;
}
.toast {
  max-width: min(36rem, 90vw);
  padding: 0.55rem 1.4rem;
  font-size: 1.2rem;
  font-weight: 900;
  text-align: center;
  background: var(--mint);
  border: var(--outline);
  border-radius: 999px;
  box-shadow: var(--shadow-sticker);
  animation: toast-in 0.45s var(--pop);
}
.toast-kind { background: var(--butter); }
.toast.out { opacity: 0; transform: translateY(-1rem); transition: opacity 0.35s, transform 0.35s; }
@keyframes toast-in { 0% { transform: translateY(-1.5rem) scale(0.7); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ---------- portrait: turn your tablet ---------- */

.rotate-card { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; text-align: center; padding: 2rem; background: linear-gradient(180deg, var(--orchid-deep), var(--night)); color: #fff; }
.rotate-inner h2 { font-size: 2.2rem; font-weight: 900; margin: 1rem 0 0.4rem; }
.rotate-inner p { font-size: 1.2rem; font-weight: 700; opacity: 0.85; }
.rotate-ico { font-size: 5rem; display: inline-block; animation: tilt 2.4s ease-in-out infinite; }
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 1100px) {
  .rotate-card { display: flex; }
}

/* ---------- short screens (laptops with the dock open) ---------- */

@media (max-height: 640px) {
  .home-main { gap: 0.6rem; }
  .title { font-size: 3.2rem; }
}

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

/* grown-ups: settings rows (added by the lead) */
.gu-step { display: flex; align-items: center; gap: 0.8rem; margin: 0.5rem 0; }
.gu-step-label { flex: 1; font-weight: 700; }
.gu-step .btn { min-width: 3.4rem; }

/* practice: pick a table (added by the lead) */
.pr-tables { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin: 0.6rem 0 1rem; }
.pr-tables[hidden] { display: none; }

/* ==========================================================================
   PROGRESS: level bar, level-up moment, journey map (progress agent)
   ========================================================================== */

/* ---- level bar ---- */
.lbar {
  --sz: 1.6rem;
  display: flex; flex-direction: column; gap: 0.2rem; align-items: flex-start;
  padding: 0.35rem 0.8rem 0.45rem;
  font: inherit; color: var(--ink); text-align: left;
  background: var(--blush);
  border: 3px solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 4px 0 var(--ink);
}
button.lbar { cursor: pointer; min-height: var(--tap); }
button.lbar:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button.lbar:focus-visible { outline: 4px solid var(--orchid); outline-offset: 3px; }
.lbar-div { background: var(--lilac); }
.lb-head { display: flex; align-items: baseline; gap: 0.45rem; min-width: 0; max-width: 100%; }
.lb-sign { font-size: 1.5rem; font-weight: 900; line-height: 1; color: var(--rose-deep); }
.lbar-div .lb-sign { color: var(--orchid-deep); }
.lb-level { font-size: 1.2rem; font-weight: 900; white-space: nowrap; }
.lb-name { font-size: 1rem; font-weight: 800; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lb-note { font-size: 1.1rem; font-weight: 800; line-height: 1.25; max-width: 17rem; }
.lb-stars { display: flex; flex-wrap: nowrap; gap: 3px; }
.lb-stars.lb-many { --sz: 1.15rem; }
.lb-slot { position: relative; display: block; width: var(--sz); height: var(--sz); color: transparent; opacity: 0.55; transition: transform 0.5s ease-in, opacity 0.5s; }
.lb-slot.on { color: var(--gold); opacity: 1; }
.lb-star { width: 100%; height: 100%; overflow: visible; }
.lb-slot.pop .lb-star { animation: lb-pop 0.8s var(--pop); }
@keyframes lb-pop { 0% { transform: scale(0) rotate(-90deg); } 55% { transform: scale(1.7) rotate(15deg); } 100% { transform: scale(1) rotate(0); } }
.lb-spark { position: absolute; left: 50%; top: 50%; width: 0.6rem; height: 0.6rem; margin: -0.3rem 0 0 -0.3rem; color: var(--gold); pointer-events: none; animation: lb-spark 0.8s ease-out forwards; }
@keyframes lb-spark { from { transform: rotate(var(--a)) translateX(0) scale(1); opacity: 1; } to { transform: rotate(var(--a)) translateX(1.7rem) scale(0.3); opacity: 0; } }
.lb-wobble .lb-stars { animation: lb-wobble 0.7s ease-in-out; }
@keyframes lb-wobble { 0%, 100% { transform: none; } 20% { transform: rotate(-3deg) translateX(-3px); } 45% { transform: rotate(3deg) translateX(3px); } 70% { transform: rotate(-1.5deg); } }
.lb-slot.fill-in { color: var(--gold); opacity: 1; animation: lb-fill 0.45s var(--pop) both; animation-delay: calc(var(--i) * 50ms); }
@keyframes lb-fill { from { transform: scale(0.3); } to { transform: scale(1); } }
.lb-fly .lb-slot { animation: none; transform: translateX(calc((var(--c) - var(--i)) * (var(--sz) + 3px))) scale(0.2); opacity: 0; }
.lb-new { animation: lb-new 0.8s var(--pop); }
@keyframes lb-new { 0% { transform: scale(0.8); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }

.lbar-compact { --sz: 1.05rem; gap: 0.1rem; padding: 0.15rem 0.7rem 0.3rem; }
.lbar-compact .lb-stars.lb-many { --sz: 0.95rem; }
.lbar-compact .lb-sign { font-size: 1.2rem; }
.lbar-compact .lb-level { font-size: 1rem; }
.lbar-compact .lb-name { font-size: 0.95rem; max-width: 9rem; }
.hud-bars { display: flex; gap: 0.6rem; }
.home-bars { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 0.2rem; }
.home-bars .lbar { flex: 1 1 14rem; }
.pr-bar { display: flex; justify-content: center; }
.pr-bar .lbar { min-width: 16rem; }
.home-buttons { grid-template-columns: 1fr 1fr 1fr; }
.home-buttons .btn-big:not(#btn-adventure) { font-size: 1.45rem; padding-left: 0.6em; padding-right: 0.6em; }

/* ---- level-up moment ---- */
.levelup-card { overflow: visible; }
.lu-hero { position: absolute; left: -10.5rem; bottom: -0.5rem; height: 17rem; width: auto; pointer-events: none; filter: drop-shadow(0 8px 0 rgba(59, 30, 84, 0.2)); animation: floaty 3s ease-in-out infinite; }
.lu-hero[hidden] { display: none; }
.lu-badge { position: relative; width: 8.5rem; height: 8.5rem; display: grid; place-items: center; animation: lu-badge 0.9s 0.25s var(--pop) both; }
.lu-badge-bg { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--gold); filter: drop-shadow(0 6px 0 var(--ink)); animation: spin-slow 14s linear infinite; }
.lu-num { position: relative; font-size: 3.6rem; font-weight: 900; line-height: 1; color: var(--ink); }
@keyframes lu-badge { 0% { transform: scale(0) rotate(-180deg); } 100% { transform: scale(1) rotate(0); } }
.lu-next { font-size: 1.2rem; font-weight: 800; color: var(--ink); background: var(--blush); border: 3px solid var(--ink); border-radius: var(--radius-s); padding: 0.4rem 0.9rem; }
.lu-next:empty { display: none; }
.lu-name { line-height: 1.15; }
.lu-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.lu-bit { position: absolute; top: -3rem; width: 1.6rem; height: 1.6rem; animation: lu-fall var(--d, 3s) linear var(--dl, 0s) 2 both; }
@keyframes lu-fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(calc(100vh + 4rem)) rotate(540deg); opacity: 1; } }

/* ---- journey map ---- */
.map-top { display: flex; align-items: center; gap: 1.2rem; padding: 0.6rem 1.6rem 0.2rem; }
.map-top .title { transform: rotate(-1deg); }
.map-paths { display: flex; flex-direction: column; gap: 0.3rem; padding-bottom: 0.6rem; }
.mp-head { display: flex; align-items: center; gap: 1rem; padding: 0 1.6rem; }
.mp-title { display: inline-flex; align-items: center; gap: 0.5rem; flex: none; padding: 0.15rem 1rem 0.15rem 0.5rem; font-size: 1.3rem; font-weight: 900; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); }
.mp-sign { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--rose); border: 3px solid var(--ink); }
.mp-path-div .mp-sign { background: var(--orchid); color: #fff; }
.mp-say { font-size: var(--size-body); font-weight: 800; line-height: 1.2; }
.mp-scroll { overflow-x: auto; overflow-y: hidden; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.mp-inner { position: relative; }
.mp-road { position: absolute; left: 0; top: 0; }
.mp-decor { position: absolute; inset: 0; pointer-events: none; opacity: 0.85; }
.mp-deco { position: absolute; width: 2rem; height: 2rem; }
.mp-star { color: var(--gold); }
.mp-moon { color: var(--peach); }
.mp-lantern { color: var(--rose); width: 1.6rem; height: 3.2rem; }
.mp-palm { position: absolute; font-size: 2.6rem; line-height: 1; }
.mp-ribbon { position: absolute; top: 6px; height: 30px; display: flex; align-items: center; justify-content: center; padding: 0 0.4rem; font-size: 0.95rem; font-weight: 900; white-space: nowrap; background: var(--turquoise); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); z-index: 3; }
.mp-ribbon.mp-dest { top: 2px; height: 42px; font-size: 1.15rem; background: var(--gold); box-shadow: 0 4px 0 var(--ink); }
.mp-stone { position: absolute; z-index: 2; transform: translate(-50%, -50%); width: 4.4rem; height: 4.4rem; padding: 0; display: grid; place-items: center; font: inherit; font-size: 1.6rem; font-weight: 900; color: var(--ink); background: var(--lilac); border: 4px solid var(--ink); border-radius: 50%; box-shadow: 0 5px 0 var(--ink); cursor: pointer; }
.mp-stone:focus-visible { outline: 4px solid var(--orchid); outline-offset: 3px; }
.mp-done { background: var(--gold); }
.mp-ahead { background: var(--paper); opacity: 0.7; border-style: dashed; box-shadow: 0 3px 0 var(--ink); }
.mp-current { z-index: 4; width: 5.6rem; height: 5.6rem; font-size: 2.4rem; background: var(--rose); color: #fff; text-shadow: 0 2px 0 var(--ink); animation: mp-pulse 1.6s ease-in-out infinite; }
@keyframes mp-pulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 5px 0 var(--ink), 0 0 0 0 rgba(255, 200, 61, 0.9); } 50% { transform: translate(-50%, -50%) scale(1.07); box-shadow: 0 5px 0 var(--ink), 0 0 0 14px rgba(255, 200, 61, 0); } }
.mp-tick { position: absolute; right: -0.4rem; top: -0.5rem; width: 1.7rem; height: 1.7rem; display: grid; place-items: center; font-size: 1rem; font-weight: 900; color: #fff; background: var(--turquoise-deep); border: 3px solid var(--ink); border-radius: 50%; }
.mp-pin { position: absolute; bottom: calc(100% + 0.5rem); left: 50%; transform: translateX(-50%); padding: 0.1rem 0.7rem; font-size: 0.95rem; font-weight: 900; white-space: nowrap; color: var(--ink); text-shadow: none; background: var(--butter); border: 3px solid var(--ink); border-radius: 999px; }
.mp-label { position: absolute; z-index: 2; transform: translateX(-50%); width: 7.6rem; text-align: center; font-size: 0.95rem; font-weight: 800; line-height: 1.15; color: var(--ink); pointer-events: none; }
.mp-label span { display: block; text-shadow: 0 0 4px var(--cream), 0 0 4px var(--cream), 0 0 4px var(--cream); }
.mp-label-cur span { font-weight: 900; }
.mp-mini { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.mp-ministar { width: 0.8rem; height: 0.8rem; color: transparent; opacity: 0.6; }
.mp-ministar.on { color: var(--gold); opacity: 1; }
.mp-flag { position: absolute; z-index: 5; transform: translateX(-50%); display: flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.7rem; font-size: 0.95rem; font-weight: 900; white-space: nowrap; background: var(--butter); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); }
.mp-end { position: absolute; z-index: 2; transform: translate(-50%, -50%); font-size: 4rem; line-height: 1; filter: drop-shadow(0 5px 0 rgba(59, 30, 84, 0.3)); pointer-events: none; }
.mp-cloud { position: absolute; z-index: 2; transform: translate(-50%, -50%); min-width: 7rem; min-height: var(--tap); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0.4rem 1.2rem; font: inherit; font-size: 1.1rem; font-weight: 900; color: var(--ink); background: var(--paper); border: 4px solid var(--ink); border-radius: 999px; box-shadow: 0 5px 0 var(--ink); opacity: 0.85; cursor: pointer; }
.mp-cloud-here { opacity: 1; background: var(--rose); color: #fff; text-shadow: 0 2px 0 var(--ink); animation: mp-pulse 1.6s ease-in-out infinite; }
.mp-detail { z-index: 50; }
.mp-card { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; width: min(30rem, 90%); padding: 1.6rem 2rem; text-align: center; animation: card-in 0.4s var(--pop); }
.mp-card-kicker { font-size: 1.1rem; font-weight: 900; color: var(--orchid-deep); }
.mp-card-name { font-size: 1.7rem; font-weight: 900; line-height: 1.15; }
.mp-card-blurb { font-size: var(--size-body); font-weight: 700; color: var(--ink-soft); }
.mp-card-ex { display: flex; flex-direction: column; align-items: center; padding: 0.4rem 1.6rem; background: var(--butter); border: 3px solid var(--ink); border-radius: var(--radius-s); }
.mp-card-ex small { font-size: 1rem; font-weight: 800; color: var(--ink-soft); }
.mp-card-ex b { font-size: 2.2rem; font-family: var(--font-num); }
.mp-card-state { font-size: 1.1rem; font-weight: 900; color: var(--turquoise-deep); }
@media (max-height: 640px) { .mp-say { font-size: 1rem; } }

/* lead: fixes from the browser run */
.mp-label { width: 8.2rem; }
.home-bars { display: grid; grid-template-columns: 1fr 1fr; }
.home-bars .lbar { --sz: 1.05rem; min-width: 0; }
.home-bars .lb-note { font-size: 0.95rem; }
.home-bars .lb-stars.lb-many { --sz: 0.85rem; gap: 2px; flex-wrap: wrap; }
.lbar { overflow: hidden; }
.home-main { gap: 0.5rem; }
.home-buttons #btn-adventure { min-height: 4.4rem; }
.home-links { margin-top: 0.1rem; }
/* HUD: keep everything on one row at 1024 px wide */
.hud-bars { gap: 0.4rem; min-width: 0; }
.hud-bars .lbar { min-width: 0; padding: 0.25rem 0.6rem 0.3rem; }
.hud-bars .lb-name { display: none; }
.hud-bars .lb-stars.lb-many { --sz: 0.72rem; gap: 1px; }
.hud .hud-mid { gap: 0.4rem; min-width: 0; }
#adv-mode button { white-space: nowrap; }

/* ==========================================================================
   FIVE SKILLS (shell agent, 1 Dec 2026): track picker, level chips, five roads, grown-ups grid
   ========================================================================== */

/* ---- track picker: HUD button and the sheet ---- */
.hud-picker { display: flex; flex: none; }
.tp-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: var(--tap); padding: 0 0.9rem;
  font: inherit; font-size: 1.1rem; font-weight: 900; color: var(--ink); white-space: nowrap;
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--radius-m); box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.tp-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tp-btn:focus-visible { outline: 4px solid var(--orchid); outline-offset: 3px; }
.tp-sign { font-size: 1.4rem; line-height: 1; color: var(--rose-deep); }
.tp-btn[data-track="div"] .tp-sign { color: var(--orchid-deep); }
.tp-btn[data-track="num"] .tp-sign { color: var(--turquoise-deep); }
.tp-btn[data-track="rem"] .tp-sign { color: var(--gold-deep); }
.tp-btn[data-track="dec"] .tp-sign { color: var(--rose-deep); }
.tp-caret { font-size: 0.9rem; color: var(--ink-soft); }
.tp-sheet { z-index: 45; }
.tp-card { display: flex; flex-direction: column; align-items: center; gap: 1rem; width: min(46rem, 94%); max-height: 94%; overflow-y: auto; padding: 1.2rem 1.4rem 1.4rem; animation: card-in 0.35s var(--pop); }
.tp-title { font-size: 1.6rem; font-weight: 900; }
.tp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; width: 100%; }
.tp-choice {
  display: flex; align-items: center; gap: 0.6rem; min-height: 4.6rem; padding: 0.4rem 0.8rem;
  font: inherit; text-align: left; color: var(--ink);
  background: var(--cream); border: 4px solid var(--ink); border-radius: var(--radius-m); box-shadow: var(--shadow-sticker);
  cursor: pointer;
}
.tp-choice:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.tp-choice[aria-pressed="true"] { background: var(--gold); }
.tp-choice:focus-visible { outline: 4px solid var(--orchid); outline-offset: 3px; }
.tp-c-sign { flex: none; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; font-size: 1.6rem; font-weight: 900; background: var(--paper); border: 3px solid var(--ink); border-radius: 50%; }
.tp-c-text { display: flex; flex-direction: column; min-width: 0; }
.tp-c-text b { font-size: 1.1rem; line-height: 1.15; }
.tp-c-text small { font-size: 1rem; font-weight: 800; color: var(--ink-soft); }
.pr-skill { display: flex; justify-content: center; }
.pr-skill .tp-btn { font-size: 1.3rem; min-height: 3.6rem; padding: 0 1.4rem; }
.pr-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.8rem; }
.pr-actions [hidden] { display: none; }
.hud .hud-mid { flex-wrap: nowrap; }

/* ---- skill colours for bars ---- */
.lbar-num { background: var(--mint); }
.lbar-rem { background: var(--butter); }
.lbar-dec { background: var(--peach); }
.lbar-num .lb-sign { color: var(--turquoise-deep); }
.lbar-rem .lb-sign { color: var(--gold-deep); }
.lbar-dec .lb-sign { color: var(--rose-deep); }

/* ---- home: a row of five level chips ---- */
.home-bars { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.2rem; }
.lchip {
  flex: 1 1 5rem; min-width: 0; min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  padding: 0.2rem 0.4rem 0.35rem; font: inherit; color: var(--ink);
  background: var(--blush); border: 3px solid var(--ink); border-radius: var(--radius-m); box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.lchip:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.lchip:focus-visible { outline: 4px solid var(--orchid); outline-offset: 3px; }
.lchip-div { background: var(--lilac); }
.lchip-num { background: var(--mint); }
.lchip-rem { background: var(--butter); }
.lchip-dec { background: var(--peach); }
.lc-sign { font-size: 1.1rem; font-weight: 900; line-height: 1; margin-right: 0.3rem; }
.lc-level { font-size: 1.4rem; font-weight: 900; line-height: 1; }
.lc-head { display: flex; align-items: baseline; justify-content: center; }
.lc-stars { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 100%; }
.lc-dot { width: 0.55rem; height: 0.55rem; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); opacity: 0.6; }
.lc-dot.on { background: var(--gold); opacity: 1; }

/* ---- map: five roads stacked, the screen scrolls ---- */
.map-paths { flex: none; gap: 0.9rem; }
.mp-path { padding-bottom: 0.3rem; border-bottom: 3px dashed rgba(59, 30, 84, 0.18); }
.mp-path:last-child { border-bottom: 0; }
.mp-head { flex-wrap: wrap; }
.mp-path-num .mp-sign { background: var(--turquoise); }
.mp-path-rem .mp-sign { background: var(--gold); }
.mp-path-dec .mp-sign { background: var(--peach); }
.mp-detail { position: fixed; z-index: 50; }
.mp-lesson { position: fixed; inset: 0; z-index: 70; background: var(--lilac); }
.mp-lesson[hidden] { display: none; }
.mp-book { position: absolute; left: -0.5rem; bottom: -0.5rem; width: 1.9rem; height: 1.9rem; display: grid; place-items: center; font-size: 1rem; line-height: 1; background: var(--paper); border: 3px solid var(--ink); border-radius: 50%; }
.mp-current .mp-book { font-size: 1.1rem; }
.mp-card .btn { width: 100%; }

/* ---- grown-ups: tidy grids ---- */
.gu-content { width: min(60rem, 100%); }
.gu-grid { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.gu-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 0.6rem; }
.gu-step-card { margin: 0; padding: 0.4rem 0.6rem; background: var(--cream); border: 3px solid var(--ink); border-radius: var(--radius-m); }
.gu-step-card .gu-step-label { font-size: 1rem; }

/* lead: the family-code box on the first screen */
.who-code { display: flex; flex-direction: column; gap: 0.6rem; max-width: 34rem; margin: 1rem auto 0; padding: 1rem 1.4rem; }
.who-code[hidden] { display: none; }
