/* Super Monster — kids' monster builder.
   Palette borrows from Čičmany folk embroidery: white geometry on dark cloth,
   with folk red and wheat yellow doing the shouting. */

:root {
  --cloth:  #241a3d;
  --cloth2: #322450;
  --cream:  #fff6e8;
  --folk:   #d8352a;
  --wheat:  #f5c542;
  --ink:    #1a1230;

  --r-sm: 12px;
  --r-md: 20px;
  --r-lg: 32px;

  --topbar-h: 64px;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%23fff6e8' stroke-opacity='.07' stroke-width='2'%3E%3Cpath d='M0 30l15-15 15 15 15-15 15 15'/%3E%3Cpath d='M0 60l15-15 15 15 15-15 15 15'/%3E%3Cpath d='M30 8v14M30 38v14'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

/* Big tap targets: no double-tap zoom, no text magnifier on a long press */
button, a, .pin__key, .word, .group, .mode {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  /* clip, not hidden: hidden would make the body a scroll container and
     break position: sticky on the top bar and the stage */
  overflow-x: clip;
}

body {
  min-height: 100dvh;
  background-color: var(--cloth);
  background-image: var(--pattern);
  color: var(--cream);
  font-family: 'Baloo 2', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  font-weight: 500;
  font-size: 18px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

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

:focus-visible {
  outline: 4px solid var(--wheat);
  outline-offset: 3px;
}

/* ---------- shared bits ---------- */

.btn {
  appearance: none;
  border: 0;
  border-radius: var(--r-md);
  background: var(--folk);
  box-shadow: 0 5px 0 #9c2119;
  color: var(--cream);
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  padding: 0.7em 1.6em;
  cursor: pointer;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #9c2119;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: progress;
}

.btn--small {
  font-size: 1rem;
  padding: 0.5em 1.1em;
  box-shadow: 0 4px 0 #9c2119;
}

.notice {
  max-width: 30ch;
  margin: 1rem auto;
  text-align: center;
  color: var(--wheat);
}

/* ---------- who is playing ---------- */

.pick {
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3rem) 1.25rem 3rem;
}

.pick__title {
  margin: 0 0 2rem;
  text-align: center;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
}

.pick__title span {
  display: block;
  font-size: 0.42em;
  font-weight: 500;
  color: #b9a8dc;
}

.pick__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  height: 100%;
  padding: 1.25rem 1rem;
  border-radius: var(--r-lg);
  background: var(--cloth2);
  box-shadow: 0 6px 0 #1a1230;
  color: inherit;
  text-decoration: none;
}

.card__monster {
  width: 100%;
  max-width: 140px;
  height: auto;
}

.card__name {
  font-size: 1.3rem;
  font-weight: 800;
}

.card__sub {
  font-size: 0.85rem;
  color: #b9a8dc;
}

.card--new {
  justify-content: center;
  gap: 0.75rem;
}

.card__plus {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--wheat);
}

.card__input {
  width: 100%;
  border: 3px solid #4b3a72;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--cream);
  font: inherit;
  padding: 0.5em 0.7em;
  text-align: center;
}

/* ---------- builder ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
}

.topbar__back {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--cloth2);
  color: var(--cream);
  font-size: 1.5rem;
  text-decoration: none;
}

.topbar__who {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.2rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.build {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 8rem;
}

.stage {
  position: relative;
  display: grid;
  place-items: end center;
  min-height: 46vh;
}

.stage__floor {
  position: absolute;
  bottom: 6%;
  width: min(78%, 340px);
  aspect-ratio: 3 / 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, .45), transparent);
}

/* the 3D monster casts its own shadow */
.stage--3d .stage__floor { display: none; }

.stage__monster {
  position: relative;
  width: min(74%, 300px);
  animation: bob 3.4s ease-in-out infinite;
}

.stage__monster .monster {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .35));
}

.stage__monster.is-popping {
  animation: bob 3.4s ease-in-out infinite, pop .28s ease-out;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06, 0.94); }
  100% { transform: scale(1); }
}

.namebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.5rem 0 1.25rem;
  flex-wrap: wrap;
}

.namebar label {
  color: #b9a8dc;
}

.namebar input {
  width: min(100%, 240px);
  border: 3px solid #4b3a72;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--cream);
  font: inherit;
  font-weight: 800;
  font-size: 1.2rem;
  padding: 0.4em 0.7em;
  text-align: center;
}

.slots {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}

.slots::-webkit-scrollbar { display: none; }

.slot {
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--r-md);
  background: var(--cloth2);
  color: var(--cream);
  font: inherit;
  padding: 0.5em 1.1em;
  cursor: pointer;
  text-align: center;
}

.slot__sk {
  display: block;
  font-weight: 800;
  font-size: 1.05rem;
}

.slot__en {
  display: block;
  font-size: 0.75rem;
  color: #b9a8dc;
}

.slot.is-active {
  background: var(--wheat);
  color: var(--ink);
}

.slot.is-active .slot__en { color: #7a6118; }

.options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  border: 4px solid transparent;
  border-radius: var(--r-md);
  background: var(--cloth2);
  color: var(--cream);
  font: inherit;
  padding: 0.6rem 0.4rem 0.5rem;
  cursor: pointer;
}

.option__monster {
  width: 100%;
  max-width: 72px;
  height: auto;
}

.option__name {
  font-size: 0.85rem;
  font-weight: 700;
}

.option.is-chosen {
  border-color: var(--wheat);
  background: #3d2c60;
}

.option.is-locked {
  opacity: 0.55;
}

.option.is-locked .option__monster {
  filter: grayscale(0.6);
}

.option.is-affordable {
  opacity: 0.85;
}

.option.is-pending {
  opacity: 1;
  border-color: var(--folk);
  background: #3d2c60;
}

.option__cost {
  position: absolute;
  top: -8px; right: -8px;
  min-width: 30px;
  border-radius: 999px;
  background: var(--wheat);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.1em 0.4em;
}

/* premium accessories: gold-trimmed tab and price tags */
.slot--premium {
  border: 2px solid rgba(245, 197, 66, .55);
}

