/* Pikko — Tokens siehe STYLE.md. Keine Roh-Hex außerhalb dieses :root-Blocks. */
:root {
  --bg:            #141B34;
  --bg-deep:       #0D1226;
  --surface:       #FFFFFF;
  --surface-edge:  #0A1024;
  --accent:        #FFC93C;
  --accent-edge:   #C99400;
  --text-light:    #FFFFFF;
  --text-muted:    #7E88AD;
  --text-dark:     #1B2340;
  --danger:        #FF4D6D;

  --p1: #FF4D6D; --p2: #FFC93C; --p3: #4ADE80; --p4: #38BDF8;
  --p5: #C084FC; --p6: #FB923C; --p7: #2DD4BF; --p8: #F472B6;

  --s-1: 8px; --s-2: 16px; --s-3: 24px; --s-4: 32px; --s-5: 48px;
  --r-card: 28px; --r-btn: 18px; --r-pill: 999px;

  --edge: 3px;
  --lift: 5px;
  --ring-size: 104px;
  --beat: 1100ms;

  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --dur: 200ms;

  --font-display: "Fredoka", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Avenir Next", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-light);
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 42%, transparent 38%, var(--bg-deep) 100%);
  pointer-events: none;
  z-index: 1;
}

/* ---------- Bühne ---------- */

#stage {
  position: fixed;
  inset: 0;
  z-index: 2;
}

#confetti {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

/* ---------- Wortmarke ---------- */

.brand {
  position: absolute;
  left: 0; right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 26vh);
  text-align: center;
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
  pointer-events: none;
}

.brand--away {
  opacity: 0;
  transform: translateY(-18px) scale(.94);
}

.brand__mark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(56px, 17vw, 92px);
  letter-spacing: -.02em;
  line-height: .9;
  color: var(--text-light);
  pointer-events: auto;
  animation: markIn 620ms var(--ease-bounce) both;
}

.brand__mark::after {
  content: "";
  display: block;
  width: 46px;
  height: 9px;
  margin: var(--s-2) auto 0;
  border-radius: var(--r-pill);
  background: var(--accent);
  animation: markIn 620ms 120ms var(--ease-bounce) both;
}

.brand__hint {
  margin: var(--s-3) 0 0;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-muted);
  animation: markIn 620ms 200ms var(--ease-bounce) both;
}

@keyframes markIn {
  from { opacity: 0; transform: translateY(22px) scale(.88); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Mitte: Countdown / Ergebnis ---------- */

.center {
  position: absolute;
  left: 0; right: 0;
  top: 26%;
  text-align: center;
  pointer-events: none;
  z-index: 0;              /* hinter den Ringen: die Finger dürfen sie überdecken */
}

/* Die Ziffer bleibt ihre ganze Sekunde stehen und bounct nur beim Wechsel —
   vorher blitzte sie 420ms auf und der Bildschirm war danach spannungslos. */
/* Groß genug, um dem Bildschirm Spannung zu geben, aber neutral und leise:
   in --accent würde sie mit dem gelben Spieler-Ring verschmelzen. */
.center__num {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(150px, 46vw, 240px);
  line-height: 1;
  color: var(--text-light);
  opacity: .17;
}

.center__num--tick { animation: tick 380ms var(--ease-bounce); }

@keyframes tick {
  0%   { transform: scale(.68); opacity: .04; }
  55%  { transform: scale(1.06); opacity: .22; }
  100% { transform: scale(1);   opacity: .17; }
}

/* Der Hinweis darf nie im Gewinner-Ring landen — der kann überall liegen,
   die Bildschirmmitte ist deshalb der falsche Ort dafür. */
.hint {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 34px);
  margin: 0;
  text-align: center;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 220ms var(--ease-out);
  pointer-events: none;
  z-index: 5;
}

.hint--on { opacity: 1; }

/* ---------- Finger-Ringe ---------- */

.rings { position: absolute; inset: 0; }

.ring {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--ring-size);
  height: var(--ring-size);
  margin-left: calc(var(--ring-size) / -2);
  margin-top: calc(var(--ring-size) / -2);
  will-change: transform;
}

/* Der Wrapper trägt NUR die Position (Inline-Transform aus app.js).
   Alles Animierte sitzt hier drin, damit sich beides nie überschreibt. */
.ring__body {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 8px solid var(--c);
  /* Keine Füllung und kein Glow beim Sammeln: eine Alpha-Füllung neutralisiert
     das Navy zu Grau, und der Glow ist laut STYLE §6 dem Gewinner vorbehalten. */
  background: transparent;
  animation: ringIn 260ms var(--ease-bounce) both;
  transition: opacity 320ms var(--ease-out), transform 320ms var(--ease-bounce),
              border-width 200ms var(--ease-out), box-shadow 320ms var(--ease-out);
}

