/* Sandplatz: Ziegelmehl, Kreidelinien, Tennisball-Gelb, grüne Anzeigetafel */
:root {
  --clay: #A94A29;
  --clay-hi: #BF5E37;
  --clay-deep: #7A3018;
  --chalk: #F7F2E8;
  --chalk-dim: rgba(247, 242, 232, .74);
  --ball: #DDF04A;
  --board: #1D3A2A;
  --board-hi: #2A4C3B;
  --ink: #23140E;
  --miss: #5E1F0C;
  --line: 3px;
  --f-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --f-text: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shade: rgba(35, 20, 14, .22);
  --shade-weak: rgba(35, 20, 14, .15);
  --wear: rgba(191, 94, 55, .75);
  --wear-0: rgba(191, 94, 55, 0);
  --stripe: none;
  --texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .48 0 0 0 0 .18 0 0 0 0 .08 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}

/* Rasenplatz: Grün mit Mähstreifen, abgespielte Stellen bräunlich */
:root[data-theme="rasen"] {
  --clay: #3A7030;
  --clay-hi: #4A8240;
  --clay-deep: #24501F;
  --board: #0F2416;
  --board-hi: #1E3D27;
  --miss: #6E1D10;
  --shade: rgba(8, 30, 10, .28);
  --shade-weak: rgba(8, 30, 10, .18);
  --wear: rgba(176, 158, 98, .45);
  --wear-0: rgba(176, 158, 98, 0);
  --stripe: rgba(255, 255, 255, .055);
  --texture:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, .04) 0 56px, rgba(0, 0, 0, .04) 56px 112px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .3 0 0 0 0 .08 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background-color: var(--clay);
  background-image: var(--texture);
  color: var(--chalk);
  font: 400 17px/1.5 var(--f-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ball); outline-offset: 3px; }

/* Screens */
.screen {
  display: none;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.screen.is-active { display: flex; flex-direction: column; }

/* Platzlinien als Rahmen jedes Screens */
.court {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border: var(--line) solid var(--chalk);
}
/* Mittelmarke an der Grundlinie */
.court::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: var(--line);
  height: 14px;
  background: var(--chalk);
  transform: translateX(-50%);
}

.court-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 10px 14px;
  border-bottom: var(--line) solid var(--chalk);
}
.court-head.has-timer { border-bottom: 0; }

.court-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 18px 40px;
}
.push { margin-top: auto; }