.slot__star { color: var(--wheat); font-size: 0.8em; }
.slot.is-active .slot__star { color: #7a6118; }

.option--premium.is-locked { opacity: 0.7; }

.option__cost--premium {
  background: linear-gradient(135deg, #f5c542, #e0903a);
  box-shadow: 0 0 0 2px #2a1b3d, 0 0 10px rgba(245, 197, 66, .6);
}

/* the babies tab stacks its own rows instead of the option grid */
.options--stack {
  display: block;
}

.babypick {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.5rem;
  scrollbar-width: none;
}

.babypick::-webkit-scrollbar { display: none; }

.babypick__btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 84px;
  border: 4px solid transparent;
  border-radius: var(--r-md);
  background: var(--cloth2);
  color: var(--cream);
  font: inherit;
  padding: 0.4rem 0.5rem 0.35rem;
  cursor: pointer;
}

.babypick__btn.is-active {
  border-color: var(--wheat);
  background: #3d2c60;
}

.babypick__monster {
  width: 56px;
  height: auto;
}

.babypick__name {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.subslots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.25rem;
}

.subslot {
  border: 0;
  border-radius: 999px;
  background: var(--cloth2);
  color: var(--cream);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.3em 0.9em;
  cursor: pointer;
}

.subslot.is-active {
  background: var(--wheat);
  color: var(--ink);
}

.babynote {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: #b9a8dc;
}

.babynote .btn__en { font-size: 0.8rem; }

.options--baby { margin-top: 0.75rem; }

.babyempty {
  text-align: center;
  padding: 0.5rem 0 0;
}

.babyempty__egg { font-size: 3rem; line-height: 1; }
.babyempty__sk { margin: 0.5rem 0 0.2rem; font-size: 1.2rem; font-weight: 800; }
.babyempty__en { margin: 0 auto 0.8rem; max-width: 34ch; font-size: 0.85rem; color: #b9a8dc; }

.babyempty__ready { margin: 0 auto 0.8rem; max-width: 36ch; font-weight: 700; color: var(--wheat); }
.babyempty__ready .btn__en { display: block; font-weight: 500; color: #b9a8dc; }

.babyempty__list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 420px;
  text-align: left;
}

.babyempty__list li {
  display: grid;
  grid-template-columns: 1fr 80px auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.babyempty__list small { font-weight: 500; color: #b9a8dc; }

.babyempty__bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 246, 232, .12);
  overflow: hidden;
}

.babyempty__bar i { display: block; height: 100%; border-radius: 4px; background: var(--wheat); }

.swatch {
  width: 56px;
  height: 56px;
  border: 4px solid;
  border-radius: 50%;
}

.savebar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--cloth) 65%, transparent);
}

.savebar__msg {
  font-weight: 700;
}

.savebar__msg.is-good { color: #86e0a0; }
.savebar__msg.is-bad  { color: var(--wheat); }


/* ---------- the 3D monster ---------- */

.stage__monster.is-3d {
  width: min(96%, 420px);      /* wider: room for the babies */
  aspect-ratio: 6 / 5;
  animation: none;             /* it bobs on its own */
}

.play__stage.is-compact .stage__monster.is-3d {
  width: min(70%, 260px);
}

.stage__monster.is-3d canvas {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .35));
}

/* the CSS acts are for the SVG; in 3D the class only drives overlays */
.stage__monster.is-3d[class*="act-"],
.stage__monster.is-3d.is-popping {
  animation: none;
}

.card__monster-wrap { display: contents; }

img.card__monster,
img.option__monster {
  height: auto;
}

/* ---------- points ---------- */

.star {
  color: var(--wheat);
  margin-right: 0.15em;
}

.points {
  margin-left: auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--cloth2);
  padding: 0.25em 0.8em;
  font-weight: 800;
  font-size: 1.1rem;
}

.points.is-bumping {
  animation: bump .5s ease-out;
}

@keyframes bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); background: var(--wheat); color: var(--ink); }
  100% { transform: scale(1); }
}

.card__points {
  font-size: 0.95rem;
  font-weight: 800;
}

.topbar__play {
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  padding-top: 0.45em;
  padding-bottom: 0.45em;
}

