/* layout for family arcade: board centered and dominant, thin stat rail,
   controls below. every colour comes from tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1,
h2,
p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -64px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--accent-fill);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 8px;
}

/* top bar: wordmark top-left in the display face, one line, icon buttons right */
.topbar {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 8px 16px 4px;
}

.wordmark {
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

/* no web audio: the mute button keeps its place but changes shape (a dashed
   outline around the crossed speaker), never opacity */
.icon-btn[hidden] {
  display: none;
}

.icon-btn.unavailable {
  border: 2px dashed var(--muted);
  color: var(--muted);
  cursor: default;
}

.stage {
  width: 100%;
  max-width: 560px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* spare height goes above the game, not between the controls and the
     footer: the thumb strip sits on the footer, where a thumb rests */
  justify-content: flex-end;
  padding: 0 16px;
  outline: none;
  /* a resting thumb must never select text, magnify, or open a callout */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* the thin stat rail: a small label over each value, along the board's top
   edge (Quizlet's game screen) */
.rail {
  width: min(100%, max(240px, calc((100dvh - 230px) * 0.875)));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
  margin: 0 auto 6px;
}

.stat {
  min-width: 0;
  display: grid;
  gap: 0;
}

.stat:nth-child(n + 3) {
  text-align: right;
}

.stat dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.stat dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* the board: as large as the viewport allows once the top bar, rail, pad and
   footer (about 230px together) are counted, keeping the 224 by 256 shape */
.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 224 / 256;
  margin: 0 auto;
}

.board {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: var(--bg);
  touch-action: none;
}

/* the card over the board: start, pause, and game over */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  overflow-y: auto;
  padding: 12px;
  /* the touch zone around it forbids panning; the card may still scroll */
  touch-action: pan-y;
}

.overlay[hidden] {
  display: none;
}

/* margin: auto centres the card, and unlike place-items it lets a card taller
   than a small board scroll from its top instead of clipping it */
.card {
  width: min(100%, 320px);
  margin: auto;
  display: grid;
  gap: 12px;
  padding: 20px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.card {
  animation: rise 160ms ease-out;
}

@keyframes rise {
  from {
    transform: translateY(6px);
  }
}

.card h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
}

.card p {
  color: var(--muted);
  font-size: 15px;
}

.btn[hidden] {
  display: none;
}

.check {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent-fill);
}

.selects {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  text-align: left;
}

.field {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field select {
  min-width: 0;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
}

.btn {
  min-height: var(--tap);
  padding: 0 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--accent-fill);
  background: var(--accent-fill);
  color: var(--accent-ink);
}

/* thumb controls: the board and the strip under it are one touch surface.
   the strip is where a resting thumb lives; it carries no buttons */
.touch-zone {
  width: min(100%, max(240px, calc((100dvh - 230px) * 0.875)));
  margin: 0 auto;
  touch-action: none;
}

.thumb-strip {
  min-height: 56px;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 8px 0 4px;
}

.thumb-line {
  width: 64px;
  height: 4px;
  border-radius: var(--radius);
  background: var(--line);
}

.thumb-hint {
  color: var(--muted);
  font-size: 12px;
}

.notice {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
}

/* an author display outranks the hidden attribute, so say it again */
.notice[hidden] {
  display: none;
}

.notice-card {
  max-width: 420px;
  display: grid;
  gap: 8px;
  text-align: center;
}

.notice-card h1 {
  font-size: 22px;
}

.notice-card p {
  color: var(--muted);
}

.site-footer {
  padding: 6px 16px 12px;
  font-size: 13px;
}

/* house footer: one link, no hover styling */
.footer-link {
  color: var(--muted);
  text-decoration: none;
}

/* reduced motion: the card appears without moving (the game itself runs in
   slow mode and holds explosions still, see main.js) */
@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
  }
}
