* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Comic Sans MS', 'Segoe UI', system-ui, sans-serif;
}

/* Ohne !important gewinnt die ID-Spezifität von #nav-screen/#display-screen
   gegen die UA-Regel "[hidden]{display:none}" - beide Screens blieben sonst
   dauerhaft sichtbar, egal was app.js per .hidden umschaltet. */
[hidden] {
  display: none !important;
}

/* ---------- Navigation ---------- */

#nav-screen {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5vh 4vw;
  background: linear-gradient(135deg, #fef9e7, #eaf6ff);
  overflow-y: auto; /* Sicherheitsnetz für sehr kleine/hohe Displays, normalerweise passt alles ohne Scrollen */
}

#nav-screen h1 {
  font-size: clamp(1.6rem, 3.2vh, 2.4rem);
  color: #4a3f8f;
  margin-bottom: 0.3rem;
}

#nav-screen .hint {
  font-size: clamp(0.85rem, 1.6vh, 1rem);
  color: #6b6b6b;
  margin-bottom: clamp(1rem, 3vh, 1.8rem);
  text-align: center;
}

#nav-screen .hint kbd {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.1em 0.5em;
  font-family: inherit;
}

#category-groups {
  display: flex;
  flex-direction: column;
  gap: clamp(0.8rem, 2.2vh, 1.4rem);
  width: min(1000px, 92vw);
}

.category-group h2 {
  font-size: clamp(0.75rem, 1.5vh, 0.95rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4a3f8f;
  opacity: 0.75;
  margin-bottom: 0.5rem;
}

.subgroup-label {
  font-size: clamp(0.7rem, 1.3vh, 0.85rem);
  color: #6b6b6b;
  margin: 0.4rem 0 0.35rem;
}

.subgroup-label:first-of-type {
  margin-top: 0;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: clamp(0.5rem, 1.2vh, 0.8rem);
  margin-bottom: 0.2rem;
}

.category-grid button.selected {
  outline: 3px solid #333;
  outline-offset: 2px;
}

.category-grid button {
  font-size: clamp(0.95rem, 2vh, 1.25rem);
  font-family: inherit;
  font-weight: 700;
  padding: clamp(0.6rem, 1.8vh, 1rem) 1rem;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  color: #fff;
  text-align: center;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  transition: transform 0.08s ease;
}

.category-grid button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
}

.category-grid button:nth-child(6n+1) { background: #ff6f61; }
.category-grid button:nth-child(6n+2) { background: #4fc3a1; }
.category-grid button:nth-child(6n+3) { background: #5b8def; }
.category-grid button:nth-child(6n+4) { background: #f5a623; }
.category-grid button:nth-child(6n+5) { background: #b06bd8; }
.category-grid button:nth-child(6n+6) { background: #ff8fb1; }

/* ---------- Distraction-free display ---------- */

#display-screen {
  height: 100vh;
  width: 100vw;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: none;
}

#char-display {
  font-weight: 800;
  font-size: min(50vh, 35vw);
  line-height: 1;
  color: #3d4db7;
  user-select: none;
  transition: color 0.15s ease;
}

#char-display.attention {
  animation: attention-pulse 0.9s ease;
}

@keyframes attention-pulse {
  0%   { color: #3d4db7; transform: scale(1); }
  30%  { color: #ff6f61; transform: scale(1.08); }
  60%  { color: #f5a623; transform: scale(1); }
  100% { color: #3d4db7; transform: scale(1); }
}

#pictures-display {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4em;
  max-width: 90vw;
  margin-top: 2vh;
  user-select: none;
}

#pictures-display .animal {
  font-size: var(--animal-size, 3rem);
  line-height: 1;
}

.number-extra {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
}

.animals-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4em;
  max-width: 90vw;
}

.letter-animal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
}

.animal-label {
  font-size: 3.5rem;
  font-weight: 700;
  color: #6b6b6b;
}

.animal-label b {
  color: #3d4db7;
}

.number-word {
  font-size: 4rem;
  font-weight: 700;
  color: #3d4db7;
}

#char-display.equation {
  font-size: min(32vh, 9vw);
}