.resetbar {
  margin: 2.5rem 0 1rem;
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.resetbar__btn:link,
.resetbar__btn:visited {
  text-decoration: none;
  display: inline-block;
}

.resetbar__btn {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8f7db5;
  background: none;
  border: 1px solid rgba(185, 168, 220, .3);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}

.resetbar__btn:hover,
.resetbar__btn:focus-visible {
  color: var(--wheat);
  border-color: rgba(255, 246, 232, .5);
}

.resetbar__btn .btn__en {
  color: inherit;
  opacity: .7;
}

.btn__en {
  font-size: 0.65em;
  font-weight: 500;
  opacity: 0.85;
}

.option__cost .star { margin-right: 0; color: var(--ink); }

/* ---------- play screen ---------- */

.play {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.play .stage {
  min-height: 40vh;
}

.play__panel,
.play__stage {
  /* grid/flex children otherwise grow to fit the scrolling chip row */
  min-width: 0;
  max-width: 100%;
}

.play__panel {
  margin-top: 0.5rem;
}

.modes {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.mode {
  flex: 1 1 0;
  max-width: 220px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--cloth2);
  color: var(--cream);
  font: inherit;
  padding: 0.5em 1em;
  cursor: pointer;
  text-align: center;
}

.mode__sk {
  display: block;
  font-weight: 800;
  font-size: 1.1rem;
}

.mode__en {
  display: block;
  font-size: 0.75rem;
  color: #b9a8dc;
}

.mode.is-active {
  background: var(--wheat);
  color: var(--ink);
}

.mode.is-active .mode__en { color: #7a6118; }

.prompt {
  min-height: 3.6rem;
  margin: 0 0 1rem;
  text-align: center;
  line-height: 1.2;
}

.prompt__sk {
  display: block;
  font-weight: 800;
  font-size: 1.2rem;
}

.prompt__en {
  display: block;
  font-size: 0.9rem;
  color: #b9a8dc;
}

.prompt__egg {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 246, 232, .1);
  font-weight: 700;
  color: var(--wheat);
}

.prompt__egg small {
  font-weight: 500;
  font-size: 0.8rem;
  color: #b9a8dc;
}

.prompt__target {
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 800;
  color: var(--wheat);
}

.words {
  display: grid;
  gap: 0.75rem;
}

.words--learn {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.words--quiz {
  grid-template-columns: repeat(2, 1fr);
}

.word {
  border: 4px solid transparent;
  border-radius: var(--r-md);
  background: var(--cloth2);
  box-shadow: 0 5px 0 #1a1230;
  color: var(--cream);
  font: inherit;
  padding: 0.7em 0.5em;
  min-height: 72px;
  cursor: pointer;
  text-align: center;
  transition: transform .1s;
}

.word:active { transform: translateY(3px); box-shadow: 0 2px 0 #1a1230; }

.word__sk {
  display: block;
  font-weight: 800;
  font-size: clamp(1.15rem, 4.5vw, 1.5rem);
}

.word__en {
  display: block;
  font-size: 0.8rem;
  color: #b9a8dc;
}

.words--quiz .word {
  min-height: 84px;
  display: grid;
  place-items: center;
}

.word.is-right {
  border-color: #86e0a0;
  background: #2b4a3a;
  animation: pop .3s ease-out;
}

.word.is-wrong {
  border-color: var(--folk);
  opacity: 0.7;
  animation: shake .4s ease-in-out;
}

.words.is-answered .word:not(.is-right):not(.is-wrong) {
  opacity: 0.4;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-8px); }
  75%      { transform: translateX(8px); }
}

.voice-note {
  margin: 1.25rem auto 0;
  max-width: 40ch;
  text-align: center;
  font-size: 0.85rem;
  color: #b9a8dc;
}

/* ---------- stickers, hard mode, party ---------- */

.stickers {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.15em;
  border-radius: 999px;
  background: var(--cloth2);
  padding: 0.25em 0.7em;
  font-weight: 800;
  font-size: 1rem;
  margin-left: auto;
}

.stickers + .points { margin-left: 0; }

.stickers.is-bumping { animation: bump .6s ease-out; }

.card__stickers {
  margin-left: 0.5em;
}

.mode--hard {
  flex: 0 1 auto;
  border: 3px solid transparent;
}

.mode--hard.is-active {
  background: var(--folk);
  color: var(--cream);
}

.mode--hard.is-active .mode__en { color: #f7c9c4; }

.prompt__worth {
  display: inline-block;
  margin-top: 0.4rem;
  border-radius: 999px;
  background: var(--cloth2);
  padding: 0.1em 0.7em;
  font-size: 0.9rem;
  font-weight: 800;
}

.words--hard {
  grid-template-columns: repeat(2, 1fr);
}

.words--hard .word { min-height: 68px; }
.words--hard .word--picture { min-height: 92px; }
.words--hard .word--picture .word__emoji { font-size: 2.6rem; }

@media (min-width: 600px) {
  .words--hard { grid-template-columns: repeat(3, 1fr); }
}

.stage__bubble--party {
  background: var(--wheat);
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  display: none;
}

.confetti.is-showing { display: block; }

.confetti i {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  opacity: 0;
  animation: confettiFall 2s linear forwards;
}

@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(0) rotate(0); }
  100% { opacity: 0.9; transform: translateY(110vh) rotate(540deg); }
}

/* Party: a milestone — bounce, spin round, arms up */
.act-party { animation: partyBounce 2.6s ease-in-out; }
.act-party .layer--arms { animation: armsWiggle .4s ease-in-out 6; }
.act-party .layer--mouth { animation: grin 2.6s ease-out; }
.act-party .layer--eyes { animation: squint 2.6s ease-out; }
@keyframes partyBounce {
  0%   { transform: translateY(0) rotate(0); }
  15%  { transform: translateY(-22%) rotate(-8deg); }
  30%  { transform: translateY(0) rotate(0); }
  45%  { transform: translateY(-22%) rotate(8deg); }
  60%  { transform: translateY(0) scaleX(1); }
  75%  { transform: translateY(-10%) scaleX(-1); }
  90%  { transform: translateY(0) scaleX(1); }
  100% { transform: translateY(0) rotate(0); }
}

/* ---------- word groups ---------- */

.groups {
  max-width: 100%;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.6rem;
  margin-bottom: 0.5rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.groups::-webkit-scrollbar { display: none; }

.group {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 82px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--cloth2);
  color: var(--cream);
  font: inherit;
  padding: 0.4em 0.7em 0.45em;
  cursor: pointer;
  line-height: 1.1;
}

.group__emoji {
  font-size: 1.5rem;
  line-height: 1.2;
}

.group__sk {
  font-weight: 800;
  font-size: 0.95rem;
}

.group__en {
  font-size: 0.7rem;
  color: #b9a8dc;
}

.group.is-active {
  background: var(--folk);
}

.group.is-active .group__en { color: #f7c9c4; }

/* baby monsters: a hatched badge or an egg filling up on the group chip */
.group { position: relative; }

.group__baby {
  position: absolute;
  top: 3px; right: 5px;
  font-size: 1rem;
  line-height: 1;
}

.group__baby--egg {
  font-size: 0.85rem;
  opacity: .85;
}

.group__egg {
  position: absolute;
  left: 10px; right: 10px; bottom: 4px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 246, 232, .18);
  overflow: hidden;
}

.group__egg i {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: var(--wheat);
}

/* 2D fallback: the babies as a little row under the monster */
.babies {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
}

.babies:empty { display: none; }

.baby { width: 40px; }

.baby.is-giggling {
  animation: babyGiggle 1s ease-in-out both;
}

@keyframes babyGiggle {
  0%, 100% { transform: none; }
  15%  { transform: translateY(-6px) rotate(-8deg); }
  35%  { transform: translateY(0) rotate(8deg); }
  55%  { transform: translateY(-5px) rotate(-7deg); }
  75%  { transform: translateY(0) rotate(6deg); }
}
.baby__svg { width: 100%; height: auto; }

/* ---------- words with pictures ---------- */

.word__emoji {
  display: block;
  font-size: 2.4rem;
  line-height: 1.15;
}

.word--card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  min-height: 118px;
  padding: 0.6em 0.4em;
}

.word--card .word__sk {
  font-size: clamp(1rem, 4vw, 1.25rem);
}

.word--phrase {
  grid-column: span 2;
}

.word--phrase .word__emoji {
  font-size: 1.8rem;
}

.words--pictures {
  grid-template-columns: repeat(2, 1fr);
}

.word--picture {
  min-height: 110px;
  display: grid;
  place-items: center;
}

.word--picture .word__emoji {
  font-size: 3.2rem;
}

.word__sk--reveal {
  display: block;
  font-size: 1rem;
  line-height: 1.1;
  margin-top: 0.05em;
}

.prompt__emoji {
  display: block;
  margin-top: 0.4rem;
  font-size: 3.4rem;
  line-height: 1.1;
}

.prompt__emoji + .prompt__target {
  margin-top: 0.15rem;
  font-size: clamp(1.4rem, 5vw, 2rem);
}

.listen {
  display: block;
  margin: 0.6rem auto 0;
  width: 84px;
  height: 84px;
  border: 0;
  border-radius: 50%;
  background: var(--wheat);
  box-shadow: 0 5px 0 #a8801c;
  font-size: 2.4rem;
  cursor: pointer;
}

.listen:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #a8801c;
}

