.wuerfel {
  --wf-s: 60px;
  --wf-gold: #d9b25a;
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  overflow: hidden;
  color: #e9e4d4;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  background: #0b0908;
}
.wuerfel.an { display: block; animation: wf-auf 620ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes wf-auf { from { clip-path: inset(50% 0 50% 0); } to { clip-path: inset(0 0 0 0); } }
html.im-wuerfel .rechtlich { z-index: 39; }

.wf-wand {
  position: absolute; inset: 0 0 48% 0;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.35) 0 2px, transparent 2px 120px),
    linear-gradient(180deg, #1a120c, #2a1b10 70%, #160e08);
}
.wf-tisch {
  position: absolute; left: 0; right: 0; bottom: 0; top: 52%;
  background:
    radial-gradient(ellipse 60% 70% at 50% 30%, #1f7a48, #0f4f2d 60%, #082c19 100%);
  border-top: clamp(8px, 1.4vh, 14px) solid #3b2213;
  box-shadow: inset 0 18px 30px rgba(0, 0, 0, 0.45);
}
.wf-tisch::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.55), transparent);
}
.wf-licht {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 34% 75% at 50% 8%, rgba(255, 236, 180, 0.2), transparent 70%);
  mix-blend-mode: screen;
}
.wf-lampe {
  position: absolute; top: 0; left: 50%; translate: -50% 0;
  width: clamp(120px, 15vw, 210px); pointer-events: none; z-index: 2;
}
.wf-lampe svg { display: block; width: 100%; }

.wuerfel button {
  position: absolute; z-index: 3; padding: 0; margin: 0; border: 0; background: none;
  cursor: pointer; color: inherit; font: inherit; -webkit-tap-highlight-color: transparent;
}
.wuerfel button svg { display: block; width: 100%; height: auto; overflow: visible; }
.wuerfel button:focus-visible { outline: 2px solid var(--wf-gold); outline-offset: 4px; border-radius: 8px; }

.wf-becher {
  right: clamp(16px, 6vw, 110px); top: 54%;
  width: calc(var(--wf-s) * 1.55);
  z-index: 7;
  transform-origin: 50% 50%;
  transform: translate(var(--bx, 0px), var(--by, 0px)) rotate(var(--ba, 0deg));
  transition: filter 200ms;
  cursor: grab;
  touch-action: none;
}
.wf-becher.gehalten { cursor: grabbing; filter: drop-shadow(0 18px 14px rgba(0, 0, 0, 0.55)) !important; }
.wf-becher.kippt { transition: transform 150ms ease-out, filter 200ms; }
.wf-becher.gleitet { transition: transform 450ms cubic-bezier(0.3, 0.7, 0.3, 1), filter 200ms; }
.wf-becher.rasselt { animation: wf-rasselt 110ms linear infinite; }
@keyframes wf-rasselt { 0%, 100% { translate: 0 0; } 25% { translate: -3px -2px; } 75% { translate: 3px 1px; } }
.wuerfel.er-dran .wf-becher { cursor: default; }

