* {
  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;
}

/* 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;
}

/* The picture names the word before a single syllable is placed. */
#word-icon {
  font-size: 7rem;
  line-height: 1;
}

/* One empty slot per syllable: the child can see how many pieces the word
   breaks into before placing the first one. */
#word-slots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.word-slot {
  min-width: 5rem;
  min-height: 4.2rem;
  padding: 0.5rem 0.8rem;
  border-radius: 16px;
  border: 4px dashed #6c8ebf;
  background: #eef4ff;
  font-size: 2.4rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-slot.filled {
  border-style: solid;
  background: #ffffff;
  box-shadow: 0 5px 0 #6c8ebf;
}

#word-slots.complete .word-slot {
  border-color: #4caf50;
  background: #f1fff3;
  box-shadow: 0 5px 0 #4caf50;
  animation: pop-in 0.2s ease;
}

#tile-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.tavu-tile {
  background: #ffffff;
  border: none;
  border-radius: 18px;
  padding: 0.8rem 1.2rem;
  cursor: pointer;
  box-shadow: 0 6px 0 #6c8ebf;
  transition: transform 0.1s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-family: inherit;
  min-width: 5rem;
}

.tavu-tile:hover {
  transform: translateY(-4px);
}

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

.tavu-text {
  font-size: 2.4rem;
  font-weight: bold;
  line-height: 1;
}

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

/* A placed syllable stays on screen but greyed out, so the child sees which
   pieces are already used up rather than the row jumping about. */
.tavu-tile.used {
  opacity: 0.35;
  box-shadow: 0 3px 0 #9aa7c7;
  cursor: default;
}

.tavu-tile.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); }
}

/* 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,
  .tavu-tile:hover {
    transform: none;
  }
}

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