@font-face {
  font-family: Andika;
  src: url("./andika-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

body.is-playing #main {
  max-width: none;
  width: 100%;
  padding: 6px;
}

body.is-playing #table-scene {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 7px;
  width: min(100%, 1440px);
  max-width: none;
  height: calc(100vh - 12px);
  height: calc(100dvh - 12px);
  min-height: 310px;
  padding: 8px;
  background: #376558;
  border: 2px solid #285445;
  border-radius: 17px;
  box-shadow: inset 0 0 0 2px #8aad8b;
  overflow: visible;
}
body.is-playing #table-top {
  display: grid;
  grid-template-columns: auto minmax(245px, 1fr) auto;
  grid-template-areas: "heading scores tools" "feedback feedback pace";
  align-items: center;
  gap: 4px 9px;
  width: 100%;
  margin: 0;
  padding: 6px 8px;
  inset: auto;
  background: #fffdf1;
}

#table-top .table-heading,
#table-top .play-heading {
  display: block;
  grid-area: heading;
  margin: 0;
  min-width: 0;
}
#table-top #round-title {
  margin: 0;
  font-size: clamp(15px, 1.7vw, 23px);
  line-height: 1.15;
  white-space: normal;
}
#table-top #level-label,
#table-top .target-chip,
#table-top #game-navigation > a,
#table-top .table-home,
#table-top .turn-marker,
#table-top .pace-controls > span,
#table-top .round-dots,
#table-top .score-player small {
  display: none;
}
#table-top #table-utility, #table-top .table-navigation, #table-top #game-navigation {
  display: contents;
}
#table-top #sound { grid-area: sound; }
#table-top #game-fullscreen { grid-area: fullscreen; }
body.is-playing #table-top {
  grid-template-columns: auto minmax(230px,1fr) auto auto auto;
  grid-template-areas: "heading scores tools sound fullscreen" "feedback feedback feedback pace pace";
}
#table-top .play-tools {
  display: flex;
  grid-area: tools;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
}
#table-top .play-heading .play-tools { display: none; }
body.is-playing #table-top button {
  min-height: 44px;
  min-width: 44px;
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1.12;
  white-space: normal;
}
body.is-playing #table-top .game-fullscreen-button {
  min-height: 44px;
}
body.is-playing #table-top .scoreboard {
  grid-area: scores;
  grid-template-columns: minmax(0,1fr) 57px minmax(0,1fr);
  width: 100%;
  max-width: none;
  margin: 0;
  gap: 4px;
}
body.is-playing #table-top .score-player {
  gap: 4px;
  padding: 2px 5px;
  height: 57px;
  min-height: 0;
  border-radius: 10px;
}
body.is-playing #table-top .score-player img { width: 38px; height: 43px; }
body.is-playing #table-top #opponent-portrait { width: 55px; height: 54px; }
#table-top .score-player > div { gap: 0; }
body.is-playing #table-top .score-player div > span {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: clamp(12px, 1.3vw, 16px);
  line-height: 1.2;
}
body.is-playing #table-top .score-player b { font-size: 22px; }
#table-top .prize-pot { gap: 0; padding: 3px; min-height: 0; }
#table-top .prize-pot > b { font-size: 17px; line-height: 1.1; }
#table-top .prize-pot > :is(small, span:last-of-type) { font-size: 9px; letter-spacing: 0; }
#table-top .prize-pot > .pot-icon,
.sight-review #table-top .prize-pot > span { font-size: 16px; }
#table-top #monkey-expression {
  position: absolute;
  top: -3px;
  left: 2px;
  right: auto;
  font-size: 15px;
  line-height: 1;
}
#table-top .pair-pile, #table-top .collected-pile {
  position: absolute;
  inset: auto 2px 2px auto;
  width: 13px;
  margin: 0;
  font-size: 11px;
}
body.is-playing #table-top .turn-banner {
  grid-area: feedback;
  gap: 5px;
  height: auto;
  min-height: 33px;
  margin: 0;
  padding: 3px 7px;
  border-radius: 6px;
  background: #f0f3e7;
}
#table-top #feedback, #table-top #pairs-left {
  font-size: 15px;
  line-height: 1.22;
}
#table-top #pairs-left { display: inline; }
#table-top .pace-controls {
  grid-area: pace;
  margin: 0;
  min-height: 0;
  gap: 4px;
  justify-content: end;
}
#table-top #match-assist {
  grid-column: 1 / -1;
  margin: 0;
  color: #204638;
  font-size: 13px;
}
#board-stage {
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  justify-items: center;
  align-items: center;
  min-width: 0;
  min-height: 0;
  padding: 5px;
  row-gap: 4px;
  border-radius: 12px;
  background: radial-gradient(ellipse,#3d7563cc,#244e40dd),
    repeating-linear-gradient(45deg,#4d846d 0 1px,#35705d 1px 3px);
  box-shadow: inset 0 2px 8px #15382a9c;
}
#board-stage > #board { grid-row: 2; }
body.is-playing #board {
  width: max-content;
  max-width: 100%;
  margin: 0;
  grid-template-columns: repeat(var(--cols), var(--card-width));
  grid-auto-rows: var(--card-height);
  gap: var(--board-gap);
}
body.is-playing #board .picture-card,
body.is-playing #board .collected-slot {
  width: var(--card-width);
  height: var(--card-height);
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
}
#board .picture-card {
  border-radius: 9px;
  box-shadow: 0 3px 5px #1233299e;
}
#board .picture-card:focus-visible {
  outline: 3px solid #ffdd71;
  outline-offset: 1px;
}
#board .card-back img { max-width: 54%; max-height: 58%; }
#board .card-back span { font-size: clamp(8px, calc(var(--card-width) * .105), 13px); }
.sight-review #board .word-face, .sight-review .flying-card .word-face {
  font: 700 clamp(13px, calc(var(--card-width, 100px) * .29), 48px)/1.1 Andika, "Century Gothic", sans-serif;
  letter-spacing: .025em;
  max-width: none;
  white-space: nowrap;
}
.sight-review #board .word-face.long { font-size: clamp(11px, calc(var(--card-width) * .24), 38px); }
.sight-review #board .speaker-replay { font-size: clamp(8px, calc(var(--card-width) * .125), 15px); }
.sight-review #board .speaker-icon { max-height: 65%; }
#board-stage #math-boost {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 2px 6px;
}
#math-boost p { margin: 0; font-size: 14px; }
#math-boost .boost-answers { margin: 0; }
#table-scene #compact-scores {
  grid-row: 3;
  margin: 0;
}
#table-scene #compact-scores > summary { color: #fffdf1 !important; }
#table-scene #compact-scores[open] {
  position: absolute;
  z-index: 14;
  bottom: 5px;
  max-height: 75%;
  overflow: auto;
}
#table-scene #compact-scores[open] > summary { color: #315a46 !important; }
#table-scene .sr-only { position: absolute; }

