/* Klecks-Arena – fröhlich, pastellig, große Knöpfe */
:root {
  --meine-farbe: #9b5de5;
  --text: #3b2f4a;
  --karte: rgba(255, 255, 255, 0.94);
  --schatten: 0 8px 0 rgba(59, 47, 74, 0.12), 0 14px 30px rgba(59, 47, 74, 0.18);
  --schrift: "Fredoka", "Baloo 2", "Nunito", "Trebuchet MS", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #bfe9ff;
  font-family: var(--schrift);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#szene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.versteckt { display: none !important; }
body:not(.touch) .nur-touch { display: none !important; }
body.touch .nur-maus { display: none !important; }

button { font-family: inherit; cursor: pointer; }
kbd {
  display: inline-block; min-width: 1.7em; padding: 0.05em 0.4em; margin: 0 0.1em;
  border-radius: 0.45em; background: #fff; border: 2px solid #d9cbe8; border-bottom-width: 4px;
  font-family: inherit; font-weight: 700; text-align: center; font-size: 0.9em;
}
kbd.breit { min-width: 5em; }

/* ---------- Overlays allgemein ---------- */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px 12px; z-index: 20;
  background: rgba(191, 233, 255, 0.35);
}
.overlay.durchsichtig { background: transparent; pointer-events: none; }
.karte {
  background: var(--karte); border-radius: 28px; padding: 22px 30px; box-shadow: var(--schatten);
  text-align: center; max-width: min(520px, 94vw); max-height: 92vh; overflow: auto;
  border: 4px solid #fff;
}
.karte.breit { max-width: min(720px, 96vw); }
.karte h2 { margin: 0.1em 0 0.5em; font-size: 2rem; }

