/* Self-hosted so the page works 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: #1d1a17; --green: #3d7a4a; --line: #d9d4cc; }
* { box-sizing: border-box; }
body {
  margin: 0; padding: 20px 24px; background: #f6f3ee; color: var(--ink);
  font-family: 'Baloo 2', system-ui, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

header { max-width: 1500px; margin: 0 auto 12px; }
header h1 { margin: 0; font-size: 2.2rem; line-height: 1.1; }
header p { margin: 4px 0 0; color: #555; }
.home { color: #666; font-weight: 700; text-decoration: none; }

#shapes {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
  max-width: 1500px; margin: 0 auto 14px;
}
#shapes button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px 4px; background: #fff; font-weight: 700; line-height: 1.15;
  border: 3px solid var(--line); border-radius: 12px;
}
#shapes svg { width: 44px; height: 38px; }
#shapes button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }

main {
  display: grid; grid-template-columns: 240px minmax(0, 1fr) 330px; gap: 16px;
  max-width: 1500px; margin: 0 auto;
}
#side, #stage, #working { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 14px; }
#side, #working { align-self: start; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: flex; justify-content: space-between; font-weight: 800; margin-bottom: 2px; }
.field output { font-size: 1.3rem; line-height: 1; }
.field input[type="range"] { width: 100%; accent-color: var(--ink); }
.field select { width: 100%; padding: 4px 8px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 700; cursor: pointer; }

.modes { display: flex; gap: 8px; margin-bottom: 10px; }
.modes button, .play button {
  padding: 4px 16px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; font-weight: 800; font-size: 1.1rem;
}
.modes button[aria-pressed="true"] { background: var(--ink); color: #fff; }

#view {
  position: relative; height: min(62vh, 620px); min-height: 340px;
  border: 2px solid var(--line); border-radius: 10px; overflow: hidden;
  background: linear-gradient(#fdfcfa, #efebe4); cursor: grab; touch-action: none;
}
#view:active { cursor: grabbing; }
#view canvas { position: absolute; inset: 0; }
#labels { position: absolute; inset: 0; pointer-events: none; }
#labels div {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  padding: 0 7px; border-radius: 7px; font-weight: 800; font-size: 1.05rem; line-height: 1.5;
  background: rgba(255, 255, 255, 0.92); border: 2px solid var(--ink);
}
#labels .face { background: rgba(255, 255, 255, 0.85); border-color: transparent; font-size: 1rem; }
#labels .slant { border-style: dashed; }
#count {
  position: absolute; left: 12px; top: 10px; font-size: 1.6rem; font-weight: 800;
  background: rgba(255, 255, 255, 0.9); padding: 0 10px; border-radius: 8px;
}
#drag { position: absolute; right: 12px; bottom: 6px; margin: 0; color: #8a837a; font-size: 0.9rem; pointer-events: none; }

.play { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.play .primary { min-width: 120px; background: var(--green); color: #fff; box-shadow: 3px 3px 0 var(--ink); }
.play input { flex: 1; accent-color: var(--green); }

#working h2 { margin: 0 0 6px; font-size: 1.5rem; }
#working ol { margin: 0; padding: 0; list-style: none; }
#working li { padding: 6px 0; border-bottom: 1px solid var(--line); }
#working li b { display: flex; align-items: center; gap: 6px; }
#working .swatch { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--ink); flex: none; }
#working .sum { font-size: 1.15rem; }
#working .total { margin-top: 12px; padding: 8px 12px; border-radius: 10px; background: #f6f3ee; }
#working .total .sum { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
#working .note { color: #666; font-size: 0.95rem; margin: 10px 0 0; }
.hidden-answer { display: inline-block; min-width: 2.2em; border-bottom: 3px dotted var(--ink); color: transparent; }

@media (max-width: 1100px) {
  main { grid-template-columns: 220px minmax(0, 1fr); }
  #working { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  body { padding: 12px; }
  #shapes { grid-template-columns: repeat(4, 1fr); }
  main { grid-template-columns: minmax(0, 1fr); }
  #view { height: 58vh; }
}
