/* Automat. Rozměry válců jsou proměnné, JS si skutečné pixely čte z DOM. */

body {
  overflow-x: hidden;
}

.top,
.stage {
  position: relative;
  z-index: 1;
}

:root {
  --card-h: clamp(170px, calc((100vh - 470px) / 1.5), 360px);
  --card-w: calc(var(--card-h) * 0.75);
  --card-gap: 12px;
  --win-h: calc(var(--card-h) * 1.5);
  --pig: calc(var(--card-h) * 0.62);
  --snout-w: clamp(180px, 24vh, 290px);
}

/* ── Hlavička ─────────────────────────────────────────── */

.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 8px 24px;
  padding: 16px 24px 8px;
}
.title {
  white-space: nowrap;
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 0 18px rgba(231, 0, 255, 0.45);
}
.title span {
  color: var(--brand);
}
.tagline {
  margin: 0;
  color: var(--dim);
  font-size: 15px;
  padding-bottom: 3px;
}
.tools {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tools #mute[aria-pressed='true'] {
  color: var(--placeholder);
  text-decoration: line-through;
}

/* ── Výběr slotu ──────────────────────────────────────── */

.stage {
  padding: 4px 16px 32px;
}
.slots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 18px;
}
.slot {
  min-width: 132px;
  padding: 9px 16px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}
.slot:hover {
  background: var(--hover);
}
.slot-name {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.slot-count {
  font-size: 12px;
  color: var(--dim);
}
.slot kbd {
  font: inherit;
  font-size: 11px;
  color: var(--placeholder);
}
.slot[aria-checked='true'] {
  border-color: var(--brand);
  color: var(--brand);
  background: rgba(231, 0, 255, 0.08);
  box-shadow:
    0 0 0 1px var(--brand) inset,
    0 0 22px rgba(231, 0, 255, 0.35);
}
.slot[aria-checked='true'] .slot-count {
  color: var(--text);
}
.slot.empty .slot-count {
  color: var(--red);
}
.slot:disabled {
  cursor: not-allowed;
}

/* ── Automat ──────────────────────────────────────────── */

.machine {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  margin: 0 auto;
}

.mascot {
  position: absolute;
  bottom: calc(var(--snout-w) * 0.62);
  width: calc(var(--card-h) * 0.82);
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.6));
  animation: bob 3.2s ease-in-out infinite;
}
.mascot-left {
  left: calc(var(--card-h) * -0.86);
  transform-origin: bottom center;
}
.mascot-right {
  right: calc(var(--card-h) * -0.84);
  bottom: calc(var(--snout-w) * 0.95);
  animation-delay: -1.6s;
}
.machine.spinning .mascot {
  animation: wiggle 0.32s ease-in-out infinite alternate;
}
.machine.win .mascot {
  animation: hop 0.45s ease-out 3;
}
@keyframes bob {
  50% {
    translate: 0 -10px;
    rotate: -2deg;
  }
}
@keyframes wiggle {
  from {
    rotate: -6deg;
    translate: 0 -4px;
  }
  to {
    rotate: 6deg;
    translate: 0 4px;
  }
}
@keyframes hop {
  40% {
    translate: 0 -38px;
    rotate: -8deg;
  }
}

.cabinet {
  position: relative;
  z-index: 2;
  padding: 10px 26px 16px;
  border: 12px solid transparent;
  border-radius: 10px;
  background:
    linear-gradient(180deg, #221b33, var(--card) 40%, #130f1d) padding-box,
    var(--hazard-stripes) border-box;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(231, 0, 255, 0.25),
    0 30px 60px rgba(0, 0, 0, 0.55);
}

.marquee {
  text-align: center;
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: clamp(14px, 1.8vh, 18px);
  color: var(--brand);
  text-shadow:
    0 0 6px rgba(231, 0, 255, 0.9),
    0 0 18px rgba(231, 0, 255, 0.6);
  margin: 4px 0 10px;
}
.marquee span {
  color: var(--hazard);
  text-shadow: 0 0 8px rgba(255, 224, 0, 0.7);
}
.machine.win .marquee {
  animation: neon-flash 0.18s steps(2) 8;
}
@keyframes neon-flash {
  50% {
    color: var(--text);
    text-shadow: 0 0 24px #fff;
  }
}

.bulbs {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
}
.bulbs-bottom {
  margin-top: 10px;
}
.bulb {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4a3a1a;
  box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.6);
  animation: twinkle 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.31s);
}
@keyframes twinkle {
  50% {
    background: var(--hazard);
    box-shadow: 0 0 10px var(--hazard);
  }
}
.machine.spinning .bulb {
  animation: chase 0.5s steps(1) infinite;
  animation-delay: calc(var(--i) * -0.125s);
}
@keyframes chase {
  0%,
  24% {
    background: var(--brand);
    box-shadow: 0 0 12px var(--brand);
  }
  25%,
  100% {
    background: #3a1d40;
    box-shadow: none;
  }
}
.machine.win .bulb {
  animation: blink-all 0.2s steps(1) 10;
}
@keyframes blink-all {
  0% {
    background: var(--hazard);
    box-shadow: 0 0 14px var(--hazard);
  }
  50% {
    background: var(--brand);
    box-shadow: 0 0 14px var(--brand);
  }
}

