:root {
  --bg: #140b2e;
  --card: #2c1d50;
  --accent: #ff8a1f;
  --text: #fff6e0;
  --muted: #c9b8f0;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Fredoka', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
/* playing: no scrolling, zooming or text selection under little fingers */
body.view-game {
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* one view at a time: the games page (hub), a game's map, or playing */
body:not(.view-game) #game { display: none; }
body:not(.view-hub) #home { display: none; }
body:not(.view-map) #map-view { display: none; }
body:not(.view-admin) #admin-view { display: none; }
body.view-game #topbar { display: none; }

#stage {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- elements ---------- */
.el .anim,
.el .art,
.el .wing,
.el .tail,
.el .lids,
.el .flames,
.el .dtail,
.el .stail,
.el .leg-a,
.el .leg-b,
.el .bubbles circle {
  transform-box: fill-box;
  transform-origin: center;
}
.el .hit { fill: transparent; }
.interactive { cursor: pointer; }
.draggable { cursor: grab; }
.dragging { cursor: grabbing; }
.dragging .art { filter: url(#fx-lift); }
.drop-hover .art { filter: url(#fx-glow); }
.hidden { visibility: hidden; pointer-events: none; }

/* background */
.twinkle { animation: twinkle 3s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .25; } }
.drift { animation: drift 40s linear infinite; }
@keyframes drift { from { transform: translateX(-500px); } to { transform: translateX(1700px); } }

/* weather (foreground layer, toggled by .storm / .lightning on the <svg>) */
.fg { pointer-events: none; }
.fg .darken { opacity: 0; transition: opacity 1.2s; }
.storm .fg .darken { opacity: .45; }
.fg .storm-clouds { transform: translateY(-260px); transition: transform 1.4s ease; }
.storm .fg .storm-clouds { transform: none; }
.fg .rain { opacity: 0; transition: opacity 1s; }
.storm .fg .rain { opacity: .75; }
.rain-fall { animation: rainFall .5s linear infinite; }
@keyframes rainFall { from { transform: translateY(0); } to { transform: translateY(900px); } }
.fg .flash, .fg .bolt { opacity: 0; }
.lightning .fg .flash { animation: flash .7s ease-out; }
.lightning .fg .bolt { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: .85; } 15% { opacity: 0; } 30% { opacity: .7; } 100% { opacity: 0; } }
/* generated boards: "night" secret and mood overlays */
.night .fg .darken { opacity: .6; }
.fg .firefly { animation: firefly 6s ease-in-out infinite; }
@keyframes firefly {
  25% { transform: translate(24px, -30px); opacity: .25; }
  50% { transform: translate(-12px, -55px); opacity: 1; }
  75% { transform: translate(-28px, -18px); opacity: .35; }
}
.el .puff { fill: #c9b8f0; transition: fill 1.2s; }
.storm .el .puff { fill: #5a5470; }

/* idle animations */
.idle-drift { animation: driftIdle 10s ease-in-out infinite; }
@keyframes driftIdle { 50% { transform: translateX(30px); } }
.idle-float { animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-18px); } }
.idle-hover { animation: hover 2.4s ease-in-out infinite; }
@keyframes hover { 50% { transform: translate(14px, -12px); } }
.idle-sway { transform-origin: 50% 0% !important; animation: sway 4s ease-in-out infinite; }
@keyframes sway { 50% { transform: rotate(4deg); } }
.idle-twinkle { animation: twinkleStar 2s ease-in-out infinite; }
@keyframes twinkleStar { 50% { transform: scale(1.12) rotate(8deg); } }
.idle-breathe { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04, .96); } }

/* bat */
.el .wing-l { transform-origin: 100% 50%; animation: flapL .35s ease-in-out infinite; }
.el .wing-r { transform-origin: 0% 50%; animation: flapR .35s ease-in-out infinite; }
@keyframes flapL { 50% { transform: rotate(22deg) scaleY(.8); } }
@keyframes flapR { 50% { transform: rotate(-22deg) scaleY(.8); } }

/* pumpkins */
.el .halo { opacity: 0; transition: opacity .3s; }
.el .face path { fill: #5a2a08; transition: fill .3s; }
.lit .halo { opacity: 1; }
.lit .face path { fill: #ffe45c; }

/* house */
.el .win { fill: url(#windowGlow); transition: fill .3s; }
.el .peek { opacity: 0; transition: opacity .4s .2s; }
.dark .win { fill: #241b38; }
.dark .peek { opacity: 1; }

.el .people { opacity: 0; }
.scared .people { opacity: 1; }
.scared .person { transform-box: fill-box; animation: jitter .12s linear infinite; }
.scared .win { fill: #fff7c0; }
@keyframes jitter { 50% { transform: translateY(-4px); } }

/* owl */
.el .lids { transform-origin: 50% 0%; transform: scaleY(0); }
.blink .lids { animation: blink .5s ease-in-out; }
@keyframes blink { 40%, 60% { transform: scaleY(1); } }

/* cat */
.el .tail { transform-origin: 0% 100%; animation: tailIdle 3s ease-in-out infinite; }
.swish .tail { animation: tailSwish .3s ease-in-out 3; }
@keyframes tailIdle { 50% { transform: rotate(-6deg); } }
@keyframes tailSwish { 50% { transform: rotate(-28deg); } }

/* witch */
.zap .art { animation: zap .8s ease-in-out; }
@keyframes zap { 50% { transform: rotate(360deg) scale(1.35); } 100% { transform: rotate(360deg); } }

/* faces: smiles turn into frowns while it rains */
.el .smile, .el .frown { transition: opacity .5s; }
.el .frown { opacity: 0; }
.storm .el .smile { opacity: 0; }
.storm .el .frown { opacity: 1; }

/* walking animals turn around; bowls empty when eaten */
.face-left .art { transform: scaleX(-1); }
.el .food { transition: opacity .4s; }
.empty .food { opacity: 0; }

/* dog */
.el .dtail { transform-origin: 100% 100%; animation: wag .35s ease-in-out infinite alternate; }
@keyframes wag { from { transform: rotate(-12deg); } to { transform: rotate(14deg); } }
.el .leg-a, .el .leg-b { transform-origin: 50% 0%; }
.running .leg-a, .walking .leg-a { animation: legs .16s linear infinite alternate; }
.running .leg-b, .walking .leg-b { animation: legs .16s linear infinite alternate-reverse; }
@keyframes legs { from { transform: skewX(-28deg); } to { transform: skewX(28deg); } }

/* squirrel */
.el .stail { transform-origin: 100% 100%; animation: stailIdle 2s ease-in-out infinite; }
.flick .stail { animation: stailFlick .15s ease-in-out 6 alternate; }
@keyframes stailIdle { 50% { transform: rotate(-5deg); } }
@keyframes stailFlick { to { transform: rotate(-22deg); } }

/* cauldron */
.el .potion { fill: var(--potion); transition: fill .6s; }
.el .flames { transform-origin: 50% 100%; animation: flicker .25s ease-in-out infinite alternate; }
@keyframes flicker { to { transform: scale(1.06, .9); } }
.bubbles circle { animation: rise 1.8s ease-in infinite; }
.bubbles .b2 { animation-delay: .5s; }
.bubbles .b3 { animation-delay: 1s; }
.bubbles .b4 { animation-delay: 1.4s; }
.boiling .bubbles circle { animation-duration: .45s; }
.boiling .flames { animation-duration: .08s; }
.boiling .potion { fill: #ff7a3c; }
@keyframes rise {
  0% { transform: translateY(0) scale(.4); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-46px) scale(1); opacity: 0; }
}

/* ---------- HUD + controls ---------- */
#hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  pointer-events: none; /* its width is set by main.js (fitTopBar) to stay clear of the buttons */
}
.counter .count { font-size: 26px; font-weight: 700; min-width: 30px; text-align: center; }
.counter.bump .count { animation: bump .4s ease-out; }
.recipe { gap: 4px; }
.slot {
  position: relative; width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 12px; border: 2px solid transparent; background: rgba(201, 184, 240, .12);
}
.slot svg { width: 34px; height: 34px; overflow: visible; }
.slot.now { border-color: #ffd23f; background: rgba(255, 210, 63, .22); animation: slotPulse 1.2s ease-in-out infinite; }
.slot.done { opacity: .45; }
.slot.done::after { content: '✓'; position: absolute; right: -5px; bottom: -8px; color: #b7ff6b; font-size: 18px; font-weight: 700; }
.slot.nudge { animation: nudge .5s ease-in-out; }
.arrow { color: var(--muted); font-size: 20px; }
@keyframes slotPulse { 50% { transform: scale(1.12); } }
@keyframes nudge { 20%, 60% { transform: translateX(-6px) scale(1.2); } 40%, 80% { transform: translateX(6px) scale(1.2); } }
@keyframes bump { 40% { transform: scale(1.5); color: #b7ff6b; } }
.goal {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(20, 11, 46, .65);
  border: 2px solid rgba(201, 184, 240, .35);
  border-radius: 999px;
}
.goal-icon { font-size: 26px; }
.dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--muted);
  transition: background .3s, transform .3s;
}
.dot.on { background: #b7ff6b; border-color: #b7ff6b; transform: scale(1.15); }

#controls {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
}
button { font-family: inherit; cursor: pointer; }
.round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(201, 184, 240, .35);
  background: rgba(20, 11, 46, .65);
  color: var(--text);
  font-size: 24px;
}

/* ---------- end card ---------- */
.overlay {
  z-index: 20;
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  place-items: safe center; /* a card taller than a short (landscape) screen scrolls instead of being cut off */
  padding: 16px;
  background: rgba(10, 5, 25, .7);
  transition: opacity .4s;
  overflow-y: auto;
}
.overlay.gone { opacity: 0; pointer-events: none; }
#btn-help { font-weight: 700; }
.help-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; text-align: left; }
.hint {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 12px;
  border-radius: 14px; border: 2px solid #ffd23f; background: rgba(255, 210, 63, .12);
  color: var(--text); font: inherit; font-size: 16px; cursor: pointer; text-align: left;
}
.hint-icon { font-size: 24px; }
.hint-label { flex: 1; }
.hint.found { border-color: rgba(201, 184, 240, .25); background: transparent; color: var(--muted); opacity: .6; }
.hint-check { color: #b7ff6b; font-weight: 700; }
@media (max-width: 480px) { .help-list { grid-template-columns: 1fr; } }
.card {
  text-align: center;
  background: var(--card);
  border: 3px solid rgba(201, 184, 240, .4);
  border-radius: 28px;
  padding: 20px 28px;
  max-width: 460px;
}
.card h1 { margin: 0; font-size: clamp(30px, 6vw, 48px); color: var(--accent); }
.card p { margin: 4px 0 12px; font-size: 19px; color: var(--muted); }
.stars { display: flex; justify-content: center; gap: 8px; font-size: clamp(44px, 10vw, 64px); line-height: 1.1; }
.star { color: #4a3a72; }
.star.on { color: #ffd23f; text-shadow: 0 0 18px rgba(255, 210, 63, .6); animation: starPop .5s ease-out backwards; }
@keyframes starPop { from { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3); } }
.secrets { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 14px; }
.secret {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 50%; font-size: 21px; background: rgba(20, 11, 46, .6);
  border: 2px dashed rgba(201, 184, 240, .35); color: var(--muted);
}
.secret.found { border: 2px solid #ffd23f; background: rgba(255, 210, 63, .15); }
.end-buttons { display: flex; justify-content: center; gap: 16px; }
.end-btn {
  width: 84px; height: 84px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 38px;
  box-shadow: 0 7px 0 #b85a0a;
}
.end-btn.alt { background: #6b4fb8; box-shadow: 0 7px 0 #3f2b7a; }
.end-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 #b85a0a; }

/* ---------- home page ---------- */
#home {
  max-width: 980px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 40px;
}
.home-head { text-align: center; padding: 12px 0 8px; }
.home-head h1 {
  margin: 0; font-size: clamp(40px, 9vw, 72px); color: var(--accent); letter-spacing: 1px;
  text-shadow: 0 4px 0 #6b2f0a;
}
.home-head p { margin: 6px auto 0; max-width: 560px; font-size: 19px; color: var(--muted); }
#home h2 { font-size: 28px; margin: 28px 0 12px; }
#home h3 { font-size: 19px; margin: 18px 0 8px; color: var(--muted); font-weight: 500; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.game-card {
  position: relative; display: flex; flex-direction: column; text-align: left;
  padding: 0; overflow: hidden; border-radius: 22px; color: var(--text);
  background: var(--card); border: 3px solid rgba(201, 184, 240, .35);
  font: inherit; cursor: pointer; transition: transform .15s, border-color .15s;
}
.game-card:hover, .game-card:focus-visible { transform: translateY(-3px); border-color: var(--accent); outline: none; }
.thumb { display: block; width: 100%; aspect-ratio: 16 / 9; height: auto; pointer-events: none; }
.game-info { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; }
.game-title { font-size: 24px; font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 14px; padding: 3px 10px; border-radius: 999px; background: rgba(201, 184, 240, .15); color: var(--muted); }
.play-badge {
  position: absolute; top: 10px; right: 10px; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; padding-left: 4px; box-sizing: border-box;
  background: var(--accent); color: #fff; font-size: 24px; box-shadow: 0 4px 0 #b85a0a;
}
.game-card.soon {
  cursor: default; align-items: center; justify-content: center; gap: 8px; min-height: 180px;
  border-style: dashed; background: transparent; color: var(--muted); text-align: center; padding: 16px;
}
.game-card.soon:hover { transform: none; border-color: rgba(201, 184, 240, .35); }
.soon-icon { font-size: 40px; }
.soon .game-title { font-size: 19px; font-weight: 500; }

.create {
  margin-top: 28px; padding: 4px 20px 22px; border-radius: 22px;
  background: linear-gradient(160deg, #2c1d50, #24164a); border: 3px solid rgba(201, 184, 240, .25);
}
.create .lead { margin: 0 0 14px; color: var(--muted); font-size: 18px; }
.upload {
  position: relative; display: grid; place-items: center; gap: 10px; min-height: 160px; padding: 16px;
  border: 3px dashed rgba(201, 184, 240, .5); border-radius: 18px; cursor: pointer;
  background: rgba(20, 11, 46, .5); text-align: center; font-size: 19px;
}
.upload:hover { border-color: var(--accent); }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload img { max-width: 100%; max-height: 280px; border-radius: 12px; }
.upload-hint { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.upload-icon { font-size: 38px; }
.has-image .upload-hint { flex-direction: row; font-size: 16px; }
.has-image .upload-icon { font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 6px 16px;
  border-radius: 999px; border: 2px solid rgba(201, 184, 240, .35); background: rgba(20, 11, 46, .5);
  color: var(--text); font: inherit; font-size: 17px; cursor: pointer;
}
.chip-icon { font-size: 22px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.big-btn {
  display: block; width: 100%; margin-top: 22px; min-height: 60px; border: none; border-radius: 18px;
  background: var(--accent); color: #fff; font: inherit; font-size: 22px; font-weight: 700;
  box-shadow: 0 6px 0 #b85a0a; cursor: pointer;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b85a0a; }
.note {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; font-size: 17px;
  background: rgba(183, 255, 107, .12); border: 2px solid rgba(183, 255, 107, .35); color: #e7ffd0;
}
.rotate { display: none; text-align: center; color: var(--muted); font-size: 15px; margin-top: 22px; }
@media (orientation: portrait) and (max-width: 700px) { .rotate { display: block; } }

/* short landscape phones: compact end card */
@media (max-height: 480px) {
  .card { padding: 12px 20px; }
  .stars { font-size: 40px; }
  .card p { font-size: 16px; margin-bottom: 8px; }
  .secret { width: 30px; height: 30px; font-size: 17px; }
  .end-btn { width: 60px; height: 60px; font-size: 28px; }
}

/* phones (narrow, or short when held sideways): a slimmer top row, so the board gets more room */
@media (max-width: 480px), (max-height: 480px) {
  .round { width: 42px; height: 42px; font-size: 19px; }
  #controls { gap: 6px; }
  #hud { gap: 6px; }
  .goal { gap: 5px; padding: 4px 10px; }
  .goal-icon { font-size: 20px; }
  .dot { width: 15px; height: 15px; border-width: 2px; }
  .slot { width: 30px; height: 30px; border-radius: 9px; }
  .slot svg { width: 24px; height: 24px; }
  .arrow { display: none; }
  .counter .count { font-size: 20px; }
}

/* ---------- top menu ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: rgba(20, 11, 46, .94); border-bottom: 2px solid rgba(201, 184, 240, .18);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 700; font-size: 26px; text-decoration: none; }
.brand-ufo { font-size: 30px; }
.topnav { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.navlink {
  padding: 8px 14px; border-radius: 999px; border: 2px solid transparent;
  color: var(--text); text-decoration: none; font-size: 18px; white-space: nowrap;
}
.navlink:hover { border-color: rgba(201, 184, 240, .35); }
.navlink.active { background: var(--accent); color: #fff; }
.player { margin-left: auto; }
a.game-card { text-decoration: none; }

/* ---------- a game's map ---------- */
#map-view { padding: 10px 0 28px; }
.map-head { text-align: center; padding: 6px 16px 12px; }
.map-head h1 { margin: 0; font-size: clamp(30px, 6vw, 48px); color: var(--accent); text-shadow: 0 3px 0 #6b2f0a; }
.map-head p { margin: 4px 0 0; color: var(--muted); font-size: 18px; }
.map-scroll { overflow-x: auto; overflow-y: hidden; padding: 0 16px 10px; -webkit-overflow-scrolling: touch; }
.map-world {
  position: relative; width: 100%; min-width: 860px; margin: 0 auto;
  max-width: min(1400px, calc((100vh - 190px) * 16 / 9)); /* the whole year fits on a tablet screen */
  aspect-ratio: 16 / 9; border-radius: 26px; overflow: hidden; border: 3px solid rgba(201, 184, 240, .35);
}
.map-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stop {
  position: absolute; transform: translate(-50%, -36%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; padding: 0; font: inherit; color: var(--text); cursor: pointer;
}
.stop-badge {
  position: relative; width: clamp(66px, 7vw, 94px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; background: #fff; border: 5px solid var(--accent);
  box-shadow: 0 6px 0 #b85a0a, 0 10px 18px rgba(0, 0, 0, .25);
}
.stop-icon { font-size: clamp(30px, 3.6vw, 46px); line-height: 1; }
.stop-num {
  position: absolute; top: -8px; left: -8px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card); color: #fff; font-weight: 700; font-size: 16px; border: 2px solid #fff;
}
.stop-label {
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
  background: rgba(20, 11, 46, .84); border-radius: 14px; padding: 4px 10px;
}
.stop-title { font-weight: 700; font-size: clamp(14px, 1.4vw, 18px); white-space: nowrap; }
.stop-when { font-size: 13px; color: var(--muted); }
.stop-stars span, .sheet-stars span { color: #6b5a92; }
.stop-stars .on, .sheet-stars .on { color: #ffd23f; }
.stop:hover .stop-badge { transform: translateY(-3px); }
.stop.done .stop-badge { border-color: #6fcf6f; box-shadow: 0 6px 0 #3f8f3f, 0 10px 18px rgba(0, 0, 0, .25); }
.stop.locked .stop-badge { background: #e4ddf3; border-color: #9a8cc0; box-shadow: 0 6px 0 #6e6290; }
.stop.soon .stop-badge { background: rgba(255, 255, 255, .55); border: 4px dashed #fff; box-shadow: none; }
.stop.soon .stop-icon { opacity: .55; filter: grayscale(.6); }
.stop.next .stop-badge { animation: stopPulse 1.4s ease-in-out infinite; }
@keyframes stopPulse { 50% { transform: scale(1.1); } }

/* ---------- a level's card ---------- */
.sheet-card { max-width: 420px; width: 100%; }
.sheet-pic {
  width: 100%; aspect-ratio: 16 / 9; margin: 0 auto 12px; border-radius: 18px; overflow: hidden;
  display: grid; place-items: center; background: var(--bg);
}
.sheet-pic .thumb { width: 100%; height: 100%; display: block; }
.sheet-pic.locked { filter: grayscale(.85) brightness(.8); }
.sheet-icon { font-size: 80px; }
.card .sheet-when { margin: 2px 0 8px; font-size: 16px; }

/* ---------- end card: points ---------- */
.points { font-size: 22px; margin-bottom: 6px; }
.points-num { font-size: 40px; font-weight: 700; color: #ffd23f; }
.points-parts { display: block; font-size: 13px; color: var(--muted); }
.card .news { color: #b7ff6b; font-weight: 700; }
.end-btn.next { background: #4caf50; box-shadow: 0 7px 0 #2e7d32; }

/* ---------- who's playing ---------- */
.welcome-card, .pm-card { max-width: 440px; width: 100%; }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 10px 0 16px; }
.avatar {
  aspect-ratio: 1; font-size: 30px; border-radius: 16px; cursor: pointer;
  border: 3px solid transparent; background: rgba(20, 11, 46, .55);
}
.avatar[aria-checked="true"] { border-color: var(--accent); background: rgba(255, 138, 31, .2); transform: scale(1.08); }
.name-label { display: block; text-align: left; color: var(--muted); font-size: 16px; margin-bottom: 6px; }
#nickname {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 24px; text-align: center; padding: 12px 14px;
  border-radius: 16px; border: 3px solid rgba(201, 184, 240, .5); background: #1d1240; color: var(--text);
}
#nickname:focus { outline: none; border-color: var(--accent); }
.form-error { margin: 10px 0 0 !important; color: #ffb3c7 !important; font-size: 16px !important; }
.card .fineprint { font-size: 14px; color: var(--muted); margin: 14px 0 0; line-height: 1.4; }
.fineprint a { color: var(--text); }
.link-btn { background: none; border: none; color: var(--muted); font: inherit; font-size: 16px; text-decoration: underline; margin-top: 10px; cursor: pointer; }
.big-btn:disabled { opacity: .6; }

.player-chip {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 999px; cursor: pointer;
  border: 2px solid rgba(201, 184, 240, .35); background: rgba(44, 29, 80, .9); color: var(--text); font: inherit; font-size: 17px;
}
.chip-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #fff; font-size: 22px; }
.chip-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-avatar { width: 84px; height: 84px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; background: #fff; font-size: 52px; }
.pm-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.pm-btn {
  min-height: 52px; border-radius: 16px; border: 2px solid rgba(201, 184, 240, .35); background: rgba(20, 11, 46, .55);
  color: var(--text); font: inherit; font-size: 18px; cursor: pointer;
}
.pm-btn.danger { border-color: rgba(255, 140, 160, .5); color: #ffc2cf; }
@media (max-width: 480px) {
  .chip-name { display: none; }
  .brand span:last-child { display: none; }
  .avatar { font-size: 24px; border-radius: 12px; }
}

/* ---------- Google sign-in, family, toast ---------- */
.pm-btn.google { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; background: #fff; color: #1f1f1f; border-color: #dadce0; }
.pm-btn.google svg { width: 22px; height: 22px; }
.pm-btn[hidden] { display: none; }
.pm-family { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.pm-family[hidden] { display: none; }
.family-btn {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 999px; cursor: pointer;
  border: 2px solid rgba(201, 184, 240, .35); background: rgba(20, 11, 46, .55); color: var(--text); font: inherit; font-size: 16px;
}
.family-btn.current { border-color: var(--accent); cursor: default; }
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: 16px; background: #fff6e0; color: #2c1d50;
  font-size: 18px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

/* ---------- players page (admins) ---------- */
#admin-view { max-width: 900px; margin: 0 auto; padding: 10px 16px 40px; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px;
  background: var(--card); border: 2px solid rgba(201, 184, 240, .25);
}
.admin-row .chip-avatar { width: 48px; height: 48px; font-size: 30px; flex: none; }
.admin-main { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.admin-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.admin-name { font-size: 20px; overflow-wrap: anywhere; }
.admin-when { font-size: 14px; color: var(--muted); }
.admin-levels { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-level { font-size: 14px; padding: 2px 8px; border-radius: 999px; background: rgba(201, 184, 240, .15); color: #ffd23f; }
.admin-none { font-size: 14px; color: var(--muted); }
.admin-remove { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 2px solid rgba(255, 140, 160, .5); background: transparent; font-size: 20px; cursor: pointer; }

/* ---------- game: the ⋯ menu and the sound/voice switches ---------- */
#controls .round[hidden] { display: none; }
.gamemenu {
  position: fixed; z-index: 15;
  top: calc(max(12px, env(safe-area-inset-top)) + 62px);
  right: max(12px, env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 4px; min-width: 230px; padding: 8px;
  border-radius: 20px; background: rgba(28, 17, 58, .96); border: 2px solid rgba(201, 184, 240, .35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.gamemenu[hidden], .gm-item[hidden] { display: none; }
.gm-item {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 12px; border: 0; border-radius: 14px;
  background: transparent; color: var(--text); font: inherit; font-size: 19px; text-align: left;
}
.gm-item:hover, .gm-item:focus-visible { background: rgba(201, 184, 240, .14); outline: none; }
.gm-icon { width: 28px; text-align: center; font-size: 22px; }
/* an on/off switch: on = green with the knob on the right */
.gm-switch {
  position: relative; flex: none; width: 46px; height: 26px; margin-left: auto; border-radius: 999px;
  background: rgba(201, 184, 240, .3); transition: background .2s;
}
.gm-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
[aria-checked="true"] > .gm-switch { background: #5fcf5f; }
[aria-checked="true"] > .gm-switch::after { transform: translateX(20px); }
.pm-settings { display: flex; gap: 10px; }
.pm-toggle { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 12px; }
@media (max-width: 480px), (max-height: 480px) {
  .gamemenu { top: calc(max(12px, env(safe-area-inset-top)) + 50px); }
  .gm-item { min-height: 46px; font-size: 17px; }
}

/* ---------- around the board, and the hint arrow ---------- */
#stage .around * { animation: none !important; } /* still: no twinkling or falling rain out there */
#stage .around { pointer-events: none; }
.around-dim { fill: #0b0618; opacity: .5; }
/* the games page: get the Android app (the website only) */
.get-app { margin: 28px 0 0; text-align: center; font-size: 17px; }
.get-app a { color: var(--accent); font-weight: 700; }
.get-app-note { display: block; margin-top: 4px; font-size: 14px; color: var(--muted); }
html.app .get-app { display: none; }
html.app .around-dim { display: none; } /* the app: the scenery around the board looks like one picture */
.hint-arrow { pointer-events: none; }
.hint-arrow-edge { fill: none; stroke: #3a2470; stroke-width: 26; stroke-linecap: round; opacity: .55; }
.hint-arrow-line {
  fill: none; stroke: #ffd23f; stroke-width: 15; stroke-linecap: round; stroke-dasharray: 34 24;
  animation: hintFlow .8s linear infinite;
}
@keyframes hintFlow { to { stroke-dashoffset: -58; } }

/* a phone held upright: the board is small, so suggest turning it */
#rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  #rotate-hint {
    display: flex; align-items: center; gap: 10px; position: fixed; left: 50%; transform: translateX(-50%);
    bottom: max(20px, env(safe-area-inset-bottom)); padding: 10px 18px; border-radius: 999px; white-space: nowrap;
    background: rgba(20, 11, 46, .8); border: 2px solid rgba(201, 184, 240, .35); font-size: 16px; pointer-events: none;
  }
  .rotate-phone { display: inline-block; font-size: 24px; animation: rotatePhone 2.4s ease-in-out infinite; }
  @keyframes rotatePhone { 0%, 30% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
}

/* "Show all levels" (testing, admins only) */
.pm-check {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: 16px;
  border: 2px dashed rgba(201, 184, 240, .35); font-size: 17px; cursor: pointer;
}
.pm-check[hidden] { display: none; }
.pm-check input { width: 22px; height: 22px; margin: 0; accent-color: #5fcf5f; cursor: pointer; }
.pm-check-note { color: var(--muted); font-size: 14px; }
a.pm-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }

/* the phone app on a short landscape screen: everything fits without scrolling (the website is not changed) */
@media (max-height: 600px) {
  html.app #home { padding-top: 6px; padding-bottom: 12px; }
  html.app .home-head { display: none; } /* the top bar already shows the Ufodufo name */
  html.app #home h2 { font-size: 22px; margin: 10px 0 8px; }
  html.app .game-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
  html.app .card { padding: 10px 18px; }
  html.app .card h1, html.app .map-head h1 { font-size: 30px; }
  /* the map: the whole year as tall as the screen allows (the top bar already names the game) */
  html.app #map-view { padding: 6px 0; }
  html.app .map-head { display: none; }
  html.app .map-scroll { padding: 0 16px; }
  html.app .map-world { min-width: 0; max-width: none; width: auto; height: calc(100dvh - 66px - 18px); }
  html.app .stop-badge { width: 50px; border-width: 4px; }
  html.app .stop-icon { font-size: 24px; }
  html.app .stop-title { font-size: 12px; }
  html.app .stop-when { font-size: 11px; }
  html.app #nickname { padding-top: 6px; padding-bottom: 6px; }
  /* a level's card: the picture beside the words and buttons, so ▶ is on screen */
  html.app .sheet-card { max-width: 640px; display: grid; grid-template-columns: 300px 1fr; column-gap: 18px; align-items: center; }
  html.app .sheet-pic { grid-row: 1 / span 4; margin: 0; }
  /* small things on the board are bigger (and so easier to tap and drag) */
  html.app .el.small > .anim { scale: 1.3; }
  html.app .avatars { grid-template-columns: repeat(12, 1fr); gap: 6px; margin: 6px 0 8px; }
  html.app .avatar { font-size: 22px; border-radius: 12px; }
  html.app .big-btn { min-height: 52px; margin-top: 12px; font-size: 20px; }
  html.app .fineprint { font-size: 12px; margin: 4px 0; }
}
