/* Gamba im Cyber-Brutalism-Look: eine Gacha-Kapsel in einer rohen Kammer.
   Die Klassennamen (niche, coffin, candle …) stammen aus der Gruft-Version, gamba.js nutzt sie weiter. */

.gamba-body {
  --r3: var(--fg);
  --r4: var(--accent-2);
  --r5: var(--accent);
}

.gamba-title { font-size: clamp(5rem, 20vw, 15rem); }

.gamba-motto {
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gamba-layout {
  display: grid;
  gap: 32px;
}

.gamba-layout > * { min-width: 0; }

.gamba-screen h2 {
  margin-bottom: 14px;
  font: clamp(1.9rem, 4vw, 2.6rem)/1 var(--display);
  font-weight: 400;
  text-transform: uppercase;
}

@media (min-width: 960px) {
  .gamba-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
    align-items: start;
  }
  .relics { grid-column: 1 / -1; }
}

/* ---------- Kammer ---------- */

.niche {
  --core: var(--fg);
  position: relative;
  overflow: hidden;
  min-height: 480px;
  display: grid;
  place-items: center;
  padding: 64px 16px 56px;
  border: var(--line);
  background:
    linear-gradient(var(--faint) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--faint) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
}

.niche[data-heat="3"] { --core: var(--r3); }
.niche[data-heat="4"] { --core: var(--r4); }
.niche[data-heat="5"] { --core: var(--r5); }

.niche-head {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: var(--line);
  background: var(--bg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.niche-state { color: #000; background: var(--core); padding: 0 6px; }
.niche-state::before { content: "Bereit"; }
.niche[data-heat="3"] .niche-state::before { content: "★★★"; }
.niche[data-heat="4"] .niche-state::before { content: "★★★★ selten"; }
.niche[data-heat="5"] .niche-state::before { content: "★★★★★ Jackpot"; }

/* Warnstreifen am Boden */
.niche::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 26px;
  border-top: var(--line);
  background: repeating-linear-gradient(-45deg, var(--core) 0 14px, #000 14px 28px);
}

.firelight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--core) 18%, transparent), transparent 55%);
}

.niche[data-heat="0"] .firelight { opacity: 0; }

/* Pegelanzeigen links und rechts (früher Kerzen) */
.candle {
  position: absolute;
  bottom: 44px;
  width: 22px;
  height: 260px;
  border: var(--line);
  background: repeating-linear-gradient(0deg, transparent 0 8px, var(--bg) 8px 12px);
}

.candle-left { left: 18px; }
.candle-right { right: 18px; }

.flame {
  position: absolute;
  inset: auto 2px 2px;
  height: 30%;
  background: repeating-linear-gradient(0deg, var(--core) 0 8px, transparent 8px 12px);
  animation: meter 1.4s steps(6) infinite;
}

.candle-right .flame { animation-duration: 1.1s; animation-delay: -0.5s; }
.niche[data-heat="5"] .flame { animation-duration: 0.5s; }

@keyframes meter {
  0%, 100% { height: 22%; }
  40% { height: 64%; }
  70% { height: 38%; }
}

@media (max-width: 520px) {
  .candle { width: 14px; height: 180px; }
  .candle-left { left: 8px; }
  .candle-right { right: 8px; }
}

.gamba-stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
}

.coffin-glow[hidden],
.reveal[hidden] { display: none; }

.coffin-glow { --tease: var(--accent); }
.tease-3 { --tease: var(--r3); }
.tease-4 { --tease: var(--r4); }
.tease-5 { --tease: var(--r5); }

/* Die Kapsel: oben Glas mit Mlem drin, unten farbige Schale, dazwischen die Naht */
.coffin {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 250px;
  height: 250px;
  padding-top: 26px;
  border: 3px solid var(--fg);
  border-radius: 50%;
  background:
    linear-gradient(180deg, transparent 0 52%, var(--tease) 52%),
    var(--bg-2);
  box-shadow: 12px 12px 0 #000, 12px 12px 0 2px var(--fg);
  overflow: hidden;
}

/* Naht */
.coffin::before {
  content: "";
  position: absolute;
  inset: calc(52% - 7px) 0 auto;
  height: 14px;
  border-block: 3px solid var(--fg);
  background: #000;
}

/* Glanzlicht */
.coffin::after {
  content: "";
  position: absolute;
  top: 26px;
  left: 40px;
  width: 34px;
  height: 14px;
  border-top: 4px solid var(--fg);
  border-radius: 50%;
  transform: rotate(-30deg);
  opacity: 0.8;
}

.coffin-window {
  position: relative;
  display: block;
  width: 92px;
  height: 92px;
  border: var(--line);
  overflow: hidden;
}

.coffin-window img {
  display: block;
  width: 100%;
  height: 100%;
  filter: grayscale(1) contrast(1.2);
}