.reels {
  display: flex;
  gap: 14px;
  align-items: center;
}

.reel {
  position: relative;
  height: var(--win-h);
  overflow: hidden;
  border-radius: 6px;
  background: #0b0812;
  border: 1px solid var(--line);
}
.reel::after {
  /* hloubka bubnu: stín nahoře a dole */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    180deg,
    rgba(5, 3, 10, 0.92) 0%,
    rgba(5, 3, 10, 0) 26%,
    rgba(5, 3, 10, 0) 74%,
    rgba(5, 3, 10, 0.92) 100%
  );
}
.strip {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  will-change: transform;
}

.reel-skin {
  width: calc(var(--card-w) + 28px);
}
.reel-pig {
  width: calc(var(--pig) + 12px);
}

.card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  margin: 0 auto var(--card-gap);
  border-radius: 6px;
  overflow: hidden;
  background: #120e1c;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 10px 9px;
  background: linear-gradient(180deg, transparent, rgba(8, 5, 14, 0.94) 45%);
  font-weight: 600;
  font-size: clamp(13px, 1.7vh, 16px);
  line-height: 1.2;
  text-align: center;
}
.card.nophoto {
  background:
    radial-gradient(circle at 50% 35%, rgba(231, 0, 255, 0.35), transparent 65%),
    linear-gradient(160deg, #2a1838, #120e1c);
}
.card.nophoto img {
  object-fit: contain;
  padding: 8% 10% 34%;
}
.card.nophoto .card-name {
  font-size: clamp(16px, 2.2vh, 21px);
  background: none;
  bottom: 8%;
}
.card-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--hazard);
  padding: 1px 6px;
  border-radius: 2px;
}
.card.idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, rgba(0, 150, 255, 0.22), transparent 65%), #120e1c;
}
.card.idle img {
  width: 62%;
  height: auto;
  animation: bob 2.6s ease-in-out infinite;
}
.card.idle .card-name {
  position: static;
  background: none;
  padding: 10px 14px 0;
  color: var(--dim);
  font-weight: 600;
}
.card.idle .card-name strong {
  display: block;
  color: var(--text);
  font-size: 1.15em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.card.empty img {
  width: 92%;
  animation: none;
}

.symbol {
  width: var(--pig);
  height: var(--pig);
  margin: 0 auto 8px;
  display: block;
  object-fit: contain;
}

.payline {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: calc(var(--card-w) + 10px);
  height: calc(var(--card-h) + 10px);
  translate: -50% -50%;
  border: 2px solid var(--brand);
  border-radius: 8px;
  box-shadow:
    0 0 14px rgba(231, 0, 255, 0.55),
    inset 0 0 14px rgba(231, 0, 255, 0.35);
  pointer-events: none;
}
.payline::before,
.payline::after {
  content: '';
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  border: 9px solid transparent;
}
.payline::before {
  left: -2px;
  border-left-color: var(--brand);
}
.payline::after {
  right: -2px;
  border-right-color: var(--brand);
}
.machine.win .payline {
  animation: payline-win 0.24s steps(2) 6;
}
@keyframes payline-win {
  50% {
    border-color: var(--hazard);
    box-shadow:
      0 0 30px rgba(255, 224, 0, 0.8),
      inset 0 0 20px rgba(255, 224, 0, 0.5);
  }
}

.pool {
  text-align: center;
  margin-top: 10px;
  font-size: 14px;
  color: var(--dim);
  min-height: 1.45em;
}
.pool strong {
  color: var(--text);
}

/* ── Rypáček ──────────────────────────────────────────── */

.snout {
  position: relative;
  z-index: 4;
  width: var(--snout-w);
  aspect-ratio: 800 / 610;
  margin-top: calc(var(--snout-w) * -0.14);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 0 18px rgba(231, 0, 255, 0.55)) drop-shadow(0 14px 18px rgba(0, 0, 0, 0.6));
  animation: breathe 2.2s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.snout img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}
