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

[hidden] { display: none !important; }

/* Arabic letters join: letter spacing would break them apart. */
body, body * { letter-spacing: 0 !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. It follows the
     window's height all the way down (a short laptop browser window), so the menus always fit. */
  font-size: clamp(11px, 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-ui);
  font-size: 1rem;
  line-height: 1.4;
  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;
  inset-inline-start: 0;
  inset-inline-end: 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 { inset-inline-start: 6%; top: 45%; }
.d-star.s2 { inset-inline-start: 31%; top: 22%; width: 1.3rem; height: 1.3rem; color: var(--peach); animation-delay: 0.8s; }
.d-star.s3 { inset-inline-end: 30%; top: 50%; width: 1.5rem; height: 1.5rem; color: #fff6c9; animation-delay: 1.6s; }
.d-star.s4 { inset-inline-end: 6%; top: 55%; width: 1.2rem; height: 1.2rem; color: var(--turquoise); animation-delay: 2.2s; }
.d-moon { inset-inline-end: 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 { inset-inline-start: 17%; color: var(--rose); }
.d-lantern.l2 { inset-inline-end: 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.13em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 0.07em 0 var(--ink);
  transform: rotate(-2deg);
  transform-origin: 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 0.5rem 0.2rem 1rem;
  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-inline-start: 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-inline-start: 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-inline-start: max(3rem, env(safe-area-inset-left)); padding-inline-end: 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 { inset-inline-start: 6%; top: 10%; width: 2.4rem; height: 2.4rem; color: var(--gold); }
.hero-glow .h2 { inset-inline-end: 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%; inset-inline-end: 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-inline-start: max(2.5rem, env(safe-area-inset-left));
  padding-inline-end: max(2.5rem, env(safe-area-inset-right));
}
.back-btn { position: absolute; inset-inline-start: 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; inset-inline-start: 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; inset-inline-end: 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: end; }
.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;
  inset-inline-start: max(0.8rem, env(safe-area-inset-left));
  inset-inline-end: 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; inset-inline-start: -1.4rem; top: -1.4rem; }
.lu-b { width: 2.2rem; height: 2.2rem; inset-inline-end: -0.9rem; top: 2rem; animation-delay: 0.7s; color: var(--turquoise); }
.lu-c { width: 2.6rem; height: 2.6rem; inset-inline-end: 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;
  inset-inline-start: 0;
  inset-inline-end: 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: start;
  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-inline-start: 0.6em; padding-inline-end: 0.6em; }

/* ---- level-up moment ---- */
.levelup-card { overflow: visible; }
.lu-hero { position: absolute; inset-inline-start: -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; inset-inline-start: 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; inset-inline-end: -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: start; 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-inline-end: 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; inset-inline-start: -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-layer {
  position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 1rem;
  background: rgba(42, 27, 94, 0.5);
}
.who-code-layer[hidden] { display: none; }
.who-code {
  position: relative; display: flex; flex-direction: column; gap: 0.6rem;
  width: min(34rem, 100%); max-height: 100%; overflow-y: auto; padding: 1.1rem 1.4rem 1.2rem;
  animation: card-in 0.3s var(--pop);
}
.who-code .lead { padding-inline-end: 2.8rem; }
.who-code-close { position: absolute; top: 0.6rem; inset-inline-end: 0.6rem; width: 2.4rem; height: 2.4rem; font-size: 1.1rem; font-weight: 900; box-shadow: 0 3px 0 var(--ink); }

/* lead: reset and delete side by side */
.gu-danger-row { display: flex; flex-wrap: wrap; gap: 0.8rem; }

/* ---- the little girl on the map ---- */
.mp-walkpath { position: absolute; width: 0; height: 0; overflow: hidden; }
.mp-girl { position: absolute; z-index: 6; height: 6rem; width: auto; transform: translate(-50%, -100%); pointer-events: none; filter: drop-shadow(0 4px 0 rgba(59, 30, 84, 0.25)); }
.mp-girl[hidden] { display: none; }
.mp-girl:not(.mp-girl-walking):not(.mp-girl-cheer) { animation: mp-girl-idle 2.4s ease-in-out infinite; }
.mp-girl-cheer { animation: mp-girl-hop 0.6s ease-in-out 3; }
@keyframes mp-girl-idle { 0%, 100% { transform: translate(-50%, -100%); } 50% { transform: translate(-50%, calc(-100% - 3px)); } }
@keyframes mp-girl-hop { 0%, 100% { transform: translate(-50%, -100%); } 50% { transform: translate(-50%, calc(-100% - 14px)); } }
.mp-arriving .mp-pin { visibility: hidden; }
.lu-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.8rem; }

/* ---- practice card: two columns, so it fits a 4:3 screen without scrolling (1 Dec) ---- */
.practice-card {
  display: grid; grid-template-columns: 1fr 1fr; align-items: center; justify-items: center;
  grid-template-areas: "title title" "lead lead" "skill stepper" "bar stepper" "actions actions";
  width: min(58rem, 94%); gap: 0.6rem 1.6rem; padding: 1.1rem 1.8rem 1.3rem;
  margin-top: 2.6rem;   /* clear of the Home button now that the card is wide */
}
.practice-card > .title { grid-area: title; }
.practice-card > .lead { grid-area: lead; }
.practice-card > .pr-skill { grid-area: skill; }
.practice-card > .pr-bar { grid-area: bar; }
.practice-card > .stepper { grid-area: stepper; }
.practice-card > .pr-actions { grid-area: actions; width: 100%; }
.practice-card .pr-tables { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); width: 100%; gap: 0.4rem; margin: 0 0 0.3rem; }
.practice-card .pr-tables[hidden] { display: none; }
.practice-card .pr-tables .btn { min-width: 0; min-height: 2.7rem; padding: 0; font-size: 1.1rem; }
.practice-card .pr-tables { order: -1; }   /* chips first, then the lesson button and Start share a row */

/* ---- never cut off: a menu that cannot fit a very short window scrolls instead (1 Dec) ---- */
.sub-body, .home-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pets-grid { gap: 0.8rem 1.2rem; }

/* ==========================================================================
   Home v2 (DESIGN 11.2): one Play button, one journey card, two small buttons
   ========================================================================== */
.home2 { gap: 0.8rem; justify-content: center; }
.home2-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.home2-hi .title { font-size: 3rem; line-height: 1; }
.home2-hi .lead { margin-top: 0.3rem; font-size: 1.2rem; }
.home2-corner {
  position: absolute; z-index: 3; top: calc(0.45rem + env(safe-area-inset-top, 0px)); inset-inline-end: max(1.2rem, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 0.5rem;
}
.home2-corner .pill-coins { font-size: 1.15rem; padding-top: 0.15rem; padding-bottom: 0.15rem; }
#screen-home .banner .l2, #screen-home .banner .d-moon { display: none; }   /* the corner sits there */
.home2-icon { width: 2.9rem; height: 2.9rem; font-size: 1.35rem; line-height: 1; }

.playcard { display: flex; flex-direction: column; gap: 0.3rem; width: 100%; padding: 0.7rem 1.1rem 1rem; }
.playcard-go { display: flex; flex-direction: column; gap: 0.6rem; cursor: pointer; border-radius: var(--radius-m); outline: none; -webkit-tap-highlight-color: transparent; }
.playcard-go:focus-visible { outline: 4px solid var(--orchid); outline-offset: 6px; }
.journey { position: relative; display: flex; flex-direction: column; gap: 0.35rem; width: 100%; color: var(--ink); text-align: start; }
.play-bar {
  display: flex; align-items: center; justify-content: center; gap: 0.9rem; min-height: 4.6rem; padding: 0.3rem 1rem;
  font-size: 2.4rem; font-weight: 900; color: var(--ink); background: var(--rose);
  border: var(--outline); border-radius: var(--radius-l); box-shadow: 0 6px 0 var(--ink);
  animation: play-pulse 2.4s ease-in-out infinite;
}
.play-bar-icon { font-size: 0.8em; }
.playcard-go:active .play-bar { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); animation: none; }
@keyframes play-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
.jr-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.jr-kicker { font-size: 0.95rem; font-weight: 900; color: var(--orchid-deep); }
.jr-map { padding: 0.1rem 0.8rem; font-size: 0.95rem; font-weight: 900; background: var(--butter); border: 3px solid var(--ink); border-radius: 999px; }
.journey .lbar { --sz: 1.2rem; padding: 0; background: none; border: none; box-shadow: none; }
.journey .lb-name { max-width: none; }
.jr-road { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 3rem; margin-top: 1.6rem; padding: 0 3.4rem 0 0.8rem; }
.jr-road::before {
  content: ''; position: absolute; inset-inline-start: 0.4rem; inset-inline-end: 0.4rem; top: 50%; height: 0.8rem; transform: translateY(-50%);
  background: var(--peach); border: 3px solid var(--ink); border-radius: 999px;
}
.jr-stone {
  position: relative; z-index: 1; width: 2.3rem; height: 2.3rem; display: grid; place-items: center;
  font-size: 1.05rem; font-weight: 900; color: var(--ink); background: var(--paper);
  border: 3px dashed var(--ink); border-radius: 50%;
}
.jr-done { background: var(--gold); border-style: solid; }
.jr-here { width: 2.9rem; height: 2.9rem; font-size: 1.4rem; color: #fff; text-shadow: 0 2px 0 var(--ink); background: var(--rose); border-style: solid; animation: jr-pulse 1.6s ease-in-out infinite; }
@keyframes jr-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 61, 0.9); } 50% { box-shadow: 0 0 0 10px rgba(255, 200, 61, 0); } }
.jr-spot { position: relative; z-index: 2; display: flex; align-items: center; }
.jr-girl { position: absolute; z-index: 3; inset-inline-end: calc(100% + 0.45rem); bottom: -0.1rem; height: 4.6rem; width: auto; pointer-events: none; filter: drop-shadow(0 4px 0 rgba(59, 30, 84, 0.25)); }
.jr-girl[hidden] { display: none; }
.jr-next { margin: 0; font-size: 0.95rem; font-weight: 800; color: var(--ink-soft); }
.jr-next:empty { display: none; }