/* Typo */
.hero {
  font: 900 clamp(66px, 19vw, 116px)/.86 var(--f-display);
  letter-spacing: -.005em;
  text-wrap: balance;
}
.title {
  font: 900 clamp(48px, 14vw, 76px)/.9 var(--f-display);
  text-wrap: balance;
}
.h3 { font: 800 28px/1.1 var(--f-display); margin-bottom: 6px; }
.lede { font-size: 19px; line-height: 1.4; max-width: 30ch; margin-top: 18px; }
.hint, .note { font-size: 15px; color: var(--chalk-dim); }
.error { font-weight: 700; color: var(--ball); }
.notice {
  font-weight: 700;
  padding: 12px 14px;
  border-left: 5px solid var(--ball);
  background: var(--shade-weak);
}
.count { font: 700 15px/1.2 var(--f-text); color: var(--chalk-dim); }
.secs { font: 800 26px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.rank { font: 800 24px/1 var(--f-display); }
.status { font-weight: 700; }

/* Start */
.start-top {
  position: relative;
  padding: 30px 18px 40px;
  border-bottom: var(--line) solid var(--chalk);
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 700; }

/* Auf der Linie ist drin. */
.ball {
  position: absolute;
  right: 26px;
  bottom: calc(-23px - var(--line) / 2);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 34% 30%, #F2FB8C 0, var(--ball) 46%, #B3C627 100%);
  transform-origin: 50% 100%;
  animation: drop 1.35s .25s both;
}
.ball::before, .ball::after {
  content: "";
  position: absolute;
  top: -12%;
  width: 100%;
  height: 124%;
  border: 3px solid rgba(255, 255, 255, .92);
  border-radius: 50%;
}
.ball::before { left: -64%; }
.ball::after { right: -64%; }

@keyframes drop {
  0%   { transform: translateY(-60vh); animation-timing-function: cubic-bezier(.55, 0, 1, .45); }
  40%  { transform: translateY(0) scale(1.1, .86); animation-timing-function: cubic-bezier(0, .55, .45, 1); }
  62%  { transform: translateY(-64px) scale(1); animation-timing-function: cubic-bezier(.55, 0, 1, .45); }
  80%  { transform: translateY(0) scale(1.05, .93); animation-timing-function: cubic-bezier(0, .55, .45, 1); }
  90%  { transform: translateY(-14px) scale(1); animation-timing-function: cubic-bezier(.55, 0, 1, .45); }
  100% { transform: translateY(0); }
}

/* Formulare */
.input {
  width: 100%;
  padding: 14px 16px;
  font-size: 20px;
  background: var(--shade);
  border: 2px solid var(--chalk);
  border-radius: 6px;
}
.input::placeholder { color: rgba(247, 242, 232, .55); }
textarea.input { font-size: 18px; min-height: 96px; resize: vertical; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 17px 22px 15px;
  border: 0;
  border-radius: 999px;
  background: var(--ball);
  color: var(--ink);
  font: 800 24px/1 var(--f-display);
  letter-spacing: .02em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .08s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: transparent; color: var(--chalk); border: 2px solid var(--chalk); }

/* Anzeigetafel-Zahl */
.board {
  display: inline-block;
  min-width: 3.4em;
  padding: 7px 12px 5px;
  border-radius: 6px;
  background: var(--board);
  color: var(--ball);
  font: 800 26px/1 var(--f-display);
  text-align: right;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}

/* Frage: Die Aufschlaglinie ist der Timer */
.timer { position: relative; height: var(--line); background: var(--chalk); }
.timer-fill {
  position: absolute;
  left: 0;
  top: -2px;
  width: 100%;
  height: 7px;
  border-radius: 4px;
  background: var(--ball);
  transform-origin: left center;
}
.q-img {
  width: 100%;
  max-height: 34vh;
  object-fit: cover;
  border: var(--line) solid var(--chalk);
  border-radius: 4px;
}
.q-text { font: 800 clamp(30px, 8.6vw, 42px)/1.04 var(--f-display); text-wrap: balance; }
.opts { display: grid; gap: 10px; }
.opt {
  width: 100%;
  padding: 15px 16px;
  text-align: left;
  background: var(--shade-weak);
  border: 2px solid var(--chalk);
  border-radius: 6px;
  font: 500 18px/1.3 var(--f-text);
  cursor: pointer;
  transition: background-color .15s, color .15s, opacity .25s;
}
.opt:active { background: rgba(247, 242, 232, .16); }
.opt:disabled { color: var(--chalk); opacity: 1; cursor: default; }
.opts.is-locked .opt:not(.is-correct):not(.is-wrong) { opacity: .4; }
.opt.is-correct { background: var(--ball); border-color: var(--ball); color: var(--ink); font-weight: 700; }
.opt.is-wrong { background: var(--miss); border-color: var(--miss); text-decoration: line-through; }
.feedback { display: flex; flex-direction: column; gap: 8px; }
.verdict { font: 900 36px/1 var(--f-display); }
.fact { max-width: 38ch; }
.fact-fig { display: grid; gap: 6px; margin-top: 4px; }
.fact-fig img {
  width: 100%;
  max-height: 42vh;
  object-fit: cover;
  border: var(--line) solid var(--chalk);
  border-radius: 4px;
}
.fact-fig figcaption { font-size: 15px; color: var(--chalk-dim); }
.feedback .btn { margin-top: 10px; }

/* Finale */
.rules { display: grid; gap: 6px; padding-left: 1.2em; }
.rules li::marker { color: var(--ball); }

.screen-game { padding: 0; }
.screen-game.is-active { height: 100dvh; overflow: hidden; }
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--clay-deep);
}
#g-canvas {
  flex: 1;
  display: block;
  width: 100%;
  min-height: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.lives { display: flex; gap: 8px; }
.lives i {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ball);
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, .16);
  transition: opacity .3s, transform .3s;
}
.lives i.is-lost { opacity: .2; transform: scale(.7); }

/* Ergebnis */
.scoreboard {
  padding: 4px 16px;
  border-radius: 8px;
  background: var(--board);
  box-shadow: inset 0 0 0 2px var(--board-hi);
}
.sb-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid rgba(247, 242, 232, .14);
  font-weight: 700;
}
.sb-row span:last-child {
  font: 800 36px/1 var(--f-display);
  color: var(--ball);
  font-variant-numeric: tabular-nums;
}
.sb-total { border-bottom: 0; }
.sb-total span:last-child { font-size: 60px; }

.promo {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 2px solid var(--chalk);
  border-radius: 8px;
}
.promo h3 { font: 800 28px/1.02 var(--f-display); text-wrap: balance; }
.promo .btn { margin-top: 6px; }

.list { list-style: none; padding: 0; }
.list li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid rgba(247, 242, 232, .25);
}
.list .rk { font: 800 22px/1 var(--f-display); color: var(--chalk-dim); }
.list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list .pt { font: 800 22px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.list li.is-me {
  margin: 0 -10px;
  padding: 9px 10px;
  border-radius: 6px;
  border-bottom-color: transparent;
  background: var(--ball);
  color: var(--ink);
}
.list li.is-me .rk { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