.ring__body::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid var(--c);
  opacity: .35;
  animation: beat var(--beat) ease-in-out infinite;
}

@keyframes ringIn {
  from { opacity: 0; transform: scale(.35); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes beat {
  0%, 100% { transform: scale(1);    opacity: .35; }
  50%      { transform: scale(1.18); opacity: 0; }
}

.ring--spot .ring__body {
  animation: none;
  transform: scale(1.16);
  border-width: 12px;
}

.ring--winner .ring__body {
  animation: none;
  transform: scale(1.42);
  border-width: 14px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  box-shadow: 0 0 60px var(--c), 0 0 140px color-mix(in srgb, var(--c) 45%, transparent);
}

.ring--winner { z-index: 4; }
.ring--winner .ring__body::before { animation: none; opacity: 0; }

.ring--out .ring__body {
  animation: none;
  opacity: 0;
  transform: scale(.55);
  transition: opacity 260ms var(--ease-out), transform 320ms var(--ease-out);
}

.ring--out .ring__body::before { animation: none; opacity: 0; }

/* ---------- Sticker-Button (Duolingo-Mechanik: dicke Unterkante) ---------- */

.btn {
  display: block;
  width: 100%;
  min-height: 58px;
  padding: 16px 24px;
  border: var(--edge) solid var(--surface-edge);
  border-bottom-width: calc(var(--edge) + var(--lift));
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--text-dark);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
  transition: transform 90ms var(--ease-out), border-bottom-width 90ms var(--ease-out);
}

.btn:active {
  transform: translateY(var(--lift));
  border-bottom-width: var(--edge);
}

.btn--accent {
  background: var(--accent);
  border-color: var(--accent-edge);
}

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Panel ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 7;
  background: color-mix(in srgb, var(--bg-deep) 78%, transparent);
  animation: fadeIn 200ms var(--ease-out) both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 8;
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--s-2) var(--s-3) calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  border: var(--edge) solid var(--surface-edge);
  border-bottom: none;
  border-radius: var(--r-card) var(--r-card) 0 0;
  background: var(--surface);
  color: var(--text-dark);
  animation: panelUp 320ms var(--ease-bounce) both;
  touch-action: pan-y;
}

@keyframes panelUp { from { transform: translateY(100%); } to { transform: none; } }

.panel__grip {
  width: 44px; height: 6px;
  margin: 0 auto var(--s-2);
  border-radius: var(--r-pill);
  background: var(--text-muted);
  opacity: .4;
}

.panel__title {
  margin: 0 0 var(--s-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
}

.panel__version {
  margin: var(--s-3) 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 58px;
  padding: var(--s-1) 0;
  margin-bottom: var(--s-1);
}

.row--stack {
  display: block;
}

.row__label {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 17px;
}

.row--stack .row__label { display: block; margin-bottom: var(--s-1); }

/* Schalter */
.switch {
  appearance: none;
  flex: 0 0 auto;
  width: 60px; height: 34px;
  margin: 0;
  border: var(--edge) solid var(--surface-edge);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--text-muted) 30%, transparent);
  position: relative;
  cursor: pointer;
  transition: background 160ms var(--ease-out);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--surface-edge);
  transition: transform 160ms var(--ease-bounce);
}

.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(26px); }
.switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Segment-Auswahl */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  padding-bottom: var(--s-1);
}

.seg button {
  flex: 1 1 auto;
  min-height: 50px;
  padding: 10px 14px;
  border: var(--edge) solid var(--surface-edge);
  border-bottom-width: var(--edge);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-dark);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 90ms var(--ease-out), border-bottom-width 90ms var(--ease-out);
}

.seg button:active { transform: translateY(var(--lift)); border-bottom-width: var(--edge); }

/* Nur die aktive Wahl steht körperlich hervor — die Unterkante ist das Signal. */
.seg button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent-edge);
  border-bottom-width: calc(var(--edge) + var(--lift));
}
.seg button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.advanced {
  margin-top: var(--s-2);
  padding-top: var(--s-1);
}

.advanced__head {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--s-1);
}

.advanced__note {
  margin: var(--s-1) 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */

@media (min-width: 720px) {
  :root { --ring-size: 132px; }
  .panel { left: 50%; transform: translateX(-50%); width: min(520px, 100%); }
}

/* ---------- Reduzierte Bewegung ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .ring__body::before { display: none; }
}