.gross-knopf {
  display: block; width: 100%; margin: 16px 0 6px; padding: 14px 20px;
  font-size: 1.7rem; font-weight: 800; letter-spacing: 0.02em; color: #fff;
  background: linear-gradient(180deg, #ff7ac4, #f15bb5); border: none; border-radius: 22px;
  box-shadow: 0 7px 0 #c23d8d, 0 12px 20px rgba(241, 91, 181, 0.35);
  transition: transform 0.08s, box-shadow 0.08s;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}
.gross-knopf:hover { transform: translateY(-2px) scale(1.01); }
.gross-knopf:active { transform: translateY(5px); box-shadow: 0 2px 0 #c23d8d; }
.gross-knopf:disabled { filter: grayscale(0.6); opacity: 0.7; }
.gross-knopf:focus-visible, .rund-knopf:focus-visible, .farbkreis:focus-visible, input:focus-visible {
  outline: 4px solid #3a86ff; outline-offset: 3px;
}
.rund-knopf {
  width: 56px; height: 56px; border-radius: 50%; border: 3px solid #fff; background: #fff4b8;
  font-size: 1.6rem; box-shadow: 0 5px 0 #e6cf6a; flex: none;
}
.rund-knopf:active { transform: translateY(4px); box-shadow: 0 1px 0 #e6cf6a; }
.rund-knopf.klein { width: 46px; height: 46px; font-size: 1.3rem; }
.text-knopf { background: none; border: none; color: #7a6a8f; font-size: 1.05rem; text-decoration: underline; margin-top: 10px; }

/* ---------- Startbildschirm ---------- */
#start { background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.35), rgba(191, 233, 255, 0.25)); }
.start-karte {
  background: var(--karte); border-radius: 34px; padding: 20px 28px 18px; width: min(560px, 96vw);
  max-height: 96vh; overflow: auto; box-shadow: var(--schatten); border: 5px solid #fff; text-align: center;
}
.titel { margin: 0; font-size: clamp(2.4rem, 8vw, 3.8rem); line-height: 1.05; font-weight: 900; letter-spacing: 0.01em; }
.titel span { display: inline-block; animation: huepf 2.4s ease-in-out infinite; text-shadow: 0 4px 0 rgba(59, 47, 74, 0.15); }
.titel span:nth-child(8n+1) { color: #ff5a5f; animation-delay: 0s; }
.titel span:nth-child(8n+2) { color: #ff9f1c; animation-delay: 0.1s; }
.titel span:nth-child(8n+3) { color: #f4b400; animation-delay: 0.2s; }
.titel span:nth-child(8n+4) { color: #2bbf6f; animation-delay: 0.3s; }
.titel span:nth-child(8n+5) { color: #19a99c; animation-delay: 0.4s; }
.titel span:nth-child(8n+6) { color: #3a86ff; animation-delay: 0.5s; }
.titel span:nth-child(8n+7) { color: #9b5de5; animation-delay: 0.6s; }
.titel span:nth-child(8n)   { color: #f15bb5; animation-delay: 0.7s; }
.titel .strich { color: #b9a9cc !important; }
@keyframes huepf { 0%, 100% { transform: translateY(0) rotate(0); } 15% { transform: translateY(-8px) rotate(-4deg); } 30% { transform: translateY(0) rotate(0); } }
.untertitel { margin: 6px 0 12px; font-size: 1.1rem; color: #6a5a7f; }
.feld-titel { display: block; font-weight: 800; font-size: 1.15rem; margin: 10px 0 6px; }
.name-zeile { display: flex; gap: 10px; align-items: center; }
#name-feld {
  flex: 1; min-width: 0; font: inherit; font-size: 1.45rem; font-weight: 700; padding: 10px 16px;
  border-radius: 18px; border: 4px solid var(--meine-farbe); background: #fff; color: var(--text);
  text-align: center; user-select: text; -webkit-user-select: text;
}
#farb-wahl { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.farbkreis {
  width: 48px; height: 48px; border-radius: 50%; border: 4px solid #fff; padding: 0;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15); transition: transform 0.12s;
}
.farbkreis:hover { transform: scale(1.1); }
.farbkreis[aria-checked="true"] { transform: scale(1.22); box-shadow: 0 0 0 4px var(--text), 0 4px 0 rgba(0, 0, 0, 0.2); }
.start-hinweis { min-height: 1.3em; color: #c23d8d; font-weight: 700; }
.anleitung {
  display: grid; gap: 4px; margin: 6px 0 4px; padding: 10px 14px; background: #f3fbff;
  border-radius: 18px; font-size: 1rem; text-align: left; border: 3px dashed #bfe0f5;
}
.anleitung .icon { font-size: 1.1em; }
.regel { margin: 8px 0 0; font-size: 0.98rem; color: #6a5a7f; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#fadenkreuz {
  position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px rgba(59, 47, 74, 0.55);
}
#fadenkreuz::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px;
  background: var(--meine-farbe); border-radius: 50%;
}
#fadenkreuz.treffer { animation: kreuzPop 0.3s ease-out; }
@keyframes kreuzPop { 0% { transform: scale(1.8); border-color: #ffd23f; } 100% { transform: scale(1); } }
#treffer-marke {
  position: absolute; left: 50%; top: calc(50% - 46px); transform: translateX(-50%);
  font-size: 1.6rem; font-weight: 900; color: #fff; opacity: 0;
  text-shadow: 0 0 6px var(--meine-farbe), 0 3px 0 rgba(59, 47, 74, 0.5);
}
#treffer-marke.an { animation: trefferPop 0.7s ease-out; }
@keyframes trefferPop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.4); }
  20% { opacity: 1; transform: translateX(-50%) scale(1.25) rotate(-6deg); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(1); }
}
#oben-mitte { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); }
#rundenzeit {
  background: var(--karte); padding: 6px 18px; border-radius: 20px; font-size: 1.45rem; font-weight: 800;
  box-shadow: var(--schatten); border: 3px solid #fff; white-space: nowrap;
}
#rundenzeit.knapp { color: #ff5a5f; animation: puls 1s infinite; }
@keyframes puls { 50% { transform: scale(1.1); } }
#oben-rechts { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; display: grid; gap: 6px; justify-items: end; }
#top3 { display: grid; gap: 4px; }
.top-zeile {
  display: flex; align-items: center; gap: 6px; background: var(--karte); padding: 3px 12px 3px 8px;
  border-radius: 16px; font-weight: 700; font-size: 1.02rem; box-shadow: 0 3px 0 rgba(59, 47, 74, 0.12);
}
.top-zeile.ich { outline: 3px solid var(--meine-farbe); }
.top-name { max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-punkte { min-width: 1.4em; text-align: right; font-weight: 900; }
.farbpunkt { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); flex: none; }
#online { background: rgba(255, 255, 255, 0.8); padding: 3px 10px; border-radius: 14px; font-size: 0.92rem; font-weight: 700; }
#feed { position: absolute; left: 12px; top: max(12px, env(safe-area-inset-top)); display: grid; gap: 5px; max-width: min(46vw, 420px); }
.meldung {
  background: var(--karte); padding: 5px 13px; border-radius: 16px; font-weight: 700; font-size: 1.02rem;
  box-shadow: 0 3px 0 rgba(59, 47, 74, 0.12); animation: rein 0.3s ease-out; transition: opacity 0.6s, transform 0.6s;
  justify-self: start;
}
.meldung .name { font-weight: 900; -webkit-text-stroke: 3px #3b2f4a; paint-order: stroke fill; letter-spacing: 0.02em; }
.meldung.ich { background: #fff4b8; }
.meldung.info { background: #e3f6ff; }
.meldung.chat { background: #f2eaff; }
.meldung.weg { opacity: 0; transform: translateX(-20px); }
@keyframes rein { from { opacity: 0; transform: translateX(-30px); } }

#klecks-meter { position: absolute; left: 14px; bottom: max(14px, env(safe-area-inset-bottom)); text-align: center; filter: drop-shadow(0 4px 0 rgba(59, 47, 74, 0.15)); }
#klecks-zahl { margin-top: -4px; font-weight: 900; font-size: 1.05rem; background: var(--karte); border-radius: 12px; padding: 1px 8px; }
#klecks-meter.fast-voll svg { animation: wackel 0.5s infinite; }
@keyframes wackel { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
#tropfen-fuellung { transition: y 0.3s, height 0.3s; }

#knoepfe-oben { position: absolute; right: 12px; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 8px; pointer-events: auto; }
body.touch #knoepfe-oben { bottom: auto; top: max(10px, env(safe-area-inset-top)); right: auto; left: 50%; transform: translateX(-50%); margin-top: 52px; }
body.touch #feed { top: auto; bottom: 150px; }

#sprechblasen { position: absolute; inset: 0; overflow: hidden; }
.sprechblase {
  position: absolute; left: 0; top: 0; background: #fff; border: 3px solid #9b5de5; border-radius: 16px;
  padding: 4px 12px; font-weight: 800; font-size: 1.05rem; white-space: nowrap; will-change: transform;
}
.sprechblase::after {
  content: ""; position: absolute; left: 50%; bottom: -10px; margin-left: -8px;
  border: 8px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.sprechblase.pop { animation: blasePop 0.35s ease-out; }
@keyframes blasePop { from { opacity: 0; } }

#nachrichten-wahl {
  position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); pointer-events: auto;
  background: var(--karte); border-radius: 22px; padding: 10px 14px; box-shadow: var(--schatten); width: min(560px, 94vw);
}
.nachrichten-titel { font-weight: 800; margin-bottom: 6px; text-align: center; }
#nachrichten-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.nachricht-knopf {
  font-size: 1.1rem; font-weight: 700; padding: 9px 10px; border-radius: 14px; border: 3px solid #e6dcf2;
  background: #fff; color: var(--text); text-align: left; display: flex; align-items: center; gap: 8px;
}
.nachricht-knopf:active { background: #f2eaff; }

#getroffen-rand {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, var(--klecks-farbe, #f15bb5) 130%);
}
#getroffen-rand.an { animation: randBlitz 0.6s ease-out; }
@keyframes randBlitz { 0% { opacity: 0.95; } 100% { opacity: 0; } }
#getroffen-text {
  position: absolute; left: 50%; top: 30%; transform: translateX(-50%); font-size: 3rem; font-weight: 900;
  color: #fff; opacity: 0; text-shadow: 0 4px 0 rgba(59, 47, 74, 0.35);
}
#getroffen-text.an { animation: platschText 0.8s ease-out; }
@keyframes platschText {
  0% { opacity: 0; transform: translateX(-50%) scale(0.3) rotate(-10deg); }
  25% { opacity: 1; transform: translateX(-50%) scale(1.2) rotate(4deg); }
  100% { opacity: 0; transform: translateX(-50%) scale(1) translateY(-30px); }
}

/* ---------- Touch ---------- */
#touch-ebene { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
#stick-ring {
  position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.85); background: rgba(255, 255, 255, 0.22); display: none;
  left: 110px; top: calc(100% - 130px);
}
#stick-ring.sichtbar { display: block; }
#stick-knopf {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.9); transform: translate(-50%, -50%); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}
.touch-knopf {
  position: absolute; border-radius: 50%; border: 4px solid #fff; color: #fff; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 2rem;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18); touch-action: none;
}
.touch-knopf span { font-size: 0.85rem; margin-top: -2px; }
.touch-knopf.gedrueckt { transform: translateY(4px) scale(0.96); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); }
#knopf-spritzen { right: 26px; bottom: calc(40px + env(safe-area-inset-bottom)); width: 108px; height: 108px; background: var(--meine-farbe); }
#knopf-huepfen { right: 146px; bottom: calc(26px + env(safe-area-inset-bottom)); width: 78px; height: 78px; background: #3ddc84; font-size: 1.6rem; }
#knopf-nachricht { right: 40px; bottom: calc(166px + env(safe-area-inset-bottom)); width: 58px; height: 58px; background: #ffd23f; font-size: 1.5rem; }
body.touch #klecks-meter { left: 50%; transform: translateX(-50%) scale(0.8); transform-origin: bottom center; }

/* ---------- Rangliste ---------- */
#ranglisten-tabelle, #pause-rest { display: grid; gap: 6px; min-width: min(360px, 80vw); }
.rang-zeile {
  display: grid; grid-template-columns: 2.2em auto 1fr auto; align-items: center; gap: 10px;
  background: #f6f1fb; padding: 6px 14px; border-radius: 14px; font-size: 1.2rem; font-weight: 700; text-align: left;
}
.rang-zeile.klein { font-size: 1.02rem; padding: 4px 12px; }
.rang-zeile.ich { background: #fff4b8; outline: 3px solid var(--meine-farbe); }
.rang-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rang-platz { font-weight: 900; color: #8a7a9f; }

/* ---------- Rundenpause / Podest ---------- */
#runden-pause { background: rgba(191, 233, 255, 0.55); }
#runden-pause .karte { position: relative; z-index: 1; }
#podest { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 6px 0 14px; }
.podest-spalte { display: flex; flex-direction: column; align-items: center; width: min(150px, 28vw); }
.podest-name { font-weight: 900; font-size: 1.15rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podest-name.ich { color: #c23d8d; }
.podest-figur {
  width: 62px; height: 74px; border-radius: 30px 30px 18px 18px; border: 4px solid #fff; margin: 4px 0 2px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  animation: huepf 1.6s ease-in-out infinite;
}
.platz1 .podest-figur { animation-duration: 1s; }
.podest-gesicht { color: #fff; font-weight: 900; font-size: 1.1rem; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.podest-block {
  width: 100%; border-radius: 14px 14px 0 0; color: #fff; font-size: 2.4rem; font-weight: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 4px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}
.podest-punkte { font-size: 1rem; }
.platz1 .podest-block { height: 130px; background: linear-gradient(#ffd23f, #f4b400); }
.platz2 .podest-block { height: 96px; background: linear-gradient(#cfd8e3, #a9b6c6); }
.platz3 .podest-block { height: 72px; background: linear-gradient(#ffb47a, #e98a4a); }
#pause-countdown { margin-top: 12px; font-weight: 800; font-size: 1.2rem; color: #6a5a7f; }
#konfetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
#konfetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; opacity: 0.95;
  animation: fallen linear infinite;
}
#konfetti i.rund { border-radius: 50%; width: 12px; height: 12px; }
@keyframes fallen {
  0% { transform: translateY(-20px) translateX(0) rotate(0); }
  50% { transform: translateY(50vh) translateX(var(--wackel)) rotate(calc(var(--dreh) / 2)); }
  100% { transform: translateY(105vh) translateX(0) rotate(var(--dreh)); }
}

/* ---------- Dusche ---------- */
#dusche-overlay { background: linear-gradient(180deg, rgba(160, 220, 255, 0.82), rgba(200, 240, 255, 0.7)); z-index: 15; }
.dusche-inhalt { text-align: center; position: relative; }
.dusche-kopf { font-size: 5rem; animation: wackel 0.9s infinite; }
.dusche-titel { font-size: clamp(2rem, 7vw, 3.4rem); font-weight: 900; color: #fff; text-shadow: 0 4px 0 #3a86ff, 0 8px 20px rgba(58, 134, 255, 0.4); }
#dusche-von { font-size: 1.3rem; font-weight: 800; color: #2a5d9f; margin-top: 4px; min-height: 1.4em; }
#dusche-zahl {
  margin: 14px auto 0; width: 110px; height: 110px; border-radius: 50%; background: #fff; color: #3a86ff;
  font-size: 4rem; font-weight: 900; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 rgba(58, 134, 255, 0.35);
}
.blasen i {
  position: absolute; bottom: -40px; width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.25);
  animation: blase 2.2s ease-in infinite;
}
.blasen i:nth-child(1) { left: -30%; animation-delay: 0s; }
.blasen i:nth-child(2) { left: -10%; animation-delay: 0.6s; width: 16px; height: 16px; }
.blasen i:nth-child(3) { left: 10%; animation-delay: 1.1s; }
.blasen i:nth-child(4) { left: 30%; animation-delay: 0.3s; width: 34px; height: 34px; }
.blasen i:nth-child(5) { left: 50%; animation-delay: 1.5s; }
.blasen i:nth-child(6) { left: 70%; animation-delay: 0.8s; width: 18px; height: 18px; }
.blasen i:nth-child(7) { left: 95%; animation-delay: 0.2s; }
.blasen i:nth-child(8) { left: 120%; animation-delay: 1.3s; width: 28px; height: 28px; }
@keyframes blase { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-340px); opacity: 0; } }

/* ---------- Pause & Verbindung ---------- */
#pause-overlay { z-index: 25; }
.regler { display: block; margin-top: 10px; font-weight: 700; color: #6a5a7f; }
.regler input { vertical-align: middle; width: 140px; accent-color: #f15bb5; }
#verbindung-overlay { z-index: 30; background: rgba(191, 233, 255, 0.7); }
.lade-kleckse { display: flex; gap: 10px; justify-content: center; margin-bottom: 4px; }
.lade-kleckse i { width: 20px; height: 20px; border-radius: 50%; animation: huepf 1s ease-in-out infinite; }
.lade-kleckse i:nth-child(1) { background: #ff5a5f; }
.lade-kleckse i:nth-child(2) { background: #ffd23f; animation-delay: 0.15s; }
.lade-kleckse i:nth-child(3) { background: #3a86ff; animation-delay: 0.3s; }

@media (max-height: 560px) {
  .start-karte { padding: 10px 18px; }
  .titel { font-size: 2.2rem; }
  .untertitel, .regel { display: none; }
  .anleitung { font-size: 0.88rem; }
  .gross-knopf { padding: 8px; font-size: 1.4rem; margin: 10px 0 4px; }
  .karte h2 { font-size: 1.5rem; }
  .platz1 .podest-block { height: 90px; } .platz2 .podest-block { height: 66px; } .platz3 .podest-block { height: 50px; }
}
