/* Self-hosted so the game works offline and behind school web filters.
   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;
  --green: #3d7a4a;
  --green-dark: #2a5634;
  --panel: rgba(30, 40, 28, 0.66);
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe0d6; color: #fff; }
button, select { 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: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.2);
}

/* ---------- Scene: fills the screen, whatever its shape (the camera
   frames the jar and rows to fit) ---------- */
#viewport, #stage { position: fixed; inset: 0; overflow: hidden; }
#scene3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Numbers at the end of each row of ten, placed by js/stage.js */
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.row-label {
  position: absolute; left: 0; top: 0;
  transform: translate(0, -50%);
  padding: 0 0.35em;
  border-radius: 0.4em;
  background: #fffdf6;
  color: var(--ink);
  font-weight: 800; line-height: 1.2;
  box-shadow: 0 0.12em 0 rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.row-label.big { background: #ffd34d; }
.row-label.pop { animation: label-pop 0.45s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes label-pop { from { transform: translate(0, -50%) scale(0.2); } to { transform: translate(0, -50%) scale(1); } }

/* ---------- HUD ---------- */
#hud-top, #hud-bottom {
  position: fixed; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: center; gap: 2vw;
  padding: 2vh 2vw;
  z-index: 10;
  pointer-events: none;
}
#hud-top { top: 0; }
#hud-bottom { bottom: 0; align-items: flex-end; padding-bottom: 4vh; }
#hud-top > *, #hud-bottom > * { pointer-events: auto; }
#toolbar { position: absolute; left: 2vw; top: 2vh; display: flex; gap: 0.6vh; }
#toolbar button {
  width: 5.2vh; height: 5.2vh;
  display: grid; place-items: center;
  border-radius: 1.4vh;
  border: none;
  background: var(--panel);
  backdrop-filter: blur(6px);
  font-size: 2.6vh;
  cursor: pointer;
  color: #fff;
}
body.menu #toolbar { display: none; }
#toolbar button:hover { background: rgba(30, 40, 28, 0.85); }

#message {
  max-width: 70vw;
  text-align: center;
  padding: 1vh 3vw 1.4vh;
  border-radius: 3vh;
  background: var(--panel);
  backdrop-filter: blur(6px);
  visibility: hidden;
}
#message.show { visibility: visible; }
#message h1 { margin: 0; font-size: clamp(24px, 5.4vh, 76px); line-height: 1.1; }
#message p { margin: 0.4vh 0 0; font-size: clamp(16px, 3vh, 40px); line-height: 1.2; }
#message p:empty { display: none; }
/* While counting: one big number */
#message.counter { padding: 0.4vh 3.4vw 1vh; }
#message.counter h1 { font-size: clamp(48px, 13vh, 180px); line-height: 1; font-variant-numeric: tabular-nums; }
#message.counter p { margin-top: -0.6vh; }
#message h1.pop { animation: pop 0.35s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes pop { from { transform: scale(0.8); } to { transform: scale(1); } }

#timer {
  position: absolute; right: 2vw; top: 2vh;
  min-width: 14vh;
  padding: 0.4vh 2vh;
  border-radius: 2vh;
  background: var(--panel);
  backdrop-filter: blur(6px);
  font-size: 6vh; font-weight: 800; line-height: 1.2;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#hud-bottom button {
  border: none;
  border-radius: 2vh;
  padding: 1.4vh 4vh;
  font-size: clamp(18px, 3.6vh, 48px); font-weight: 800;
  cursor: pointer;
  background: #fffaf0;
  color: var(--ink);
  box-shadow: 0 0.7vh 0 rgba(0, 0, 0, 0.3);
}
#hud-bottom button.primary { background: var(--green); color: #fff; box-shadow: 0 0.7vh 0 var(--green-dark); }
#hud-bottom button:active { transform: translateY(0.4vh); box-shadow: 0 0.3vh 0 rgba(0, 0, 0, 0.3); }
#hud-bottom button.primary::after { content: 'Space'; margin-left: 1.4vh; font-size: 0.5em; opacity: 0.75; vertical-align: middle; border: 2px solid currentColor; border-radius: 0.6vh; padding: 0 0.6vh; }

/* ---------- Menu ---------- */
#setup {
  position: fixed; inset: 0;
  z-index: 20;
  display: flex; align-items: center;
  padding: 3vh 4vw;
  overflow: auto;
  background: linear-gradient(90deg, rgba(20, 30, 22, 0.5), rgba(20, 30, 22, 0) 65%);
}
.panel {
  width: min(560px, 92vw);
  background: rgba(255, 252, 245, 0.97);
  color: var(--ink);
  border-radius: 28px;
  padding: 28px 34px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.logo { margin: 0; font-size: 52px; line-height: 1; font-weight: 800; color: var(--green); letter-spacing: -0.5px; }
.tagline { margin: 8px 0 16px; font-size: 19px; line-height: 1.35; color: #5b4a3a; }
.today {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 16px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: #f1e8d6;
  font-size: 18px;
}
.today b { font-size: 21px; }
.panel h2 { margin: 0 0 8px; font-size: 18px; }
.choices { display: flex; gap: 10px; margin-bottom: 16px; }
.choices button {
  flex: 1;
  padding: 8px 0;
  border: 3px solid #d8ccb5;
  border-radius: 14px;
  background: #fff;
  font-size: 26px; font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}
.choices button[aria-checked="true"] { border-color: var(--green); background: #e3f1e3; color: var(--green-dark); }
.row { display: flex; gap: 16px; margin-bottom: 10px; }
.row label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 17px; }
select { padding: 6px 10px; border-radius: 10px; border: 2px solid #d8ccb5; background: #fff; font-size: 17px; }
.check { display: flex; gap: 10px; align-items: center; margin: 6px 0; font-size: 17px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }
.buttons { margin-top: 18px; }
.buttons button.primary {
  width: 100%;
  padding: 12px 30px;
  border: none;
  border-radius: 16px;
  background: var(--green);
  color: #fff;
  font-size: 24px; font-weight: 800;
  box-shadow: 0 6px 0 var(--green-dark);
  cursor: pointer;
}
.buttons button.primary:disabled { opacity: 0.6; cursor: wait; }
.buttons button.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--green-dark); }
.error { color: #b3261e; font-weight: 700; }
#offline-status { margin: 10px 0 0; font-size: 15px; font-weight: 700; color: var(--green); }
.help { margin-top: 14px; font-size: 16px; line-height: 1.4; }
.help summary { cursor: pointer; font-weight: 700; }
.help ul { padding-left: 20px; margin: 8px 0 0; }
.help li { margin-bottom: 6px; }

@media (max-width: 700px) {
  #setup { padding: 12px; justify-content: center; background: rgba(20, 30, 22, 0.4); }
  .panel { padding: 20px; }
  .logo { font-size: 40px; }
}
