/* Boggle (public/arcade/boggle.js). Arcade tokens come from arcade.css; everything is scoped to its stage.
   The tray is the bold thing: the cabinets' indigo with their hard darker side, sixteen cool-white dice with ink letters in
   Jersey 10. A traced die goes black with your colour; a white thread joins them under the letters. A pixel sand timer. */
.ag-stage[data-kind="boggle"] .bog {
  --felt: #3340a0; --side: #222b73; --die: #f6f7ff; --lip: #9ea3c6; --ink: #12142e; --pink: #b3bcff; --mute: #9ea3c6;
  --t: min(calc(100cqw - 36px), calc(100cqh - 250px), 460px);
  position: absolute; inset: 0; display: flex; flex-direction: column; color: var(--die);
  font-family: var(--ac-pixel, "Jersey 10"); container: bog / size;
}
.ag-stage[data-kind="boggle"] .bog [hidden] { display: none !important; }
.ag-stage[data-kind="boggle"] .bog p, .ag-stage[data-kind="boggle"] .bog h3 { margin: 0; }

/* ---------- top row: the sand timer (solo: words to find); the scores are on the bar beside Back ---------- */
.ag-stage[data-kind="boggle"] .bog-hud { grid-area: hud; flex: none; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 10px 14px 0; }
.ag-stage[data-kind="boggle"] .bog-clock { display: flex; align-items: center; gap: 8px; }
.ag-stage[data-kind="boggle"] .bog-hg svg { display: block; width: 18px; height: 30px; }
.ag-stage[data-kind="boggle"] .bog-hgf { fill: var(--lip); }
.ag-stage[data-kind="boggle"] .bog-hgs { fill: var(--die); }
.ag-stage[data-kind="boggle"] .bog-time { font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.ag-stage[data-kind="boggle"] .bog-clock.low .bog-time { color: #7c8cff; animation: bog-blink 1s steps(1) infinite; }
.ag-stage[data-kind="boggle"] .bog-clock.low .bog-hgs { fill: #7c8cff; }
@keyframes bog-blink { 50% { opacity: .35; } }
@keyframes bog-pop { from { transform: scale(1.5); color: #7c8cff; } }
.ag-stage[data-kind="boggle"] .bog-them { justify-self: end; display: flex; align-items: center; gap: 6px; font-size: 22px; line-height: 1; text-align: right; }
.ag-stage[data-kind="boggle"] .bog-total { color: var(--mute); font-size: 20px; }

/* ---------- the word being traced, or how the last one went ---------- */
.ag-stage[data-kind="boggle"] .bog-word { grid-area: word; flex: none; height: 70px; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 0 12px; overflow: hidden; white-space: nowrap; }
.ag-stage[data-kind="boggle"] .bog-w { font-size: min(48px, calc(100cqw / 11)); line-height: 1; letter-spacing: .08em; }
.ag-stage[data-kind="boggle"] .bog-msg { font-size: 26px; line-height: 1; color: #7c8cff; }
.ag-stage[data-kind="boggle"] .bog-word.tracing .bog-msg { font: 400 14px/1.2 var(--font); color: var(--mute); white-space: normal; max-width: 9em; }
.ag-stage[data-kind="boggle"] .bog-word.off .bog-w, .ag-stage[data-kind="boggle"] .bog-word.bad .bog-w { color: var(--pink); }
.ag-stage[data-kind="boggle"] .bog-word.bad .bog-msg, .ag-stage[data-kind="boggle"] .bog-word.dup .bog-msg { font: 400 15px/1.2 var(--font); color: var(--pink); }
.ag-stage[data-kind="boggle"] .bog-word.dup .bog-w, .ag-stage[data-kind="boggle"] .bog-word.wait .bog-w { opacity: .55; }
.ag-stage[data-kind="boggle"] .bog-word.ok .bog-msg { font-size: 40px; color: var(--die); text-shadow: 0 0 6px #7c8cff, 0 0 18px #4a5ad6; animation: bog-pop .4s steps(3, end); }

/* ---------- the tray ---------- */
.ag-stage[data-kind="boggle"] .bog-trayw { grid-area: tray; flex: none; display: flex; justify-content: center; padding: 0 0 8px; }
.ag-stage[data-kind="boggle"] .bog-tray { position: relative; width: var(--t); height: var(--t); margin-right: 6px; border-radius: 14px; background: var(--felt);
  box-shadow: 6px 6px 0 var(--side); touch-action: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ag-stage[data-kind="boggle"] .bog-dice, .ag-stage[data-kind="boggle"] .bog-lets, .ag-stage[data-kind="boggle"] .bog-line {
  position: absolute; inset: 3.5%; width: 93%; height: 93%; display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); pointer-events: none; }
.ag-stage[data-kind="boggle"] .bog-die { margin: 7%; border-radius: 18%; background: var(--die); box-shadow: inset 0 calc(var(--t) * -.014) 0 var(--lip); }
.ag-stage[data-kind="boggle"] .bog-die.on { background: #000; box-shadow: inset 0 0 0 3px var(--pc); }
.ag-stage[data-kind="boggle"] .bog-line { overflow: visible; }
.ag-stage[data-kind="boggle"] .bog-line polyline { fill: none; stroke: var(--pink); stroke-width: .14; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.ag-stage[data-kind="boggle"] .bog-l { display: grid; place-items: center; padding-bottom: 4%; font-weight: 400; font-size: calc(var(--t) * .15); line-height: 1; color: var(--ink); }
.ag-stage[data-kind="boggle"] .bog-l.qu { font-size: calc(var(--t) * .11); }
.ag-stage[data-kind="boggle"] .bog-l.on { color: var(--pc); -webkit-text-stroke: 6px #000; paint-order: stroke fill; }
/* the dice roll in when the countdown ends */
.ag-stage[data-kind="boggle"] .bog-tray.roll .bog-die, .ag-stage[data-kind="boggle"] .bog-tray.roll .bog-l {
  animation: bog-roll .5s steps(5, end) both; animation-delay: calc(var(--d) * 24ms); }
@keyframes bog-roll { from { transform: rotate(-180deg) scale(.4); opacity: 0; } 40% { opacity: 1; } }
.ag-stage[data-kind="boggle"] .bog-tray.shake { animation: bog-shake .3s steps(4); }
@keyframes bog-shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

/* ---------- your words so far ---------- */
.ag-stage[data-kind="boggle"] .bog-found { grid-area: found; flex: 1; min-height: 0; overflow: auto; padding: 8px 18px 12px; -webkit-overflow-scrolling: touch; }
.ag-stage[data-kind="boggle"] .bog-fh { font: 400 14px/1.35 var(--font); color: var(--mute); text-align: center; }
.ag-stage[data-kind="boggle"] .bog-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; margin-top: 6px; }
.ag-stage[data-kind="boggle"] .bog-fw { font-size: 24px; line-height: 1.1; }
.ag-stage[data-kind="boggle"] .bog sub { margin-left: 2px; font-size: .55em; vertical-align: baseline; color: var(--mute); }

/* ---------- time's up: both lists, then what nobody found (the result card covers the bottom, so this scrolls clear of it) ---------- */
.ag-stage[data-kind="boggle"] .is-over .bog-word, .ag-stage[data-kind="boggle"] .is-over .bog-trayw, .ag-stage[data-kind="boggle"] .is-over .bog-found { display: none; }
.ag-stage[data-kind="boggle"] .bog-res { grid-area: res; flex: 1; min-height: 0; overflow: auto; padding: 14px 16px 360px; -webkit-overflow-scrolling: touch; }
.ag-stage[data-kind="boggle"] .bog-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ag-stage[data-kind="boggle"] .bog-cols.one { grid-template-columns: 1fr; }
.ag-stage[data-kind="boggle"] .bog-col h3, .ag-stage[data-kind="boggle"] .bog-missed h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding-bottom: 4px; margin-bottom: 6px; border-bottom: 2px solid var(--ac-line, #262a52); font-weight: 400; font-size: 26px; line-height: 1; }
.ag-stage[data-kind="boggle"] .bog-col h3 span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-stage[data-kind="boggle"] .bog-col.mine h3 span { color: #7c8cff; }
.ag-stage[data-kind="boggle"] .bog-col h3 b { font-weight: 400; font-size: 34px; }
.ag-stage[data-kind="boggle"] .bog-cl { font-size: 22px; line-height: 1.25; word-spacing: .3em; }
.ag-stage[data-kind="boggle"] .bog-cl s { color: var(--pink); text-decoration-thickness: 2px; }
.ag-stage[data-kind="boggle"] .bog-cl i { font: italic 400 15px/1.3 var(--font); color: var(--mute); }
.ag-stage[data-kind="boggle"] .bog-note { margin-top: 10px !important; font: 400 14px/1.35 var(--font); color: var(--mute); }
.ag-stage[data-kind="boggle"] .bog-missed { margin-top: 18px; }
.ag-stage[data-kind="boggle"] .bog-missed h3 span { font: 400 13px/1.2 var(--font); color: var(--mute); }
.ag-stage[data-kind="boggle"] .bog-missed .bog-cl { color: var(--mute); }

/* short screens: a smaller word line */
@container bog (max-height: 600px) {
  .ag-stage[data-kind="boggle"] .bog { --t: min(calc(100cqw - 36px), calc(100cqh - 190px), 460px); }
  .ag-stage[data-kind="boggle"] .bog-word { height: 52px; }
}
/* landscape: the tray on the left, everything else beside it */
@container bog (min-aspect-ratio: 5/4) {
  .ag-stage[data-kind="boggle"] .bog { --t: min(calc(100cqh - 30px), 52cqw, 460px); display: grid; grid-template-columns: auto 1fr;
    grid-template-rows: auto auto 1fr; grid-template-areas: "tray hud" "tray word" "tray found"; column-gap: 8px; }
  .ag-stage[data-kind="boggle"] .bog-trayw { align-items: center; padding: 0 0 6px 14px; }
  .ag-stage[data-kind="boggle"] .is-over { grid-template-columns: 1fr; grid-template-areas: "hud" "res"; grid-template-rows: auto 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .ag-stage[data-kind="boggle"] .bog-tray.roll .bog-die, .ag-stage[data-kind="boggle"] .bog-tray.roll .bog-l, .ag-stage[data-kind="boggle"] .bog-tray.shake,
  .ag-stage[data-kind="boggle"] .bog-clock.low .bog-time, .ag-stage[data-kind="boggle"] .bog-word.ok .bog-msg { animation: none; }
}
