/* Wörtchen — Candy-Onlinegame-Look: dunkles Lila als Bühne,
   Bonbon-Farben für Kacheln und Tasten. Keine externen Ressourcen;
   die runde Schrift kommt aus dem System (SF Rounded / Arial Rounded). */

:root {
  --bg1: #251144;
  --bg2: #140a28;
  --karte: #261a44;
  --text: #ffffff;
  --text-gedimmt: #a99fc9;

  --kachel-rand: #3f3760;
  --kachel-rand-aktiv: #7a6fb4;

  /* Bonbon-Farben: hell → satt für den Glanz-Verlauf */
  --gruen-hell: #4ce88f;
  --gruen: #23b563;
  --gruen-kante: #178a49;
  --gelb-hell: #ffcf57;
  --gelb: #f5a623;
  --gelb-kante: #c77f0f;
  --grau-hell: #57506e;
  --grau: #443d5c;
  --grau-kante: #322c46;

  --taste-hell: #8d84bd;
  --taste: #6f65a3;
  --taste-kante: #514a7c;

  --pink: #ff5fa2;
  --orange: #ffb020;
  --cyan: #3fd8f7;

  --font-rund: "Arial Rounded MT Bold", ui-rounded, "Hiragino Maru Gothic ProN",
    "Comic Sans MS", "Helvetica Neue", Arial, sans-serif;
  --flip-dauer: 500ms;
}

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

.versteckt { display: none !important; }

html, body { height: 100%; }

body {
  background: radial-gradient(120% 90% at 50% 0%, var(--bg1) 0%, var(--bg2) 70%) fixed;
  color: var(--text);
  font-family: "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

header {
  width: 100%;
  max-width: 500px;
  text-align: center;
  padding: 12px 0 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#kopfzeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

#kopf-platzhalter { width: 30px; }

h1 {
  font-family: var(--font-rund);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(92deg, var(--pink) 0%, var(--orange) 45%, var(--cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}

#untertitel {
  color: var(--text-gedimmt);
  font-size: 0.75rem;
  margin-top: 2px;
  min-height: 1em;
}

#stats-knopf {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-gedimmt);
  cursor: pointer;
  transition: transform 120ms, color 120ms;
}

#stats-knopf:hover { color: var(--cyan); transform: scale(1.15); }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 500px;
  padding: 10px;
}

/* — Spielfeld — */

#grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  margin: auto 0;
  padding: 10px 0;
}

.zeile {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.zeile.schuetteln { animation: schuetteln 500ms; }

.kachel {
  width: min(62px, 15vw);
  height: min(62px, 15vw);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-rund);
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid var(--kachel-rand);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  transition: transform 100ms;
}

.kachel.gefuellt {
  border-color: var(--kachel-rand-aktiv);
  animation: hopser 120ms;
}

/* Flip-Animation: Farbe wird zur Halbzeit des Flips per JS gesetzt */
.kachel.flip { animation: flip var(--flip-dauer) ease; }

/* Bonbon-Optik: Farbverlauf + Glanzlicht oben + farbige Unterkante */
.kachel.correct,
.kachel.present,
.kachel.absent {
  border: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.kachel.correct {
  background: linear-gradient(180deg, var(--gruen-hell) 0%, var(--gruen) 55%);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.45), 0 4px 0 var(--gruen-kante);
}

.kachel.present {
  background: linear-gradient(180deg, var(--gelb-hell) 0%, var(--gelb) 55%);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.45), 0 4px 0 var(--gelb-kante);
}

.kachel.absent {
  background: linear-gradient(180deg, var(--grau-hell) 0%, var(--grau) 55%);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.15), 0 4px 0 var(--grau-kante);
}

.kachel.huepfer { animation: siegeshuepfer 450ms ease; }

@keyframes hopser {
  50% { transform: scale(1.12); }
}

@keyframes flip {
  0%   { transform: rotateX(0); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

@keyframes schuetteln {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

@keyframes siegeshuepfer {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-18px) scale(1.08); }
  70% { transform: translateY(2px) scale(0.98); }
}

/* — Konfetti (Siegesregen) — */

.konfetti {
  position: fixed;
  top: -12px;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 30;
  animation: konfetti-fall linear forwards;
}

@keyframes konfetti-fall {
  to {
    transform: translateY(105vh) rotate(720deg);
    opacity: 0.6;
  }
}

/* — Besucher-Hinweis (Direktaufruf ohne Discord) — */

#besucher {
  margin: auto;
  text-align: center;
  padding: 24px;
}

#besucher-kacheln {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 22px;
}

.kachel.mini {
  width: min(44px, 10vw);
  height: min(44px, 10vw);
  font-size: 1.3rem;
  animation: hopser 400ms backwards;
}

.kachel.mini:nth-child(2) { animation-delay: 80ms; }
.kachel.mini:nth-child(3) { animation-delay: 160ms; }
.kachel.mini:nth-child(4) { animation-delay: 240ms; }
.kachel.mini:nth-child(5) { animation-delay: 320ms; }
.kachel.mini:nth-child(6) { animation-delay: 400ms; }
.kachel.mini:nth-child(7) { animation-delay: 480ms; }
.kachel.mini:nth-child(8) { animation-delay: 560ms; }

