/* ==========================================================================
   Busy Book — felt & stitches design system
   ========================================================================== */

@font-face {
  font-family: 'Grandstander';
  src: url('../assets/fonts/Grandstander.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
  /* Grandstander's own metrics (asc 1465 / desc 530 per 2000) make text ride high in every box.
     Re-balance so the midpoint of cap- and x-height sits in the centre of the line box
     (same total height, so line-height: normal is unchanged). */
  ascent-override: 79.3%;
  descent-override: 20.45%;
  line-gap-override: 0%;
}

:root {
  /* felt palette (mirrors PALETTE in js/core/ui.js) */
  --c-red: #e8553f;
  --c-orange: #f28c38;
  --c-yellow: #f6c945;
  --c-green: #6dbb63;
  --c-blue: #4fa3d9;
  --c-purple: #9a5fb5;
  --c-pink: #f08aa8;
  --c-brown: #9b6b43;
  --c-teal: #34b3a0;
  --c-navy: #2f4b7c;
  --c-black: #3a3330;
  --c-white: #fffaf0;

  --linen: #f4e9d6;
  --linen-dark: #e9d9bd;
  --ink: #4a3426;
  --ink-soft: #8a6e58;
  --stitch: rgba(255, 250, 240, 0.85);

  --radius: 28px;
  --gap: 16px;
  --font: 'Grandstander', 'Comic Sans MS', 'Chalkboard SE', 'Trebuchet MS', sans-serif;
  --emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif;

  /* Edge margin for every control/label (home button, game buttons, counters…). Backgrounds stay full-bleed
     (they use inset: 0); everything placed with var(--safe-*) + Npx automatically sits this much further in. */
  --edge: clamp(8px, calc(1.2vmin + 2px), 16px);
  --safe-top: calc(env(safe-area-inset-top, 0px) + var(--edge));
  --safe-left: calc(env(safe-area-inset-left, 0px) + var(--edge));
  --safe-right: calc(env(safe-area-inset-right, 0px) + var(--edge));
  --safe-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--edge));
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overflow: clip;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--linen);
  /* woven linen texture */
  background-image:
    repeating-linear-gradient(0deg, rgba(120, 90, 50, 0.045) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(120, 90, 50, 0.04) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 20% 0%, rgba(255, 255, 255, 0.6), transparent 60%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

img {
  -webkit-user-drag: none;
}

.emoji {
  font-family: var(--emoji);
  line-height: 1;
  display: inline-block;
}

/* ui.centreGlyph(): the drawing (not its box) sits in the middle and turns round its own centre.
   Uses left/top so it never fights the rotate/translate/scale reactions; :where keeps .react-wave's origin. */
.emoji.is-centred {
  position: relative;
  left: calc(var(--gx) * -1em);
  top: calc(var(--gy) * -1em);
}

:where(.emoji.is-centred) {
  transform-origin: calc(50% + var(--gx) * 1em) calc(50% + var(--gy) * 1em);
}

/* drawn icons (js/core/icons.js) sized like the emoji they stand in for */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  line-height: 0;
}
.icon > svg {
  width: 100%;
  height: 100%;
}
.tile .icon {
  width: calc(var(--tile) * 0.42);
  height: calc(var(--tile) * 0.42);
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.15));
}
.felt-btn .icon {
  width: 62%;
  height: 62%;
}

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

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

/* ---- felt surfaces ---------------------------------------------------- */

.felt,
.felt-card,
.felt-btn,
.tile {
  --c: var(--c-blue);
  position: relative;
  background-color: var(--c);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.10) 1px, transparent 1.5px),
    radial-gradient(rgba(0, 0, 0, 0.07) 1px, transparent 1.5px),
    linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.06));
  background-size: 5px 5px, 7px 7px, 100% 100%;
  background-position: 0 0, 2px 3px, 0 0;
  border: none;
  color: #fff;
  box-shadow:
    0 6px 0 color-mix(in srgb, var(--c) 70%, #000),
    0 12px 22px rgba(74, 52, 38, 0.22);
}

/* stitched edge */
.felt::before,
.felt-card::before,
.felt-btn::before,
.tile::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 3px dashed var(--stitch);
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.85;
}

