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

:root {
  --bg: #07070a;
  --bg-lift: #12121b;
  --ink: #f5f5f7;
  --muted: #7a7a86;
  --red: #ff2d37;
  --red-deep: #c50f18;
  --amber: #ffb224;
  --amber-hi: #ffe08a;
  --pad: clamp(20px, 6vw, 44px);
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    system-ui, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(130% 90% at 50% 6%, var(--bg-lift), transparent 55%),
    var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Feiner Film-Grain über allem */
.noise {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Herzschlag-Vignette (Opacity wird per JS getrieben) */
.pulse {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, transparent 42%, rgba(255, 45, 55, 0.6) 100%);
  will-change: opacity;
}

/* Partikel-Explosion beim Payoff */
.fx {
  position: fixed;
  inset: 0;
  z-index: 15;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad)
    max(var(--pad), env(safe-area-inset-bottom));
  will-change: transform;
}

.stage > section {
  grid-area: 1 / 1;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ---------------- Idle ---------------- */
.idle {
  gap: clamp(28px, 7vh, 56px);
}

.kicker,
.hint {
  font-size: clamp(0.72rem, 3vw, 0.85rem);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.hint {
  letter-spacing: 0.14em;
  max-width: 22ch;
  line-height: 1.5;
}

.hint b {
  color: var(--amber);
  font-weight: 800;
}

.trigger {
  position: relative;
  width: clamp(172px, 56vw, 224px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: clamp(1.35rem, 5.4vw, 1.7rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.04;
  background: var(--red);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 20px 60px -18px rgba(255, 45, 55, 0.7);
  transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  isolation: isolate;
}

.trigger__label {
  position: relative;
  z-index: 2;
  pointer-events: none;
}

/* Dünner, rotierender Akzent-Ring statt Glow-Puls */
.trigger__ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  z-index: 1;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255, 45, 55, 0) 200deg,
    var(--red) 320deg,
    var(--amber) 360deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: spin 3.4s linear infinite;
  opacity: 0.9;
}

.trigger:hover {
  transform: scale(1.02);
  background: #ff3d46;
}

.trigger:active {
  transform: scale(0.95);
}

.trigger:focus-visible {
  outline: 2px solid var(--amber-hi);
  outline-offset: 10px;
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

/* ---------------- Run ---------------- */
.run {
  gap: clamp(8px, 2.4vh, 20px);
  justify-content: center;
}

.count {
  font-size: clamp(3.4rem, 17vw, 6.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.count.ex {
  color: var(--amber);
  letter-spacing: 0.02em;
  font-style: italic;
}

.count.punch {
  animation: punch 0.34s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes punch {
  0% { transform: scale(1.28); filter: blur(7px); opacity: 0.35; }
  100% { transform: scale(1); filter: blur(0); opacity: 1; }
}

.glass-wrap {
  display: grid;
  place-items: center;
  height: min(46vh, 380px);
}

.glass-wrap.slam {
  animation: slam 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slam {
  0% { transform: translateY(-20px); }
  55% { transform: translateY(0) scaleY(0.93); }
  76% { transform: translateY(0) scaleY(1.03); }
  100% { transform: translateY(0) scaleY(1); }
}

#glassCanvas {
  display: block;
}

.bar {
  width: min(60%, 220px);
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bar__fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--amber-hi));
  transform-origin: left center;
}

/* ---------------- Finale ---------------- */
.finale {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-top: 4px;
}

.finale__title {
  font-size: clamp(1.9rem, 9vw, 3.2rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--amber);
  animation: rise-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise-in {
  0% { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.again {
  padding: 13px 34px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.1s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  animation: rise-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.08s both;
}

.again:hover {
  border-color: var(--red);
  background: rgba(255, 45, 55, 0.12);
}

.again:active {
  transform: translateY(1px);
}

.again:focus-visible {
  outline: 2px solid var(--amber-hi);
  outline-offset: 3px;
}

/* Weißer Blitz im Moment des Exens */
.flash {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.9), transparent 60%);
  opacity: 0;
}

.flash.go {
  animation: flash 0.5s ease-out;
}

@keyframes flash {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .trigger__ring,
  .count.punch,
  .finale__title,
  .again,
  .flash.go,
  .glass-wrap.slam {
    animation: none !important;
  }
  .flash,
  .pulse { display: none; }
}