/* The monster showing you the thing */
.stage__bubble {
  position: absolute;
  top: 8%;
  left: 8%;
  min-width: 96px;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-size: 3rem;
  line-height: 1.2;
  text-align: center;
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}

.stage__bubble::after {
  content: '';
  position: absolute;
  right: 12px;
  bottom: -14px;
  border: 10px solid transparent;
  border-top-color: var(--cream);
  border-right-color: var(--cream);
}

.stage__bubble.is-showing {
  animation: bubbleIn 1.8s ease-out forwards;
}

.stage__bubble--count {
  font-size: 1.6rem;
  max-width: 200px;
  line-height: 1.1;
}

.stage__bubble--count .star {
  color: #cf9a15;
  margin: 0;
}

@keyframes bubbleIn {
  0%   { opacity: 0; transform: scale(0.4); }
  15%  { opacity: 1; transform: scale(1.12); }
  25%  { transform: scale(1); }
  80%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.8); }
}

/* Nod — the monster taking a word in: a little bounce and a look up */
.act-nod { animation: nod .9s ease-in-out; }
.act-nod .layer--eyes { animation: lookUp .9s ease-in-out; }
@keyframes nod {
  0%, 100% { transform: translateY(0) rotate(0); }
  30%  { transform: translateY(-6%) rotate(-5deg); }
  60%  { transform: translateY(2%) rotate(3deg); }
}
@keyframes lookUp {
  0%, 100% { transform: translate(0, 0); }
  30%, 70% { transform: translate(-6px, -8px); }
}

/* Phones and portrait: the top bar and the monster stay put while the word
   list scrolls underneath. The stage shrinks a little once you scroll. */
@media (max-width: 819px), (orientation: portrait) {
  .page-play .topbar {
    position: sticky;
    top: 0;
    z-index: 4;
    min-height: var(--topbar-h);
    background-color: var(--cloth);
    background-image: var(--pattern);
  }

  .play__stage {
    position: sticky;
    top: var(--topbar-h);
    z-index: 3;
    max-width: none;
    margin: 0 -1rem;
    padding: 0 1rem;
    background-color: var(--cloth);
    background-image: var(--pattern);
  }

  /* soft edge so words fade out under the monster instead of cutting off */
  .play__stage::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -18px;
    height: 18px;
    background: linear-gradient(to bottom, var(--cloth), transparent);
    pointer-events: none;
  }

  .play .stage {
    transition: min-height .25s ease;
  }

  .play .stage__monster {
    transition: width .25s ease;
  }

  .play__stage.is-compact .stage {
    min-height: 26vh;
  }

  .play__stage.is-compact .stage__monster {
    width: min(42%, 170px);
  }

  .play__stage.is-compact .stage__bubble {
    font-size: 2rem;
    top: 4%;
    left: 4%;
  }
}

/* Quiz on a phone: the whole round fits the screen — top bar, a smaller
   monster, the question and every answer — so nothing hides under the fold.
   The answers keep their size; the monster takes whatever room is left. */
@media (max-width: 819px), (orientation: portrait) {
  .page-play.is-quiz {
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .page-play.is-quiz .play {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }

  .page-play.is-quiz .play__stage {
    position: static;
    flex: 1 1000 200px;          /* gives way long before the answers do */
    min-height: 84px;
    max-height: 42dvh;
    display: flex;
    flex-direction: column;
  }

  .page-play.is-quiz .play__stage::after { display: none; }

  /* flex, not grid: a percentage height inside an auto grid row never
     resolves, so the monster would keep its full size and overflow */
  .page-play.is-quiz .play .stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: none;
  }

  .page-play.is-quiz .play .stage__monster,
  .page-play.is-quiz .play .stage__monster.is-3d {
    flex: 0 0 auto;
    height: 100%;
    min-height: 0;
    width: auto;
    max-width: 96%;
    transition: none;
  }

  .page-play.is-quiz .play .stage__monster:not(.is-3d) {
    aspect-ratio: 200 / 240;
  }

  .page-play.is-quiz .play .stage__monster .monster {
    width: 100%;
    height: 100%;
  }

  .page-play.is-quiz .play__panel {
    flex: 0 1 auto;              /* only shrinks once the stage is at its smallest */
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-top: 0.25rem;
    overflow-y: auto;            /* last resort on very short screens */
  }

  .page-play.is-quiz .groups {
    flex: 0 0 auto;
    padding: 0.15rem 0 0.4rem;
    margin-bottom: 0.25rem;
  }

  .page-play.is-quiz .modes {
    flex: 0 0 auto;
    margin-bottom: 0.5rem;
  }

  .page-play.is-quiz .mode { padding: 0.35em 0.8em; }

  .page-play.is-quiz .prompt {
    flex: 0 0 auto;
    min-height: 0;
    margin-bottom: 0.5rem;
  }

  .page-play.is-quiz .prompt__en { font-size: 0.8rem; }
  .page-play.is-quiz .prompt__emoji { font-size: 2.4rem; margin-top: 0.2rem; }
  .page-play.is-quiz .prompt__emoji + .prompt__target { font-size: clamp(1.3rem, 5vw, 1.8rem); }
  .page-play.is-quiz .prompt__target { font-size: clamp(1.5rem, 6vw, 2.2rem); margin-top: 0.2rem; }
  .page-play.is-quiz .prompt__worth { margin: 0 0 0 0.5rem; vertical-align: middle; }

  .page-play.is-quiz .listen {
    width: 64px;
    height: 64px;
    font-size: 1.9rem;
    margin-top: 0.3rem;
    display: inline-block;
    vertical-align: middle;
  }

  .page-play.is-quiz .words {
    flex: 1 1 auto;
    min-height: 0;
    gap: 0.5rem;
    grid-auto-rows: minmax(0, 1fr);
  }

  .page-play.is-quiz .words .word {
    min-height: 56px;
    padding: 0.35em 0.4em;
  }

  .page-play.is-quiz .word--picture .word__emoji { font-size: 2.2rem; line-height: 1.1; }
  .page-play.is-quiz .word__sk--reveal { font-size: 0.95rem; margin-top: 0; }
}

/* iPad in landscape: monster on the left, words on the right */
@media (min-width: 820px) and (orientation: landscape) {
  .play {
    max-width: 1100px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
  }
  /* the grid item itself sticks; an inner sticky has no room in a
     start-aligned cell */
  .play__stage {
    position: sticky;
    top: 0;
    align-self: start;
  }
  .play .stage {
    min-height: 90vh;
    place-items: center;
  }
  .play .stage__monster {
    width: min(80%, 440px);
  }
  .play .stage__monster.is-3d {
    width: min(96%, 520px);
  }
  .play__panel {
    margin-top: 1rem;
  }
}