.felt-btn {
  --size: 76px;
  width: var(--size);
  height: var(--size);
  min-width: var(--size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--emoji);
  font-size: calc(var(--size) * 0.46);
  line-height: 1;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.felt-btn::before {
  inset: 6px;
  border-width: 2.5px;
}

.felt-btn:active,
.felt-card:active,
.tile:active {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 color-mix(in srgb, var(--c) 70%, #000),
    0 4px 10px rgba(74, 52, 38, 0.2);
}

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

.home {
  overflow-x: hidden; /* never scroll sideways (tooltips, tilted tiles) */
  overflow-x: clip;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 16px)
    calc(var(--safe-left) + 16px);
  overflow-y: auto;
}

.home__header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 80px;
  margin-bottom: 16px;
  padding-inline: 72px;
}

.ribbon {
  --c: var(--c-red);
  position: relative;
  padding: 16px 48px;
  font-size: clamp(25px, 4.8vw, 42px);
  font-weight: 800;
  letter-spacing: 0.5px;
  border-radius: 18px;
  transform: rotate(-1.5deg);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.parent-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px dashed var(--ink-soft);
  background: transparent;
  color: var(--ink-soft);
  font-size: 24px;
  opacity: 0.55;
  display: grid;
  place-items: center;
}

.parent-btn__tag {
  position: absolute;
  right: -13px;
  bottom: -8px;
  padding: 3px 7px;
  border: 2px solid var(--linen);
  border-radius: 999px;
  background: var(--c-yellow);
  color: var(--ink);
  font: 700 10px/1 var(--font);
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(74, 52, 38, 0.2);
}

.home__language {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.home__language select {
  min-width: 52px;
  min-height: 44px;
  padding: 6px 8px;
  border: 2px dashed var(--linen-dark);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.85);
  color: var(--ink-soft);
  font: 700 14px var(--font);
  cursor: pointer;
}

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

.tiles {
  /* sized so all nine tiles fit a landscape tablet without scrolling */
  --tile: clamp(110px, min(15vw, 26dvh), 220px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 24px 20px;
  /* at most seven per row → balanced 7 + 6 for 13 tiles on wide screens */
  max-width: calc(var(--tile) * 7 + 20px * 6 + 8px);
  width: 100%;
  align-self: center;
  margin-block: auto; /* vertically centred, but never clipped when it overflows */
  padding: 8px 4px 32px;
}

.home__footer {
  width: min(100%, 980px);
  align-self: center;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 4px 8px;
}

/* installed app: only the privacy card is left, full width */
.home__footer.home__footer--single {
  grid-template-columns: 1fr;
}

.home__footer-card {
  padding: 10px 14px;
  border: 2px dashed var(--linen-dark);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.78);
}

.home__install-card {
  padding-bottom: 18px;
}

.home__footer-card h2 {
  margin: 0 0 4px;
  font-size: clamp(17px, 2vw, 21px);
}

.home__footer-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.35;
}

.home__privacy-more {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.home__privacy-more:focus-visible {
  outline: 2px solid var(--c-blue);
  outline-offset: 2px;
  border-radius: 2px;
}

.home__footer-card .pill {
  margin-top: 4px;
}

.pill.primary.home__install-button {
  width: 100%;
  min-height: 42px;
  padding: 2px 10px;
  border-color: var(--c-green);
  background: var(--c-green);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c-green) 70%, #000);
}

.home__installed {
  margin-top: 10px !important;
  font-weight: 700;
}

@media (orientation: portrait) {
  .tiles {
    --tile: clamp(120px, min(40vw, 24dvh), 230px);
  }
}

@media (orientation: landscape) and (min-height: 620px) {
  .home {
    overflow: hidden;
    padding-bottom: calc(var(--safe-bottom) + 4px);
  }

  .tiles {
    --tile: clamp(96px, min(18vw, 21dvh, calc((100dvh - 320px) / 3), calc((100vw - 176px) / 5)), 160px);
    flex: 0 0 auto;
    overflow: visible;
    align-content: center;
    gap: 18px 20px;
    max-width: calc(var(--tile) * 5 + 20px * 4 + 8px);
    position: relative;
    top: -5px;
    margin-block: auto;
    padding: 8px 4px;
  }
}

