/* Rubik (OFL, assets/fonts/OFL.txt) für Geräte ohne SF Rounded, v. a. Android. Nur Latin-Subset.
   Kopiert aus Tabubu (gleiche Spielfamilie, gleiche Lizenz). Gewichtsachse umgemappt (avar):
   CSS 600 → 400, 900 → 700, 1100 → 900; bis 400 unverändert. */
@font-face {
  font-family: "Rubik";
  src: url("./assets/fonts/rubik.woff2") format("woff2");
  font-weight: 300 1100;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  font-family: ui-rounded, "SF Pro Rounded", "Rubik", system-ui, sans-serif;
  --ink: #231f20;
  --paper: #fffaf2;
  --canvas: #f5efe5;
  --accent: #f97316;
  --muted: #746d66;
  --success: #15803d;
  --skip: #57534e;
}

/* height: 100% hebelt viewport-fit=cover aus (Safari faellt aufs Nicht-Cover-Layout
   zurueck). --app-height setzt app.js auf die echte Bildschirmhoehe, 100vh ist der
   Fallback fuer Desktop und fuer den Moment vor dem ersten Messen. */
html {
  height: var(--app-height, 100vh);
}

html,
body {
  margin: 0;
  overscroll-behavior: none;
}

body {
  /* Fester Body: kein Rubber-Band-Scroll, keine Adressleisten-Animation, und das
     Layout haengt an --app-height statt an den in Standalone falschen Viewport-Einheiten. */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-height, 100vh);
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 28rem),
    var(--canvas);
  transition: background 180ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button,
input {
  font: inherit;
}

button {
  min-height: 3rem;
  cursor: pointer;
}

.settings-button,
.settings-close {
  display: grid;
  place-items: center;
  width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 0.12rem solid var(--ink);
  border-radius: 999px;
}

.settings-icon {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  width: min(100%, 44rem);
  height: 100%;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.screen {
  display: grid;
  min-height: 0;
  align-content: start;
}

.brand,
.game-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.9rem;
}

.brand {
  margin-bottom: 1.1rem;
}

.brand .settings-button {
  margin-left: auto;
}

.brand-mark {
  width: 3.4rem;
  height: 3.4rem;
  font-size: 1.6rem;
  font-weight: 950;
  color: var(--paper);
  background: var(--ink);
  border: 0.12rem solid var(--ink);
  border-radius: 1rem;
  transform: rotate(-4deg);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 8vw, 2.6rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0.4rem;
  font-size: clamp(1.6rem, 6vw, 2rem);
  line-height: 1.1;
}

.eyebrow,
.kicker {
  margin-bottom: 0.2rem;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.kicker {
  color: var(--accent);
}

.setup-card {
  overflow: hidden;
  background: var(--paper);
  border: 0.14rem solid var(--ink);
  border-radius: 1.6rem;
  box-shadow: 0 0.45rem 0 var(--ink);
}

.setup-intro,
#setup-form {
  padding: 1.5rem;
}

.setup-intro {
  border-bottom: 0.14rem solid color-mix(in srgb, var(--ink) 25%, transparent);
}

.setup-intro p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

#setup-form {
  display: grid;
  gap: 1.2rem;
}

legend {
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* min-width: 0 – Fieldsets sind sonst mindestens so breit wie ihr Inhalt (min-content). */
fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.age-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.age-options label {
  position: relative;
}

.age-options input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
}

.age-options label > span {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  min-height: 5.4rem;
  padding: 0.8rem 0.4rem;
  font-weight: 900;
  background: var(--paper);
  border: 0.14rem solid var(--ink);
  border-radius: 1.1rem;
  box-shadow: 0 0.22rem 0 var(--ink);
}

.age-options input:focus-visible + span {
  outline: 0.2rem solid var(--accent);
  outline-offset: 0.15rem;
}

.age-options strong {
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  color: var(--tile-accent, var(--accent));
}

.age-options small {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.age-options input:checked + span {
  background: color-mix(in srgb, var(--tile-accent, var(--accent)) 22%, var(--paper));
  border-color: var(--tile-accent, var(--accent));
}

.primary-button,
.action-button {
  padding: 0.9rem 1.4rem;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--paper);
  background: var(--ink);
  border: 0.14rem solid var(--ink);
  border-radius: 1.1rem;
}

.primary-button {
  box-shadow: 0 0.28rem 0 var(--ink);
}

.primary-button:active,
.action-button:active {
  transform: translateY(0.18rem);
}

.secondary-button {
  padding: 0.9rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--paper);
  border: 0.14rem solid var(--ink);
  border-radius: 1.1rem;
  box-shadow: 0 0.28rem 0 var(--ink);
}

.summary-actions {
  display: grid;
  gap: 0.6rem;
}

.game-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.85rem;
  overflow: hidden;
}

.game-header {
  display: grid;
  min-height: 3.5rem;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.45rem;
}

.game-header .settings-button {
  width: 2.6rem;
  min-height: 2.6rem;
  justify-self: end;
}

.timer {
  display: flex;
  grid-column: 2;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
}

.timer span {
  min-width: 4.6ch;
  font-size: 2.65rem;
  line-height: 1;
  text-align: right;
  letter-spacing: 0.03em;
}

.timer.urgent {
  color: #b91c1c;
  animation: pulse 700ms ease-in-out infinite alternate;
}

.card-stage {
  display: grid;
  min-height: 0;
  place-items: center;
  perspective: 900px;
}

.game-card {
  position: relative;
  width: min(100%, 38rem);
  min-height: min(29rem, 57dvh);
  user-select: none;
  will-change: transform, opacity;
}