/* ---------- the monster acting ---------- */

.monster .layer {
  transform-box: fill-box;
  transform-origin: center;
}

/* Depth: the stage monster leans toward the finger (set by Monster.tilt). */
.stage__monster .monster {
  --rx: 0deg;
  --ry: 0deg;
  transform: perspective(700px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .35s ease-out;
  will-change: transform;
}

/* Idle life: a blink every few seconds, pupils that wander, and a glance
   down at the words when a round starts. Only on the stage, not thumbnails. */
.stage__monster .layer--eyes {
  animation: blink 5.2s ease-in-out infinite;
}

.stage__monster .pupil {
  transform-box: fill-box;
  transform-origin: center;
  animation: wander 9s ease-in-out infinite;
}

.stage__monster.is-glancing .pupil {
  animation: glance 1.1s ease-in-out;
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(0.08); }
}

@keyframes wander {
  0%, 18%, 100% { transform: translate(0, 0); }
  24%, 40%      { transform: translate(5px, -2px); }
  46%, 60%      { transform: translate(-5px, 1px); }
  66%, 80%      { transform: translate(1px, 4px); }
}

@keyframes glance {
  0%, 100% { transform: translate(0, 0); }
  20%, 80% { transform: translate(0, 7px); }
}

.stage__plus {
  position: absolute;
  top: 12%;
  right: 14%;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--wheat);
  opacity: 0;
  pointer-events: none;
}

.stage__plus.is-showing {
  animation: floatUp 1.2s ease-out forwards;
}

@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(20px) scale(0.6); }
  20%  { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-50px) scale(1); }
}

.stage__zzz {
  position: absolute;
  top: 18%;
  right: 22%;
  font-weight: 800;
  color: var(--cream);
  opacity: 0;
  pointer-events: none;
}

.stage__zzz span {
  display: inline-block;
  font-size: 1.4rem;
}
.stage__zzz span:nth-child(2) { font-size: 1.8rem; }
.stage__zzz span:nth-child(3) { font-size: 2.3rem; }

.stage__monster.act-spi + .stage__zzz {
  animation: zzz 2.6s ease-in-out forwards;
}

@keyframes zzz {
  0%   { opacity: 0; transform: translate(0, 10px); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(24px, -50px); }
}

/* Skoč! — jump */
.act-skoc { animation: jump .9s cubic-bezier(.3, .8, .4, 1); }
@keyframes jump {
  0%   { transform: translateY(0) scale(1); }
  15%  { transform: translateY(6px) scale(1.12, 0.86); }
  45%  { transform: translateY(-34%) scale(0.94, 1.08); }
  75%  { transform: translateY(0) scale(1.1, 0.9); }
  100% { transform: translateY(0) scale(1); }
}

/* Tancuj! — dance */
.act-tancuj { animation: dance 1.8s ease-in-out; }
.act-tancuj .layer--arms { animation: armsWiggle .45s ease-in-out 4; }
.act-tancuj .layer--horns { animation: hornsSway .9s ease-in-out 2; }
@keyframes dance {
  0%, 100% { transform: translateX(0) rotate(0); }
  12%  { transform: translateX(-10%) rotate(-8deg) translateY(-6px); }
  37%  { transform: translateX(10%) rotate(8deg) translateY(-6px); }
  62%  { transform: translateX(-10%) rotate(-8deg) translateY(-6px); }
  87%  { transform: translateX(10%) rotate(8deg) translateY(-6px); }
}
@keyframes armsWiggle {
  0%, 100% { transform: rotate(0); }
  50%      { transform: rotate(14deg) translateY(-6px); }
}
@keyframes hornsSway {
  0%, 100% { transform: rotate(0); }
  50%      { transform: rotate(-10deg); }
}

/* Spi! — sleep: eyes shut, head tilts */
.act-spi { animation: doze 2.6s ease-in-out; }
.act-spi .layer--eyes { animation: eyesShut 2.6s ease-in-out; }
@keyframes doze {
  0%   { transform: rotate(0); }
  25%, 85% { transform: rotate(9deg) translateY(8px); }
  100% { transform: rotate(0); }
}
@keyframes eyesShut {
  0%   { transform: scaleY(1); }
  20%, 85% { transform: scaleY(0.08); }
  100% { transform: scaleY(1); }
}

/* Zamávaj! — wave */
.act-zamavaj .layer--arms { animation: wave .38s ease-in-out 4; }
.act-zamavaj { animation: sway 1.5s ease-in-out; }
@keyframes wave {
  0%, 100% { transform: rotate(-12deg) translateY(-8px); }
  50%      { transform: rotate(12deg) translateY(-14px); }
}
@keyframes sway {
  0%, 100% { transform: rotate(0); }
  50%      { transform: rotate(-4deg); }
}

/* Otoč sa! — turn around */
.act-otoc-sa { animation: turnAround 1.3s ease-in-out; }
@keyframes turnAround {
  0%   { transform: scaleX(1); }
  30%  { transform: scaleX(-1) translateY(-4px); }
  70%  { transform: scaleX(-1) translateY(-4px); }
  100% { transform: scaleX(1); }
}

/* Jedz! — eat: chomp chomp */
.act-jedz .layer--mouth { animation: chomp .3s ease-in-out 5; }
.act-jedz { animation: munch 1.5s ease-in-out; }
@keyframes chomp {
  0%, 100% { transform: scaleY(0.5); }
  50%      { transform: scaleY(1.7); }
}
@keyframes munch {
  0%, 100% { transform: scale(1); }
  20%, 60% { transform: scale(1.04, 0.97); }
  40%, 80% { transform: scale(0.98, 1.03); }
}