@media (max-width: 600px) {
  .home {
    overflow-y: auto;
  }

  .tiles {
    flex: 0 0 auto;
  }

  .home__footer {
    grid-template-columns: 1fr;
  }

  /* grid instead of absolute side controls, so the ribbon can never run under them */
  .home__header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 16px;
    padding-inline: 0 8px; /* room for the "For parents" tag hanging off the gear */
  }

  .home__language,
  .parent-btn {
    position: relative;
    inset: auto;
    transform: none;
  }

  .parent-btn {
    justify-self: end;
  }

  .ribbon {
    justify-self: center;
    padding: 12px 20px;
    font-size: clamp(22px, 6.4vw, 34px);
    text-align: center;
    text-wrap: balance;
  }
}

.tile {
  width: var(--tile);
  aspect-ratio: 1;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  animation: drop-in 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  transition: transform 0.15s ease;
}

.tile:nth-child(3n + 1) {
  transform: rotate(-1.2deg);
}
.tile:nth-child(3n + 2) {
  transform: rotate(1deg);
}

.tile .emoji {
  font-size: calc(var(--tile) * 0.4);
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.15));
}

.tile__label {
  font-size: clamp(16px, calc(var(--tile) * 0.11), 24px);
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  text-align: center;
  line-height: 1.1;
}

/* ---- game screen ------------------------------------------------------ */

.game-screen .stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overflow: clip;
  touch-action: none;
}

.home-btn {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 12px);
  z-index: 1000; /* above every game layer, celebration and mascot */
  --size: 64px;
}

.stage-title {
  position: absolute;
  top: calc(var(--safe-top) + 20px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 800;
  pointer-events: none;
  z-index: 5;
}

/* ---- picker (choose a page / puzzle / story) -------------------------- */

.picker-wrap {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: calc(var(--safe-top) + 12px) 20px calc(var(--safe-bottom) + 32px);
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
}

/* the title shares the home button's row (same top, same 64px height, clear of it on both sides)… */
.picker-wrap > :first-child:not(.picker) {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-inline: 76px;
}

/* …and the cards are centred in the space below; auto margins never clip when it overflows */
.picker-wrap > :nth-child(2) {
  margin-top: auto;
}
.picker-wrap > :last-child {
  margin-bottom: auto;
}

.picker-title {
  margin: 0 0 16px;
  text-align: center;
  font-size: clamp(22px, 4vw, 34px);
}

.picker {
  --card: clamp(150px, min(26vw, 40dvh), 300px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  max-width: 1320px;
  margin: 0 auto;
}

@media (orientation: portrait) {
  .picker {
    --card: clamp(140px, 42vw, 300px);
  }
}

.felt-card {
  width: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: drop-in 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  transition: transform 0.12s ease;
}

.felt-card__art {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  background: var(--c-white);
  overflow: hidden;
  overflow: clip;
  display: grid;
  place-items: center;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.12);
  color: var(--ink);
}

.felt-card__art > img,
.felt-card__art > svg,
.felt-card__art > canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.felt-card__label {
  font-weight: 700;
  font-size: 20px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

/* ---- effects ----------------------------------------------------------- */

.fx-dot {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 60;
}

.fx-celebrate {
  position: absolute;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  overflow: clip;
  display: grid;
  place-items: center;
}

.fx-confetti {
  position: absolute;
  top: 0;
}


.wiggle {
  animation: wiggle 0.45s ease;
}

.boing {
  animation: boing 0.5s cubic-bezier(0.3, 1.8, 0.5, 1);
}

@keyframes drop-in {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.9);
  }
}


@keyframes wiggle {
  0%, 100% { translate: 0; }
  20% { translate: -10px 0; }
  40% { translate: 9px 0; }
  60% { translate: -6px 0; }
  80% { translate: 4px 0; }
}

@keyframes boing {
  0% { scale: 1; }
  40% { scale: 1.25; }
  100% { scale: 1; }
}

/* ---- character reactions (ui.react) ----------------------------------- */
/* individual transform properties so they stack on top of a game's own positioning transform */