.btn-play { width: 100%; min-height: 5.2rem; display: flex; align-items: center; justify-content: center; gap: 0.9rem; font-size: 2.4rem; }
.btn-play .btn-emoji { font-size: 1.1em; }
.play-words { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.play-note { font-size: 0.95rem; font-weight: 800; }
.play-note:empty { display: none; }
.home2-more { display: flex; justify-content: center; gap: 0.8rem; }
.btn-quiet { --c: var(--paper); flex: 0 1 13rem; min-height: 2.9rem; padding: 0.2em 1em; font-size: 1.15rem; border-width: 3px; box-shadow: 0 3px 0 var(--ink); }
.quiet-chip { padding: 0 0.5rem; font-size: 0.8rem; font-weight: 800; background: var(--butter); border: 2px solid var(--ink); border-radius: 999px; }
.quiet-chip:empty { display: none; }

/* ---- warm-up ---- */
.wu-body { justify-content: center; }
.wu-card { display: flex; align-items: flex-end; gap: 1.6rem; width: min(46rem, 92%); padding: 1.4rem 2rem 1.6rem; }
.wu-ahmed { flex: 0 0 auto; height: 15rem; width: auto; filter: drop-shadow(0 6px 0 rgba(59, 30, 84, 0.2)); }
.wu-ahmed[hidden] { display: none; }
.wu-words { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0.8rem; text-align: center; }
.wu-dots { display: flex; gap: 0.6rem; }
.wu-dot { width: 1.2rem; height: 1.2rem; border: 3px solid var(--ink); border-radius: 50%; background: var(--paper); }
.wu-dot.done { background: var(--gold); }
.wu-dot.now { background: var(--rose); }
.wu-actions { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.wu-cheer .wu-ahmed { animation: wu-hop 0.42s ease-in-out 3; }
@keyframes wu-hop { 0%, 100% { transform: none; } 50% { transform: translateY(-8%); } }
@media (prefers-reduced-motion: reduce) { .wu-cheer .wu-ahmed, .jr-here, .play-bar { animation: none; } }

/* ==========================================================================
   First-run intro (DESIGN 11.3): she walks in, Ahmed arrives, he says how it works
   ========================================================================== */
.screen-intro { overflow: hidden; background: #f3c99b url('../assets/bg/dunes.jpg') center bottom / cover no-repeat; }
.in-stage { position: absolute; inset: 0; }
.in-char { position: absolute; bottom: 6%; display: flex; flex-direction: column; align-items: center; }
.in-girl { inset-inline-start: 16%; }
.in-ahmed { inset-inline-end: 15%; transform: translateX(-80vw); }
.in-ahmed.in-arrive { transform: none; transition: transform 1.1s cubic-bezier(0.2, 0.8, 0.3, 1); }
.in-ahmed.in-arrive .in-img { animation: in-bob 0.27s ease-in-out 4 alternate; }
.in-img { display: block; height: min(50vh, 520px); width: auto; filter: drop-shadow(0 8px 0 rgba(59, 30, 84, 0.25)); }
.in-ahmed .in-img { height: min(58vh, 600px); }
.in-hop .in-img { animation: in-hop 0.42s ease-in-out 2; }

.in-tag {
  position: absolute; bottom: 96%; left: 50%; z-index: 2; display: flex; flex-direction: column; align-items: center; pointer-events: none;
  opacity: 0; transform: translate(-50%, 12px) scale(0.9); transition: opacity 0.3s, transform 0.4s var(--pop);
}
.in-tag.in-show { opacity: 1; transform: translate(-50%, 0); }
.in-tag-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; width: max-content; max-width: 15rem; padding: 0.45rem 1.1rem 0.6rem;
  background: var(--paper); border: var(--outline); border-radius: var(--radius-m); box-shadow: var(--shadow-sticker);
}
.in-tag-name { font-size: 2.1rem; font-weight: 900; line-height: 1.05; color: var(--rose); -webkit-text-stroke: 0.09em var(--ink); paint-order: stroke fill; }
.in-tag-role { font-size: 1.05rem; font-weight: 800; line-height: 1.25; color: var(--ink); }
.in-arrow { width: 3.4rem; height: 3.8rem; margin: -0.1rem 1.4rem 0 0; stroke: var(--ink); stroke-width: 6; overflow: visible; }
.in-arrow-flip { margin: -0.1rem 0 0 1.4rem; }
.in-arrow-flip { transform: scaleX(-1); }
.in-arrow path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.in-show .in-arrow path { animation: in-draw 0.55s 0.2s ease-out forwards; }
.in-show .in-arrow .in-arrow-head { animation-delay: 0.7s; animation-duration: 0.25s; }

.in-bubble {
  position: absolute; top: 4%; inset-inline-start: 18%; inset-inline-end: 18%; z-index: 3; padding: 0.8rem 1.4rem 0.9rem;
  background: var(--paper); border: var(--outline); border-radius: var(--radius-l); box-shadow: var(--shadow-sticker);
  opacity: 0; transform: scale(0.7); transform-origin: 8% 100%; transition: opacity 0.25s, transform 0.4s var(--pop);
}
.in-bubble.in-show { opacity: 1; transform: none; }
.in-bubble::after {
  content: ''; position: absolute; inset-inline-end: 4.4rem; bottom: -1.1rem; width: 1.8rem; height: 1.8rem; transform: rotate(45deg) skew(10deg, 10deg);
  background: var(--paper); border-right: var(--outline); border-bottom: var(--outline);
}
.in-bubble-hi { display: block; font-size: 1.6rem; font-weight: 900; color: var(--orchid-deep); }
.in-bubble ul { margin: 0.4rem 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1.4rem; }
.in-bubble li { display: flex; align-items: baseline; gap: 0.6rem; font-size: 1.1rem; font-weight: 800; line-height: 1.25; }
.in-bubble li span { flex: 0 0 auto; font-size: 1.35rem; }

.in-skip { position: absolute; z-index: 5; top: max(1rem, env(safe-area-inset-top)); inset-inline-end: max(1.2rem, env(safe-area-inset-right)); }
.in-foot { position: absolute; z-index: 5; inset-inline-end: max(1.6rem, env(safe-area-inset-right)); bottom: max(1.2rem, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 1rem; }
.in-next { min-width: 10rem; }
.in-next:disabled { opacity: 0.45; cursor: default; }
.in-next-ready { animation: in-ready 1.3s ease-in-out 2; }
@keyframes in-draw { to { stroke-dashoffset: 0; } }
@keyframes in-bob { from { transform: translateY(0); } to { transform: translateY(-4%); } }
@keyframes in-hop { 0%, 100% { transform: none; } 50% { transform: translateY(-9%); } }
@keyframes in-ready { 0%, 100% { transform: none; } 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) {
  .in-ahmed.in-arrive { transition: none; }
  .in-ahmed.in-arrive .in-img, .in-hop .in-img, .in-next-ready { animation: none; }
  .in-arrow path { stroke-dasharray: none; stroke-dashoffset: 0; }
}
.in-coin .coin-ico { width: 1.3rem; height: 1.3rem; display: inline-block; vertical-align: -0.2rem; }

/* ---- start screen: one player for now (DESIGN 11.4) ---- */
#screen-who .who-body { justify-content: center; gap: 1.2rem; }
#screen-who .title { font-size: 3.4rem; }
.who-play {
  display: flex; align-items: flex-end; gap: 1.6rem; padding: 1rem 1.4rem 1.4rem 2.4rem;
  font: inherit; color: var(--ink); cursor: pointer; text-align: start;
}
.who-play:active { transform: translateY(3px); }
.who-play.loading { opacity: 0.6; pointer-events: none; }
.who-play-img { height: 15rem; width: auto; filter: drop-shadow(0 6px 0 rgba(59, 30, 84, 0.2)); animation: floaty 3.6s ease-in-out infinite; }
.who-play-words { display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; padding-bottom: 0.4rem; }
.who-play-small { font-size: 1.3rem; font-weight: 800; color: var(--ink-soft); }
.who-play-name { font-size: 3.2rem; font-weight: 900; line-height: 1; color: var(--rose); -webkit-text-stroke: 0.08em var(--ink); paint-order: stroke fill; }
.who-play .who-coins { font-size: 1.2rem; font-weight: 800; }
.who-play .who-coins:empty { display: none; }
.who-play-go { margin-top: 0.6rem; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .who-play-img { animation: none; } }
.who-sync { font-size: 1rem; font-weight: 800; color: var(--ink-soft); background: rgba(255, 255, 255, 0.55); }
.who-sync[hidden] { display: none; }
.who-sync-synced { color: #17703a; }
.who-sync-refused, .who-sync-offline { background: var(--butter); color: var(--ink); }
.who-code-msg { margin: 0.2rem 0 0; font-size: 0.95rem; font-weight: 800; color: var(--ink); }
.who-code-msg:empty { display: none; }
.who-logout { margin-top: 0.3rem; font-size: 0.95rem; }
.who-logout[hidden] { display: none; }
.test-pill { background: #c9f2d0; font-size: 1rem; font-weight: 900; }
.test-pill[hidden] { display: none; }

/* ---- the sixth track: Fractions and percentages (frac, DESIGN 12.1) ---- */
.lbar-frac { background: #d8ebff; }
.lbar-frac .lb-sign { color: #2c6bc9; }
.lchip-frac { background: #d8ebff; }
.mp-path-frac .mp-sign { background: #8fc6ff; }

/* ---- time's up: the daily play limit (DESIGN 13) ---- */
.tu-hold { position: relative; overflow: hidden; margin-top: 0.4rem; font-size: 1rem; -webkit-user-select: none; user-select: none; touch-action: none; }
.tu-hold-fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; background: var(--mint); }
.tu-holding .tu-hold-fill { width: 100%; transition: width 2s linear; }
.tu-hold-label { position: relative; }
.time-pill { background: var(--paper); font-size: 1rem; font-weight: 900; }
.time-pill[hidden] { display: none; }
.time-pill.time-low { background: var(--butter); }
.gu-playtime .seg button { min-width: 4.2rem; }

/* ==========================================================================
   Yalla Nahw!: right-to-left touch-ups and the lesson bar
   ========================================================================== */
.lb-slot.lb-wrong { color: var(--peach); opacity: 0.9; }
.lb-fly .lb-slot { transform: translateX(calc((var(--i) - var(--c)) * (var(--sz) + 3px))) scale(0.2); }
.lbar-nahw .lb-name { max-width: none; white-space: normal; }
.jr-where { display: flex; flex-direction: column; gap: 0.05rem; line-height: 1.25; }
.jr-stage { font-size: 0.95rem; font-weight: 800; color: var(--ink-soft); }
.jr-lesson { font-size: 1.35rem; font-weight: 900; color: var(--ink); }
.jr-hint { margin: 0; font-size: 0.85rem; font-weight: 800; color: var(--ink-soft); }
.jr-stone { font-family: var(--font-ui); }
.jr-placed { background: #ffe9a8; border-style: solid; }
.btn-emoji { margin-inline-end: 0.1rem; }
.text-input { font-family: var(--font-ui); }
.journey .lbar .lb-head { display: none; }   /* the title above already says the lesson */
.journey .lbar-nahw { --sz: 1.1rem; }

/* Arabic letters and their marks reach higher and lower than Latin ones: the line heights of 1 to
   1.05 this layout came with clip them or let them run into the next line (lead, 2 Dec 2026). */
.play-words { line-height: 1.3; gap: 0.15rem; }
.play-note { line-height: 1.5; }
.home2-hi .title, .who-play-name, .in-tag-name, .lu-kicker, .lu-name, .mp-card-name, .tp-c-text b { line-height: 1.3; }
.play-bar-icon { display: inline-block; transform: scaleX(-1); }   /* points the way she reads: left */
