/* Stadion-Stile der Sek-1-Edition (Matchday/Focus/Classic), Manager und Fans.
   Übernommen aus Vocab Cup (styles.css, Stand 30.09.2026, nur gelesen) und an Math Cup angepasst.
   Das Matchday-Overlay kommt über --experience-overlay aus der Ausgabe (theme.css). */

/* Moving fans in the front row (stadium-fans.js, 26.09.2026). Back view on the empty front
   terrace of the crowd arenas; jersey, scarf and flag take the team colour through the pose
   mask, multiplied on canvas in stadium-fans.js (keeps the shading). Canvas 768 px with feet at y = 740, so the box is
   shifted down by 3.65 % of its own height to put the feet on the terrace. */
.vc-fans {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.vc-fan {
  position: absolute;
  left: var(--fan-x, 50%);
  bottom: -1.5%;
  width: calc(16% * var(--fan-scale, 1));
  aspect-ratio: 1;
  transform: translate(-50%, 3.65%);
}

.vc-fan:not(.is-ready) {
  visibility: hidden;
}

/* Possession Rush: places between the icons on the bottom edge, none in the middle. */
body.possession-rush-active .vc-fan {
  left: var(--fan-x-rush, var(--fan-x, 50%));
}

body.possession-rush-active .vc-fan.vc-fan-duel-only {
  display: none;
}

.vc-fan-body {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: 50% 96.35%;
  animation: vcFanBob 2.8s ease-in-out var(--fan-delay, 0s) infinite;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.vc-fan-sprite {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
}

body.level-challenge .vc-fan-body {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35)) brightness(0.94);
}

body.level-elite .vc-fan-body {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45)) brightness(0.86) saturate(1.06);
}

.vc-fan.is-cheer .vc-fan-body {
  animation: vcFanHop 950ms cubic-bezier(0.3, 0.7, 0.3, 1) both;
}

.vc-fan.is-goal .vc-fan-body {
  animation: vcFanJump 2600ms ease-in-out both;
}

@keyframes vcFanBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.4%); }
}

@keyframes vcFanHop {
  0% { transform: translateY(0); }
  35% { transform: translateY(-6%); }
  70% { transform: translateY(0); }
  85% { transform: translateY(-1.5%); }
  100% { transform: translateY(0); }
}

@keyframes vcFanJump {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  12% { transform: translateY(-6%) rotate(-2deg); }
  25% { transform: translateY(0) rotate(0deg); }
  38% { transform: translateY(-6%) rotate(2deg); }
  50% { transform: translateY(0) rotate(0deg); }
  63% { transform: translateY(-5%) rotate(-1.5deg); }
  76% { transform: translateY(0) rotate(0deg); }
  88% { transform: translateY(-3%) rotate(1deg); }
}

@media (prefers-reduced-motion: reduce) {
  .vc-fan-body,
  .vc-fan.is-cheer .vc-fan-body,
  .vc-fan.is-goal .vc-fan-body {
    animation: none !important;
  }
}

body.performance-mode .vc-fan-body,
body.performance-mode .vc-fan.is-cheer .vc-fan-body,
body.performance-mode .vc-fan.is-goal .vc-fan-body {
  animation: none !important;
  filter: none;
}

/* Ball size follows the field, not the window (26.09.2026). Before, the ball was sized in vw:
   about 6 % of the field width on a laptop and 12 % on a phone, far bigger than the painted
   goals of the crowd arenas. Now 4 % of the field width on every screen. */
#field.field .ball {
  width: max(24px, 4%);
  height: auto;
  aspect-ratio: 1;
}

#field.field .ball-shadow {
  width: max(20px, 3.4%);
  height: auto;
  aspect-ratio: 3.6;
}

/* Living stadium (stadium-ambience.js): canvas over the arena image, below the pitch UI. */
.vc-ambience {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .vc-ambience {
    display: none;
  }
}

body.performance-mode .vc-ambience {
  display: none;
}