/* Sadni si! — sit down */
.act-sadni-si { animation: sitDown 1.8s ease-in-out; }
.act-sadni-si .layer--feet { animation: feetTuck 1.8s ease-in-out; }
@keyframes sitDown {
  0%   { transform: translateY(0) scale(1); }
  30%, 80% { transform: translateY(9%) scale(1.12, 0.82); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes feetTuck {
  0%, 100% { transform: scaleY(1); }
  30%, 80% { transform: scaleY(0.35) scaleX(1.3); }
}

/* Vstaň! — stand up: from a crouch to a tall stretch */
.act-vstan { animation: standUp 1.2s ease-out; }
@keyframes standUp {
  0%   { transform: translateY(9%) scale(1.12, 0.82); }
  35%  { transform: translateY(9%) scale(1.12, 0.82); }
  70%  { transform: translateY(-8%) scale(0.9, 1.14); }
  100% { transform: translateY(0) scale(1); }
}

/* Bež! — run: dash across the stage */
.act-bez { animation: run 1.7s ease-in-out; }
.act-bez .layer--feet { animation: feetRun .16s linear 10; }
.act-bez .layer--arms { animation: armsWiggle .3s ease-in-out 5; }
@keyframes run {
  0%   { transform: translateX(0) rotate(0); }
  15%  { transform: translateX(-10%) rotate(-6deg); }
  45%  { transform: translateX(45%) rotate(8deg); }
  55%  { transform: translateX(45%) scaleX(-1) rotate(8deg); }
  90%  { transform: translateX(-5%) scaleX(-1) rotate(-6deg); }
  95%  { transform: translateX(0) scaleX(1); }
  100% { transform: translateX(0) rotate(0); }
}
@keyframes feetRun {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(10px) translateY(-6px); }
}

/* Schovaj sa! — hide: drop out of sight, then peek back */
.act-schovaj-sa { animation: hide 2.2s ease-in-out; }
@keyframes hide {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  20%  { transform: translateY(75%) scale(0.75); opacity: 0; }
  55%  { transform: translateY(75%) scale(0.75); opacity: 0; }
  70%  { transform: translateY(45%) scale(0.85); opacity: 1; }
  80%  { transform: translateY(50%) scale(0.85); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Yeah! — a right answer: a happy bounce, big grin, eyes squeezed shut */
.act-yeah { animation: yeah .9s ease-out; }
.act-yeah .layer--mouth { animation: grin .9s ease-out; }
.act-yeah .layer--eyes { animation: squint .9s ease-out; }
.act-yeah .layer--arms { animation: armsUp .9s ease-out; }
@keyframes yeah {
  0%   { transform: translateY(0) scale(1); }
  20%  { transform: translateY(6px) scale(1.08, 0.9); }
  50%  { transform: translateY(-18%) scale(0.96, 1.06) rotate(-4deg); }
  75%  { transform: translateY(0) scale(1.06, 0.94) rotate(3deg); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes grin {
  0%   { transform: scale(1); }
  25%, 80% { transform: scale(1.5, 1.35); }
  100% { transform: scale(1); }
}
@keyframes squint {
  0%   { transform: scaleY(1); }
  25%, 80% { transform: scaleY(0.3) translateY(4px); }
  100% { transform: scaleY(1); }
}
@keyframes armsUp {
  0%, 100% { transform: rotate(0); }
  30%, 75% { transform: rotate(-18deg) translateY(-22px); }
}

/* Tickles (SVG fallback; the 3D monster has its own) */
.stage__monster { cursor: pointer; }
.act-laugh0 { animation: giggle 1.3s ease-in-out; }
.act-laugh0 .layer--eyes, .act-laugh2 .layer--eyes, .act-laugh4 .layer--eyes { animation: squint 1.4s ease-out; }
.act-laugh0 .layer--mouth, .act-laugh1 .layer--mouth, .act-laugh2 .layer--mouth { animation: grin 1.5s ease-out; }
.act-laugh1 { animation: bellyLaugh 1.7s ease-in-out; }
.act-laugh1 .layer--arms { animation: armsUp 1.7s ease-out; }
.act-laugh2 { animation: wriggle 1.6s ease-in-out; }
.act-laugh3 { animation: hiccup 1.4s ease-in-out; }
.act-laugh4 { animation: curl 1.9s ease-in-out; }
@keyframes giggle {
  0%, 100% { transform: rotate(0); }
  10%, 30%, 50%, 70%, 90% { transform: rotate(-3deg) translateY(-3px); }
  20%, 40%, 60%, 80% { transform: rotate(3deg) translateY(0); }
}
@keyframes bellyLaugh {
  0%, 100% { transform: rotate(0) translateY(0); }
  20%, 60% { transform: rotate(-8deg) translateY(-10%); }
  40%, 80% { transform: rotate(-8deg) translateY(0); }
}
@keyframes wriggle {
  0%, 100% { transform: scaleX(1) rotate(0); }
  20% { transform: scaleX(0.7) rotate(6deg); }
  40% { transform: scaleX(1) rotate(-6deg); }
  60% { transform: scaleX(0.7) rotate(6deg); }
  80% { transform: scaleX(1) rotate(-6deg); }
}
@keyframes hiccup {
  0%, 50%, 100% { transform: translateY(0) scale(1); }
  25%, 75% { transform: translateY(-26%) scale(0.94, 1.1); }
}
@keyframes curl {
  0%, 100% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.12, 0.72) translateY(12%); }
  55% { transform: scale(1.12, 0.72) translateY(12%) rotateY(180deg); }
  80% { transform: scale(1.12, 0.72) translateY(12%) rotateY(360deg); }
}

.stage__bubble--laugh {
  left: auto;
  right: 6%;
  top: 6%;
  font-size: 1.5rem;
  font-weight: 800;
  min-width: 0;
  padding: 0.35rem 0.9rem;
}
.stage__bubble--laugh::after {
  right: auto;
  left: 12px;
  border-right-color: transparent;
  border-left-color: var(--cream);
}

/* Hmm? — a wrong answer: head tilts, eyes go crooked, mouth shrinks */
.act-hmm { animation: hmm 1s ease-in-out; }
.act-hmm .layer--eyes { animation: crookedEyes 1s ease-in-out; }
.act-hmm .layer--mouth { animation: smallMouth 1s ease-in-out; }
@keyframes hmm {
  0%   { transform: rotate(0); }
  30%, 80% { transform: rotate(-9deg) translateX(-3%); }
  100% { transform: rotate(0); }
}
@keyframes crookedEyes {
  0%   { transform: rotate(0) scaleY(1); }
  30%, 80% { transform: rotate(12deg) scaleY(0.8) translateX(4px); }
  100% { transform: rotate(0) scaleY(1); }
}
@keyframes smallMouth {
  0%   { transform: scale(1); }
  30%, 80% { transform: scale(0.55, 0.6) translateX(-14px); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .stage__monster,
  .stage__monster.is-popping,
  .stage__monster[class*="act-"],
  .stage__monster[class*="act-"] .layer {
    animation-duration: .01s !important;
    animation-iteration-count: 1 !important;
  }
  .stage__monster { animation: none; }
  .btn:active, .word:active { transform: none; }
}

/* ---------- the PIN screen ---------- */

.pin {
  max-width: 360px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  text-align: center;
}

.pin__monster {
  width: 110px;
  margin: 0 auto 0.25rem;
}

.pin__svg { width: 100%; height: auto; display: block; }

.pin__title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
}

.pin__sub {
  margin: 0.1rem 0 1rem;
  color: #b9a8dc;
}

.pin__dots {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 0.5rem 0;
}

.pin__dots i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--cream);
  transition: background .12s ease, transform .12s ease;
}

.pin__dots i.is-on {
  background: var(--wheat);
  border-color: var(--wheat);
  transform: scale(1.15);
}

.pin__dots.is-shaking {
  animation: pinShake .4s ease;
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-10px); }
  40%  { transform: translateX(10px); }
  60%  { transform: translateX(-7px); }
  80%  { transform: translateX(7px); }
}

