/* ── Palco 16:9 ────────────────────────────────────────────────
   Disegnato a 1920×1080 e scalato con transform (js/stage.js → --scale):
   stesse proporzioni su portatile, proiettore e TV 4K, senza stirarsi. */
#viewStage {
  overflow: hidden;
  background: radial-gradient(ellipse 60% 55% at 38% 48%, var(--stage-glow), transparent 70%);
}

.stage {
  --row-h: 140px;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  padding: 44px 56px 48px;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Intestazione ──────────────────────────────────────────── */
.stage-head {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 92px;
  margin-bottom: 32px;
}

.stage-head .logo {
  width: 210px;
}

.stage-title {
  flex: 1;
  min-width: 0;
  padding-left: 32px;
  border-left: 1px solid var(--sep);
}

.stage-title .eyebrow {
  font-size: 17px;
  letter-spacing: .16em;
}

.stage-title h1 {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-meta {
  display: flex;
  gap: 12px;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ghost-bg);
  border: 1px solid var(--ghost-border);
  font-size: 19px;
  color: var(--text-sub);
  white-space: nowrap;
}

.chip strong {
  font-size: 23px;
  font-weight: 800;
  color: var(--text-h);
  font-variant-numeric: tabular-nums;
}

.stage-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-tools .icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.stage-tools .icon-btn svg {
  width: 22px;
  height: 22px;
}

/* Stato dei salvataggi sul foglio */
.sync {
  width: 14px;
  height: 14px;
  margin: 0 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent);
  transition: background 200ms ease, box-shadow 200ms ease;
}

.sync[data-state="pending"] {
  background: var(--warn);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 22%, transparent);
  animation: pulse 1.2s ease-in-out infinite;
}

.sync[data-state="error"] {
  background: var(--err);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--err) 25%, transparent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: .45; }
}

/* ── Corpo: slot (3/4) + vincitori (1/4) ───────────────────── */
.stage-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
  gap: 40px;
}

.slot-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Slot ──────────────────────────────────────────────────── */
.cabinet {
  position: relative;
  padding: 30px 44px 44px;
  border-radius: 34px;
  background: var(--face-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.30);
}

/* Bordo sfumato blu */
.cabinet::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg, rgba(77, 184, 255, 0.75), rgba(10, 102, 194, 0.12) 38%, rgba(10, 102, 194, 0.12) 62%, rgba(77, 184, 255, 0.6));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

.reel-labels,
.reels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 20px;
}

.reel-labels {
  margin-bottom: 14px;
}

.reel-labels span {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-eyebrow);
}

.reels {
  position: relative;
  height: calc(var(--row-h) * 3);
}

.reel {
  position: relative;
  min-width: 0;
  border-radius: 22px;
  background: var(--reel-bg);
  border: 1px solid var(--reel-border);
  box-shadow: inset 0 18px 30px var(--reel-shadow), inset 0 -18px 30px var(--reel-shadow);
  overflow: hidden;
}

/* Le righe sopra e sotto restano leggibili ma sfumate */
.reel-window {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .22) 0%, rgba(0, 0, 0, .5) 22%, #000 34%, #000 66%, rgba(0, 0, 0, .5) 78%, rgba(0, 0, 0, .22) 100%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .22) 0%, rgba(0, 0, 0, .5) 22%, #000 34%, #000 66%, rgba(0, 0, 0, .5) 78%, rgba(0, 0, 0, .22) 100%);
}

.reel-strip {
  will-change: transform;
}

.cell {
  height: var(--row-h);
  line-height: var(--row-h);
  padding: 0 26px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--reel-text);
}

/* Linea vincente sulla riga centrale */
.payline {
  position: absolute;
  left: -30px;
  right: -30px;
  top: var(--row-h);
  height: var(--row-h);
  border-top: 2px solid var(--payline);
  border-bottom: 2px solid var(--payline);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--payline) 7%, transparent) 12%, color-mix(in srgb, var(--payline) 7%, transparent) 88%, transparent);
  box-shadow: 0 0 34px var(--payline-glow), inset 0 0 34px color-mix(in srgb, var(--payline) 10%, transparent);
  pointer-events: none;
  transition: opacity 300ms ease;
}

.payline::before,
.payline::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  transform: translateY(-50%);
  filter: drop-shadow(0 0 10px var(--payline-glow));
}

.payline::before {
  left: -2px;
  border-left: 22px solid var(--payline);
}

.payline::after {
  right: -2px;
  border-right: 22px solid var(--payline);
}

.reels.is-spinning .payline {
  opacity: .55;
}

.reels.is-win .payline {
  animation: paylineWin 1.1s ease-in-out 3;
}

.reels.is-win .reel-strip .cell:nth-child(2) {
  color: #fff;
  text-shadow: 0 0 22px var(--payline-glow);
}

:root:not(.dark) .reels.is-win .reel-strip .cell:nth-child(2) {
  color: #0a66c2;
  text-shadow: none;
}

.reels.is-rejected .reel-strip .cell:nth-child(2) {
  opacity: .4;
}

.reels.is-rejected .payline {
  border-color: var(--text-muted);
  box-shadow: none;
}

.reels.is-rejected .payline::before {
  border-left-color: var(--text-muted);
}

.reels.is-rejected .payline::after {
  border-right-color: var(--text-muted);
}

