:root {
  --sky: #bfe6ff;
  --ink: #2b2340;
  --muted: #5a5375;
  --card: #ffffff;
  --go: #2f9e44;
  --go-dark: #237a34;
  --seek: #e8590c;
  --seek-dark: #b8460a;
  --line: #2b2340;
  --sun: #ffd93d;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; flex-direction: column; min-height: 100%;
  background: var(--sky); color: var(--ink);
  font-family: Fredoka, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--ink); text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; }

/* Every game: a way back to the others, and who's signed in. */
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.6); font-size: 15px;
  position: relative; z-index: 5;
}
.bar .home { color: var(--muted); text-decoration: none; }
.bar .home:hover { color: var(--ink); }
.bar .account { color: var(--muted); text-align: right; }
.bar .account strong { color: var(--ink); }

main { flex: 1; display: flex; position: relative; }
.screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); text-align: center;
}
.screen[hidden] { display: none; }

h1 {
  font-size: clamp(48px, 13vw, 96px); line-height: 1; margin: 0; font-weight: 700;
  color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink);
}
h1 span { color: var(--sun); }
h2 { font-size: clamp(26px, 6vw, 36px); margin: 0; font-weight: 700; }
.lead { font-size: 20px; margin: 0; color: var(--muted); }
.hello { font-size: 26px; margin: 0; font-weight: 600; }
.error { color: #c92a2a; font-size: 18px; min-height: 1.4em; margin: 0; font-weight: 600; }

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.big {
  border: 3px solid var(--line); border-radius: 22px; background: var(--card);
  font-size: 24px; font-weight: 600; padding: 14px 26px; min-height: 64px; cursor: pointer;
  box-shadow: 0 5px 0 var(--line); transition: transform 0.08s;
}
.big:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.big.go { background: var(--go); color: #fff; }
.big.seek { background: var(--seek); }
.big:disabled { opacity: 0.45; cursor: default; transform: none; }
.small {
  border: 2px solid var(--muted); border-radius: 14px; background: transparent;
  color: var(--muted); font-size: 17px; padding: 8px 18px; cursor: pointer;
}

.name, .join { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 20px; }
.join .row { display: flex; gap: 10px; }
input {
  border: 3px solid var(--line); border-radius: 18px; background: #fff;
  font-size: 26px; padding: 10px 16px; width: min(320px, 80vw); text-align: center;
}
#code { width: 150px; letter-spacing: 6px; }

.code {
  font-size: clamp(64px, 20vw, 110px); font-weight: 700; letter-spacing: 10px; margin: 0;
  background: #fff; border: 4px solid var(--line); border-radius: 28px; padding: 4px 28px 4px 38px;
}

.players { font-size: 20px; margin: 0; }
.players .dot {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); vertical-align: -2px; margin-right: 6px;
}
.players .away { color: var(--muted); }

.places { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.place {
  width: clamp(96px, 28vw, 190px); padding: 0; border: 4px solid var(--line); border-radius: 22px;
  background: #fff; overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  box-shadow: 0 5px 0 var(--line);
}
.place img { width: 100%; height: auto; display: block; aspect-ratio: 1; object-fit: cover; }
.place span { font-size: clamp(17px, 4.4vw, 24px); font-weight: 600; padding: 6px 0 8px; }
.place[aria-pressed="true"] { border-color: var(--go); box-shadow: 0 0 0 5px var(--sun), 0 5px 0 var(--go-dark); transform: scale(1.05); }

/* The game: the 3D world fills the screen, with big friendly overlays. */
.screen.game { padding: 0; position: relative; overflow: hidden; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); pointer-events: none;
}
.banner {
  margin: 0; background: #fff; border: 3px solid var(--line); border-radius: 20px;
  padding: 10px 16px; font-size: clamp(19px, 4.6vw, 26px); font-weight: 600; box-shadow: 0 4px 0 var(--line);
}
.timer { margin: 8px auto 0; height: 14px; width: 70%; background: #fff; border: 3px solid var(--line); border-radius: 10px; overflow: hidden; }
#timerFill { height: 100%; background: var(--sun); width: 100%; }
.bubble {
  position: absolute; left: 50%; top: 24%; transform: translate(-50%, -50%);
  margin: 0; background: #fff; border: 4px solid var(--line); border-radius: 30px;
  padding: 12px 26px; font-size: clamp(30px, 8vw, 46px); font-weight: 700; pointer-events: none;
  animation: pop 0.3s ease-out;
}
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.4); } }
.giggle {
  position: absolute; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  border: 4px solid var(--line); border-radius: 50px; background: var(--sun);
  font-size: 30px; font-weight: 700; padding: 14px 34px; box-shadow: 0 6px 0 var(--line); cursor: pointer;
}
.giggle:active { transform: translate(-50%, 4px); box-shadow: 0 2px 0 var(--line); }
.sound {
  position: absolute; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom));
  width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--line); background: #fff;
  font-size: 24px; cursor: pointer;
}
.count, .found {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 16px; text-align: center; font-size: 24px;
}
.count { background: #6741d9; color: #fff; }
.count p { margin: 0; }
.count .number { font-size: clamp(120px, 40vw, 240px); font-weight: 700; line-height: 1; text-shadow: 0 8px 0 rgba(0, 0, 0, 0.25); }
.eyes { font-size: 80px; margin: 0; line-height: 1; }
.found { background: rgba(191, 230, 255, 0.55); gap: 12px; }
.found h2 { font-size: clamp(44px, 12vw, 72px); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.found > p:not(.eyes) { margin: 0; background: #fff; border: 3px solid var(--line); border-radius: 18px; padding: 8px 18px; }
.count[hidden], .found[hidden], .bubble[hidden], .giggle[hidden], .timer[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .bubble { animation: none; }
}