.pin__msg {
  min-height: 1.4em;
  margin: 0.25rem 0 0.75rem;
  font-size: 0.9rem;
  color: #b9a8dc;
}

.pin__msg.is-bad { color: #ff8a7a; }

.pin__pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  max-width: 280px;
  margin: 0 auto;
}

.pin__pad.is-disabled { opacity: .45; pointer-events: none; }

.pin__key {
  font: inherit;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--cream);
  background: var(--cloth2);
  border: 0;
  border-radius: var(--r-md);
  aspect-ratio: 1.25;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .3);
  -webkit-tap-highlight-color: transparent;
}

.pin__key:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .3);
}

.pin__key--back { font-size: 1.4rem; color: #b9a8dc; }

/* ---------- play time ---------- */

.timebadge {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.15em;
  border-radius: 999px;
  background: var(--cloth2);
  padding: 0.25em 0.6em;
  font-weight: 800;
  font-size: 0.9rem;
  color: #b9a8dc;
  margin-left: auto;
}

.timebadge + .stickers { margin-left: 0; }
.timebadge.is-near { color: var(--wheat); }

/* bedtime: the daily limit is used up */
.bedtime {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(20, 12, 40, .78);
  animation: fadeIn .6s ease-out;
}

.bedtime__card {
  max-width: 340px;
  text-align: center;
  border-radius: var(--r-lg);
  background: var(--cloth2);
  padding: 1.5rem 1.25rem 1.25rem;
  box-shadow: 0 12px 0 #1a1230;
}

.bedtime__zzz { font-size: 3.5rem; line-height: 1; }
.bedtime__sk { margin: 0.6rem 0 0.2rem; font-size: 1.5rem; font-weight: 800; }
.bedtime__en { margin: 0 0 1.2rem; color: #b9a8dc; }
.bedtime .btn { text-decoration: none; }

.is-bedtime .play__panel,
.is-bedtime .options,
.is-bedtime .slots { pointer-events: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- insights (the parent page) ---------- */

.pick__parent {
  margin: 2rem 0 0;
  text-align: center;
}

.pick__parent .resetbar__btn { text-decoration: none; display: inline-block; }

.insights {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.5rem 1rem 3rem;
}

.topbar__form { margin-left: auto; }

.kids { margin-bottom: 0.75rem; }
.kids .group { text-decoration: none; }

.insights .card {
  background: var(--cloth2);
  border-radius: var(--r-md);
  padding: 1rem 1rem 0.9rem;
  margin: 0 0 1rem;
}

.insights h2 {
  text-align: left;
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
  font-weight: 800;
}

.insights h2 small {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #b9a8dc;
}

.insights code {
  background: var(--ink);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
}

.card--login { max-width: 360px; margin: 2rem auto; text-align: center; }

.loginform { display: flex; gap: 0.5rem; justify-content: center; }

.loginform input,
.limitform input {
  width: 8em;
  border: 3px solid #4b3a72;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--cream);
  font: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.35em 0.6em;
  text-align: center;
}

.notice--bad { color: #f7c9c4; }
.notice--good { color: #86e0a0; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
  margin: 0 0 1rem;
}

.tile {
  background: var(--cloth2);
  border-radius: var(--r-md);
  padding: 0.7rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.tile__n { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.tile__n small { font-size: 0.85rem; font-weight: 700; color: #b9a8dc; }
.tile__l { font-size: 0.8rem; color: #b9a8dc; line-height: 1.2; }

.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: rgba(255, 246, 232, .12); stroke-width: 1; }
.chart .axis { stroke: rgba(255, 246, 232, .3); stroke-width: 1; }
.chart .tick { fill: #b9a8dc; font-size: 15px; font-family: inherit; }
.chart .dot { fill: #b9a8dc; }
.chart .bar:hover path, .chart .bar:hover rect:not([fill="transparent"]) { filter: brightness(1.2); }

.hint { margin: 0.5rem 0 0; font-size: 0.8rem; color: #b9a8dc; }
.muted { color: #b9a8dc; font-weight: 500; }

.legend { margin: 0.4rem 0 0; font-size: 0.85rem; color: #b9a8dc; }
.legend__k { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin: 0 0.2em 0 0.6em; }

.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th { text-align: left; font-weight: 700; color: #b9a8dc; font-size: 0.75rem; padding: 0 0.4rem 0.3rem 0; }
.tbl td { padding: 0.35rem 0.4rem 0.35rem 0; border-top: 1px solid rgba(255, 246, 232, .08); vertical-align: middle; }
.tbl-wrap { overflow-x: auto; }

.meter {
  display: inline-block;
  width: 64px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 246, 232, .12);
  vertical-align: middle;
  overflow: hidden;
}

.meter i { display: block; height: 100%; border-radius: 4px; }
.meter--sm { width: 48px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.wordlist, .events { list-style: none; margin: 0; padding: 0; }
.wordlist li { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; border-top: 1px solid rgba(255, 246, 232, .08); }
.wordlist li:first-child { border-top: 0; }
.wordlist__emoji { width: 1.6em; text-align: center; }
.wordlist__w { flex: 1; min-width: 0; }
.wordlist__n { font-size: 0.85rem; white-space: nowrap; }
.events li { padding: 0.3rem 0; border-top: 1px solid rgba(255, 246, 232, .08); font-size: 0.9rem; }
.events li:first-child { border-top: 0; }
.events__k { margin-right: 0.3em; }

.limitform { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.limitform label { color: #b9a8dc; display: flex; align-items: center; gap: 0.5rem; }
.limitform input { width: 5.5em; }

@media (max-width: 640px) {
  .two { grid-template-columns: 1fr; }
  .tbl { font-size: 0.8rem; }
  .meter { width: 44px; }
}

/* ============================================================
   The app: no connection, a queue waiting to be sent, a new
   version ready, and the PIN screen that stands in for the
   server's one when the page came off the device.
   ============================================================ */

.netpill {
  position: fixed;
  left: 50%;
  /* under the top bar, not over it: the name, the minutes and the stars
     matter more than the pill */
  top: calc(env(safe-area-inset-top, 0px) + var(--topbar-h) + 6px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: .4rem;
  max-width: calc(100vw - 24px);
  padding: .3rem .8rem;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ink);
  background: var(--wheat);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
  animation: fadeIn .3s ease-out;
  pointer-events: none;
}

/* The hidden attribute loses to `display: flex` above — without this the
   pill sits there empty at the top of every screen. */
.netpill[hidden] { display: none; }

.netpill--off  { background: #b9a8dc; }
.netpill--sync { background: var(--wheat); }
.netpill--new  { background: transparent; box-shadow: none; padding: 0; pointer-events: auto; }

.netpill__en {
  font-weight: 500;
  opacity: .7;
  font-size: .8rem;
}
.netpill__en::before { content: '· '; }

.netpill--new button {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--wheat);
  border: 0;
  border-radius: 999px;
  padding: .35rem .9rem;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}

.pick__install { margin-right: .5rem; }

/* The offline lock. The server cannot check a PIN when the page came
   straight off the device, so the same four digits are checked here. */
.offlock {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: var(--cloth);
  background-image: var(--pattern);
}

.offlock__card {
  width: min(20rem, 100%);
  text-align: center;
}

.offlock__card.is-wrong { animation: shake .4s; }

.offlock__sk { margin: 0; font-size: 1.6rem; font-weight: 800; }
.offlock__en { margin: 0 0 1.2rem; color: #b9a8dc; }

.offlock__dots {
  display: flex;
  justify-content: center;
  gap: .7rem;
  margin-bottom: 1.4rem;
}

.offlock__dots i {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 246, 232, .2);
}

.offlock__dots i.is-on { background: var(--wheat); }

.offlock__keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
}

body.is-locked { overflow: hidden; }

/* ---------- the front door ---------- */

/* One keypad, and three screens nobody sees twice: the welcome, making the
   first player, and joining a family that already exists. index.php holds all
   four and home.js shows exactly one, which is why they share a wrapper. */

.home {
  max-width: 380px;
  margin: 0 auto;
  padding: clamp(1rem, 4vh, 2.5rem) 1rem 2rem;
  text-align: center;
}

.home__step[hidden] { display: none; }

.home__mark {
  width: 120px;
  margin: 0 auto 0.5rem;
}

.home__svg { width: 100%; height: auto; display: block; }

.home__title {
  margin: 0 0 0.75rem;
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  font-weight: 800;
  line-height: 1.1;
}

.home__title span {
  display: block;
  font-size: 0.46em;
  font-weight: 500;
  color: #b9a8dc;
}

.home__lede {
  margin: 0 0 1.5rem;
  color: var(--cream);
  line-height: 1.4;
}

.home__lede span,
.home__hint span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: #b9a8dc;
}

.home__hint {
  margin: 1.25rem 0 0.4rem;
  font-weight: 700;
}

.home__hint--grown { margin-top: 1.6rem; }

.home__choice {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.home__form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: left;
}

.home__input {
  font: inherit;
  font-size: 1.1rem;
  padding: 0.7em 0.8em;
  border: 0;
  border-radius: var(--r-md);
  background: var(--cloth2);
  color: var(--cream);
  width: 100%;
  box-sizing: border-box;
}

.home__input::placeholder { color: #7e6ea6; }

/* Digits and codes are read back character by character, so they get the
   spacing that makes that possible. */
.home__input--pin,
.home__input--code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.35em;
  text-align: center;
  font-weight: 800;
}

.home__input--code { text-transform: uppercase; letter-spacing: 0.2em; }

.home__foot {
  margin-top: 2.5rem;
  text-align: center;
}

/* The welcome screen's second button is the one almost nobody wants. */
.btn--quiet {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--cloth2);
  color: #b9a8dc;
  font-size: 1rem;
}

.btn--quiet:active {
  transform: translateY(2px);
  box-shadow: inset 0 0 0 2px var(--cloth2);
}

/* ---------- letting another device in ---------- */

.joinbox {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.joinbox__qr {
  flex: 0 0 auto;
  width: 180px;
  max-width: 100%;
  background: #fff;
  border-radius: var(--r-md);
  padding: 0;
  line-height: 0;
  overflow: hidden;
}

.qr { width: 100%; height: auto; display: block; }

.joinbox__side { flex: 1 1 260px; min-width: 0; }

.joinbox__code {
  margin: 0 0 0.5rem;
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  color: var(--wheat);
  word-break: break-word;
}

.hint--warn { color: #f3c98b; }

.limitform--wrap label { flex: 1 1 auto; }
.limitform--wrap input[type="text"] { width: 100%; min-width: 6em; }

/* ---------- the two cards a parent should have to mean ---------- */

/* Marked, not hidden. A parent looking for "how do I delete this" should find
   it without reading the page twice, and should also not press it by accident
   — which is what the typed confirmation is for. */
.insights .card--danger {
  border: 1px solid #6b2f2a;
  background: linear-gradient(180deg, rgba(224, 72, 58, .07), rgba(224, 72, 58, 0));
}

.card--danger h2 { color: #f3a99f; }

.btn--danger {
  background: #a5342a;
  box-shadow: 0 5px 0 #6b2019;
}

.btn--danger:active { box-shadow: 0 1px 0 #6b2019; }

.hint--foot {
  margin: 2rem 0 0;
  text-align: center;
}

.hint--foot a { color: #b9a8dc; }

.home__legal {
  display: block;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: #7e6ea6;
}

/* display: above beats the UA's [hidden] rule, so say it again. */
.home__legal[hidden] { display: none; }

.home__legal--grown {
  margin-top: 1.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #b9a8dc;
  text-decoration: none;
}

/* The store link: a pill like the install button, quiet enough for a footer. */
.home__legal--store {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.45rem 1rem;
  border: 1px solid rgba(185, 168, 220, .35);
  border-radius: 999px;
  font-size: 0.85rem;
  color: #b9a8dc;
  text-decoration: none;
}
.home__legal--store[hidden] { display: none; }   /* same trap, fourth time */
.home__legal--store b { font-weight: 700; }
.home__legal--store span { opacity: .7; font-size: 0.85em; margin-left: .35em; }
.home__legal--store:hover,
.home__legal--store:focus-visible { color: var(--wheat); border-color: rgba(255, 246, 232, .5); }

.home__legal--grown span {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #7e6ea6;
}