@keyframes paylineWin {
  50% {
    box-shadow: 0 0 70px var(--payline-glow), 0 0 140px var(--payline-glow), inset 0 0 50px color-mix(in srgb, var(--payline) 18%, transparent);
  }
}

/* ── Annuncio e comandi sotto la slot ──────────────────────── */
.announce {
  min-height: 150px;
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.announce .eyebrow {
  font-size: 18px;
  letter-spacing: .18em;
}

.announce-name {
  max-width: 100%;
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.announce-company {
  max-width: 100%;
  font-size: 27px;
  color: var(--text-sub);
  overflow-wrap: anywhere;
}

.announce-note {
  font-size: 26px;
  color: var(--text-sub);
}

.announce.is-win .eyebrow {
  color: var(--gold);
}

.announce.is-rejected .announce-name {
  color: var(--text-sub);
  text-decoration: line-through;
  text-decoration-thickness: 3px;
}

.announce.is-enter > * {
  animation: riseIn 520ms cubic-bezier(.2, .8, .2, 1) both;
}

.announce.is-enter > :nth-child(2) { animation-delay: 70ms; }
.announce.is-enter > :nth-child(3) { animation-delay: 140ms; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
}

.stage-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 22px;
  min-height: 80px;
}

.btn-xl {
  min-width: 300px;
  height: 80px;
  padding: 0 44px;
  border-radius: 22px;
  font-size: 25px;
  gap: 14px;
}

.btn-xl kbd {
  font-size: 15px;
}

.spin-note {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 24px;
  color: var(--text-sub);
}

.spin-note .loader-spinner {
  width: 26px;
  height: 26px;
}

/* ── Vincitori ─────────────────────────────────────────────── */
.winners {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 28px 26px 26px;
  border-radius: 30px;
}

.winners-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--sep);
}

.trophy {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  color: var(--gold);
  flex-shrink: 0;
}

.trophy svg {
  width: 26px;
  height: 26px;
}

.winners-head h2 {
  flex: 1;
  font-size: 30px;
  font-weight: 800;
}

.winners-head .chip {
  padding: 6px 14px;
}

.winners-list {
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.winners-list::-webkit-scrollbar {
  display: none;
}

.winners-list.is-scrolled {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 56px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 56px);
}

.w-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 16px;
  border-radius: 18px;
  border: 1px solid var(--area-border);
  background: var(--area-bg);
  flex-shrink: 0;
}

.w-item.is-new {
  animation: winnerIn 700ms cubic-bezier(.2, .8, .2, 1) both, winnerGlow 2.4s ease-out 1;
}

@keyframes winnerIn {
  from { opacity: 0; transform: translateX(40px) scale(.96); }
}

@keyframes winnerGlow {
  0%, 30% { border-color: var(--payline); box-shadow: 0 0 30px var(--payline-glow); }
}

.w-num {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a66c2, #4db8ff);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.w-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.w-name {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.w-company {
  font-size: 18px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.winners-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text-sub);
  padding: 0 20px;
}

.winners-empty svg {
  width: 54px;
  height: 54px;
  opacity: .35;
}

.winners-empty strong {
  font-size: 23px;
  color: var(--text-h);
}

.winners-empty span {
  font-size: 18px;
  line-height: 1.5;
}

.winners-foot {
  padding-top: 18px;
}

.winners-foot .btn {
  height: 64px;
  font-size: 20px;
  border-radius: 18px;
}

/* ── Schermata finale ──────────────────────────────────────── */
.finale {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 70px 90px 56px;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 60% 50% at 50% 40%, var(--stage-glow), transparent 70%), radial-gradient(circle, var(--bg-dot) 1px, transparent 1px);
  background-size: auto, 26px 26px;
  animation: fadeIn 500ms ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
}

.finale .logo {
  width: 200px;
  margin-bottom: 34px;
}

.finale h2 {
  font-size: 88px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(120deg, #4db8ff, #ffffff 55%, #4db8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

:root:not(.dark) .finale h2 {
  background-image: linear-gradient(120deg, #0a66c2, #0b1629 55%, #0a66c2);
}

.finale-sub {
  margin-top: 14px;
  font-size: 28px;
  color: var(--text-sub);
}

.finale-grid {
  --cols: 1;
  margin-top: 48px;
  width: 100%;
  max-width: calc(var(--cols) * 560px + (var(--cols) - 1) * 22px);
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 16px 22px;
  align-content: start;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.finale-grid .w-item {
  padding: 16px 20px;
  animation: riseIn 600ms cubic-bezier(.2, .8, .2, 1) both;
}

.finale-grid .w-name {
  font-size: 28px;
}

.finale-grid .w-company {
  font-size: 20px;
}

.finale-foot {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 26px;
}

.finale-foot .btn {
  font-size: 17px;
  padding: 14px 24px;
  border-radius: 14px;
}

.finale-foot .msg-warn {
  font-size: 17px;
}

/* ── Dialog dentro il palco: scala con lui ─────────────────── */
.stage .pd-wrap {
  position: absolute;
  z-index: 40;
}

.stage .pd-sheet {
  width: 680px;
  max-width: none;
  padding: 34px 36px 36px;
  gap: 20px;
  border-radius: 28px;
}

.stage .pd-title {
  font-size: 30px;
}

.stage .pd-body {
  font-size: 22px;
}

.stage .pd-actions .btn {
  padding: 20px;
  font-size: 21px;
  border-radius: 16px;
}