.react-dance { animation: r-dance 1.1s ease-in-out; transform-origin: 50% 100%; }
.react-jump { animation: r-jump 0.8s cubic-bezier(0.3, 0.7, 0.4, 1); }
.react-spin { animation: r-spin 0.9s cubic-bezier(0.4, 1.4, 0.5, 1); }
.react-wave { animation: r-wave 1s ease-in-out; transform-origin: 30% 90%; }
.react-nod { animation: r-nod 0.8s ease-in-out; }
.react-shiver { animation: r-shiver 0.6s linear; }
.react-grow { animation: r-grow 0.9s cubic-bezier(0.3, 1.6, 0.5, 1); }
.react-love { animation: r-love 1.1s ease-in-out; }
.react-laugh { animation: r-laugh 0.9s ease-in-out; transform-origin: 50% 100%; }
.react-sing { animation: r-sing 1.2s ease-in-out; transform-origin: 50% 100%; }

@keyframes r-dance {
  0%, 100% { rotate: 0deg; translate: 0 0; }
  15% { rotate: -14deg; translate: 0 -12%; }
  30% { rotate: 12deg; translate: 0 0; }
  45% { rotate: -12deg; translate: 0 -12%; }
  60% { rotate: 10deg; translate: 0 0; }
  80% { rotate: 0deg; scale: 1.15; translate: 0 -18%; }
}
@keyframes r-jump {
  0%, 100% { translate: 0 0; scale: 1 1; }
  15% { scale: 1.15 0.85; }
  45% { translate: 0 -45%; scale: 0.9 1.12; }
  75% { translate: 0 0; scale: 1.12 0.9; }
}
@keyframes r-spin { from { rotate: 0deg; scale: 1; } 50% { scale: 1.2; } to { rotate: 360deg; scale: 1; } }
@keyframes r-wave {
  0%, 100% { rotate: 0deg; }
  20%, 60% { rotate: -16deg; }
  40%, 80% { rotate: 14deg; }
}
@keyframes r-nod { 0%, 100% { rotate: 0deg; } 25%, 75% { rotate: 8deg; translate: 0 6%; } 50% { rotate: 0deg; } }
@keyframes r-shiver { 0%, 100% { translate: 0 0; } 20%, 60% { translate: -5% 0; } 40%, 80% { translate: 5% 0; } }
@keyframes r-grow { 0%, 100% { scale: 1; } 40% { scale: 1.45; } 60% { scale: 1.3; } }
@keyframes r-love { 0%, 100% { scale: 1; } 20%, 60% { scale: 1.2; } 40%, 80% { scale: 1.05; } }
@keyframes r-laugh {
  0%, 100% { rotate: 0deg; scale: 1; }
  10%, 30%, 50%, 70% { rotate: -6deg; scale: 1.08 0.94; }
  20%, 40%, 60%, 80% { rotate: 6deg; scale: 0.96 1.06; }
}
@keyframes r-sing {
  0%, 100% { scale: 1; rotate: 0deg; }
  25% { scale: 1.08 1.14; rotate: -6deg; }
  50% { scale: 1; rotate: 0deg; }
  75% { scale: 1.08 1.14; rotate: 6deg; }
}

.fx-float {
  position: fixed;
  z-index: 90;
  pointer-events: none;
}

/* ---- mascot (core/buddy.js) -------------------------------------------- */

