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

:root {
  --ink: #2b2118;
  --cream: #fff8ec;
  --green: #2f6e4f;
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3a2a1c; color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
kbd {
  font: 700 0.85em/1 ui-monospace, monospace;
  padding: 0.15em 0.4em; border-radius: 0.3em;
  background: #f1e6d2; border: 1px solid #c9b896;
}

#table { position: fixed; inset: 0; }
#table canvas { display: block; }

/* Big, chunky buttons that are easy to hit on a whiteboard */
#toolbar { position: fixed; top: 14px; left: 14px; display: flex; gap: 10px; }
#toolbar button {
  width: 56px; height: 56px; display: grid; place-items: center;
  border: 3px solid var(--ink); border-radius: 16px;
  background: var(--cream); font-size: 26px; font-weight: 800;
  box-shadow: 0 4px 0 var(--ink);
}
#toolbar button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

#controls {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 26px;
  box-shadow: 0 6px 0 var(--ink);
  max-width: calc(100vw - 16px); overflow-x: auto;
}
.group { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 18px; background: #efe2c8; }
.group button, #total-btn {
  min-width: 64px; height: 64px; padding: 0 10px;
  border: 3px solid transparent; border-radius: 14px;
  background: transparent; font-size: 32px; font-weight: 800; line-height: 1;
  display: grid; place-items: center;
}
.group button:hover, #total-btn:hover { background: #fff; }
.group [aria-checked="true"] { background: var(--ink); color: var(--cream); }
.group [aria-checked="true"]:hover { background: var(--ink); }
.group output { min-width: 44px; text-align: center; font-size: 40px; font-weight: 800; }
.group .label { padding: 0 10px 0 4px; font-size: 20px; font-weight: 700; color: #6b5a44; }
#total-btn { font-size: 26px; border-color: var(--ink); }
#total-btn[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
#roll {
  height: 76px; padding: 0 36px;
  border: 4px solid var(--ink); border-radius: 20px;
  background: #e0453a; color: #fff;
  font-size: 40px; font-weight: 800; letter-spacing: 0.02em;
  box-shadow: 0 5px 0 var(--ink);
}
#roll:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

/* The sum, above the tray */
#total {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 2px 20px;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 22px;
  box-shadow: 0 5px 0 var(--ink);
  font-size: 46px; font-weight: 800; line-height: 1.2;
  animation: pop 0.25s ease-out;
}
#total b {
  min-width: 1.3em; text-align: center; padding: 0 8px; border-radius: 12px;
  background: var(--die); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
#total i { font-style: normal; color: #6b5a44; }
#total span { font-size: 1.2em; }
@keyframes pop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } }

#help {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: rgba(20, 14, 8, 0.55); padding: 16px;
}
#help .card {
  max-width: 640px; padding: 20px 32px 24px;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 24px;
  font-size: 20px; line-height: 1.45;
}
#help h1 { margin: 0 0 4px; font-size: 40px; }
#help ul { padding-left: 1.1em; margin: 0 0 12px; }
#help li { margin-bottom: 6px; }
#offline-status { color: var(--green); font-weight: 700; }
#help .close {
  padding: 8px 28px; border: 3px solid var(--ink); border-radius: 14px;
  background: var(--ink); color: var(--cream); font-size: 22px; font-weight: 800;
}

@media (max-width: 760px), (max-height: 520px) {
  #controls { gap: 6px; padding: 6px; border-radius: 18px; flex-wrap: wrap; justify-content: center; width: max-content; }
  .group button, #total-btn { min-width: 46px; height: 48px; font-size: 24px; }
  .group output { min-width: 30px; font-size: 28px; }
  .group .label { display: none; }
  #total-btn { font-size: 18px; }
  #roll { height: 56px; padding: 0 18px; font-size: 28px; }
  #total { font-size: 34px; }
}
@media (max-width: 760px) {
  #total { top: 82px; }
}