.wf-kasse {
  left: clamp(16px, 6vw, 110px); top: 54%;
  width: calc(var(--wf-s) * 2.3);
}
.wf-kasse-zahl {
  position: absolute; left: 17%; width: 66%; top: 35.5%; height: 27.4%;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 6%;
  box-sizing: border-box;
  font: 700 calc(var(--wf-s) * 0.42) / 1 ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color: #ffd56b; text-shadow: 0 0 6px rgba(255, 190, 60, 0.7);
  pointer-events: none;
}
.wf-kasse-zahl.falsch { color: #ff5a4f; text-shadow: 0 0 6px rgba(255, 60, 40, 0.8); }
.wf-kasse-zahl.nein { animation: wf-nein 420ms ease-out; }
@keyframes wf-nein { 0%, 100% { opacity: 1; } 20%, 60% { opacity: 0.15; } 40%, 80% { opacity: 1; } }
.wf-kasse.klingelt .ka-lade, .wf-kasse.klingelt .ka-lade-griff { animation: wf-lade 700ms ease-out; }
@keyframes wf-lade { 0%, 100% { transform: translateY(0); } 30%, 60% { transform: translateY(9px); } }
.wf-kasse.klingelt .ka-taste { animation: wf-taste 260ms ease-out; }
@keyframes wf-taste { 50% { transform: translateY(5px); } }

.wf-becher.bereit, .wf-kasse.bereit { filter: drop-shadow(0 0 calc(var(--wf-s) * 0.18) rgba(255, 214, 120, 0.75)); }
.wf-becher:not(.bereit), .wf-kasse:not(.bereit) { filter: brightness(0.72) saturate(0.8); }
.wuerfel.er-dran .wf-becher { filter: none; }

.wf-zettel {
  left: clamp(14px, 3vw, 60px); top: calc(clamp(10px, 2vh, 20px) + 64px);
  width: clamp(150px, 15vw, 230px);
  rotate: -3deg;
  transform-origin: 0 0;
  transition: scale 220ms ease, rotate 220ms ease;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
}
.wf-zettel.gross { scale: 1.7; rotate: 0deg; z-index: 6; }
.zt-papier { fill: #efe6cf; }
.zt-nadel { fill: #c9302c; }
.zt-wuerfel { fill: #fffaf0; stroke: #3a3020; stroke-width: 5; }
.zt-auge { fill: #1c1712; }
.zt-auge.eins { fill: #b3202a; }
.zt-gleich { fill: #3a3020; font: 700 18px system-ui, sans-serif; }
.zt-zahl { fill: #1c1712; font: 700 17px ui-monospace, Menlo, monospace; text-anchor: end; }
.zt-strich { stroke: #3a3020; stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.5; }

.wf-ablage {
  position: absolute; z-index: 3; left: 50%; translate: -50% 0;
  top: 60%;
  display: flex; gap: calc(var(--wf-s) * 0.16);
  padding: calc(var(--wf-s) * 0.14) calc(var(--wf-s) * 0.2);
  background: linear-gradient(180deg, #5b3a1e, #3b2213);
  border: 2px solid #1e1006; border-radius: 10px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.55), inset 0 2px 0 rgba(255, 220, 160, 0.15);
}
.wf-ablage i {
  display: block; width: calc(var(--wf-s) * 1.08); height: calc(var(--wf-s) * 1.08);
  border-radius: 9px; background: #24140a; box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.7);
}

.wf-kopf {
  position: absolute; z-index: 4;
  top: calc(env(safe-area-inset-top, 0px) + clamp(8px, 2vh, 20px));
  left: clamp(14px, 3vw, 60px); right: clamp(14px, 3vw, 60px);
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
}
.wf-seite { display: grid; grid-template-columns: auto auto; gap: 5px 12px; align-items: center; opacity: 0.62; transition: opacity 300ms; }
.wf-seite.dran { opacity: 1; }
.wf-er { justify-items: end; }
.wf-zaehler {
  font: 700 clamp(1.1rem, 2.4vw, 1.7rem) / 1 ui-monospace, Menlo, Consolas, monospace;
  background: #0e0d0a; border: 2px solid #5a4a30; border-radius: 6px; padding: 4px 10px;
  color: #ffd56b; text-shadow: 0 0 6px rgba(255, 190, 60, 0.6);
}
.wf-seite.dran .wf-zaehler { border-color: #d9b25a; box-shadow: 0 0 12px rgba(255, 205, 90, 0.45); }
.wf-zaehler em { font-style: normal; font-size: 0.62em; color: #b9a77a; text-shadow: none; }
.wf-zaehler em::before { content: ' / '; }
.wf-balken {
  grid-column: 1 / -1; grid-row: 2; width: 100%; height: 6px; border-radius: 3px; background: #2a2520; overflow: hidden;
}
.wf-balken i { display: block; height: 100%; background: linear-gradient(90deg, #8a6a20, #ffd56b); transform-origin: 0 50%; transform: scaleX(0); transition: transform 500ms ease; }
.wf-er .wf-balken i { background: linear-gradient(90deg, #5a1414, #e0473f); }
.wf-herzen { display: flex; gap: 6px; grid-row: 1; }
.wf-herzen i { width: clamp(22px, 2.4vw, 32px); display: block; }
.wf-herzen svg { display: block; width: 100%; fill: #e0473f; stroke: #5a0d0b; stroke-width: 1.4; filter: drop-shadow(0 0 4px rgba(224, 71, 63, 0.6)); }
.wf-herzen i.weg svg { fill: transparent; stroke: #6a4a44; filter: none; }
.wf-herzen i.bricht { animation: wf-bricht 900ms ease-out; }
@keyframes wf-bricht { 0% { scale: 1.6; } 30% { rotate: -14deg; } 60% { rotate: 10deg; } 100% { scale: 1; rotate: 0deg; } }

.wf-zocker {
  position: absolute; z-index: 2; left: 50%; translate: -50% 0;
  bottom: calc(48% - 16px);
  width: clamp(240px, 26vw, 400px);
  pointer-events: none;
  transform-origin: 50% 100%;
  transition: scale 500ms ease;
}
.wf-zocker svg { display: block; width: 100%; overflow: visible; }
.wuerfel.er-dran .wf-zocker { scale: 1.04; }
.wf-zocker .zk-finger { fill: #7d5a42; stroke: #4a3020; stroke-width: 1; }
.wf-zocker .zk-finger, .wf-zocker .zk-augen, .wf-zocker .zk-hand, .wf-zocker .zk-leib { transform-box: fill-box; transform-origin: 50% 100%; }
.wf-zocker .zk-finger.f0, .wf-zocker .zk-finger.f1, .wf-zocker .zk-finger.f2, .wf-zocker .zk-finger.f3 { animation: zk-trommel 1.5s ease-in-out infinite; }
.wf-zocker .zk-finger.f1 { animation-delay: 0.09s; }
.wf-zocker .zk-finger.f2 { animation-delay: 0.18s; }
.wf-zocker .zk-finger.f3 { animation-delay: 0.27s; }
@keyframes zk-trommel { 0%, 30%, 100% { transform: none; } 12% { transform: translateY(-5px); } }
.wf-zocker .zk-augen { transform-origin: 50% 50%; animation: zk-blinzeln 5.2s infinite; }
@keyframes zk-blinzeln { 0%, 94%, 100% { transform: none; } 96% { transform: scaleY(0.1); } }
.wf-zocker .zk-glut { animation: zk-glut 2.6s ease-in-out infinite; }
@keyframes zk-glut { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.wf-zocker .zk-rauch { fill: rgba(220, 210, 190, 0.25); animation: zk-rauch 3.4s linear infinite; transform-box: fill-box; transform-origin: 50% 50%; }
.wf-zocker .zk-rauch.r2 { animation-delay: 1.7s; }
@keyframes zk-rauch { 0% { transform: translate(0, 0) scale(0.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(14px, -60px) scale(2.6); opacity: 0; } }
.wf-zocker.lacht .zk-leib { animation: zk-lacht 0.28s ease-in-out 4; }
@keyframes zk-lacht { 50% { transform: translateY(-5px); } }
.wf-zocker.haut .zk-hand { animation: zk-haut 0.5s ease-in; }
@keyframes zk-haut { 0% { transform: none; } 40% { transform: translateY(-18px); } 70% { transform: translateY(3px); } 100% { transform: none; } }

.wf-blase {
  position: absolute; z-index: 8; left: 50%; top: 20%;
  max-width: clamp(180px, 22vw, 320px);
  padding: 8px 13px; border-radius: 14px;
  background: #f3ead2; color: #1c1712; border: 2px solid #3a3020;
  font: 600 clamp(13px, 1.25vw, 18px) / 1.3 system-ui, -apple-system, 'Segoe UI', sans-serif;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55);
  opacity: 0; transform: scale(0.85); transform-origin: 0 0;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}
.wf-blase::before {
  content: ''; position: absolute; left: -12px; top: 14px;
  border: 7px solid transparent; border-right: 12px solid #3a3020; border-left: 0;
}
.wf-blase.da { opacity: 1; transform: none; }

.wf-ansage { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }

.wuerfel.verzockt .wf-tisch { animation: wf-rot 1.2s ease-out; }
@keyframes wf-rot { 0%, 30% { filter: hue-rotate(-110deg) saturate(1.6) brightness(0.8); } 100% { filter: none; } }
.wuerfel.heiss .wf-licht { animation: wf-heiss 1.2s ease-out; }
@keyframes wf-heiss { 0%, 40% { background: radial-gradient(ellipse 50% 90% at 50% 40%, rgba(255, 120, 30, 0.55), transparent 70%); } }
.wuerfel.ziel .wf-zaehler { animation: wf-ziel 750ms ease-in-out; }
@keyframes wf-ziel { 50% { scale: 1.15; box-shadow: 0 0 18px rgba(255, 214, 107, 0.9); } }

.wf-wuerfel { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: none; }
.wf-wuerfel svg { display: block; width: 100%; height: 100%; overflow: visible; }
.wf-wuerfel { filter: drop-shadow(0 0 calc(var(--wf-s, 60px) * 0.06) rgba(0, 0, 0, 0.6)); }
.wf-wuerfel .wk-koerper { fill: url(#wk-bein); stroke: #8f8571; stroke-width: 2; }
.wf-wuerfel .wk-auge { fill: #1c1712; opacity: 0; }
.wf-wuerfel .wk-auge.an { opacity: 1; }
.wf-wuerfel[data-auge="1"] .wk-mm { fill: #b3202a; r: 11; }
.wf-wuerfel.im-becher { opacity: 0; pointer-events: none; }
.wf-wuerfel.fliegt { transition: transform 300ms cubic-bezier(0.3, 0.7, 0.3, 1), opacity 200ms; }
.wf-wuerfel.schimmert .wk-koerper { stroke: #f0c35a; stroke-width: 6; filter: drop-shadow(0 0 6px rgba(255, 205, 90, 0.9)); }
.wf-wuerfel.beiseite .wk-koerper { stroke: #f0c35a; stroke-width: 5; }
.wf-wuerfel.fest .wk-koerper { fill: #d9d0bb; stroke: #6a604c; }
.wf-wuerfel.fest { cursor: default; }
.wf-wuerfel.verzockt .wk-koerper { fill: #f2c4bd; stroke: #d8262f; stroke-width: 6; }
.wf-wuerfel:focus-visible { outline: 2px solid #f0c35a; outline-offset: 3px; border-radius: 18%; }

@media (prefers-reduced-motion: reduce) {
  .wuerfel.an, .wf-becher.rasselt, .wf-herzen i.bricht, .wf-zocker * { animation: none !important; }
}

html.handy .wf-zettel { width: 92px; top: 52px; left: 10px; }
html.handy .wf-zettel.gross { scale: 2.6; }
html.handy .wf-ablage { top: 57%; }
html.handy .wf-zocker { width: 170px; }
html.handy .wf-blase { max-width: 240px; font-size: 13px; padding: 6px 10px; }
html.handy .wf-becher { top: 44%; right: 14px; }
html.handy .wf-kasse { top: 44%; left: 14px; width: calc(var(--wf-s) * 2.1); }
html.handy .wf-kopf { top: 6px; left: 12px; right: 12px; }
html.handy .wf-zaehler { font-size: 1rem; padding: 2px 8px; }
html.handy .wf-seite { gap: 3px 8px; }
html.handy .wf-herzen i { width: 20px; }
html.handy .wf-lampe { width: 90px; translate: -50% -30%; }