#besucher h2 {
  font-family: var(--font-rund);
  font-size: 1.3rem;
  margin-bottom: 10px;
}

#besucher p {
  color: var(--text-gedimmt);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* — Tastatur — */

#tastatur {
  width: 100%;
  padding-bottom: 10px;
}

.tastenreihe {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.taste {
  flex: 1;
  max-width: 42px;
  height: 54px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--taste-hell) 0%, var(--taste) 60%);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35), 0 4px 0 var(--taste-kante);
  color: var(--text);
  font-family: var(--font-rund);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 60ms, box-shadow 60ms, filter 120ms;
}

.taste.breit { max-width: 64px; flex: 1.4; font-size: 0.7rem; }

.taste:active {
  transform: translateY(3px);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35), 0 1px 0 var(--taste-kante);
}

.taste.correct {
  background: linear-gradient(180deg, var(--gruen-hell) 0%, var(--gruen) 60%);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.4), 0 4px 0 var(--gruen-kante);
}

.taste.present {
  background: linear-gradient(180deg, var(--gelb-hell) 0%, var(--gelb) 60%);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.4), 0 4px 0 var(--gelb-kante);
}

.taste.absent {
  background: linear-gradient(180deg, var(--grau-hell) 0%, var(--grau) 60%);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1), 0 4px 0 var(--grau-kante);
  color: var(--text-gedimmt);
}

/* — Toast — */

#toast {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #241a3e;
  font-family: var(--font-rund);
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
  z-index: 20;
}

#toast.sichtbar { opacity: 1; }

/* — Statistik- & Ergebnis-Overlay — */

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 25, 0.65);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#overlay.versteckt { display: none; }

#overlay-karte {
  position: relative;
  background: var(--karte);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  padding: 26px 28px;
  text-align: center;
  width: min(420px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  animation: karte-rein 250ms ease;
}

@keyframes karte-rein {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

#overlay-karte h2 {
  font-family: var(--font-rund);
  font-size: 1.5rem;
  margin-bottom: 4px;
  min-height: 1em;
  background: linear-gradient(92deg, var(--pink), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#overlay-karte h3 {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-gedimmt);
  margin: 20px 0 10px;
}

#overlay-text { color: var(--text-gedimmt); min-height: 1em; }

/* — Statistik-Zahlen — */

#stat-zahlen {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 56px;
}

.stat b {
  font-family: var(--font-rund);
  font-size: 1.9rem;
  font-weight: 700;
}

.stat span { font-size: 0.7rem; color: var(--text-gedimmt); line-height: 1.2; }

/* — Versuchsverteilung — */

#verteilung {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.balken-zeile {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.balken-zeile .nr { width: 12px; text-align: right; color: var(--text-gedimmt); }

.balken-spur { flex: 1; display: flex; }

.balken {
  background: linear-gradient(180deg, var(--grau-hell), var(--grau));
  color: var(--text);
  font-weight: 700;
  font-size: 0.8rem;
  text-align: right;
  padding: 3px 7px;
  min-width: 22px;
  border-radius: 6px;
}

.balken.heute {
  background: linear-gradient(180deg, var(--gruen-hell), var(--gruen));
  box-shadow: 0 2px 0 var(--gruen-kante);
}

/* — Ergebnis & Teilen — */

#teilen-knopf {
  background: linear-gradient(92deg, var(--pink), var(--orange));
  color: var(--text);
  border: none;
  border-radius: 999px;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.35), 0 5px 0 #b23a6f,
    0 10px 22px rgba(255, 95, 162, 0.35);
  padding: 13px 36px;
  font-family: var(--font-rund);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 18px;
  transition: transform 60ms, box-shadow 60ms;
}

#teilen-knopf:active {
  transform: translateY(4px);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.35), 0 1px 0 #b23a6f;
}

#overlay-countdown {
  color: var(--text-gedimmt);
  font-size: 0.8rem;
  margin-top: 12px;
}

/* Kopier-Fallback: markierbarer Ergebnistext (body hat user-select: none) */
#teilen-fallback {
  user-select: text;
  -webkit-user-select: text;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px;
  margin-top: 12px;
}

#teilen-fallback.versteckt { display: none; }

/* — Rangliste — */

#lb-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}

#lb-tabs button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: var(--text-gedimmt);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 14px;
  cursor: pointer;
  transition: transform 80ms;
}

#lb-tabs button:hover { transform: scale(1.06); }

#lb-tabs button.aktiv {
  background: linear-gradient(92deg, var(--cyan), #2ea8e0);
  border-color: transparent;
  color: #10233a;
}

#lb-liste {
  list-style: none;
  text-align: left;
  font-size: 0.9rem;
}

#lb-liste li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#lb-liste li:last-child { border-bottom: none; }

#lb-liste .platz {
  width: 22px;
  color: var(--text-gedimmt);
  text-align: right;
  font-family: var(--font-rund);
}

#lb-liste .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#lb-liste li.ich .name { color: var(--gruen-hell); font-weight: 700; }

#lb-liste .wert { color: var(--text-gedimmt); font-weight: 600; }

.lb-leer { color: var(--text-gedimmt); font-size: 0.85rem; }

#overlay-zu {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-gedimmt);
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 100ms, color 100ms;
}

#overlay-zu:hover { color: var(--pink); transform: scale(1.2); }