@media (max-width: 850px) {
  body.is-playing #table-top {
    grid-template-columns: 1fr auto auto;
    grid-template-areas: "heading sound fullscreen" "scores scores scores" "tools tools pace" "feedback feedback feedback";
  }
  body.is-playing #table-top button { padding-inline: 5px; }
  #table-top .play-tools { justify-content: start; }
}
@media (orientation: landscape) and (max-height: 540px) {
  body.is-playing #table-scene {
    grid-template-columns: clamp(158px, 25vw, 220px) minmax(0,1fr);
    grid-template-rows: minmax(0,1fr);
  }
  body.is-playing #table-top {
    grid-template-columns: minmax(0,1fr) auto;
    grid-template-areas: "heading heading" "scores scores" "tools tools" "sound fullscreen" "feedback feedback" "pace pace";
    grid-auto-rows: min-content;
    align-content: start;
    gap: 3px;
    padding: 4px;
    overflow-y: auto;
  }
  #table-top .pace-controls { justify-content: start; }
  body.is-playing #table-top .scoreboard { grid-template-columns: minmax(0,1fr) 40px minmax(0,1fr); }
  body.is-playing #table-top .score-player { height: 63px; }
  #table-top .score-player { flex-direction: column; justify-content: center; gap: 1px; }
  body.is-playing #table-top .score-player img,
  body.is-playing #table-top #opponent-portrait { width: 32px; height: 34px; }
  #table-top .score-player > div > span { display: none; }
  #table-top #pairs-left { font-size: 12px; }
  #table-top #feedback { font-size: 13px; }
  #table-scene #compact-scores { display: none; }
}

