/* Spielautomat „777“ – bildschirmfüllendes Overlay (public/js/slot.js)
   Look: rotes Gehäuse mit Chromrand, Lauflicht, dunkles Walzenfenster, cremefarbene Panels
   mit 3-px-Rahmen wie im restlichen HUD. Alles in vw/vh skaliert, max. 900 px breit. */

#slot-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(60, 12, 12, .78) 0%, rgba(8, 4, 4, .94) 100%);
  backdrop-filter: blur(4px);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: #2b2b2b; user-select: none; -webkit-user-select: none; touch-action: pan-y;
  --cell: clamp(54px, 11vw, 104px);
  --chrome: linear-gradient(180deg, #ffffff 0%, #c9ced4 30%, #7d848c 50%, #d7dce1 70%, #8d949b 100%);
}
#slot-overlay.hidden { display: none !important; }
#slot-overlay * { box-sizing: border-box; }

/* ------------------------------------------------------------ stage: cabinet + lever */
.slot-stage {
  display: flex; align-items: center; justify-content: center; gap: 0;
  width: min(96vw, 900px); max-height: 98vh; overflow-y: auto; overflow-x: hidden; padding: 6px 0;
}
.slot-cabinet {
  position: relative; flex: 1 1 auto; min-width: 0;
  background: linear-gradient(180deg, #e0392b 0%, #c21f14 45%, #8f0e08 100%);
  border: 6px solid #e4e8ec; border-radius: 26px;
  box-shadow: inset 0 0 0 3px #6c737a, inset 0 0 0 5px #f6f8fa,
              0 0 0 4px #2b2b2b, 0 22px 50px rgba(0, 0, 0, .65), 0 0 60px rgba(255, 120, 40, .25);
  padding: clamp(14px, 2.6vw, 26px) clamp(12px, 2.4vw, 24px);
}
.slot-cabinet.win { animation: cabinet-win .5s ease-in-out 4; }
@keyframes cabinet-win {
  0%, 100% { box-shadow: inset 0 0 0 3px #6c737a, inset 0 0 0 5px #f6f8fa, 0 0 0 4px #2b2b2b, 0 22px 50px rgba(0,0,0,.65), 0 0 60px rgba(255,120,40,.25); }
  50%      { box-shadow: inset 0 0 0 3px #6c737a, inset 0 0 0 5px #fff4b0, 0 0 0 4px #2b2b2b, 0 22px 50px rgba(0,0,0,.65), 0 0 90px rgba(255, 220, 60, .9); }
}

/* chasing-light frame */
.slot-lights { position: absolute; inset: 4px; pointer-events: none; }
.slot-bulb {
  position: absolute; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%;
  background: #ffe27a; border: 2px solid #2b2b2b;
  box-shadow: 0 0 6px 2px rgba(255, 220, 90, .9);
  animation: bulb-chase 1.2s steps(1, end) infinite;
}
.slot-bulb:nth-child(3n + 2) { animation-delay: -.4s; }
.slot-bulb:nth-child(3n + 3) { animation-delay: -.8s; }
@keyframes bulb-chase {
  0%   { background: #ffe27a; box-shadow: 0 0 7px 3px rgba(255, 225, 90, 1); }
  34%  { background: #b2882a; box-shadow: 0 0 1px 0 rgba(255, 225, 90, 0); }
}
.slot-cabinet.win .slot-bulb, .slot-cabinet.jackpot .slot-bulb { animation-duration: .3s; }
.slot-cabinet.jackpot .slot-bulb:nth-child(2n) { background: #ff5a3c; }

/* marquee */
.slot-marquee {
  position: relative; text-align: center; margin: 0 auto 10px;
  background: linear-gradient(180deg, #fff7e6, #f3e4c3); border: 3px solid #2b2b2b; border-radius: 14px;
  box-shadow: 0 5px 0 #2b2b2b; padding: 6px 12px 8px;
}
.slot-marquee .slot-title {
  font-size: clamp(30px, 6.5vw, 54px); font-weight: 900; letter-spacing: 6px; line-height: 1;
  color: #e8541e; text-shadow: 0 3px 0 #2b2b2b, 0 0 14px rgba(255, 140, 40, .6);
}
.slot-marquee .slot-title small { font-size: .45em; letter-spacing: 2px; color: #2b2b2b; text-shadow: none; display: block; margin-top: 2px; }
.slot-display-text {
  margin-top: 6px; font-family: "Courier New", monospace; font-weight: bold; font-size: clamp(11px, 1.6vw, 14px);
  color: #ffd166; background: #1b1b1f; border: 2px solid #2b2b2b; border-radius: 6px; padding: 3px 8px;
  letter-spacing: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ------------------------------------------------------------ body grid */
.slot-body {
  display: grid; gap: 10px clamp(8px, 1.6vw, 16px);
  grid-template-columns: minmax(150px, 190px) 1fr;
  grid-template-areas: "pay reels" "pay displays" "controls controls";
  align-items: start;
}

/* paytable */
.slot-paytable {
  grid-area: pay; background: #fff7e6; border: 3px solid #2b2b2b; border-radius: 12px; box-shadow: 0 5px 0 #2b2b2b;
  padding: 8px 10px; font-size: 12px;
}
.slot-paytable h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: #e8541e; text-align: center; }
.slot-payrow { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 3px 0; border-bottom: 1px solid #e0d6c4; }
.slot-payrow:last-child { border-bottom: none; }
.slot-payrow .slot-paysyms { display: flex; gap: 2px; }
.slot-payrow .slot-paysyms svg { width: 22px; height: 22px; }
.slot-payrow .slot-payval { font-weight: 900; color: #2b2b2b; white-space: nowrap; }
.slot-payrow.jackpot .slot-payval { color: #c0392b; }
.slot-payrow .slot-payany { font-size: 10px; color: #777; margin-left: 2px; }

/* reels */
.slot-reels-wrap {
  grid-area: reels; position: relative; padding: 10px;
  background: var(--chrome); border-radius: 16px; border: 3px solid #2b2b2b; box-shadow: 0 6px 0 #2b2b2b;
}
.slot-reels {
  position: relative; display: flex; gap: 6px; justify-content: center;
  background: #0f1014; border-radius: 10px; padding: 6px;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, .9);
}
.slot-reel {
  position: relative; width: var(--cell); height: calc(var(--cell) * 3); overflow: hidden;
  background: linear-gradient(180deg, #d9d9d9 0%, #ffffff 35%, #ffffff 65%, #d9d9d9 100%);
  border: 2px solid #2b2b2b; border-radius: 6px;
}
.slot-reel::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 28%, rgba(0,0,0,0) 72%, rgba(0,0,0,.55) 100%);
}
.slot-strip { position: absolute; left: 0; top: 0; width: 100%; will-change: transform; }
.slot-cell { width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center; }
.slot-cell svg { width: 82%; height: 82%; display: block; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .25)); }
.slot-reel.blur .slot-strip { filter: blur(1.6px); }
.slot-reel.stopped { animation: reel-land .25s ease-out; }
@keyframes reel-land { 0% { transform: translateY(0); } 40% { transform: translateY(3px); } 100% { transform: translateY(0); } }
.slot-payline {
  position: absolute; left: 0; right: 0; top: 50%; height: 3px; margin-top: -1.5px; pointer-events: none;
  background: rgba(232, 84, 30, .55);
}
.slot-payline::before, .slot-payline::after {
  content: ""; position: absolute; top: -7px; width: 0; height: 0; border: 8px solid transparent;
}
.slot-payline::before { left: -4px; border-left: 10px solid #e8541e; }
.slot-payline::after { right: -4px; border-right: 10px solid #e8541e; }
.slot-reels.win .slot-payline { background: #ffd54a; box-shadow: 0 0 10px #ffd54a; animation: payline-flash .25s steps(1, end) infinite; }
@keyframes payline-flash { 50% { opacity: .2; } }
.slot-reels.win .slot-reel { box-shadow: inset 0 0 0 3px #ffd54a; }

/* displays */
.slot-displays { grid-area: displays; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot-disp {
  background: #fff7e6; border: 3px solid #2b2b2b; border-radius: 10px; box-shadow: 0 4px 0 #2b2b2b; padding: 4px 6px; text-align: center; min-width: 0;
}
.slot-disp label { display: block; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: #777; }
.slot-disp output {
  display: block; font-family: "Courier New", monospace; font-weight: 900; font-size: clamp(13px, 2.2vw, 20px);
  color: #2b2b2b; background: #1b1b1f; border-radius: 5px; margin-top: 2px; padding: 3px 2px; color: #7CFF8A;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot-disp.kasse output { color: #ffe59a; }
.slot-disp.gewinn output { color: #7CFF8A; }
.slot-disp.jackpot output { color: #ff6a5c; }
.slot-disp.flash output { animation: disp-flash .3s steps(1, end) infinite; }
@keyframes disp-flash { 50% { background: #ffd54a; color: #2b2b2b; } }
.slot-disp.shake { animation: disp-shake .4s ease-in-out; }
@keyframes disp-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* controls */
.slot-controls { grid-area: controls; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.slot-bets { display: flex; gap: 6px; }
.slot-bets .slot-bets-label { align-self: center; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: #fff7e6; text-shadow: 0 1px 0 #2b2b2b; margin-right: 2px; }
.slot-bet {
  width: clamp(42px, 8vw, 56px); height: 40px; font-size: 15px; font-weight: 900; cursor: pointer;
  background: #fff7e6; color: #2b2b2b; border: 3px solid #2b2b2b; border-radius: 50%; box-shadow: 0 4px 0 #2b2b2b;
  font-family: inherit;
}
.slot-bet:active { transform: translateY(3px); box-shadow: 0 1px 0 #2b2b2b; }
.slot-bet.active { background: #ffd54a; box-shadow: 0 4px 0 #2b2b2b, 0 0 12px #ffd54a; }
.slot-bet:disabled { opacity: .5; cursor: default; }
.slot-spin {
  flex: 1 1 160px; height: 52px; font-size: clamp(15px, 2.4vw, 20px); font-weight: 900; letter-spacing: 2px; cursor: pointer;
  color: #fff; background: linear-gradient(180deg, #ff7a4a, #e8541e); border: 3px solid #2b2b2b; border-radius: 12px;
  box-shadow: 0 6px 0 #2b2b2b, 0 0 16px rgba(255, 120, 40, .5); font-family: inherit;
}
.slot-spin:active { transform: translateY(4px); box-shadow: 0 2px 0 #2b2b2b; }
.slot-spin:disabled { filter: grayscale(.6) brightness(.8); cursor: default; }
.slot-leave {
  height: 40px; padding: 0 16px; font-size: 14px; font-weight: bold; cursor: pointer; font-family: inherit;
  color: #2b2b2b; background: #fff7e6; border: 3px solid #2b2b2b; border-radius: 10px; box-shadow: 0 4px 0 #2b2b2b;
}
.slot-leave:active { transform: translateY(3px); box-shadow: 0 1px 0 #2b2b2b; }

/* ------------------------------------------------------------ lever */
.slot-lever {
  position: relative; flex: 0 0 auto; width: 74px; height: calc(var(--cell) * 3 + 60px); margin-left: -6px; cursor: grab; touch-action: none;
  --pull: 0px;
}
.slot-lever.dragging { cursor: grabbing; }
.slot-lever .lever-base {
  position: absolute; left: 0; top: 50%; width: 34px; height: 60px; margin-top: -30px;
  background: var(--chrome); border: 3px solid #2b2b2b; border-radius: 0 10px 10px 0; box-shadow: 0 5px 0 #2b2b2b;
}
.slot-lever .lever-base::after {
  content: ""; position: absolute; left: 8px; top: 20px; width: 12px; height: 12px; border-radius: 50%; background: #2b2b2b;
}
.slot-lever .lever-rod {
  position: absolute; left: 32px; width: 12px; top: calc(28px + var(--pull)); bottom: 50%;
  background: var(--chrome); border: 2px solid #2b2b2b; border-radius: 6px 6px 0 0;
}
.slot-lever .lever-knob {
  position: absolute; left: 19px; top: calc(var(--pull)); width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a7a, #d3261a 55%, #7a0c06); border: 3px solid #2b2b2b;
  box-shadow: 0 4px 0 #2b2b2b, inset 0 -4px 6px rgba(0, 0, 0, .3);
}
@property --pull { syntax: '<length>'; inherits: true; initial-value: 0px; }
.slot-lever.pulled { animation: lever-pull .6s ease-in-out; }
@keyframes lever-pull { 0% { --pull: 0px; } 35% { --pull: 110px; } 100% { --pull: 0px; } }
.slot-lever .lever-hint { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 10px; color: #fff7e6; text-shadow: 0 1px 0 #2b2b2b; letter-spacing: 1px; }

/* ------------------------------------------------------------ jackpot banner + confetti */
.slot-jackpot-banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-6deg); z-index: 5; pointer-events: none;
  font-size: clamp(40px, 11vw, 110px); font-weight: 900; letter-spacing: 6px; color: #ffd54a;
  -webkit-text-stroke: 3px #2b2b2b; text-shadow: 0 8px 0 #2b2b2b, 0 0 40px rgba(255, 213, 74, .9);
  animation: jackpot-pop .35s cubic-bezier(.2, 1.6, .4, 1), jackpot-flash .25s steps(1, end) .35s infinite;
}
.slot-jackpot-banner.hidden { display: none; }
.slot-jackpot-banner small { display: block; font-size: .35em; letter-spacing: 3px; color: #fff7e6; -webkit-text-stroke: 1px #2b2b2b; text-shadow: 0 3px 0 #2b2b2b; }
@keyframes jackpot-pop { from { transform: translate(-50%, -50%) rotate(-6deg) scale(.2); } to { transform: translate(-50%, -50%) rotate(-6deg) scale(1); } }
@keyframes jackpot-flash { 50% { color: #fff7e6; } }

.slot-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 4; }
.slot-confetti i {
  position: absolute; top: -14px; width: 10px; height: 14px; opacity: .95; border: 1px solid rgba(0, 0, 0, .35);
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--rot)); opacity: .8; }
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 640px) {
  #slot-overlay { --cell: clamp(50px, 17vw, 80px); }
  .slot-stage { width: 97vw; align-items: flex-start; }
  .slot-cabinet { padding: 12px 10px; border-radius: 18px; }
  .slot-body { grid-template-columns: 1fr; grid-template-areas: "reels" "displays" "controls" "pay"; }
  .slot-paytable { font-size: 11px; }
  .slot-displays { grid-template-columns: repeat(2, 1fr); }
  .slot-lever { width: 56px; margin-left: -4px; margin-top: 80px; }
  .slot-lever .lever-knob { width: 32px; height: 32px; left: 16px; }
  .slot-lever .lever-rod { left: 27px; width: 10px; }
  .slot-lever .lever-base { width: 28px; }
  .slot-marquee .slot-title { letter-spacing: 3px; }
}
@media (max-height: 560px) {
  #slot-overlay { --cell: clamp(40px, 16vh, 80px); }
  .slot-marquee { margin-bottom: 6px; padding: 2px 8px 4px; }
  .slot-marquee .slot-title { font-size: 26px; }
  .slot-paytable { font-size: 10px; padding: 4px 8px; }
  .slot-payrow { padding: 1px 0; }
}

/* spectator mode: watch only – no lever, no bets, no spin button */
#slot-overlay.spectate .slot-lever, #slot-overlay.spectate .slot-bets, #slot-overlay.spectate .slot-spin { display: none !important; }
#slot-overlay.spectate .slot-leave { font-size: 18px; padding: 12px 26px; }
