/* ---------------------------------------------------------------
   Bilder-Raten — a picture game for kids who can't read yet.
   Design rules: no reading required to play, thumb-sized targets,
   nothing that scrolls, nothing that can be tapped by accident.
   --------------------------------------------------------------- */

:root {
  --bg: #141026;
  --bg-2: #1e1838;
  --ink: #ffffff;
  --ink-dim: rgba(255, 255, 255, 0.62);
  --accent: #22c55e;
  --accent-press: #16a34a;
  --radius: 28px;
  --tap: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(120% 90% at 50% 0%, var(--bg-2) 0%, var(--bg) 62%);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand",
               system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px);
}
.screen[hidden] { display: none; }

/* ============================ Home ============================ */

.home-head {
  text-align: center;
  padding: 10px 0 18px;
  flex: 0 0 auto;
}

.home-title {
  font-size: clamp(26px, 7vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(96deg, #a78bfa, #f472b6 55%, #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.home-sub {
  margin-top: 6px;
  font-size: clamp(14px, 4vw, 18px);
  color: var(--ink-dim);
}

.cat-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(104px, 1fr);
  gap: 12px;
  align-content: stretch;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

.cat {
  position: relative;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius);
  background: var(--cat-bg, #333);
  box-shadow: 0 6px 0 0 var(--cat-shadow, #222), 0 12px 24px rgba(0, 0, 0, 0.34);
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.cat:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 0 var(--cat-shadow, #222), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.cat-icon {
  font-size: clamp(38px, 11vw, 54px);
  line-height: 1;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}

.cat-name {
  font-size: clamp(13px, 3.6vw, 16px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* The mixed-bag tile spans the full width so it reads as "everything". */
.cat--all { grid-column: 1 / -1; }
.cat--all .cat-icon { font-size: clamp(34px, 9vw, 46px); }

.home-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink-dim);
  font-size: 14px;
  font-weight: 600;
}
.chip:active { background: rgba(255, 255, 255, 0.16); }
.chip[aria-pressed="false"] { opacity: 0.45; }
.chip-icon { font-size: 17px; }

/* Short phones: shrink the tiles so all nine still fit without scrolling —
   a half-visible tile reads as broken to a small child. */
@media (max-height: 740px) {
  .home-head { padding: 2px 0 10px; }
  .home-title { font-size: clamp(22px, 6vw, 30px); }
  .home-sub { font-size: 13px; }
  .cat-grid { grid-auto-rows: minmax(78px, 1fr); gap: 9px; }
  .cat { min-height: 78px; gap: 2px; }
  .cat-icon { font-size: clamp(30px, 8vw, 40px); }
  .cat-name { font-size: 12px; }
  .home-foot { padding-top: 8px; }
  .chip { min-height: 40px; font-size: 13px; }
}

/* ============================ Play ============================ */

#screen-play { padding-left: 12px; padding-right: 12px; }

.play-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.round-btn {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  font-size: 22px;
}
.round-btn:active { background: rgba(255, 255, 255, 0.2); }
.round-btn svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink-dim);
}
.score-star { font-size: 17px; }

/* The picture itself — the only thing that matters on this screen. */
.card-area {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
}

.card {
  flex: 1 1 auto;
  width: min(100%, 460px);
  min-height: 0;
  max-height: min(64vh, 620px);
  display: grid;
  place-items: center;
  border-radius: 40px;
  background:
    radial-gradient(120% 120% at 30% 20%,
      color-mix(in srgb, var(--card-tint, #6366f1) 42%, transparent) 0%,
      rgba(255, 255, 255, 0.05) 62%),
    rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.42);
}

.card-emoji {
  font-size: min(44vh, 62vw, 320px);
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
}

/* Fresh picture: pops in so the change is unmissable. */
.card.pop { animation: pop 320ms cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pop {
  0%   { transform: scale(0.72) rotate(-5deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.card-word {
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
}
.card-word[hidden] { display: none; }

/* One big button. Full width, thumb-height, impossible to miss. */
.next-btn {
  flex: 0 0 auto;
  height: clamp(84px, 15vh, 116px);
  margin-top: 14px;
  display: grid;
  place-items: center;
  border-radius: 34px;
  background: linear-gradient(180deg, #34d97b, var(--accent));
  box-shadow: 0 8px 0 0 var(--accent-press), 0 16px 30px rgba(34, 197, 94, 0.28);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.next-btn:active {
  transform: translateY(7px);
  box-shadow: 0 1px 0 0 var(--accent-press), 0 6px 12px rgba(34, 197, 94, 0.22);
}

.next-btn svg {
  width: clamp(52px, 13vw, 74px);
  height: clamp(52px, 13vw, 74px);
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.22));
}

/* Landscape: picture and button side by side so nothing gets cropped. */
@media (orientation: landscape) and (max-height: 560px) {
  #screen-play { flex-direction: row; align-items: stretch; gap: 12px; }
  .play-top {
    flex-direction: column;
    justify-content: space-between;
    order: -1;
  }
  .card-emoji { font-size: min(56vh, 34vw, 300px); }
  .next-btn {
    height: auto;
    width: clamp(96px, 18vw, 150px);
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card.pop { animation: none; }
  * { transition-duration: 1ms !important; }
}
