* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

@font-face {
  font-family: "Peli Emoji";
  src: url("/fonts/NotoColorEmoji.woff2") format("woff2");
  font-display: swap;
}

/* The page itself never scrolls: on a touch screen that only lets a child
   drag the game out of view or rubber-band the whole layout. Anything that
   does not fit is scrolled inside <main> instead. */
html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Comic Sans MS", "Trebuchet MS", Verdana, sans-serif;
  background: linear-gradient(180deg, #bde0fe 0%, #a2d2ff 100%);
  color: #2b2d42;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}

/* Only pulled in when common.js detects missing/broken emoji rendering. */
:root.no-emoji-font body {
  font-family: "Comic Sans MS", "Trebuchet MS", Verdana, "Peli Emoji", sans-serif;
}

header {
  width: 100%;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

#hub-link {
  flex-shrink: 0;
  color: #2b2d42;
  font-weight: bold;
  text-decoration: none;
  background: #ffffff;
  border-radius: 14px;
  padding: 0.5rem 0.9rem;
  box-shadow: 0 4px 0 #6c8ebf;
}

#active-player {
  flex-shrink: 0;
  font-weight: bold;
  background: #ffffff;
  border-radius: 14px;
  padding: 0.5rem 0.9rem;
  box-shadow: 0 4px 0 #6c8ebf;
}

header h1 {
  margin: 0;
  font-size: 2.2rem;
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 900px;
  padding: 0 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden {
  display: none !important;
}

#category-view h2 {
  text-align: center;
}

/* Four practices, two across: each card carries a line of explanation, so a
   parent can see at a glance which step of learning to read it trains. */
#category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
  width: 100%;
  max-width: 620px;
}

.category-button {
  background: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 1.3rem 1rem;
  font-size: 1.3rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 0 #6c8ebf;
  transition: transform 0.1s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.category-button:hover {
  transform: translateY(-4px);
}

.category-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #6c8ebf;
}

.category-button .icon {
  display: block;
  font-size: 3rem;
}

.category-desc {
  font-size: 0.85rem;
  font-weight: normal;
  color: #5a5f7a;
}

#game-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

#back-button {
  align-self: flex-start;
  background: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #6c8ebf;
}

#round-progress {
  font-size: 1.2rem;
  font-weight: bold;
  background: #ffffff;
  border-radius: 14px;
  padding: 0.5rem 1.1rem;
  box-shadow: 0 4px 0 #6c8ebf;
}

#instruction {
  font-size: 1.4rem;
  font-weight: bold;
  background: #ffffff;
  border-radius: 20px;
  padding: 0.6rem 1.4rem;
  box-shadow: 0 6px 0 #6c8ebf;
  text-align: center;
}

/* The listen button is the one a child reaches for over and over in this
   game, so it is the biggest thing on the screen after the answers. */
#listen-button {
  font-size: 1.4rem;
  padding: 0.9rem 1.9rem;
  border-radius: 18px;
  box-shadow: 0 6px 0 #6c8ebf;
}

.game-button {
  background: #ffffff;
  border: none;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
}

#choice-row {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.choice-card {
  background: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 1.2rem 1.5rem;
  cursor: pointer;
  box-shadow: 0 6px 0 #6c8ebf;
  transition: transform 0.1s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-family: inherit;
  min-width: 7rem;
}

.choice-card:hover {
  transform: translateY(-4px);
}

.choice-card:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #6c8ebf;
}

/* Capital above, small below: the same letter in both the shape a child
   learns first and the shape every book uses. */
.letter-big {
  font-size: 4.5rem;
  font-weight: bold;
  line-height: 1;
  color: #2b2d42;
}

.letter-small {
  font-size: 2rem;
  line-height: 1;
  color: #5a5f7a;
}

.choice-number {
  font-size: 1.4rem;
  font-weight: bold;
  color: #6c8ebf;
  background: #eef4ff;
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choice-card.correct {
  box-shadow: 0 6px 0 #4caf50;
  background: #f1fff3;
  animation: pop-in 0.2s ease;
}

.choice-card.correct .choice-number {
  background: #d7f7dc;
  color: #2e7d32;
}

.choice-card.wrong {
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

@keyframes pop-in {
  0% { transform: scale(0.85); }
  100% { transform: scale(1); }
}

/* The picture is all the child gets to go on until the answer is right. */
#word-icon {
  font-size: 7rem;
  line-height: 1;
}

/* Revealed only after the sound has been named, with the letter that was
   asked about picked out of the word. */
#word-reveal {
  font-size: 2.2rem;
  font-weight: bold;
  min-height: 3.4rem;
  padding: 0.4rem 1.2rem;
  border-radius: 16px;
  visibility: hidden;
}

#word-reveal.visible {
  visibility: visible;
  background: #ffffff;
  box-shadow: 0 5px 0 #4caf50;
  animation: pop-in 0.2s ease;
}

.reveal-letter {
  color: #2e7d32;
  background: #d7f7dc;
  border-radius: 8px;
  padding: 0 0.15em;
}

/* Touch devices: no lingering hover state after a tap, and no double-tap zoom
   when a child taps quickly. */
button,
a {
  touch-action: manipulation;
}

@media (hover: none) {
  button:hover,
  a:hover,
  .category-button:hover,
  .choice-card:hover {
    transform: none;
  }
}

/* Keyboard-only hints make no sense on a touch screen. */
@media (hover: none) and (pointer: coarse) {
  .kbd-hint {
    display: none;
  }
}