#table-top #paps-updates-open { display: none; }
#board-stage { grid-row: 2; }
#table-top #opponent-portrait { transition: transform 180ms ease; }
#table-top [data-mood="happy"] #opponent-portrait { transform: rotate(-4deg) scale(1.04); }
#table-top [data-mood="oops"] #opponent-portrait { transform: rotate(7deg); }
#table-top [data-mood="cheering"] #opponent-portrait { transform: translateY(-2px) rotate(-7deg) scale(1.09); }
#comeback-offer {
  padding: 7px 12px;
  border: 1px solid #b7c8a4;
  border-radius: 11px;
  background: #e8efdc;
}
.reading-mode { display: grid; justify-items: start; gap: 4px; margin-top: 12px; }
#reading-mode {
  min-height: 44px;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid #6a8b71;
  border-radius: 8px;
  background: #fffdf1;
  color: #234d3f;
  font: inherit;
}

@media (orientation: landscape) and (max-height: 540px) {
  #board-stage { grid-column: 2; grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #table-top #opponent-portrait { transition: none; transform: none !important; }
}
.reduce-motion #table-top #opponent-portrait { transition: none; transform: none !important; }

body.is-playing #plh-help-button { display: none !important; }
body.is-playing #table-utility,
body.is-playing #table-top #game-navigation { display: contents !important; }
body.is-playing #table-top .table-home {
  display: inline-flex;
  min-height: 44px;
  padding-inline: 6px;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
body.is-playing #table-top #game-navigation > a { display: none !important; }
body.is-playing #table-top .play-tools { width: auto; justify-content: start; }
body.is-playing #table-top #pairs-left { margin-left: auto; flex: 0 0 auto; }
body.is-playing #table-top .scoreboard { min-width: 0; }
#board-stage #math-boost { min-height: 0; }
#board-stage #math-boost .boost-answers button {
  min-width: 44px;
  min-height: 44px;
  margin: 0;
}
body.is-playing #board .card-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
body.is-playing #board .card-back span {
  font-size: clamp(8px, calc(var(--card-width) * .103), 13px);
  line-height: 1.05;
  text-align: center;
}
body.is-playing #board .card-back img { max-width: 51%; max-height: 55%; }
body.is-playing #table-scene #compact-scores > summary {
  min-height: 44px;
  padding: 10px 4px;
  cursor: pointer;
}
body.is-playing #table-scene #compact-scores {
  justify-self: start;
  width: min(100%, 1100px);
}
body.is-playing .parent-notes, body.is-playing footer { display: none; }

@media (orientation: portrait) and (max-width: 620px) {
  body.is-playing #table-top {
    grid-template-areas: "heading sound fullscreen" "scores scores scores" "tools tools tools" "feedback feedback pace";
  }
  body.is-playing #table-top .pace-controls button { font-size: 12px; }
  #table-top #pairs-left { display: none; }
  #table-top #feedback { font-size: 13px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  body.is-playing #table-top {
    grid-template-columns: minmax(0,1fr) max-content;
    grid-template-areas: "heading heading" "scores scores" "tools tools" "sound fullscreen" "feedback feedback" "pace pace";
  }
  body.is-playing #table-top button { padding-inline: 4px; font-size: 13px; }
  body.is-playing #table-top .game-fullscreen-button { font-size: 13px !important; }
  body.is-playing #table-top #pairs-left { display: none; }
  #table-top .pace-controls { flex-wrap: wrap; }
}

