.play { padding-top: 12px; }
.back { display: inline-flex; align-items: center; min-height: 44px; font-size: 0.9375rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.hud { position: relative; min-height: 64px; margin: 0 0 8px; }
.hud p { margin: 0; }
.hud-row { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; font-size: 1.0625rem; }
.hud-caught { color: var(--muted); font-size: 0.9375rem; }

.seats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #cdbf9d url('/px/classroom.webp') center / cover;
}
.seat {
  position: relative;
  aspect-ratio: 1;
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.55);
  cursor: pointer;
  display: grid;
  place-items: center;
  font: inherit;
  color: var(--ink);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.seat:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.seat:active { background: rgba(255, 250, 240, 0.85); }
.seat-art { display: grid; width: 100%; height: 100%; animation: bob 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * -0.3s); }
/* Both poses are stacked in one cell. The idle image is always opaque underneath; only the
   action image on top fades in and out (0.25 s), so combined alpha never dips. */
.seat-img { grid-area: 1 / 1; width: 100%; height: 100%; object-fit: contain; }
.seat-img-1 { opacity: 0; transition: opacity 250ms ease; }
.seat-img-1.is-on { opacity: 1; }
.seat-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 4px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: pre-line;
  background: var(--paper);
  border-radius: 6px;
}
.stamp {
  display: none;
  position: absolute;
  inset: auto 4px 4px auto;
  padding: 0 6px;
  border: 2px solid #b3261e;
  border-radius: 4px;
  color: #b3261e;
  background: rgba(255, 250, 240, 0.9);
  font-weight: 800;
  font-size: 0.8125rem;
  transform: rotate(-8deg);
}
.seat[data-caught] .stamp-caught { display: block; }
.seat[data-caught] { border-color: #b3261e; }
.seat[data-caught] .seat-art, .seat[data-caught] .seat-fallback { filter: grayscale(1); opacity: 0.55; }
/* A caught seat never shows the action pose: hidden at once, no fade. */
.seat[data-caught] .seat-img-1 { opacity: 0; transition: none; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .seat-art { animation: none; } .seat-img { transition: none; } }

/* Compact tap feedback over the HUD box only (inset: 0 inside .hud), never over the seats. */
.toast {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  max-height: 72px;
  padding: 6px 12px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  font-weight: 800;
  font-size: 0.9375rem;
  line-height: 1.35;
  word-break: keep-all;
}
.toast[hidden] { display: none; }

.end-label { margin: 0 0 4px; color: var(--muted); font-size: 0.875rem; }
.end-title { font-size: 1.75rem; line-height: 1.25; outline: none; }
.end-numbers { font-size: 1.125rem; font-weight: 700; margin: 0 0 4px; }
.end-time, .end-hint { margin: 0 0 6px; color: var(--muted); }
.end-actions { display: grid; gap: 8px; margin-top: 12px; }
.end-actions .btn { margin-top: 0; width: 100%; min-height: 44px; text-align: center; }
.end-status { min-height: 1.5em; margin: 8px 0 0; font-weight: 700; }
.end-link { width: 100%; min-height: 44px; margin-top: 4px; padding: 0 8px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--paper); color: var(--ink); font: inherit; }

.end-basis { color: var(--muted); font-size: 0.875rem; }
.end-dex { display: inline-flex; align-items: center; min-height: 44px; }

/* Remaining-time bar: width and colour are set per frame by scene.js (scaleX + hsl hue). */
.timebar { height: 12px; margin: 0 0 8px; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); }
.timebar-fill { display: block; width: 100%; height: 100%; transform-origin: left center; background: hsl(120 72% 42%); }
.timebar[data-low] { animation: timebar-pulse 0.8s ease-in-out infinite; }
@keyframes timebar-pulse { 50% { box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.35); } }
@media (prefers-reduced-motion: reduce) { .timebar[data-low] { animation: none; } }

/* Result grid: the play grid's look, each seat labelled with its outcome. */
.rgrid { margin: 10px 0 4px; }
.rseat { padding: 2px; overflow: hidden; border-width: 3px; }
.rseat > * { grid-area: 1 / 1; }
.rseat-img { width: 100%; height: 100%; object-fit: contain; }
.rseat-badge { align-self: start; justify-self: start; margin: 2px; }
.rseat-name {
  align-self: end;
  justify-self: stretch;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 2px 4px;
  border-radius: 0 0 5px 5px;
  background: rgba(32, 28, 24, 0.75);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  word-break: keep-all;
}
.rseat.is-caught { border-color: #2e7d32; }
.rseat.is-missed { border-color: #b3261e; }
.rseat.is-wrong { border-color: #b26a00; }
.badge { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 0.8125rem; font-weight: 800; color: #fff; }
.badge-ok { background: #2e7d32; }
.badge-miss { background: #b3261e; }
.badge-wrong { background: #b26a00; }
.badge-calm { background: #5f5a52; }
.end-actions { grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
.end-actions .btn { padding-left: 4px; padding-right: 4px; white-space: nowrap; }
.end-goal { margin-top: 4px; }
.end-note { font-weight: 700; color: #b26a00; }

/* Seat explanation dialog. */
.detail {
  width: min(92vw, 480px);
  max-height: 85vh;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}
.detail::backdrop { background: rgba(0, 0, 0, 0.45); }
.detail p { margin: 0 0 8px; }
.detail-head { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: center; margin-bottom: 10px; }
.detail-img { width: 72px; height: 72px; object-fit: contain; border-radius: 6px; background: #efe6d2; }
.detail-title { margin: 0 0 4px; font-size: 1.0625rem; line-height: 1.3; word-break: keep-all; }
.detail-tags { margin: 0; }
.detail-fact strong { display: block; font-size: 0.8125rem; color: var(--muted); }
.detail-close { width: 100%; min-height: 44px; margin-top: 4px; }