.buddy {
  position: fixed;
  left: calc(var(--safe-left) + 8px);
  bottom: -200px; /* fully hidden, even at the big-cheer size (1.4×) */
  width: 120px;
  height: 120px;
  z-index: 85;
  pointer-events: none;
  transition: bottom 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.buddy.is-up {
  bottom: calc(var(--safe-bottom) + 12px);
}

.buddy .star-face {
  filter: drop-shadow(0 6px 6px rgba(74, 52, 38, 0.25));
}

/* reactions move the star beyond its viewBox; never clip it */
.star-face {
  overflow: visible;
}

.buddy.is-up .star-face__body {
  transform-origin: 50% 60%;
  animation: r-wave 1s ease-in-out;
}
.buddy.is-up[data-mood='cheer'] .star-face__body { animation: r-jump 0.7s 2 cubic-bezier(0.3, 0.7, 0.4, 1); }
.buddy.is-up[data-mood='love'] .star-face__body { animation: r-love 1.1s ease-in-out; }
.buddy.is-up[data-mood='laugh'] .star-face__body { animation: r-laugh 0.9s ease-in-out; }
.buddy.is-up[data-mood='oops'] .star-face__body { animation: r-shiver 0.6s linear; }
.buddy.is-up[data-mood='wow'] .star-face__body { animation: r-grow 0.9s cubic-bezier(0.3, 1.6, 0.5, 1); }
.buddy.is-up[data-mood='sleepy'] .star-face__body { animation: r-nod 1.6s ease-in-out; }

/* big cheer (celebrations): grows out of its corner and jumps three times */
.buddy.is-big .star-face {
  scale: 1.4;
  transform-origin: 0% 100%;
  transition: scale 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.buddy.is-up.is-big[data-mood='cheer'] .star-face__body { animation: r-jump 0.7s 3 cubic-bezier(0.3, 0.7, 0.4, 1); }

.buddy__fx {
  position: absolute;
  top: 10px;
  font-size: 26px;
}

/* ---- overlay / parent area -------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(74, 52, 38, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade 0.2s ease both;
}

.sheet {
  background: var(--linen);
  border-radius: var(--radius);
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  font-size: 18px;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
}

.sheet h2 {
  margin: 0 0 16px;
  font-size: 28px;
}

.sheet h3 {
  margin: 24px 0 8px;
  font-size: 20px;
}

.sheet p {
  margin: 8px 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  min-height: 48px;
  padding: 8px 20px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: transparent;
  font-weight: 700;
  font-size: 18px;
}

.pill[aria-pressed='true'],
.pill.primary {
  background: var(--ink);
  color: var(--linen);
}

.gate-answers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.gate-answers .pill {
  min-height: 64px;
  font-size: 26px;
}

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

.photo-thumb {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  overflow: clip;
  aspect-ratio: 4 / 3;
  background: var(--linen-dark);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  font-size: 18px;
  line-height: 1;
}

.muted {
  color: var(--ink-soft);
  font-size: 15px;
}

.sheet-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 12px;
}

.load-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 24px;
  text-align: center;
  padding: 24px;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

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

/* hover (mouse/trackpad only — never sticks on touch screens): lift + glow so it's obvious what's clickable.
   Uses translate/scale so it combines with the tiles' tilt and the pressed state. */
@media (hover: hover) and (pointer: fine) {
  .felt-btn,
  .felt-card,
  .tile {
    transition: transform 0.12s ease, box-shadow 0.15s ease, translate 0.15s ease, scale 0.15s ease, filter 0.15s ease;
  }
  /* round buttons: a calm lift + brighten, no growing (they often sit close together) */
  .felt-btn {
    transition: transform 0.12s ease, box-shadow 0.2s ease-out, translate 0.2s ease-out, filter 0.2s ease-out;
  }
  .felt-btn:hover {
    translate: 0 -2px;
    filter: brightness(1.06);
  }
  .felt-card:hover,
  .tile:hover {
    translate: 0 -4px;
    scale: 1.05;
    filter: brightness(1.08) saturate(1.05);
    box-shadow:
      0 9px 0 color-mix(in srgb, var(--c) 70%, #000),
      0 18px 28px rgba(74, 52, 38, 0.28);
  }
  .felt-btn:active,
  .felt-card:active,
  .tile:active {
    translate: 0 0;
    scale: 1;
  }
  .pill:hover {
    background: var(--ink);
    color: var(--linen);
  }
  .parent-btn:hover {
    opacity: 0.9;
  }
  /* any other button a game draws itself */
  [data-game] button:not(.felt-btn):not(.felt-card):hover {
    filter: brightness(1.08);
  }
  button {
    cursor: pointer;
  }
}

/* the felt sun (core/buddy.js sunFace) stands in for ☀️, so it is sized like an emoji */
.sun-face {
  width: 1em;
  height: 1em;
  vertical-align: middle;
}

/* ---- free games of the day (core/access.js) ----------------------------------------------- */

/* games not free today: faded with a padlock (tap → shake + "locked today" popup) */
.tile.is-asleep {
  filter: grayscale(0.55) brightness(0.96);
  opacity: 0.72;
}

.tile.is-asleep .icon,
.tile.is-asleep .emoji {
  opacity: 0.8;
}

/* hover tooltip on locked tiles (mouse/trackpad only; touch gets the tap popup) */
@media (hover: hover) and (pointer: fine) {
  .tile.is-asleep:hover {
    z-index: 5;
    opacity: 1;
    filter: none;
  }

  .tile.is-asleep[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    top: calc(100% + 10px);
    z-index: 5;
    width: max-content;
    max-width: calc(var(--tile) + 24px); /* stays inside the page gutter, even under the edge tiles */
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--ink);
    color: var(--linen);
    box-shadow: 0 6px 16px rgba(74, 52, 38, 0.3);
    font: 700 14px/1.35 var(--font);
    text-align: center;
    text-shadow: none;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    translate: -50% -4px;
    transition: opacity 0.12s ease, translate 0.12s ease;
  }

  .tile.is-asleep[data-tip]:hover::after {
    opacity: 1;
    translate: -50% 0;
  }
}

.tile__lock {
  position: absolute;
  top: 10px;
  right: 12px;
  font-family: var(--emoji);
  font-size: calc(var(--tile) * 0.2);
  line-height: 1;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.2));
}