body.is-playing #board .center-target {
  width: 96%;
  height: 95%;
  max-width: none;
  box-sizing: border-box;
  padding: 4px;
  overflow: hidden;
}
body.is-playing #board .center-target .target-label,
body.is-playing #board .center-target .target-help,
body.is-playing #board .center-target .pair-caption {
  font-size: clamp(10px, calc(var(--card-width) * .25), 16px);
  line-height: 1.13;
}
body.is-playing #board .center-target strong {
  font-size: clamp(20px, calc(var(--card-width) * .65), 62px);
  line-height: 1;
}
body.is-playing #board .center-target strong.pair-equation {
  font-size: clamp(13px, calc(var(--card-width) * .37), 29px);
}
body.is-playing #board .center-target .feedback-line {
  max-height: clamp(19px, calc(var(--card-width) * .45), 36px);
}

#board-opponent { display: none; }
@media (min-width: 1080px) and (min-height: 541px) {
  #board-stage {
    grid-template-columns: minmax(0,1fr) clamp(118px, 12vw, 175px);
    column-gap: 7px;
  }
  #board-stage #math-boost { grid-column: 1 / -1; }
  #board-stage #board { grid-column: 1; }
  #board-opponent {
    display: grid;
    grid-area: 2 / 2;
    align-items: center;
    justify-items: center;
    width: 100%;
    position: relative;
    padding: 12px;
    border: 1px solid #c6deb855;
    border-radius: 50%;
    background: radial-gradient(circle,#b6d3a871,#7da9952e 62%,transparent 70%);
  }
  #board-opponent-portrait {
    width: 100%;
    height: clamp(114px, 17vw, 190px);
    object-fit: contain;
    filter: drop-shadow(0 5px 5px #18382d9c);
    transition: transform 180ms ease;
  }
  #board-opponent-mood {
    position: absolute;
    top: 2%;
    right: 4%;
    font-size: clamp(24px, 3vw, 40px);
  }
  #board-opponent[data-mood="happy"] img { transform: rotate(-4deg) scale(1.04); }
  #board-opponent[data-mood="oops"] img { transform: rotate(7deg); }
  #board-opponent[data-mood="cheering"] img { transform: translateY(-5px) rotate(-7deg) scale(1.07); }
}
@media (prefers-reduced-motion: reduce) {
  #board-opponent-portrait { transition: none; transform: none !important; }
}
.reduce-motion #board-opponent-portrait { transition: none; transform: none !important; }

@media (orientation: landscape) and (max-height: 540px) {
  body.is-playing #table-top #sound,
  body.is-playing #table-top #hear-number {
    font-size: 0;
    white-space: nowrap;
    justify-self: start;
  }
  #table-top #sound::before,
  #table-top #hear-number::before {
    content: "🔊";
    font-size: 17px;
  }
  #table-top #sound[aria-pressed="false"]::before { content: "🔇"; }
  body.is-playing #table-top .play-tools button,
  body.is-playing #table-top .table-home {
    min-width: 44px;
    padding-inline: 5px;
    font-size: 12px;
  }
  #table-top .pace-controls button { padding-inline: 4px; }
  #table-top .turn-banner { overflow-wrap: anywhere; }
}

body.is-playing #table-scene .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body.is-playing #table-top button,
body.is-playing #table-top .table-home {
  font-size: 14px !important;
}
body.is-playing #board .card-back span {
  font-size: clamp(8px, calc(var(--card-width) * .13), 13px) !important;
}
@media (orientation: landscape) and (max-height: 540px) {
  body.is-playing #table-top #sound,
  body.is-playing #table-top #hear-number {
    font-size: 0 !important;
  }
  body.is-playing #table-top .play-tools button,
  body.is-playing #table-top .table-home,
  body.is-playing #table-top .pace-controls button {
    font-size: 12px !important;
  }
  body.is-playing #table-top #sound,
  body.is-playing #table-top #hear-number {
    font-size: 0 !important;
  }
  body.is-playing #table-top .game-fullscreen-button { font-size: 13px !important; }
}