.snout-down {
  visibility: hidden;
}
.snout.pressed .snout-down,
.snout:active .snout-down {
  visibility: visible;
}
.snout.pressed .snout-up,
.snout:active .snout-up {
  visibility: hidden;
}
.snout.pressed,
.snout:active {
  scale: 0.93;
  animation: none;
}
.snout-label {
  position: absolute;
  left: 0;
  right: 0;
  top: 15%;
  text-align: center;
  font-weight: 700;
  font-size: calc(var(--snout-w) * 0.11);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.snout:disabled {
  cursor: default;
  animation: none;
}
.machine.spinning .snout {
  filter: drop-shadow(0 0 8px rgba(231, 0, 255, 0.3)) drop-shadow(0 10px 14px rgba(0, 0, 0, 0.6));
}
@keyframes breathe {
  50% {
    scale: 1.04;
    filter: drop-shadow(0 0 30px rgba(231, 0, 255, 0.85)) drop-shadow(0 14px 18px rgba(0, 0, 0, 0.6));
  }
}

/* ── Historie ─────────────────────────────────────────── */

.history {
  max-width: 900px;
  margin: 22px auto 0;
}
.history h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 8px;
  text-align: center;
}
.history ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.history li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 14px;
}
.history li time {
  color: var(--placeholder);
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
.history li b {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  margin-right: 6px;
}
.history .history-empty {
  color: var(--placeholder);
  border-style: dashed;
}

/* ── Výsledek ─────────────────────────────────────────── */

.result {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 3, 10, 0.74);
  backdrop-filter: blur(5px);
  animation: fade-in 0.2s ease-out;
}
.result[hidden] {
  display: none;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.result-card {
  position: relative;
  width: min(880px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 300px) 1fr;
  background: var(--card);
  border-top: 6px solid transparent;
  border-image: var(--hazard-stripes) 6;
  box-shadow:
    0 0 0 1px var(--line),
    0 0 70px rgba(231, 0, 255, 0.35),
    0 30px 80px rgba(0, 0, 0, 0.6);
  animation: pop-in 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes pop-in {
  from {
    scale: 0.6;
    opacity: 0;
  }
}
.result-photo {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #120e1c;
}
.result-photo .card {
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
}
.result-photo .card-name {
  display: none;
}
.result-body {
  padding: 28px 30px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.result-slot {
  align-self: flex-start;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
  padding: 2px 10px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.result-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.25;
  color: var(--text);
  text-shadow: 0 0 22px rgba(231, 0, 255, 0.5);
  overflow-wrap: anywhere;
}
.result-quip {
  margin: 0;
  font-size: 19px;
  color: var(--hazard);
  font-weight: 600;
}
.result-quip::before {
  content: 'Pupíček: ';
  color: var(--dim);
  font-weight: 400;
}
.result-relay {
  margin: 0;
  color: var(--dim);
  font-size: 15px;
}
.result-next {
  margin-top: auto;
  align-self: flex-start;
  background: var(--brand);
  color: var(--ink);
  border: 0;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(231, 0, 255, 0.5);
}
.result-next kbd {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.7;
  margin-left: 6px;
}
.result-pig {
  position: absolute;
  right: -46px;
  bottom: -40px;
  width: 210px;
  pointer-events: none;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.6));
  animation: pig-in 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) 0.15s both;
}
@keyframes pig-in {
  from {
    translate: 60px 80px;
    rotate: 25deg;
    opacity: 0;
  }
}
.result.sad .result-card {
  box-shadow:
    0 0 0 1px var(--line),
    0 30px 80px rgba(0, 0, 0, 0.6);
}
.result.sad .result-name {
  text-shadow: none;
}

/* ── Konfety ──────────────────────────────────────────── */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}
.confetti > * {
  position: absolute;
  top: -60px;
  left: var(--x);
  animation: fall var(--dur) cubic-bezier(0.25, 0.4, 0.6, 1) var(--delay) forwards;
}
.confetti .tag {
  width: 16px;
  height: 26px;
  background: var(--hazard);
  border-radius: 2px 2px 3px 3px;
  clip-path: polygon(50% 0, 100% 22%, 100% 100%, 0 100%, 0 22%);
}
.confetti .bit {
  width: 10px;
  height: 14px;
  background: var(--c);
}
.confetti img {
  width: 56px;
}
@keyframes fall {
  to {
    translate: var(--dx) 112vh;
    rotate: var(--rot);
  }
}

.toast {
  z-index: 70;
}

/* ── Menší obrazovky ──────────────────────────────────── */

@media (max-width: 1180px) {
  .mascot {
    display: none;
  }
}
@media (max-width: 760px) {
  :root {
    --card-h: clamp(180px, calc((100svh - 400px) / 1.5), 300px);
    --snout-w: clamp(160px, 22svh, 210px);
  }
  .top {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 10px 16px 4px;
  }
  .top .brandline,
  .tagline {
    display: none;
  }
  .title {
    font-size: 24px;
  }
  .slots {
    flex-wrap: nowrap;
    gap: 6px;
    margin: 6px 0 12px;
  }
  .slot-name {
    font-size: 14px;
    letter-spacing: 0.06em;
  }
  .slot-count {
    font-size: 11px;
  }
  .reel-pig {
    display: none;
  }
  .cabinet {
    padding: 8px 14px 12px;
  }
  .slot {
    min-width: 0;
    flex: 1 1 0;
    padding: 7px 4px 6px;
  }
  .slot kbd {
    display: none;
  }
  .result-card {
    grid-template-columns: 1fr;
  }
  .result-photo {
    aspect-ratio: auto;
    height: 34vh;
  }
  .result-pig {
    width: 130px;
    right: -10px;
    bottom: -24px;
  }
}

.result.sad .result-pig {
  display: none;
}