/* "locked today" popup: the game's tile picture with a padlock */
.locked-sheet {
  text-align: center;
}

.locked-sheet__art {
  position: relative;
  width: 112px;
  height: 112px;
  margin: 4px auto 8px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background: var(--c);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 70%, #000);
  font-size: 56px;
}

.locked-sheet__art .icon {
  width: 60%;
  height: 60%;
}

.locked-sheet__lock {
  position: absolute;
  right: -10px;
  bottom: -8px;
  font-family: var(--emoji);
  font-size: 40px;
  line-height: 1;
}

.locked-sheet .sheet-footer {
  justify-content: center;
}

/* parent area: unlock everything */
.unlock-box {
  margin: 8px 0 16px;
  padding: 4px 16px 12px;
  border: 2px dashed var(--linen-dark);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.7);
}

.buy-card {
  margin: 12px 0;
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 0 rgba(74, 52, 38, 0.12);
  text-align: center;
}

/* buying is always the friendly green button (beats .pill.primary's brown) */
.pill.buy-btn {
  display: flex; /* full width in the buy card; wraps to centred lines on narrow screens */
  width: 100%;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  min-height: 52px;
  padding: 12px 20px 10px; /* Grandstander sits high in its line box: a little more room on top */
  border-color: var(--c-green);
  background: var(--c-green);
  color: #fff;
  font-size: 18px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c-green) 70%, #000);
}

.locked-sheet .pill.buy-btn {
  width: auto;
  min-height: 44px;
  font-size: 16px;
}

.buy-card__safe {
  margin: 10px 0 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

.pay-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.pay-chip {
  padding: 3px 10px;
  border: 1.5px solid var(--linen-dark);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink-soft);
  font: 700 12px/1.4 system-ui, sans-serif;
}

.unlock-input {
  min-height: 44px;
  min-width: 0;
  flex: 1 1 180px;
  padding: 8px 12px;
  border: 2px solid var(--linen-dark);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: 700 18px/1.2 var(--font);
  letter-spacing: 1px;
  text-transform: uppercase;
  user-select: text;
  -webkit-user-select: text;
}

a.pill {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.pill.buy-btn:hover {
  background: var(--c-green);
  color: #fff;
  filter: brightness(1.08);
}

/* parent area, unlocked: the (masked) license key */
.license-key strong {
  font-family: ui-monospace, monospace;
  letter-spacing: 1px;
}

/* start-up splash while a new version loads (only shown if that takes a moment) */
.boot-splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  font-size: clamp(26px, 6vw, 42px);
}

.boot-splash p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 32px;
  animation: boot-dots 1s ease-in-out infinite alternate;
}

@keyframes boot-dots {
  from { opacity: 0.3; }
  to { opacity: 1; }
}