/* Word card, middle way (user 26.09.2026): smaller and half-transparent so the crowd and
   the stadium effects stay visible behind it; still large and calm enough to read from the
   back of the classroom. Laptop and larger only; phone layouts keep their own sizes. */
@media (min-width: 981px) {
  #field .word-display {
    top: 15.5%;
    width: min(64%, 860px);
    height: clamp(112px, 24%, 172px);
    background:
      radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--mode-accent) 16%, transparent), transparent 64%),
      linear-gradient(135deg, rgba(3, 13, 24, 0.7), rgba(9, 38, 54, 0.58));
    -webkit-backdrop-filter: blur(7px) saturate(1.08);
    backdrop-filter: blur(7px) saturate(1.08);
  }

  body.possession-rush-active #field .word-display {
    top: 10%;
    width: min(66%, 820px);
    height: clamp(100px, 23%, 142px);
  }
}

/* Team managers (stadium-managers.js, 26.09.2026): back view from the hips up at the bottom
   edge of the pitch, team A left, team B right. Size and places keep both goals free (goal
   points at x 11.8 / 88.2 %). The right manager is mirrored so gestures point to the middle. */
.vc-managers {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.vc-manager {
  position: absolute;
  bottom: 0;
  left: 27%;
  width: 26%;
  aspect-ratio: 1;
  translate: -50% 0;
}

.vc-manager-right {
  left: 73%;
}

.vc-manager:not(.is-ready) {
  visibility: hidden;
}

.vc-manager-body {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
  animation: vcManagerBreathe var(--manager-breathe, 4.2s) ease-in-out infinite;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45));
}

.vc-manager-right .vc-manager-body {
  animation-delay: -1.9s;
}

.vc-manager-pose {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 200ms ease;
}

.vc-manager-pose.is-front {
  opacity: 1;
}

.vc-manager-right .vc-manager-pose {
  transform: scaleX(-1);
}

/* One bounded gesture at a time. The director varies pose, cadence and pauses. */
.vc-manager[data-motion]:not([data-motion="watch"]):not([data-motion=""]) .vc-manager-body {
  animation-duration: var(--manager-gesture, 1600ms);
  animation-timing-function: ease-in-out;
  animation-iteration-count: 1;
  animation-fill-mode: both;
  animation-delay: 0s;
}
.vc-manager[data-motion="jump"] .vc-manager-body { animation-name: vcManagerJump; }
.vc-manager[data-motion="urge"] .vc-manager-body { animation-name: vcManagerUrge; }
.vc-manager[data-motion="sink"] .vc-manager-body { animation-name: vcManagerSink; }
.vc-manager[data-motion="weight"] .vc-manager-body { animation-name: vcManagerWeight; }
.vc-manager[data-motion="lean"] .vc-manager-body { animation-name: vcManagerLean; }
.vc-manager[data-motion="nod"] .vc-manager-body { animation-name: vcManagerNod; }
.vc-manager[data-motion="lift"] .vc-manager-body { animation-name: vcManagerLift; }
.vc-manager[data-motion="pulse"] .vc-manager-body { animation-name: vcManagerPulse; }
.vc-manager[data-motion="burst"] .vc-manager-body { animation-name: vcManagerBurst; }

body.level-challenge .vc-manager-body {
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)) brightness(0.95);
}

body.level-elite .vc-manager-body {
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.55)) brightness(0.88) saturate(1.05);
}

@keyframes vcManagerBreathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-0.5%) scale(1.01); }
}

@keyframes vcManagerJump {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5%); }
  70% { transform: translateY(0); }
}

@keyframes vcManagerUrge {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-1.5%) rotate(-1deg); }
}

@keyframes vcManagerSink {
  0% { transform: translateY(0); }
  100% { transform: translateY(2%); }
}

