/* Baloo 2: self-hosted so the game works offline and behind school web
   filters (SIL Open Font License, latin subset). */
@font-face {
  font-family: 'Baloo 2';
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/baloo2.woff2) format('woff2');
}

:root {
  --ink: #2b2118;
  --red: #c8322a;
  --panel: rgba(28, 38, 22, 0.62);
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7fa35a; color: #fff; }
button { font: inherit; }
[hidden] { display: none !important; }
kbd {
  font: 700 0.6em/1 ui-monospace, monospace;
  padding: 0.25em 0.45em;
  border-radius: 0.3em;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  vertical-align: 0.2em;
}

/* ---------- Scene ---------- */
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.group-label {
  position: absolute; left: 0; top: 0;
  display: grid; place-items: center;
  width: 9vh; height: 9vh;
  border-radius: 50%;
  background: var(--c);
  color: var(--ink);
  font-size: 6.4vh; font-weight: 800; line-height: 1;
  box-shadow: 0 0.6vh 0 rgba(0, 0, 0, 0.25);
  transform: translate(var(--dx), -50%) scale(0.3);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(.2, .9, .3, 1.4), opacity 0.2s;
}
.group-label.left { --dx: -100%; }
.group-label.right { --dx: 0%; }
.group-label.show { transform: translate(var(--dx), -50%) scale(1); opacity: 1; }

/* ---------- Toolbar, prompt and buttons ---------- */
#toolbar { position: fixed; top: 2vh; left: 2vw; display: flex; gap: 0.6vw; z-index: 10; }
#toolbar button {
  width: 5.6vh; height: 5.6vh;
  border-radius: 1.4vh; border: none;
  background: var(--panel);
  backdrop-filter: blur(6px);
  font-size: 2.6vh; color: #fff;
  cursor: pointer;
}
#toolbar button:hover { background: rgba(255, 255, 255, 0.28); }

#prompt {
  position: fixed; top: 2.5vh; left: 50%;
  transform: translateX(-50%);
  margin: 0;
  max-width: 70vw;
  padding: 1vh 3.5vh;
  border-radius: 2.6vh;
  background: var(--panel);
  backdrop-filter: blur(6px);
  font-size: 6.2vh; font-weight: 800; line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0.3vh 0 rgba(0, 0, 0, 0.3);
  z-index: 10;
}
#prompt:empty { display: none; }
#prompt small { display: block; font-size: 0.6em; font-weight: 700; opacity: 0.9; }
#prompt .answer { font-size: 1.35em; }
#prompt .answer b { font-weight: 800; }
body[data-phase=done] #prompt { animation: pop 0.45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { from { transform: translateX(-50%) scale(0.6); } to { transform: translateX(-50%) scale(1); } }

#controls {
  position: fixed; bottom: 3vh; left: 0; right: 0;
  display: flex; justify-content: center; gap: 2vw;
  z-index: 10;
}
#controls button {
  display: none;
  border: none; border-radius: 999px;
  padding: 1.4vh 4.5vh;
  font-size: 4.2vh; font-weight: 800;
  cursor: pointer;
  color: #fff;
}
#controls .go { background: var(--red); box-shadow: 0 0.8vh 0 #8c1f19; }
#controls .again { background: var(--panel); backdrop-filter: blur(6px); box-shadow: 0 0.8vh 0 rgba(0, 0, 0, 0.3); }
#controls button:active { transform: translateY(0.5vh); box-shadow: 0 0.3vh 0 #8c1f19; }
body[data-phase=ready] #controls .show,
body[data-phase=think] #controls .reveal,
body[data-phase=think] #controls .again,
body[data-phase=done] #controls .new { display: block; }

/* ---------- Menu ---------- */
#menu {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  overflow: auto;
  padding: 3vh 2vw;
  background: radial-gradient(ellipse at center, rgba(20, 30, 10, 0.45), rgba(10, 16, 6, 0.8));
  z-index: 20;
}
body:not([data-phase=menu]) #menu { display: none; }
body[data-phase=menu] #prompt, body[data-phase=menu] #controls { display: none; }
.panel {
  width: min(820px, 94vw);
  background: rgba(255, 252, 245, 0.97);
  color: var(--ink);
  border-radius: 28px;
  padding: 28px 36px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.logo { margin: 0; font-size: 56px; line-height: 1; font-weight: 800; color: var(--red); }
.tagline { margin: 8px 0 20px; font-size: 19px; line-height: 1.4; color: #5b4a3a; }
.option { margin-bottom: 16px; }
.option h2 { margin: 0 0 6px; font-size: 19px; }
.choice { display: flex; flex-wrap: wrap; gap: 10px; }
.choice button {
  min-width: 140px;
  padding: 10px 20px;
  border: 3px solid #d9cfbf; border-radius: 16px;
  background: #fff; color: var(--ink);
  font-size: 19px; font-weight: 700;
  cursor: pointer;
}
.choice button[aria-pressed=true] { border-color: var(--red); background: #fdecea; }
#start {
  margin-top: 8px;
  border: none; border-radius: 999px;
  padding: 12px 44px;
  background: var(--red); color: #fff;
  font-size: 24px; font-weight: 800;
  box-shadow: 0 6px 0 #8c1f19;
  cursor: pointer;
}
#start:disabled { opacity: 0.5; cursor: wait; }
#start:active { transform: translateY(3px); box-shadow: 0 3px 0 #8c1f19; }
#offline-status { margin: 12px 0 0; color: #3d7a4a; font-size: 15px; }
.help { margin-top: 18px; font-size: 15px; color: #5b4a3a; }
.help summary { cursor: pointer; font-weight: 700; }
.help ul { padding-left: 20px; line-height: 1.5; }
.help kbd { background: #eee5d6; border-color: #cbbda7; color: var(--ink); font-size: 0.85em; vertical-align: 0; }
