/*
 * GhostSiege – Tageskisten: Leiste im Menue und Oeffnungs-Zeremonie
 * -----------------------------------------------------------------
 * Gehoert zu js/crates.js und crates.js im Projektstamm. Bewusst eine eigene
 * Datei: style.css ist die Buehne des ganzen Spiels, dies hier ist ein in sich
 * geschlossener Aufbau, der nur auf der Startseite vorkommt.
 *
 * Eingebunden NACH style.css (index.html) – die wenigen Regeln, die das
 * Menue-Raster umbauen, muessen dessen Fassung ueberschreiben.
 *
 * Zwei Fassungen derselben Leiste:
 *   Grundfassung  waagerecht, volle Breite ueber den beiden Karten. Gilt
 *                 ueberall dort, wo neben dem Raster kein Platz ist.
 *   ab 1480px     senkrecht in der freien Spalte LINKS neben der Spielkarte.
 *                 Der Balken waechst dann von unten nach oben wie eine
 *                 Erfahrungsleiste, die vier Kisten sitzen als Knoten darauf.
 *
 * Die Kartenbreiten aendern sich dabei NICHT: --launcher-w waechst genau um die
 * neue Spalte plus Rasterabstand, kleiner wird nur der freie Rand daneben.
 */

/* ==================================================================
   DIE LEISTE
   ================================================================== */

.crate-rail {
  position: relative;
  /* Grundfassung: eine eigene ZEILE ueber beiden Karten, volle Rasterbreite.
     Erst ab 1480px wird daraus eine eigene Spalte (siehe unten) – vorher
     wuerde sie den Karten die Breite wegnehmen. */
  grid-column: 1 / -1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 12px;
  border: 1px solid rgba(146, 132, 255, 0.32);
  border-radius: 18px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(120, 90, 220, 0.22), transparent 70%),
    rgba(11, 14, 26, 0.72);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(180, 180, 255, 0.09);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.crate-rail[hidden] { display: none; }