.coffin-plate {
  position: relative;
  z-index: 1;
  margin-top: 48px;
  padding: 3px 8px;
  background: #000;
  color: var(--fg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.coffin-glow.shaking { animation: jitter 0.1s steps(2) infinite; }
.coffin-glow.shaking .coffin-window img { filter: none; animation: flash 0.2s steps(2) infinite; }

@keyframes jitter {
  0% { transform: translate(-5px, 2px) rotate(-3deg); }
  50% { transform: translate(5px, -2px) rotate(3deg); }
  100% { transform: translate(-3px, 0) rotate(-1deg); }
}

@keyframes flash { 50% { filter: invert(1); } }

/* ---------- Enthüllung ---------- */

.rarity-3 { --rarity: var(--r3); }
.rarity-4 { --rarity: var(--r4); }
.rarity-5 { --rarity: var(--r5); }

.reveal {
  width: 100%;
  text-align: center;
  animation: slam 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes slam {
  from { transform: scale(1.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.reveal-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

/* Strahlenkranz für seltene Treffer, hart statt weich */
.rarity-4 .reveal-frame::before,
.rarity-5 .reveal-frame::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 160%;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: repeating-conic-gradient(var(--rarity) 0 5deg, transparent 5deg 20deg);
  -webkit-mask: radial-gradient(closest-side, #000 50%, transparent 51%);
  mask: radial-gradient(closest-side, #000 50%, transparent 51%);
  opacity: 0.35;
  animation: rays-spin 18s linear infinite;
}

@keyframes rays-spin { to { rotate: 360deg; } }

.reveal-frame img {
  position: relative;
  display: block;
  max-width: min(100%, 270px);
  max-height: 270px;
  object-fit: contain;
  padding: 8px;
  border: 3px solid var(--rarity);
  background: var(--bg);
  box-shadow: 10px 10px 0 var(--rarity);
}

.reveal-stars {
  position: relative;
  display: inline-block;
  margin-top: 22px;
  padding: 2px 10px;
  background: var(--rarity);
  color: #000;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.reveal-name {
  position: relative;
  margin-top: 8px;
  font: clamp(1.8rem, 4vw, 2.6rem)/1 var(--display);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

/* ---------- Steuerpult ---------- */

.altar {
  padding: 22px 18px 24px;
  border: var(--line);
  border-top: 0;
  text-align: center;
}

.souls {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.souls strong {
  display: block;
  color: var(--accent);
  font: clamp(3.5rem, 9vw, 5.5rem)/0.9 var(--display);
  font-weight: 400;
}

.gamba-status {
  min-height: 1.6em;
  margin: 10px 0 18px;
  font-style: italic;
}

.offerings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.offer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 10px;
  border: var(--line);
  background: transparent;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.offer b {
  font: 2rem/1 var(--display);
  font-weight: 400;
  text-transform: uppercase;
}

.offer small { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }

.offer-big { background: var(--accent); border-color: var(--accent); color: #000; }

.offer:hover:not(:disabled),
.offer:focus-visible {
  transform: translate(-4px, -4px);
  box-shadow: 4px 4px 0 var(--accent);
  outline: none;
}

.offer-big:hover:not(:disabled),
.offer-big:focus-visible { box-shadow: 4px 4px 0 var(--fg); }

.offer:active:not(:disabled) { transform: none; box-shadow: none; }

.offer:disabled {
  border: 2px dashed #555;
  background: transparent;
  color: #555;
  cursor: not-allowed;
}

.farm-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.farm-link:hover { background: var(--accent); color: #000; }

/* 10×-Ergebnis als Liste */
.receipt {
  list-style: none;
  margin-top: 20px;
  border-top: var(--line);
  font-size: 13px;
  text-align: left;
}

.receipt[hidden] { display: none; }

.receipt li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--faint);
  overflow-wrap: anywhere;
}

.receipt b { flex: none; color: var(--rarity); }
.receipt .rarity-5 { background: var(--accent); color: #000; padding-inline: 6px; }
.receipt .rarity-5 b { color: #000; }

/* ---------- Statistik ---------- */

.ledger {
  border: var(--line);
  padding: 18px;
}

.ledger dl { border-top: var(--line); }

.ledger dl > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--faint);
}

.ledger dt { color: var(--dim); font-size: 13px; }

.ledger dd {
  margin-left: auto;
  font: 1.6rem/1 var(--display);
  white-space: nowrap;
}

.ledger-small {
  margin-top: 14px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.55;
}

/* ---------- Archiv ---------- */

.relic-wall {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  border-top: var(--line);
  border-left: var(--line);
}

.relic-wall li { transform: none; }

.relic {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  height: 100%;
  min-height: 96px;
  padding: 26px 10px 10px;
  border: 0;
  border-right: var(--line);
  border-bottom: var(--line);
  background: var(--bg);
  color: var(--fg);
  font: 1.15rem/1.05 var(--display);
  text-align: left;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

/* Seltenheitsbalken oben */
.relic::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 8px;
  background: var(--rarity, transparent);
}

.relic small {
  margin-top: 4px;
  color: var(--dim);
  font: 700 10px/1.3 var(--mono);
  letter-spacing: 0.06em;
}

button.relic { cursor: pointer; }

button.relic:hover,
button.relic:focus-visible {
  background: var(--rarity);
  color: #000;
  outline: none;
}

button.relic:hover small,
button.relic:focus-visible small { color: #000; }

.relic.locked {
  justify-content: center;
  align-items: center;
  background: repeating-linear-gradient(45deg, transparent 0 6px, var(--faint) 6px 7px), var(--bg);
  color: #444;
  font-family: var(--mono);
  font-size: 14px;
}

.gamba-reset {
  margin-top: 20px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--dim);
  font: 12px/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-decoration: underline;
  text-transform: uppercase;
  cursor: pointer;
}

.gamba-reset:hover { color: var(--red); }

@media (prefers-reduced-motion: reduce) {
  .flame,
  .coffin-glow.shaking,
  .coffin-glow.shaking .coffin-window img,
  .reveal,
  .rarity-4 .reveal-frame::before,
  .rarity-5 .reveal-frame::before { animation: none; }
}