@keyframes vcManagerWeight {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  35% { transform: translateX(-0.7%) rotate(-0.65deg); }
  72% { transform: translateX(0.5%) rotate(0.4deg); }
}
@keyframes vcManagerLean {
  0%, 100% { transform: scale(1) translateY(0); }
  35%, 68% { transform: scale(1.014, 0.992) translateY(-0.6%); }
}
@keyframes vcManagerNod {
  0%, 45%, 100% { transform: scaleY(1); }
  22%, 68% { transform: scaleY(0.987) translateY(0.5%); }
}
@keyframes vcManagerLift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  28%, 65% { transform: translateY(-1.3%) rotate(0.65deg); }
}
@keyframes vcManagerPulse {
  0%, 45%, 100% { transform: translateY(0); }
  22% { transform: translateY(-2%); }
  68% { transform: translateY(-1.1%); }
}
@keyframes vcManagerBurst {
  0%, 38%, 76%, 100% { transform: translateY(0) rotate(0deg); }
  18% { transform: translateY(-3.5%) rotate(-0.8deg); }
  57% { transform: translateY(-2.4%) rotate(0.65deg); }
}

/* A rare sideline voice: warm paper, ink text, team-colour edge. Kept off the ball route. */
.vc-manager-speech {
  --speech-paper: #fff8e8;
  --speech-edge: var(--manager-speech-team, #a9c8ef);
  position: absolute;
  z-index: 3;
  bottom: 64%;
  left: 50%;
  translate: -50% 0;
  width: max-content;
  max-width: min(225px, 100%);
  box-sizing: border-box;
  padding: 11px 16px 12px;
  border: 1px solid #e5d5ad;
  border-left: 4px solid var(--speech-edge);
  border-radius: 18px 18px 18px 6px;
  background: var(--speech-paper);
  color: #14283b;
  box-shadow: 0 5px 0 rgba(4, 14, 28, .2), 0 10px 22px rgba(4, 14, 28, .25);
  font-family: inherit;
  font-size: clamp(13px, 1.2vw, 18px);
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
  pointer-events: none;
  animation: vcManagerSpeechIn 180ms ease-out both;
}
.vc-manager-speech[hidden] { display: none; }
.vc-manager-speech::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  bottom: -7px;
  left: 32%;
  rotate: 45deg;
  background: var(--speech-paper);
  border-right: 1px solid #e5d5ad;
  border-bottom: 1px solid #e5d5ad;
}
.vc-manager-right .vc-manager-speech { border-radius: 18px 18px 6px 18px; }
.vc-manager-right .vc-manager-speech::after { left: auto; right: 32%; }
.vc-manager-speech[data-tone="celebrate"] {
  --speech-paper: #fff0c6;
  --speech-edge: #d6a53c;
  border-top: 2px solid #e2bd62;
}
.vc-manager-speech[data-tone="reassure"] { --speech-paper: #eff7fc; }
@keyframes vcManagerSpeechIn {
  from { opacity: 0; transform: translateY(4px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
/* Small pitches: beside the shoulder, with the tip pointing UP towards the head.
   Fixed top anchor keeps longer lines growing into the foreground, never onto the pitch. */
@media (max-width: 1000px) {
  .vc-manager-speech { top: 40%; bottom: auto; left: 27%; translate: -70% 0; max-width: min(200px, 110%); padding: 8px 11px; font-size: 13px; }
  .vc-manager-right .vc-manager-speech { left: 73%; translate: -30% 0; }
  .vc-manager-speech::after { top: -7px; bottom: auto; left: auto; right: 12%; border: 0; border-top: 1px solid #e5d5ad; border-left: 1px solid #e5d5ad; }
  .vc-manager-right .vc-manager-speech::after { left: 12%; right: auto; }
}
@media (max-width: 844px) and (max-height: 500px) {
  .vc-manager-speech { padding: 6px 9px; font-size: 12px; border-radius: 13px 13px 13px 4px; }
  .vc-manager-right .vc-manager-speech { border-radius: 13px 13px 4px 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .vc-manager-speech { animation: none; display: none; }
}
body.performance-mode .vc-manager-speech { display: none; }

/* With managers: only a few small fans stay beside them in Duel, none in Possession Rush. */
body.has-managers .vc-fan {
  display: none;
}

body.has-managers:not(.possession-rush-active) .vc-fan.vc-fan-keep {
  display: block;
  left: var(--fan-x-manager, var(--fan-x));
}

@media (prefers-reduced-motion: reduce) {
  .vc-manager-body,
  .vc-manager[data-pose] .vc-manager-body {
    animation: none !important;
  }

  .vc-manager-pose {
    transition: none;
  }
}

body.performance-mode .vc-manager-body,
body.performance-mode .vc-manager[data-pose] .vc-manager-body {
  animation: none !important;
  filter: none;
}

/* ---------------------------------------------------------------------------
   Stadium presets and a calmer setup (26.09.2026, after the Math Cup design review).
   Only Matchday shows managers, fans and stadium effects; Focus and Classic stay calm. */
body:not(.experience-matchday) .vc-managers,
body:not(.experience-matchday) .vc-fans,
body:not(.experience-matchday) .vc-ambience {
  display: none !important;
}

#setup .stadium-experience-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

#setup .experience-option {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  min-width: 0;
  padding: 8px 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(8, 22, 39, 0.62);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

#setup .experience-option:hover {
  border-color: rgba(247, 216, 74, 0.45);
}

#setup .experience-option:has(input:checked) {
  border-color: rgba(247, 216, 74, 0.85);
  box-shadow: inset 0 0 0 1px rgba(247, 216, 74, 0.5), 0 10px 26px rgba(0, 0, 0, 0.35);
}

#setup .experience-option:has(input:focus-visible) {
  outline: 2px solid #f7d84a;
  outline-offset: 2px;
}

#setup .experience-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#setup .experience-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
}

#setup .experience-copy {
  display: grid;
  gap: 2px;
  padding: 0 4px;
  min-width: 0;
}

#setup .experience-copy strong {
  color: #f4f8fc;
  font-size: 16px;
  letter-spacing: 0.01em;
}