@media (max-width: 600px) {
  .setup-intro p:last-child {
    display: none;
  }

  .setup-intro h2 {
    margin-bottom: 0;
  }
}

.countdown {
  color: var(--accent);
  font-size: clamp(8rem, 45vw, 14rem);
  font-weight: 950;
  line-height: 1;
  animation: countdown-pop 900ms ease-out both;
}

.game-screen.counting .game-actions {
  visibility: hidden;
}

.game-card.enter {
  animation: draw-card 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* Aufgabenkarte: großer Buchstabe wie beim Stadt-Land-Fluss, Kategorie darunter,
   Fußzeile mit Zielzahl und mitgezählten Antworten. */
.task-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.6rem;
  padding: 1.5rem;
  color: var(--ink);
  background: var(--paper);
  border: 0.14rem solid var(--ink);
  border-radius: 1.6rem;
  box-shadow: 0 0.45rem 0 var(--ink);
  text-align: center;
}

.task-letter {
  font-size: clamp(7rem, 36vmin, 15rem);
  font-weight: 950;
  line-height: 0.95;
  color: var(--accent);
  text-shadow: 0.12rem 0.12rem 0 color-mix(in srgb, var(--ink) 20%, transparent);
}

.task-category {
  max-width: 24ch;
  margin-bottom: 0;
  font-size: clamp(1.6rem, 7vmin, 2.4rem);
  font-weight: 900;
  line-height: 1.15;
}

.card-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.card-footer span {
  padding: 0.35rem 0.9rem;
  font-size: 1rem;
  font-weight: 800;
  background: color-mix(in srgb, var(--accent) 16%, var(--paper));
  border: 0.12rem solid var(--ink);
  border-radius: 999px;
}

.task-progress strong {
  font-variant-numeric: tabular-nums;
}

.game-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
}

.action-button {
  padding: 0.8rem;
  background: var(--paper);
  box-shadow: 0 0.25rem 0 var(--ink);
}

/* Antwort zählt hoch (Hauptknopf), −1 nimmt die letzte zurück. */
.correct-button {
  color: white;
  background: var(--success);
}

.undo-button {
  min-width: 3.4rem;
  color: var(--muted);
}

/* „Andere Aufgabe“ unter der Knopfzeile, volle Breite. */
.skip-button {
  grid-column: 1 / -1;
  padding: 0.7rem 1.4rem;
  color: var(--skip);
}

.summary-screen {
  position: relative;
  display: grid;
  align-content: center;
  gap: 1.1rem;
}

.summary-card {
  display: grid;
  padding: 1.6rem;
  background: var(--paper);
  border: 0.14rem solid var(--ink);
  border-radius: 1.6rem;
  box-shadow: 0 0.45rem 0 var(--ink);
}

.summary-settings {
  position: absolute;
  top: 0;
  right: 0;
}

.summary-header {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  text-align: center;
}

/* Punktzahl als schräge Tafel mit Sternen. */
.scorecard {
  display: grid;
  justify-items: center;
  margin: 0.4rem 0 0.6rem;
  padding: 0.8rem 2.2rem;
  background: var(--canvas);
  border: 0.14rem solid var(--ink);
  border-radius: 1.1rem;
  transform: rotate(-2deg);
}

.scorecard strong {
  font-size: 4rem;
  font-weight: 950;
  line-height: 1;
}

.scorecard small {
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stars {
  font-size: 1.3rem;
  letter-spacing: 0.15em;
}

.stars i {
  opacity: 0.25;
  font-style: normal;
}

.summary-task {
  margin: 0;
  font-size: 1.05rem;
  color: var(--muted);
}

dialog {
  width: min(92vw, 26rem);
  padding: 0;
  color: var(--ink);
  background: var(--canvas);
  border: 0.14rem solid var(--ink);
  border-radius: 1.4rem;
}

dialog::backdrop {
  background: rgb(35 31 32 / 55%);
}

.settings-panel {
  display: grid;
  padding: 1.4rem;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.settings-header h2,
.settings-header p {
  margin-bottom: 0;
}

.audio-setting {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.audio-setting > label {
  font-weight: 900;
}

/* Lautsprecher-Knopf + Regler. Regler ganz links = aus, der Knopf schaltet stumm und zurück. */
.volume-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.volume-row input[type="range"] {
  flex: 1;
}

.mute-button {
  display: grid;
  place-items: center;
  width: 2.4rem;
  min-height: 2.4rem;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 0.12rem solid var(--ink);
  border-radius: 999px;
}

.mute-button svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

.mute-button .icon-off,
.mute-button.muted .icon-on {
  display: none;
}

.mute-button.muted .icon-off {
  display: block;
}

.mute-button.muted {
  color: var(--muted);
}

.abort-round-button {
  padding: 0.8rem;
  font-weight: 800;
  color: #b91c1c;
  background: var(--paper);
  border: 0.14rem solid #b91c1c;
  border-radius: 1.1rem;
}

@keyframes draw-card {
  from {
    transform: translateY(1.2rem) scale(0.92);
    opacity: 0;
  }

  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes pulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.06);
  }
}

@keyframes countdown-pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }

  20% {
    transform: scale(1.05);
    opacity: 1;
  }

  100% {
    transform: scale(0.95);
    opacity: 0.9;
  }
}

:focus-visible {
  outline: 0.2rem solid var(--accent);
  outline-offset: 0.15rem;
}

@media (max-height: 700px) {
  .setup-intro .kicker,
  .setup-intro p:last-child {
    display: none;
  }

  .setup-intro h2 {
    margin-bottom: 0;
    font-size: 1.75rem;
  }

  #setup-form {
    gap: 0.8rem;
  }

  .game-card {
    min-height: 22rem;
  }

  .task-card {
    gap: 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
