/* ==========================================================================
   Whiteboard games: target number, word drop, code breaker.
   Loaded only on those pages.
   ========================================================================== */
.game-body { gap: 18px; }
.g-label { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.g-msg { font-size: clamp(1.05rem, 2.2vw, 1.5rem); font-weight: 650; color: var(--text-2); min-height: 1.4em; margin: 0; }
.g-msg.win { color: var(--green); }
.g-msg.lose { color: var(--red); }
.g-score { display: flex; gap: 18px; align-items: baseline; font-weight: 650; color: var(--text-2); }
.g-score b { font-size: 1.6rem; color: var(--text); letter-spacing: -0.03em; }
.g-clock { position: relative; width: 64px; height: 64px; display: grid; place-items: center; font-weight: 750; font-size: 1.1rem; }
.g-clock svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.g-clock circle { fill: none; stroke-width: 6; }
.g-clock .trk { stroke: var(--surface-3); }
.g-clock .arc { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.25s linear; }
.g-clock.warn .arc { stroke: var(--amber); }
.g-clock.over .arc { stroke: var(--red); }
.g-clock.over { color: var(--red); }
body.presenting .g-clock { width: clamp(64px, 11vh, 120px); height: clamp(64px, 11vh, 120px); font-size: clamp(1.1rem, 3vh, 2.2rem); }
body.presenting .g-msg { font-size: clamp(1.3rem, 3.4vh, 2.6rem); }

/* Target number */
.tn-target { display: grid; justify-items: center; gap: 4px; }
.tn-target b { font-size: clamp(4rem, 13vw, 8rem); font-weight: 800; letter-spacing: -0.05em; line-height: 1; color: var(--accent); padding: 6px 28px; border-radius: 22px; background: var(--accent-soft); }
.tn-cards { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.tn-card {
  min-width: clamp(70px, 10vw, 110px); padding: 14px 16px; border-radius: 16px; font: inherit; font-weight: 750; font-size: clamp(1.8rem, 4.4vw, 3rem); letter-spacing: -0.03em;
  background: var(--surface); color: var(--text); border: 2px solid var(--border-strong); box-shadow: 0 4px 0 var(--border-strong); cursor: pointer; transition: transform 0.12s, background 0.15s;
}
.tn-card:hover { border-color: var(--accent); }
.tn-card.made { background: color-mix(in srgb, var(--green) 12%, var(--surface)); border-color: color-mix(in srgb, var(--green) 60%, var(--border)); }
.tn-card.sel { background: var(--accent); color: var(--on-accent); border-color: var(--accent); transform: translateY(-4px); }
.tn-card.hit { background: var(--green); color: #fff; border-color: var(--green); animation: land 0.5s var(--ease); }
.tn-ops { display: flex; gap: 10px; }
.tn-op { width: clamp(52px, 7vw, 72px); height: clamp(52px, 7vw, 72px); border-radius: 50%; font: inherit; font-size: clamp(1.6rem, 3.4vw, 2.4rem); font-weight: 800; border: 2px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer; }
.tn-op[aria-pressed='true'] { background: var(--amber); border-color: var(--amber); color: #1b1300; }
.tn-op[disabled] { opacity: 0.35; cursor: default; }
.tn-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; color: var(--text-2); font-weight: 600; font-size: 1rem; }
.tn-solution { font-size: clamp(1rem, 2vw, 1.3rem); background: var(--surface-2); border-radius: 14px; padding: 12px 18px; color: var(--text); font-weight: 600; }
.tn-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; }
body.presenting .tn-target b { font-size: clamp(5rem, 20vh, 14rem); }
body.presenting .tn-card { font-size: clamp(2.2rem, 7vh, 5rem); min-width: clamp(90px, 14vh, 180px); }
body.presenting .tn-op { width: clamp(60px, 10vh, 110px); height: clamp(60px, 10vh, 110px); font-size: clamp(2rem, 5vh, 3.6rem); }
body.presenting .tn-steps, body.presenting .tn-solution { font-size: clamp(1.1rem, 2.6vh, 2rem); }
.num-inputs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.num-inputs input { text-align: center; padding: 8px 2px; font-weight: 650; }

/* Word drop: word card | board | score card */
.wd-wrap { display: grid; grid-template-columns: minmax(150px, 230px) minmax(0, 1fr) minmax(150px, 230px); gap: 20px; align-items: stretch; justify-content: center; width: 100%; }
.wd-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 18px; background: var(--surface-2); text-align: left; min-width: 0; }
.wd-grid {
  --cols: 6; --rows: 6; position: relative; display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 6px;
  width: min(100%, calc((100vh - 330px) * var(--cols) / var(--rows)), 560px); min-width: min(100%, 260px); justify-self: center; touch-action: none; user-select: none; -webkit-user-select: none;
  padding: 8px; border-radius: 18px; background: var(--surface-2); container-type: inline-size; align-self: start;
}
.wd-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
.wd-line polyline { fill: none; stroke: var(--amber); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.75; }
.wd-tile {
  position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px; font-weight: 800; font-size: calc(70cqw / var(--cols)); line-height: 1;
  background: var(--surface); color: var(--text); border: 2px solid var(--border-strong); box-shadow: 0 3px 0 var(--border-strong); cursor: pointer;
  animation: drop 0.35s var(--ease) backwards; text-transform: uppercase;
}
.wd-tile.n { font-size: calc(62cqw / var(--cols)); }
.wd-tile svg { width: 72%; height: 72%; pointer-events: none; }
.wd-tile.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.wd-tile.bad { animation: shake 0.35s; background: color-mix(in srgb, var(--red) 18%, var(--surface)); border-color: var(--red); color: var(--text); }
.wd-tile.good { background: var(--green); border-color: var(--green); color: #fff; }
@keyframes drop { from { transform: translateY(calc(var(--fall, 1) * -110%)); opacity: 0.3; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.wd-word {
  font-size: clamp(1.4rem, 2.6vw, 2.2rem); font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); line-height: 1.15;
  min-height: 2.2em; display: flex; align-items: center; padding: 6px 12px; border-radius: 12px; background: var(--surface); border: 2px dashed var(--border-strong); overflow-wrap: anywhere;
}
.wd-word:empty::before { content: attr(data-empty); font-size: 0.9rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); }
.wd-word.has { border-style: solid; border-color: var(--accent); }
.wd-msg { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.35; color: var(--text-2); min-height: 2.7em; }
.wd-msg.win { color: var(--green); }
.wd-msg.lose { color: var(--red); }
.wd-judge { display: flex; gap: 8px; flex-wrap: wrap; }
.wd-scoreline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wd-scoreline > div:first-child { display: grid; gap: 2px; }
.wd-score { font-size: clamp(2rem, 3.6vw, 3rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; color: var(--text); }
.wd-found { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; max-height: 320px; overflow: auto; }
.wd-found li { font-size: 0.85rem; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-transform: uppercase; }
.wd-found li small { font-weight: 700; color: var(--green); margin-left: 4px; }
.wd-none { margin: 0; font-size: 0.9rem; color: var(--muted); }
.wd-target { display: grid; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.wd-target b { font-size: clamp(2.4rem, 4vw, 3.4rem); color: var(--accent); letter-spacing: -0.04em; line-height: 1; }
.seg-stack { display: grid; grid-template-columns: 1fr; }
.wd-body { container-type: inline-size; }
@container (max-width: 820px) {
  .wd-wrap { grid-template-columns: minmax(0, 1fr) minmax(150px, 220px); }
  .wd-left { grid-column: 2; grid-row: 1; }
  .wd-right { grid-column: 2; grid-row: 2; }
  .wd-grid { grid-column: 1; grid-row: 1 / span 2; }
}
@container (max-width: 520px) {
  .wd-wrap { grid-template-columns: 1fr; }
  .wd-left, .wd-right, .wd-grid { grid-column: 1; grid-row: auto; }
  .wd-grid { width: 100%; min-width: 0; }
  .wd-msg { min-height: 0; }
}
body.presenting .wd-wrap { grid-template-columns: minmax(180px, 22vw) minmax(0, 1fr) minmax(180px, 22vw); }
body.presenting .wd-grid { width: min(calc((100vh - 200px) * var(--cols) / var(--rows)), 52vw); grid-column: auto; grid-row: auto; }
body.presenting .wd-left, body.presenting .wd-right { grid-column: auto; grid-row: auto; }
body.presenting .wd-word { font-size: clamp(1.8rem, 5vh, 3.6rem); }
body.presenting .wd-msg { font-size: clamp(1rem, 2.4vh, 1.6rem); }
body.presenting .wd-score { font-size: clamp(2.4rem, 7vh, 5rem); }
body.presenting .wd-found li { font-size: clamp(0.9rem, 2vh, 1.4rem); }
body.presenting .wd-found { max-height: 48vh; }
body.presenting .wd-target b { font-size: clamp(2.6rem, 8vh, 6rem); }

/* Code breaker */
.cb-board { display: grid; gap: 6px; width: min(100%, 560px); }
.cb-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 14px; background: var(--surface-2); }
.cb-row.current { background: var(--accent-soft); outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.cb-row.empty { opacity: 0.45; }
.cb-n { font-size: 0.85rem; font-weight: 700; color: var(--muted); text-align: center; }
.cb-slots { display: flex; gap: 8px; }
.cb-slot { width: clamp(38px, 6vw, 56px); aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 2px dashed var(--border-strong); padding: 4px; cursor: default; }
.cb-row.current .cb-slot { cursor: pointer; }
.cb-slot.filled { border-style: solid; border-color: var(--border); }
.cb-slot svg { width: 100%; height: 100%; }
.cb-pegs { display: grid; grid-template-columns: repeat(3, 14px); gap: 4px; }
.cb-peg { width: 14px; height: 14px; border-radius: 50%; background: var(--surface-3); }
.cb-peg.hit { background: var(--text); }
.cb-peg.near { background: var(--surface); border: 3px solid var(--text); }
.cb-palette { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.cb-pick { width: clamp(52px, 8vw, 76px); aspect-ratio: 1; border-radius: 16px; display: grid; place-items: center; padding: 6px; background: var(--surface); border: 2px solid var(--border-strong); box-shadow: 0 3px 0 var(--border-strong); cursor: pointer; }
.cb-pick:hover { border-color: var(--accent); }
.cb-pick svg { width: 100%; height: 100%; }
.cb-key { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; font-size: 0.88rem; color: var(--muted); font-weight: 550; }
.cb-key span { display: inline-flex; gap: 6px; align-items: center; }
.cb-secret { display: flex; gap: 8px; justify-content: center; }
.cb-secret .cb-slot { border-style: solid; }
.cb-secret .q { font-size: 1.6rem; font-weight: 800; color: var(--muted); }
.cb-setter { display: flex; gap: 6px; flex-wrap: wrap; }
.cb-setter .cb-slot { width: 44px; cursor: pointer; border-style: solid; }
.cb-setter-pal { display: flex; gap: 6px; flex-wrap: wrap; }
.cb-setter-pal button { width: 38px; height: 38px; padding: 3px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }
.cb-setter-pal button svg, .cb-setter .cb-slot svg { width: 100%; height: 100%; }
body.presenting .cb-board { width: min(90vw, 760px); gap: 0.8vh; }
body.presenting .cb-slot { width: clamp(38px, 6.2vh, 76px); }
body.presenting .cb-row { padding: 0.5vh 12px; }
body.presenting .cb-pick { width: clamp(56px, 9vh, 100px); }
body.presenting .cb-peg { width: clamp(14px, 1.8vh, 22px); height: clamp(14px, 1.8vh, 22px); }
body.presenting .cb-pegs { grid-template-columns: repeat(3, clamp(14px, 1.8vh, 22px)); }
.game-tools .btn { white-space: nowrap; }

/* Code breaker layout: board on the left, shapes and clues on the right */
.cb-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 22px; align-items: start; width: 100%; max-width: 860px; }
.cb-wrap .cb-board { width: 100%; }
.cb-side { display: grid; gap: 10px; justify-items: start; text-align: left; position: sticky; top: 12px; }
.cb-side .cb-secret, .cb-side .cb-palette, .cb-side .cb-key { justify-content: flex-start; }
.cb-side .cb-key { flex-direction: column; gap: 6px; }
.cb-row { padding: 4px 10px; }
.cb-slot { width: clamp(34px, 4.6vw, 48px); border-radius: 10px; }
.cb-pick { width: clamp(48px, 5.6vw, 64px); }
@media (max-width: 760px) {
  .cb-wrap { grid-template-columns: 1fr; }
  .cb-side { position: static; order: -1; justify-items: center; text-align: center; }
  .cb-side .cb-secret, .cb-side .cb-palette { justify-content: center; }
}
body.presenting .cb-wrap { max-width: 94vw; grid-template-columns: minmax(0, 1fr) minmax(260px, 34vw); }
body.presenting .cb-board { width: 100%; gap: 0.6vh; }
body.presenting .cb-slot { width: clamp(34px, calc((100vh - 260px) / var(--cb-rows, 10) - 12px), 76px); }
body.presenting .cb-pick { width: clamp(56px, 8vh, 96px); }
body.presenting .cb-side .cb-secret .cb-slot { width: clamp(48px, 8vh, 90px); }
.cb-secret .q { font-size: 1.2rem; }

/* Frog code */
.fc-level { width: auto; max-width: 260px; height: 36px; padding: 0 30px 0 10px; font-weight: 650; }
.fc-body { container-type: inline-size; }
.fc-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 330px); gap: 20px; align-items: start; width: 100%; }
.fc-board-wrap { display: grid; gap: 10px; justify-items: center; min-width: 0; }
.fc-board {
  --w: 6; --h: 4; position: relative; display: grid; grid-template-columns: repeat(var(--w), 1fr); gap: 3px; padding: 6px; border-radius: 16px;
  width: min(100%, calc((100vh - 300px) * var(--w) / var(--h)), 720px); background: #2f8a50; box-shadow: inset 0 0 0 3px #26733f; user-select: none; -webkit-user-select: none;
}
.fc-cell { position: relative; aspect-ratio: 1; border-radius: 6px; background: #5cc27a; display: grid; place-items: center; }
.fc-cell:nth-child(odd) { background: #55b973; }
.fc-cell svg { width: 86%; height: 86%; image-rendering: pixelated; }
.fc-cell.goal { background: #3d9ad1; }
.fc-cell.goal:nth-child(odd) { background: #3994ca; }
.fc-cell.trail::after { content: ''; position: absolute; width: 18%; height: 18%; border-radius: 50%; background: rgba(255, 255, 255, 0.65); }
.fc-cell.crash { background: #f27c7f !important; animation: shake 0.4s; }
.fc-board.editing .fc-cell { cursor: pointer; }
.fc-board.editing .fc-cell:hover { outline: 3px solid #ffd43b; outline-offset: -3px; }
.fc-frog {
  --cw: calc((100% - 12px - (var(--w) - 1) * 3px) / var(--w)); --ch: calc((100% - 12px - (var(--h) - 1) * 3px) / var(--h));
  position: absolute; z-index: 3; pointer-events: none; width: var(--cw); height: var(--ch);
  left: calc(6px + var(--fx, 0) * (var(--cw) + 3px)); top: calc(6px + var(--fy, 0) * (var(--ch) + 3px));
  transition: left var(--sp, 0.4s) ease-in-out, top var(--sp, 0.4s) ease-in-out;
}
.fc-frog .fc-frog-in { position: absolute; inset: 3%; transition: transform var(--sp, 0.4s) ease-in-out; }
.fc-frog svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.25)); }
.fc-frog.hop .fc-frog-in svg { animation: hop var(--sp, 0.4s) ease-in-out; }
.fc-frog.bump .fc-frog-in svg { animation: bump 0.4s; }
.fc-frog.win .fc-frog-in svg { animation: win 0.6s ease-in-out 2; }
@keyframes hop { 50% { transform: scale(1.25) translateY(-8%); } }
@keyframes bump { 30% { transform: scale(0.85); } 60% { transform: scale(1.05) rotate(8deg); } }
@keyframes win { 50% { transform: translateY(-22%) scale(1.15); } }
.fc-msg { margin: 0; min-height: 1.5em; font-size: clamp(1.05rem, 2vw, 1.4rem); font-weight: 700; color: var(--text-2); text-align: center; }
.fc-msg.win { color: var(--green); }
.fc-msg.lose { color: var(--red); }
.fc-side { display: grid; gap: 10px; padding: 16px; border-radius: 18px; background: var(--surface-2); align-content: start; }
.fc-code-head { display: flex; justify-content: space-between; align-items: baseline; }
.fc-count { font-size: 0.85rem; color: var(--muted); font-weight: 650; }
.fc-code { list-style: none; margin: 0; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; min-height: 64px; max-height: 260px; overflow: auto; border-radius: 12px; background: var(--surface); border: 2px dashed var(--border-strong); align-content: flex-start; counter-reset: step; }
.fc-code:empty::before { content: 'Tap the arrows below to add steps.'; color: var(--muted); font-size: 0.9rem; font-weight: 550; padding: 10px 4px; }
.fc-step {
  position: relative; counter-increment: step; width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; cursor: pointer;
  background: var(--accent-soft); color: var(--accent-text); border: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); font: inherit; padding: 0;
}
.fc-step svg { width: 26px; height: 26px; }
.fc-step::before { content: counter(step); position: absolute; top: -7px; left: -6px; font-size: 0.62rem; font-weight: 750; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 99px; background: var(--surface); color: var(--muted); border: 1px solid var(--border); display: grid; place-items: center; }
.fc-step .x { position: absolute; bottom: -6px; right: -6px; font-size: 0.7rem; font-weight: 800; padding: 1px 5px; border-radius: 99px; background: var(--amber); color: #1b1300; }
.fc-step.now { background: var(--amber); color: #1b1300; border-color: var(--amber); transform: scale(1.1); }
.fc-step.done { opacity: 0.55; }
.fc-step.bad { background: var(--red); color: #fff; border-color: var(--red); }
.fc-cmds { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.fc-cmds.arrows { display: grid; grid-template-columns: repeat(3, 64px); grid-template-areas: '. up .' 'left down right'; justify-content: center; }
.fc-cmd { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; cursor: pointer; font: inherit; padding: 0; background: var(--surface); color: var(--text); border: 2px solid var(--border-strong); box-shadow: 0 4px 0 var(--border-strong); }
.fc-cmd svg { width: 34px; height: 34px; }
.fc-cmd:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--border-strong); }
.fc-cmd:hover { border-color: var(--accent); }
.fc-cmd[data-cmd='up'] { grid-area: up; }
.fc-cmd[data-cmd='down'] { grid-area: down; }
.fc-cmd[data-cmd='left'] { grid-area: left; }
.fc-cmd[data-cmd='right'] { grid-area: right; }
.fc-cmds.turns .fc-cmd { width: auto; padding: 0 14px; gap: 6px; grid-auto-flow: column; font-weight: 700; font-size: 0.95rem; }
.fc-run-row { display: flex; gap: 8px; flex-wrap: wrap; }
.fc-run-row .btn { flex: 1 1 auto; justify-content: center; }
.fc-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fc-tools button { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px 0 6px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: var(--text); }
.fc-tools button svg { width: 26px; height: 26px; }
.fc-tools button[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.fc-size { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.fc-size label { display: grid; gap: 4px; }
.fc-size input { width: 44px; text-align: center; border: 0; padding: 0; }
.fc-confetti { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; border-radius: 16px; }
.fc-confetti i { position: absolute; top: -10px; width: 8px; height: 12px; border-radius: 2px; animation: fall 1.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(110cqh) rotate(540deg); opacity: 0.6; } }
@container (max-width: 640px) {
  .fc-wrap { grid-template-columns: 1fr; }
  .fc-board { width: 100%; }
}
body.presenting .fc-wrap { grid-template-columns: minmax(0, 1fr) minmax(280px, 30vw); }
body.presenting .fc-board { width: min(calc((100vh - 190px) * var(--w) / var(--h)), 100%); }
body.presenting .fc-cmd { width: clamp(64px, 9vh, 96px); height: clamp(64px, 9vh, 96px); }
body.presenting .fc-cmds.arrows { grid-template-columns: repeat(3, clamp(64px, 9vh, 96px)); }
body.presenting .fc-cmds.turns .fc-cmd { width: auto; font-size: 1.15rem; }
body.presenting .fc-step { width: clamp(46px, 6vh, 64px); height: clamp(46px, 6vh, 64px); }
body.presenting .fc-code { max-height: 34vh; }
body.presenting .fc-msg { font-size: clamp(1.2rem, 3vh, 2.2rem); }
.fc-fly { position: absolute; inset: 14%; display: grid; place-items: center; pointer-events: none; z-index: 1; }
.fc-fly:empty { display: none; }
.fc-fly svg { width: 100%; height: 100%; }