#setup .experience-copy small {
  color: rgba(197, 222, 236, 0.78);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}

/* Setup background follows the stadium preset: Matchday adds the managers and a few fans
   (a transparent layer with the same 1672 × 941 frame as the arena, so it lines up). */
body.experience-matchday .setup {
  background:
    linear-gradient(180deg, rgba(2, 8, 16, 0.2), rgba(1, 5, 10, 0.42)),
    radial-gradient(circle at 18% 8%, var(--season-setup-tone-soft, rgba(76, 201, 240, 0.14)), transparent 34%),
    radial-gradient(circle at 86% 6%, var(--season-setup-tone-cool, rgba(97, 238, 214, 0.1)), transparent 38%),
    var(--experience-overlay, none) center / cover no-repeat,
    var(--setup-arena-preview-background) center / cover no-repeat,
    linear-gradient(180deg, rgba(2, 8, 16, 0.9), rgba(1, 5, 10, 0.94));
}


/* Rebuilt arenas place the pitch higher. Keep the card above the ball route and
   between the goals at every viewport; Classic retains its existing layout. */
#field.field[data-arena-geometry="v4"] .word-display {
  top: 11%;
  width: min(64%, 860px);
  height: 23%;
  min-height: 0;
  max-height: 172px;
  padding: clamp(4px, 0.8vw, 12px) clamp(8px, 1.5vw, 24px);
  background: linear-gradient(135deg, rgba(3, 13, 24, 0.7), rgba(9, 38, 54, 0.58));
}

#field.field[data-arena-geometry="v4"] .word-display.answer-visible {
  padding-top: clamp(14px, 2vw, 24px);
}

/* The former 24 px minimum made the ball wider than the new goal on phones. */
#field.field[data-arena-geometry="v4"] .ball {
  width: 4%;
}

#field.field[data-arena-geometry="v4"] .ball-shadow {
  width: 3.4%;
}
