/* Rechenlawine (Entwurf) - Kopfrechnen gegen fallende Schneebälle. Nutzt die Variablen aus polar.css/hub.css. */
:root { --rl-himmel1: #dfeefe; --rl-himmel2: #f6fbff; --rl-ball: #ffffff; --rl-ball-text: #12324f; --rl-eis: #bfe3f7; --rl-eis-kante: #8cc8ea; }
@media (prefers-color-scheme: dark) { :root { --rl-himmel1: #0c1d31; --rl-himmel2: #152b44; --rl-ball: #eaf4ff; --rl-ball-text: #0d2740; --rl-eis: #2c5d7d; --rl-eis-kante: #4d8db6; } }

.spiel { text-align: center; }
.modi { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 12px 26px; margin-bottom: 14px; }
.seg-gruppe { display: grid; gap: 5px; justify-items: center; }
.kap { font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; justify-content: center; max-width: 100%; gap: 2px; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 9%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent); }
.seg button { min-width: 42px; padding: 6px 15px; border: 0; border-radius: 999px; background: transparent; color: var(--text); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; }
.seg button:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.seg button[aria-selected=true] { background: var(--accent); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 45%, transparent); }

.rl-kopf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.rl-wert { display: grid; gap: 2px; justify-items: center; padding: 6px 4px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 7%, transparent); }
.rl-wert strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.rl-leben { display: flex; gap: 4px; height: 1.5rem; align-items: center; }
.rl-leben i { width: 16px; height: 10px; border-radius: 3px 3px 6px 6px; background: var(--rl-eis); box-shadow: inset 0 -2px 0 var(--rl-eis-kante); }
.rl-leben i.weg { opacity: .2; }

.rl-feld { position: relative; height: clamp(330px, 56vh, 520px); overflow: hidden; border-radius: 18px; isolation: isolate;
  background: linear-gradient(180deg, var(--rl-himmel1), var(--rl-himmel2)); box-shadow: inset 0 0 0 1px var(--line); touch-action: manipulation; }
.rl-flocken { position: absolute; inset: 0; z-index: -1; opacity: .55;
  background-image: radial-gradient(circle, #fff 1.2px, transparent 1.6px), radial-gradient(circle, #fff 1px, transparent 1.4px);
  background-size: 46px 46px, 73px 73px; background-position: 0 0, 20px 30px; animation: rl-schnee 14s linear infinite; }
@keyframes rl-schnee { to { background-position: 0 460px, 20px 760px; } }
.rl-feld.pausiert .rl-flocken, .rl-feld.frost .rl-flocken { animation-play-state: paused; }

.rl-scholle { position: absolute; left: 6%; right: 6%; bottom: 0; height: 30px; border-radius: 40% 40% 0 0 / 100% 100% 0 0;
  background: linear-gradient(180deg, var(--rl-eis), var(--rl-eis-kante)); box-shadow: 0 -2px 10px color-mix(in srgb, var(--rl-eis-kante) 60%, transparent); }
.rl-scholle.treffer { animation: rl-wackeln .35s ease; }
@keyframes rl-wackeln { 25% { transform: translateX(-6px) } 75% { transform: translateX(6px) } }
.rl-riss { position: absolute; top: 4px; width: 2px; height: 22px; background: color-mix(in srgb, var(--text) 55%, transparent); transform: rotate(14deg); opacity: 0; transition: opacity .2s; }
.rl-riss.r1 { left: 24%; } .rl-riss.r2 { left: 52%; transform: rotate(-18deg); } .rl-riss.r3 { left: 76%; }
.rl-riss.sichtbar { opacity: 1; }

.rl-ball { position: absolute; top: 0; left: 0; display: grid; place-items: center; min-width: 74px; height: 50px; padding: 0 14px; border-radius: 999px;
  background: radial-gradient(circle at 30% 25%, #fff, var(--rl-ball) 60%); color: var(--rl-ball-text); font-weight: 800; font-size: 1.08rem; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(10, 40, 70, .22), inset 0 -3px 0 rgba(10, 40, 70, .08); font-variant-numeric: tabular-nums; will-change: transform; }
.rl-ball.nah { box-shadow: 0 0 0 3px var(--err), 0 6px 16px rgba(10, 40, 70, .22); }
.rl-ball.ziel { box-shadow: 0 0 0 3px var(--accent), 0 6px 16px rgba(10, 40, 70, .22); }
.rl-ball.platzt { animation: rl-platzen .32s ease-out forwards; }
.rl-ball.zerschellt { animation: rl-zerschellen .4s ease-in forwards; }
@keyframes rl-platzen { to { opacity: 0; scale: 1.6; filter: blur(2px); } }
@keyframes rl-zerschellen { to { opacity: 0; scale: 1.2 .4; } }
.rl-plus { position: absolute; font-weight: 800; color: var(--accent); pointer-events: none; animation: rl-hoch .8s ease-out forwards; }
@keyframes rl-hoch { to { opacity: 0; translate: 0 -36px; } }

.rl-start { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px;
  background: color-mix(in srgb, var(--surface) 72%, transparent); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 3; }
.rl-start-titel { font-size: 1.5rem; font-weight: 800; }
.rl-frost { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.4rem; font-weight: 900; color: #fff; letter-spacing: .06em; z-index: 2;
  background: color-mix(in srgb, #7fd3ff 28%, transparent); text-shadow: 0 2px 12px rgba(0, 60, 110, .5); pointer-events: none; animation: rl-frost-ein .3s ease; }
@keyframes rl-frost-ein { from { opacity: 0; } }

.rl-eingabe { display: grid; grid-template-columns: minmax(120px, 1fr) 2.2fr; gap: 12px; align-items: stretch; margin-top: 12px; }
.rl-antwort { display: grid; place-content: center; gap: 2px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 9%, transparent); }
.rl-antwort strong { font-size: 2rem; line-height: 1.1; min-height: 1.1em; font-variant-numeric: tabular-nums; }
.rl-antwort.falsch { animation: rl-wackeln .3s ease; color: var(--err); }
.pad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pad button { height: 50px; padding: 0; border: 0; border-radius: 10px; background: var(--accent-soft); color: var(--text); font: inherit; font-weight: 700; font-size: 1.3rem; cursor: pointer; touch-action: manipulation; }
.pad button:active { filter: brightness(.9); }

.ende { margin-top: 18px; text-align: center; display: grid; gap: 10px; }
.rl-ende-titel { font-size: 1.3rem; font-weight: 800; }
.rl-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rl-stats div { display: grid; gap: 2px; padding: 10px 4px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 7%, transparent); }
.rl-stats strong { font-size: 1.3rem; }
.reihe { display: flex; flex-wrap: wrap; gap: 8px; }
.mitte { justify-content: center; }
.klein { font-size: .88rem; }

@media (max-width: 560px) {
  .rl-kopf { gap: 5px; margin-bottom: 8px; }
  .rl-wert { padding: 4px 2px; } .rl-wert strong { font-size: 1.05rem; } .rl-leben i { width: 12px; height: 8px; }
  .rl-stats { grid-template-columns: repeat(2, 1fr); }
  .rl-feld { height: 44vh; height: 44dvh; min-height: 280px; }
  .rl-eingabe { grid-template-columns: 76px 1fr; gap: 8px; margin-top: 8px; }
  .rl-antwort strong { font-size: 1.5rem; }
  .pad { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .pad button { height: 44px; font-size: 1.2rem; }
  .rl-ball { min-width: 64px; height: 44px; font-size: 1rem; padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) { .rl-flocken, .rl-scholle.treffer, .rl-antwort.falsch { animation: none; } }