.crate-rail-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.crate-rail-head .crh-kicker {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #b9a8ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crate-rail-head strong {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--gold);
}
.crate-rail-head strong small { font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.crate-rail-head .crh-reset {
  font-size: 0.62rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.crate-rail-head .crh-reset::before { content: "\21BB\00A0"; opacity: 0.7; }
.crate-rail-head .crh-reset:empty { display: none; }

.crate-rail-foot {
  margin: 0;
  font-size: 0.64rem;
  line-height: 1.35;
  color: var(--muted);
  text-align: center;
}
.crate-rail-foot .crf-ready {
  color: var(--gold);
  font-weight: 800;
  animation: crateFootPulse 2.2s ease-in-out infinite;
}
@keyframes crateFootPulse { 50% { opacity: 0.55; } }

/* ---------------------------------------------- Der Balken (waagerecht)
   `.ct-rail` sitzt eingerueckt in der Spur: die Knoten stehen bei 25/50/75/100 %
   und der letzte braucht rechts (senkrecht: oben) seine halbe Breite Platz,
   sonst haengt er ueber dem Rand. */
.crate-track {
  position: relative;
  min-height: 100px;
}
.ct-rail {
  position: absolute;
  inset: 0 48px;
}
.ct-groove,
.ct-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 9px;
  transform: translateY(-50%);
  border-radius: 99px;
}
.ct-groove {
  right: 0;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}
.ct-fill {
  width: var(--fill, 0%);
  background: linear-gradient(90deg, #4aa8ff 0%, #9b7bff 55%, #ffb43a 100%);
  box-shadow: 0 0 14px rgba(155, 123, 255, 0.65), 0 0 4px rgba(255, 255, 255, 0.5);
  transition: width 900ms cubic-bezier(0.22, 1, 0.36, 1);
}
/* Der Funke am Kopf des Balkens – er macht aus einem Strich einen Fortschritt. */
.ct-spark {
  position: absolute;
  left: var(--fill, 0%);
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd35b 45%, rgba(255, 180, 58, 0) 72%);
  transition: left 900ms cubic-bezier(0.22, 1, 0.36, 1);
  animation: crateSpark 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes crateSpark {
  50% { transform: scale(1.45); opacity: 0.75; }
}

/* ---------------------------------------------- Die Knoten */
.crate-node {
  position: absolute;
  left: var(--cr-at, 0%);
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 84px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: default;
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.crate-node .cn-art {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: radial-gradient(circle at 50% 62%,
    color-mix(in srgb, var(--cr-color) 30%, transparent), rgba(10, 12, 22, 0.9) 72%);
  border: 1px solid color-mix(in srgb, var(--cr-color) 45%, transparent);
  transition: box-shadow 240ms ease, border-color 240ms ease, transform 240ms ease;
}
.crate-node .cn-art img {
  width: 40px;
  height: auto;
  max-height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.65));
  transition: filter 240ms ease, transform 240ms ease;
}
.crate-node .cn-stack {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 19px;
  padding: 1px 4px;
  border-radius: 99px;
  background: var(--gold);
  color: #241703;
  font-size: 0.6rem;
  font-weight: 900;
  font-style: normal;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.crate-node .cn-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  max-width: 100%;
}
.crate-node .cn-text b {
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
}
.crate-node .cn-text i {
  font-size: 0.58rem;
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
/* Die Wellenmarke sitzt als Ecke AUF dem Bild, nicht daneben: in der schmalen
   Spalte waere jeder Platz neben dem Knoten schon ausserhalb der Leiste. */
.crate-node .cn-wave {
  position: absolute;
  left: 10px;
  top: -6px;
  padding: 0 5px;
  border-radius: 99px;
  border: 1px solid color-mix(in srgb, var(--cr-color) 55%, transparent);
  background: rgba(8, 10, 20, 0.94);
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--cr-color) 80%, #fff);
  white-space: nowrap;
  z-index: 1;
}

/* Gesperrt: da, aber ohne Versprechen. */
.crate-node.is-locked { opacity: 0.72; cursor: help; }
.crate-node.is-locked .cn-art img { filter: grayscale(1) brightness(0.5); }

/* Admin-Testmodus: gesperrte Kisten bleiben erkennbar gesperrt, sehen aber
   klickbar aus – der Admin oeffnet sie ohne Runs (siehe js/crates.js). */
.crate-node.is-admin { opacity: 0.95; cursor: pointer; }
.crate-node.is-admin .cn-art img { filter: grayscale(0.35) brightness(0.85); }
.crate-node.is-admin .cn-text i { color: #ffd27f; }

/* Heute schon geholt: sichtbar erledigt, nicht mehr verlockend. */
.crate-node.is-done .cn-art {
  border-color: rgba(120, 220, 160, 0.55);
  box-shadow: 0 0 0 1px rgba(120, 220, 160, 0.2);
}
.crate-node.is-done .cn-art img { filter: grayscale(0.55) brightness(0.8); }
.crate-node.is-done .cn-text i { color: #6fdca0; }
.crate-node.is-done .cn-text i::before { content: "\2713\00A0"; }

/* Bereit: DAS ist der Knopf, auf den geklickt werden soll. */
.crate-node.is-ready { cursor: pointer; z-index: 2; }
.crate-node.is-ready .cn-art {
  border-color: var(--cr-color);
  box-shadow: 0 0 0 1px var(--cr-color), 0 0 22px var(--cr-glow), 0 8px 20px rgba(0, 0, 0, 0.55);
  animation: crateReady 2.1s ease-in-out infinite;
}
.crate-node.is-ready .cn-art img {
  filter: drop-shadow(0 0 10px var(--cr-glow)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.7));
}
.crate-node.is-ready .cn-text i { color: var(--gold); font-weight: 800; }
.crate-node.is-ready:hover { transform: translate(-50%, -50%) scale(1.14); }
.crate-node.is-ready:active { transform: translate(-50%, -50%) scale(1.02); }
.crate-node.is-ready:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 14px; }
@keyframes crateReady {
  0%, 100% { box-shadow: 0 0 0 1px var(--cr-color), 0 0 18px var(--cr-glow), 0 8px 20px rgba(0, 0, 0, 0.55); }
  50%      { box-shadow: 0 0 0 2px var(--cr-color), 0 0 34px var(--cr-glow), 0 12px 26px rgba(0, 0, 0, 0.6); }
}

/* Kurzer Hinweis, wenn eine gesperrte Kiste angeklickt wird. */
.crate-toast {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  max-width: calc(100% - 20px);
  padding: 6px 11px;
  border-radius: 10px;
  border: 1px solid rgba(146, 132, 255, 0.4);
  background: rgba(16, 18, 34, 0.96);
  font-size: 0.63rem;
  line-height: 1.3;
  text-align: center;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.crate-toast.show { animation: crateToast 3s ease forwards; }
@keyframes crateToast {
  0%   { opacity: 0; transform: translate(-50%, 6px); }
  12%  { opacity: 1; transform: translate(-50%, 0); }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------------------------------------------- Senkrechte Fassung (ab 1480px)
   Erst hier ist links neben dem Raster wirklich Platz: .menu-content misst dann
   mindestens 1392px, das Raster mit Kistenspalte 1372px. */
@media (min-width: 1480px) {
  #menu .hero-screen { --launcher-w: 1372px; }
  #menu .launcher-grid {
    grid-template-columns: 118px minmax(430px, 1.28fr) minmax(300px, 1fr);
  }
  /* Ohne Bestenliste bleiben zwei Spalten – die Leiste faellt nicht weg. */
  #menu .launcher-grid:has(.board-card.hidden),
  #menu .launcher-grid.board-disabled {
    max-width: 860px;
    grid-template-columns: 118px minmax(0, 1fr);
  }

  .crate-rail {
    grid-column: 1;
    grid-row: 1;
    align-self: stretch;
    padding: 14px 8px 12px;
    gap: 8px;
  }
  .crate-rail-head {
    flex-direction: column;
    align-items: center;
    gap: 1px;
    text-align: center;
  }
  .crate-rail-head .crh-kicker { flex: 0 0 auto; font-size: 0.55rem; letter-spacing: 0.1em; }

  .crate-track { flex: 1 1 auto; min-height: 400px; }
  .ct-rail { inset: 42px 0; }

  /* Aus der Waagerechten wird die Senkrechte: der Balken waechst nach OBEN. */
  .ct-groove,
  .ct-fill {
    left: 50%;
    right: auto;
    top: auto;
    bottom: 0;
    width: 9px;
    height: auto;
    transform: translateX(-50%);
  }
  .ct-groove { top: 0; }
  .ct-fill {
    height: var(--fill, 0%);
    background: linear-gradient(0deg, #4aa8ff 0%, #9b7bff 55%, #ffb43a 100%);
    transition: height 900ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .ct-spark {
    left: 50%;
    top: auto;
    bottom: var(--fill, 0%);
    margin: 0 0 -7px -7px;
    transition: bottom 900ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .crate-node {
    left: 50%;
    top: auto;
    bottom: var(--cr-at, 0%);
    transform: translate(-50%, 50%);
    width: 100px;
  }
  .crate-node .cn-art { width: 52px; height: 52px; }
  .crate-node .cn-art img { width: 46px; max-height: 48px; }
  .crate-node .cn-text b { max-width: 100px; }
  .crate-node .cn-wave { left: 18px; }
  .crate-node.is-ready:hover { transform: translate(-50%, 50%) scale(1.14); }
  .crate-node.is-ready:active { transform: translate(-50%, 50%) scale(1.02); }
}

/* Im gestapelten Menue (schmale Schirme) ist das Raster ein Flex-Container –
   die Leiste braucht dort dieselbe Ausnahme wie die beiden Karten. */
@media (max-width: 900px) {
  #menu .launcher-grid > .crate-rail { flex: 0 0 auto; width: 100%; align-self: auto; }
  .crate-track { min-height: 92px; }
  .ct-rail { inset: 0 42px; }
  .crate-node { width: 74px; }
  .crate-node .cn-art { width: 44px; height: 44px; }
  .crate-node .cn-art img { width: 38px; max-height: 40px; }
  .crate-node .cn-text b { max-width: 74px; font-size: 0.55rem; }
}

/* Handy: vier Knoten nebeneinander lassen keinen Platz mehr fuer vier Namen –
   sie ueberlappten einander. Das Bild TRAEGT die Kiste ohnehin, also bleibt nur
   der Zaehler stehen. Den Namen nennt weiterhin der Titel (und die Zeremonie). */
@media (max-width: 560px) {
  .ct-rail { inset: 0 32px; }
  .crate-node { width: 58px; }
  .crate-node .cn-text b { display: none; }
  .crate-node .cn-text i { font-size: 0.6rem; white-space: nowrap; }
  /* "heute geholt" braucht zwei Zeilen und schoebe die Knoten auseinander –
     der Haken allein sagt dasselbe. */
  .crate-node.is-done .cn-text i { font-size: 0; }
  .crate-node.is-done .cn-text i::before { font-size: 0.8rem; }
  .crate-node .cn-wave { left: 4px; font-size: 0.5rem; }
  .crate-rail { padding: 12px 10px 10px; }
}

/* ==================================================================
   DIE ZEREMONIE – Vollbild, fuenf Stufen
   Anspannung -> Sprengung -> Walze -> Bremsung -> Enthuellung
   ================================================================== */

body.crate-open { overflow: hidden; }

.crate-stage {
  position: fixed;
  inset: 0;
  z-index: 10060;              /* ueber allem, auch ueber der Zwischenanzeige */
  display: grid;
  place-items: center;
  padding: 20px;
  animation: crateStageIn 240ms ease both;
}
.crate-stage[hidden] { display: none; }
.crate-stage.is-closing { animation: crateStageOut 220ms ease both; }
@keyframes crateStageIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes crateStageOut { to { opacity: 0; transform: scale(1.03); } }

.cs-veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 46%, color-mix(in srgb, var(--cr-color) 22%, transparent) 0%, transparent 58%),
    rgba(4, 5, 12, 0.93);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
}

/* Lichtspeichen hinter der Kiste. Sie drehen sich langsam und werden zur
   Enthuellung hin heller – der guenstigste Weg zu "hier passiert etwas". */
.cs-rays {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 150vmax;
  height: 150vmax;
  margin: -75vmax 0 0 -75vmax;
  opacity: 0;
  pointer-events: none;
  background: repeating-conic-gradient(
    from 0deg,
    color-mix(in srgb, var(--cr-color) 46%, transparent) 0deg 5deg,
    transparent 5deg 16deg);
  mask-image: radial-gradient(circle, #000 6%, rgba(0, 0, 0, 0.45) 34%, transparent 62%);
  -webkit-mask-image: radial-gradient(circle, #000 6%, rgba(0, 0, 0, 0.45) 34%, transparent 62%);
  animation: crateRays 26s linear infinite;
  transition: opacity 600ms ease;
}
.crate-stage.is-bursting .cs-rays { opacity: 0.5; }
.crate-stage.is-rolling .cs-rays { opacity: 0.22; }
.crate-stage.is-prize .cs-rays { opacity: 0.42; }
.crate-stage.is-jackpot .cs-rays { opacity: 0.66; }
@keyframes crateRays { to { transform: rotate(360deg); } }

.cs-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(760px, 100%);
  text-align: center;
}

/* Niedrige Fenster (Laptop im Querformat, Handy quer): die Vorstellung darf
   nicht ueber den Rand wachsen. Statt zu scrollen – waehrend die Walze laeuft,
   sieht das nach Fehler aus – schrumpfen Kiste und Fenster mit. */
@media (max-height: 820px) {
  .cs-crate { width: min(220px, 44vw); }
  .csr-window { height: 132px; }
  .csp-portrait { width: 104px; height: 104px; }
  .csp-portrait img { max-width: 92px; max-height: 92px; }
}
@media (max-height: 680px) {
  .crate-stage { padding: 10px; }
  .cs-box { gap: 6px; }
  .cs-crate { width: min(160px, 34vw); }
  .csr-window { height: 116px; }
  .cr-tile .crt-glyph { font-size: 1.15rem; }
  .csp-portrait { width: 78px; height: 78px; }
  .csp-portrait img { max-width: 68px; max-height: 68px; }
  .csp-name { font-size: 1.25rem; }
  .csp-souls { font-size: 2.1rem; }
}

.cs-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--cr-color) 75%, #fff);
  text-shadow: 0 0 18px var(--cr-glow);
}

/* ---------------------------------------------- Stufe 1+2: die Kiste */
.cs-crate {
  position: relative;
  display: grid;
  place-items: center;
  width: min(300px, 62vw);
  aspect-ratio: 400 / 550;
  cursor: pointer;
}
.cs-crate .csc-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 40px var(--cr-glow)) drop-shadow(0 18px 40px rgba(0, 0, 0, 0.75));
  transform-origin: 50% 88%;
}
/* Anspannung: die Kiste atmet erst, dann bebt sie – ein Bogen, kein Blinken. */
.crate-stage.is-charging .csc-img { animation: crateShake 1.5s cubic-bezier(0.4, 0, 0.6, 1) both; }
@keyframes crateShake {
  0%   { transform: scale(1) rotate(0deg); }
  20%  { transform: scale(1.03) rotate(-1deg); }
  40%  { transform: scale(1.01) rotate(1.4deg); }
  55%  { transform: scale(1.05) rotate(-2.2deg); }
  70%  { transform: scale(1.03) rotate(2.6deg); }
  82%  { transform: scale(1.08) rotate(-3.4deg); }
  91%  { transform: scale(1.05) rotate(3.4deg); }
  100% { transform: scale(1.12) rotate(0deg); }
}
.crate-stage.is-bursting .csc-img { animation: crateBurst 700ms cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes crateBurst {
  0%   { transform: scale(1.12); filter: drop-shadow(0 0 40px var(--cr-glow)) brightness(2.6); }
  25%  { transform: scale(1.3);  filter: drop-shadow(0 0 90px var(--cr-glow)) brightness(1.9); }
  100% { transform: scale(1);    filter: drop-shadow(0 0 46px var(--cr-glow)) drop-shadow(0 18px 40px rgba(0, 0, 0, 0.75)) brightness(1); }
}
/* Waehrend die Walze laeuft, rueckt die Kiste klein aus dem Weg. */
.crate-stage.is-rolling .cs-crate,
.crate-stage.is-prize .cs-crate {
  width: min(150px, 30vw);
  transition: width 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Druckwelle und Lichtsaeule im Moment des Aufsprengens. */
.csc-shock,
.csc-beam { position: absolute; pointer-events: none; opacity: 0; }
.csc-shock {
  left: 50%; top: 50%;
  width: 40px; height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--cr-color) 80%, #fff);
}
.crate-stage.is-bursting .csc-shock { animation: crateShock 820ms cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes crateShock {
  0%   { opacity: 0.95; transform: scale(0.3); border-width: 5px; }
  100% { opacity: 0; transform: scale(16); border-width: 0.5px; }
}
.csc-beam {
  left: 50%; bottom: 34%;
  width: 130px; height: 90vh;
  margin-left: -65px;
  background: linear-gradient(to top,
    color-mix(in srgb, var(--cr-color) 80%, #fff) 0%,
    color-mix(in srgb, var(--cr-color) 40%, transparent) 40%,
    transparent 100%);
  filter: blur(6px);
  transform-origin: 50% 100%;
}
.crate-stage.is-bursting .csc-beam { animation: crateBeam 900ms cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes crateBeam {
  0%   { opacity: 0; transform: scaleY(0) scaleX(0.4); }
  18%  { opacity: 0.95; transform: scaleY(1) scaleX(1.25); }
  100% { opacity: 0; transform: scaleY(1) scaleX(0.5); }
}

.cs-shard {
  position: absolute;
  left: 50%; top: 50%;
  width: var(--sz, 8px);
  height: var(--sz, 8px);
  border-radius: 2px;
  pointer-events: none;
  animation: crateShard var(--dur, 1s) cubic-bezier(0.12, 0.75, 0.3, 1) forwards;
}
@keyframes crateShard {
  0%   { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(0.3); }
}

.cs-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  animation: crateFootPulse 1.6s ease-in-out infinite;
}
.cs-hint[hidden] { display: none; }
.cs-hint.is-error { color: #ff8a9c; animation: none; }

/* ---------------------------------------------- Stufe 3+4: die Walze */
.cs-reel {
  position: relative;
  width: min(720px, 96vw);
  margin-top: 4px;
  animation: crateReelIn 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.cs-reel[hidden] { display: none; }
@keyframes crateReelIn { from { opacity: 0; transform: translateY(22px) scaleY(0.7); } }

.csr-window {
  position: relative;
  height: 150px;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--cr-color) 40%, transparent);
  background: linear-gradient(180deg, rgba(8, 10, 20, 0.9), rgba(16, 18, 34, 0.9));
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), 0 12px 40px rgba(0, 0, 0, 0.6);
  /* Zu den Raendern hin blendet das Band aus – der Blick bleibt in der Mitte. */
  mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 86%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 86%, transparent 100%);
}
.csr-strip {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  display: flex;
  gap: 12px;
  padding: 11px 0;
  will-change: transform;
}

/* Die feste Marke in der Mitte: hier wird gewertet. */
.csr-marker {
  position: absolute;
  left: 50%;
  top: -8px;
  bottom: -8px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 99px;
  background: linear-gradient(180deg, transparent, var(--gold) 12%, #fff 50%, var(--gold) 88%, transparent);
  box-shadow: 0 0 16px var(--gold), 0 0 42px rgba(255, 211, 91, 0.5);
  pointer-events: none;
}
.csr-marker::before,
.csr-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 0; height: 0;
  margin-left: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
}
.csr-marker::before { top: 0; border-top: 10px solid var(--gold); }
.csr-marker::after  { bottom: 0; border-bottom: 10px solid var(--gold); }

/* Ein Feld. 120px breit + 12px Abstand = 132 – dieselbe Zahl steht in
   js/crates.js als TILE. Wer eine aendert, muss die andere mitaendern. */
.cr-tile {
  position: relative;
  flex: 0 0 120px;
  width: 120px;
  border-radius: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(30, 34, 58, 0.9), rgba(14, 16, 30, 0.95));
  overflow: hidden;
}
.cr-tile .crt-glyph { font-size: 1.5rem; line-height: 1; opacity: 0.9; }
.cr-tile .crt-name {
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--text);
}
.cr-tile .crt-kind {
  font-size: 0.54rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.cr-tile .crt-badge {
  position: absolute;
  top: 5px; right: 6px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--tint, var(--accent2));
  color: #0b0e18;
  font-size: 0.55rem;
  font-weight: 900;
}
.cr-tile.is-souls.grade-0 { opacity: 0.55; }
.cr-tile.is-souls.grade-1 .crt-glyph { color: #7f8bb0; }
.cr-tile.is-souls.grade-2 { border-color: rgba(79, 195, 255, 0.45); }
.cr-tile.is-souls.grade-2 .crt-glyph { color: #4fc3ff; }
.cr-tile.is-souls.grade-3 { border-color: rgba(180, 92, 255, 0.6); }
.cr-tile.is-souls.grade-3 .crt-glyph { color: #b45cff; }
.cr-tile.is-souls.grade-4 {
  border-color: rgba(255, 180, 58, 0.75);
  background: linear-gradient(180deg, rgba(70, 50, 16, 0.9), rgba(24, 18, 8, 0.95));
}
.cr-tile.is-souls.grade-4 .crt-glyph { color: var(--gold); }
.cr-tile.is-skin {
  border-color: color-mix(in srgb, var(--tint) 70%, transparent);
  background:
    radial-gradient(120% 80% at 50% 110%, color-mix(in srgb, var(--tint) 40%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(34, 26, 62, 0.95), rgba(14, 16, 30, 0.95));
  box-shadow: inset 0 0 24px color-mix(in srgb, var(--tint) 26%, transparent);
}
.cr-tile.is-skin .crt-glyph { color: color-mix(in srgb, var(--tint) 70%, #fff); }
/* Das Skin-Bild fuellt das Feld. Solange es da ist, tritt das Zeichen dahinter
   zurueck – faellt das Bild aus (onerror entfernt es), steht es wieder allein. */
.cr-tile.is-skin .crt-art {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
}
.cr-tile.is-skin .crt-art + .crt-glyph { display: none; }
.cr-tile.is-skin .crt-kind { color: color-mix(in srgb, var(--tint) 65%, #fff); }
.cr-tile.is-skin.t-top { animation: crateTileTop 1.4s ease-in-out infinite; }
@keyframes crateTileTop {
  50% { box-shadow: inset 0 0 34px color-mix(in srgb, var(--tint) 45%, transparent),
                    0 0 20px color-mix(in srgb, var(--tint) 40%, transparent); }
}
.cr-tile.is-winner {
  z-index: 2;
  animation: crateTileWin 620ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes crateTileWin {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.16); box-shadow: 0 0 34px var(--gold); }
  100% { transform: scale(1.08); box-shadow: 0 0 22px var(--gold); }
}

/* ---------------------------------------------- Stufe 5: die Belohnung */
.cs-prize {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: cratePrizeIn 520ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.cs-prize[hidden] { display: none; }
@keyframes cratePrizeIn {
  0%   { opacity: 0; transform: scale(0.7) translateY(14px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.csp-tier {
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.csp-portrait {
  position: relative;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
}
.csp-portrait img {
  max-width: 118px;
  max-height: 118px;
  object-fit: contain;
  filter: drop-shadow(0 0 26px var(--tint));
}
.cspp-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--tint);
  box-shadow: 0 0 34px var(--tint), inset 0 0 34px color-mix(in srgb, var(--tint) 40%, transparent);
  animation: cratePrizeRing 2.6s ease-in-out infinite;
}
@keyframes cratePrizeRing { 50% { transform: scale(1.07); opacity: 0.65; } }
.csp-name {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.1;
  background: linear-gradient(90deg, #fff, var(--gold), #fff);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: crateShine 2.6s linear infinite;
}
@keyframes crateShine { to { background-position: 200% 0; } }
.csp-souls {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 2.9rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 26px rgba(255, 211, 91, 0.6);
  font-variant-numeric: tabular-nums;
}
.csp-souls span { font-size: 1.4rem; opacity: 0.85; }
.crate-stage.is-dud .csp-souls { color: var(--muted); text-shadow: none; }
.csp-sub { font-size: 0.8rem; color: var(--muted); }
.csp-warn { margin-top: 4px; font-size: 0.7rem; color: #ffcf6b; }

.cs-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  animation: cratePrizeIn 420ms ease both 160ms;
}
.cs-actions[hidden] { display: none; }
.cs-actions button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  border: 1px solid rgba(146, 132, 255, 0.5);
  background: rgba(24, 26, 48, 0.9);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.cs-actions button:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55); }
.cs-actions button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.cs-actions .csa-next {
  border-color: var(--gold);
  background: linear-gradient(95deg, rgba(120, 80, 20, 0.6), rgba(60, 40, 12, 0.8));
}
.cs-actions .csa-next img { width: 26px; height: auto; }

@media (max-width: 620px) {
  .csr-window { height: 128px; }
  .cs-crate { width: min(230px, 62vw); }
  .csp-name { font-size: 1.25rem; }
  .csp-souls { font-size: 2.2rem; }
  .cs-actions { flex-direction: column; width: 100%; }
  .cs-actions button { width: 100%; justify-content: center; }
}

/* Weniger Bewegung: die Vorstellung bleibt, das Zappeln geht. js/crates.js
   kuerzt zusaetzlich alle Laufzeiten und laesst Splitter und Ueberschwinger weg. */
@media (prefers-reduced-motion: reduce) {
  .ct-fill,
  .ct-spark { transition: none; }
  .ct-spark,
  .crate-rail-foot .crf-ready,
  .crate-node.is-ready .cn-art,
  .cr-tile.is-skin.t-top,
  .cs-rays,
  .cspp-ring,
  .csp-name,
  .cs-hint,
  .cs-reel,
  .cs-prize,
  .cs-actions,
  .crate-stage.is-charging .csc-img,
  .crate-stage.is-bursting .csc-img,
  .crate-stage.is-bursting .csc-shock,
  .crate-stage.is-bursting .csc-beam { animation: none; }
  .cr-tile.is-winner { animation: none; box-shadow: 0 0 22px var(--gold); }
}
