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

: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;
  gap: 1.2rem;
}

.hidden {
  display: none !important;
}

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

#size-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  width: 100%;
  max-width: 500px;
}

#category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  width: 100%;
}

.option-button,
.category-button {
  background: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 1.5rem 1rem;
  font-size: 1.3rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 0 #6c8ebf;
  transition: transform 0.1s ease;
}

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

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

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

#size-back-button,
#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;
}

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

#game-body {
  width: 100%;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

#controls-help {
  background: #ffffff;
  border-radius: 16px;
  padding: 1rem 1.2rem;
  box-shadow: 0 5px 0 #6c8ebf;
  min-width: 220px;
  max-width: 260px;
}

#controls-help p {
  margin: 0.5rem 0;
  font-size: 0.95rem;
}

#memory-grid {
  display: grid;
  gap: 0.5rem;
  width: min(100%, 540px);
}

.memory-card {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  aspect-ratio: 1;
  perspective: 600px;
}

.memory-card.empty {
  cursor: default;
  visibility: hidden;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

.memory-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-back,
.card-front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #6c8ebf;
}

.card-back {
  background: #6c8ebf;
  color: #ffffff;
  font-size: 1.5rem;
  font-weight: bold;
}

.card-front {
  background: #ffffff;
  transform: rotateY(180deg);
  font-size: 4rem;
}

.memory-card.matched .card-front {
  background: #d7f7dc;
  box-shadow: 0 4px 0 #4caf50;
}

.memory-card.cursor .card-inner {
  outline: 5px solid #e6390b;
  outline-offset: 3px;
  border-radius: 12px;
  box-shadow: 0 0 0 3px #ffffff, 0 0 14px 4px rgba(230, 57, 11, 0.6);
}

#complete-view {
  text-align: center;
  background: #ffffff;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 6px 0 #6c8ebf;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

#complete-message {
  font-size: 1.8rem;
  font-weight: bold;
  margin: 0;
}

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

/* 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,
  .game-card:hover,
  .category-button:hover,
  .choice-card:hover,
  .option-button:hover,
  .difficulty-button:hover,
  .food-button:hover,
  .gender-button:hover,
  .device-button:hover,
  .book-button:hover,
  .memory-card:hover {
    transform: none;
  }
}

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