/* Self-hosted so the game works offline and behind school web filters.
   Baloo 2 is a variable font (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;
  --panel: rgba(16, 44, 56, 0.66);
  --gold: #ffd43b;
  --sea: #1f7a8c;
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9edcf3; color: #fff; }
button, select, input { font: inherit; }
[hidden] { display: none !important; }
kbd {
  font: 700 0.85em/1 ui-monospace, monospace;
  padding: 0.15em 0.4em;
  border-radius: 0.3em;
  background: #eee5d6;
  border: 1px solid #cbbda7;
  color: var(--ink);
}

#viewport { position: fixed; inset: 0; overflow: hidden; cursor: pointer; }
#viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#confetti { pointer-events: none; z-index: 5; }

/* ---------- Top: toolbar and message ---------- */
#hud-top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; gap: 2vw;
  padding: 2vh 2vw;
  z-index: 10;
  pointer-events: none;
}
#hud-top > * { pointer-events: auto; }
#toolbar { display: flex; gap: 0.5vw; position: absolute; left: 2vw; top: 2vh; }
#toolbar button {
  width: 5.2vh; height: 5.2vh;
  border-radius: 1.4vh;
  border: none;
  background: var(--panel);
  backdrop-filter: blur(6px);
  font-size: 2.6vh;
  cursor: pointer;
  color: #fff;
  display: grid; place-items: center;
}
#toolbar button:hover { background: rgba(255, 255, 255, 0.3); }

#message {
  margin: 0 auto;
  max-width: 62vw;
  text-align: center;
  font-size: clamp(20px, 4.2vh, 60px);
  font-weight: 800;
  line-height: 1.15;
  padding: 0.6vh 2.4vw;
  border-radius: 4vh;
  background: var(--panel);
  backdrop-filter: blur(6px);
  text-shadow: 0 0.3vh 0 rgba(0, 0, 0, 0.3);
}
#message:empty { display: none; }
#message b { color: #fff3b0; }
#message b.t0 { color: #8ff0b4; }
#message b.t1 { color: #e3c6ff; }
#message.warn { background: rgba(120, 52, 12, 0.78); }
#message.win { background: rgba(140, 92, 0, 0.85); animation: pop 0.6s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }

/* ---------- The two sides of the room ---------- */
.team {
  position: fixed; top: 12vh;
  width: 16.5vw; max-height: 70vh;
  display: flex; flex-direction: column; align-items: center;
  padding: 1.6vh 1vw;
  border-radius: 2.6vh;
  background: var(--panel);
  backdrop-filter: blur(6px);
  border: 0.5vh solid transparent;
  z-index: 10;
  transition: border-color 0.3s, transform 0.3s;
}
#team-0 { left: 1.5vw; }
#team-1 { right: 1.5vw; }
.team .mascot { font-size: 6vh; line-height: 1; }
.team .name { margin: 0.4vh 0 0; font-size: 3.6vh; line-height: 1.1; color: #fff; text-align: center; overflow-wrap: anywhere; }
.team .score { font-size: 2.4vh; color: rgba(255, 255, 255, 0.85); }
.team .score b { font-size: 4.6vh; color: var(--gold); vertical-align: -0.3vh; }
.team .turn {
  visibility: hidden;
  margin: 0.6vh 0;
  padding: 0.2vh 1.6vh;
  border-radius: 999px;
  background: var(--team);
  font-size: 2.4vh; font-weight: 800;
}
.team.active { border-color: var(--team); transform: scale(1.04); }
.team.active .turn { visibility: visible; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { transform: scale(1.08); } }
.team.scored .score b { display: inline-block; animation: pop 0.8s cubic-bezier(.2, .9, .3, 1.6); }
.digs {
  list-style: none; margin: 0; padding: 0;
  width: 100%;
  overflow: hidden;
  font-size: 2.6vh;
}
.digs li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.3vh 0.6vw;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.digs li span {
  min-width: 4.2vh;
  padding: 0 1vh;
  border-radius: 999px;
  background: var(--clue);
  text-align: center;
  font-weight: 800;
  font-size: 2.2vh;
}

/* ---------- Bottom: calling a spot ---------- */
#call {
  position: fixed; bottom: 2.2vh; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 1.2vw;
  padding: 1vh 1.2vw;
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(6px);
  z-index: 10;
}
#call form { display: flex; gap: 0.6vw; }
#call-input {
  width: 9em;
  padding: 0.3vh 1.4vh;
  border: 0.4vh solid #fff;
  border-radius: 999px;
  background: #fffaf0;
  color: var(--ink);
  font-size: 4vh; font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}
#call-input::placeholder { color: #c9b9a0; }
#call button {
  white-space: nowrap;
  border: none;
  border-radius: 999px;
  padding: 0.6vh 2.2vh;
  font-size: 2.8vh; font-weight: 800;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
}
#call button:hover { background: rgba(255, 255, 255, 0.32); }
#call button:disabled { opacity: 0.4; cursor: default; }
#call button.primary { background: #f2a516; color: #3a2400; font-size: 3.4vh; padding: 0.6vh 3.4vh; box-shadow: 0 0.5vh 0 #a86d00; }
#call button.primary:active { transform: translateY(0.3vh); box-shadow: 0 0.2vh 0 #a86d00; }

/* ---------- Menu ---------- */
#setup {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 20;
  background: radial-gradient(ellipse at center, rgba(10, 40, 50, 0.5), rgba(5, 20, 30, 0.85));
  overflow: auto;
  padding: 3vh 2vw;
}
.panel {
  width: min(900px, 94vw);
  background: rgba(255, 252, 245, 0.97);
  color: var(--ink);
  border-radius: 28px;
  padding: 26px 36px 22px;
  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(--sea); letter-spacing: -0.5px; }
.tagline { margin: 6px 0 18px; font-size: 19px; line-height: 1.35; color: #5b4a3a; }
.panel h2 { margin: 0 0 10px; font-size: 20px; }
#level-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.level-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 8px 10px;
  border: 4px solid transparent;
  border-radius: 18px;
  background: #f3dfb1;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
  transition: transform 0.15s, border-color 0.15s;
}
.level-card canvas { width: 100%; aspect-ratio: 1; }
.level-card b { font-size: 19px; line-height: 1.1; }
.level-card span { font-size: 14px; line-height: 1.25; color: #6b5a48; }
.level-card:hover { transform: translateY(-3px); }
.level-card[aria-pressed='true'] { border-color: var(--sea); transform: translateY(-3px); }
.row { display: flex; gap: 18px; flex-wrap: wrap; }
.row label { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 16px; }
.row select, .row input { padding: 8px 10px; border-radius: 12px; border: 2px solid #d9cfbf; background: #fff; font-size: 16px; }
.buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.buttons button, #reset-scores {
  border: 2px solid var(--sea);
  background: #fff;
  color: var(--sea);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 19px; font-weight: 800;
  cursor: pointer;
}
.buttons button.primary { background: var(--sea); color: #fff; font-size: 22px; padding: 12px 30px; box-shadow: 0 6px 0 #145563; }
.buttons button.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #145563; }
.buttons button:disabled { opacity: 0.6; cursor: wait; }
#offline-status { margin: 10px 0 0; font-size: 15px; font-weight: 700; color: var(--sea); }
.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; }
#reset-scores { font-size: 14px; padding: 6px 14px; border-color: #b3261e; color: #b3261e; }

@media (max-width: 760px) {
  #level-list { grid-template-columns: repeat(2, 1fr); }
}
