/* LocGaming: stile arcade condiviso (caricamento, menù, ruota) */
:root {
  --bg: #07060d;
  --panel: #0f0d1c;
  --line: #2a2350;
  --green: #4db84d;
  --green-hi: #7cf07c;
  --green-dark: #2d7a2d;
  --cyan: #22e6ff;
  --pink: #ff3cac;
  --gold: #e0c07a;
  --blue: #2f8cff;
  --red: #ff4d5e;
  --text: #f1f0ff;
  --muted: #9a96b8;
  --pixel: 'Press Start 2P', monospace;
  --sans: 'Rajdhani', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
}

/* righe del vecchio monitor */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .2) 0, rgba(0, 0, 0, .2) 1px, transparent 1px, transparent 3px);
}

/* sfondo: cielo viola, bagliore all'orizzonte e pavimento a griglia che scorre verso chi guarda.
   Il piano è molto alto e inclinato: in prospettiva l'orizzonte cade a circa 350 px dal fondo, su ogni schermo. */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 38% at 50% 70%, rgba(255, 60, 172, .2), transparent 70%),
    radial-gradient(ellipse at 50% 0%, #2a1450 0%, var(--bg) 60%);
}
.bg-grid::before {
  content: "";
  position: absolute;
  left: -150%;
  right: -150%;
  bottom: 0;
  height: 300vh;
  background-image:
    linear-gradient(rgba(255, 60, 172, .55) 3px, transparent 3px),
    linear-gradient(90deg, rgba(34, 230, 255, .4) 3px, transparent 3px);
  background-size: 80px 80px;
  transform: perspective(800px) rotateX(60deg);
  transform-origin: 50% 100%;
  animation: grid 2.5s linear infinite;
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 12%, transparent 45%);
  mask-image: linear-gradient(to top, #000 0%, #000 12%, transparent 45%);
}
@keyframes grid { to { background-position: 0 80px, 0 0; } }

.hidden { display: none !important; }
.pixel { font-family: var(--pixel); }
.neon { color: var(--green-hi); text-shadow: 0 0 8px rgba(124, 240, 124, .8), 4px 4px 0 var(--pink); }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* pulsanti */
.btn {
  font-family: var(--pixel);
  font-size: 12px;
  letter-spacing: 1px;
  line-height: 1.4;
  color: #0b0b12;
  background: var(--green-hi);
  border: 3px solid #0b0b12;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--green-dark);
  transition: transform .05s, box-shadow .05s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--green-dark); }
.btn.alt { background: var(--cyan); box-shadow: 0 5px 0 #0a7f91; }
.btn.alt:active { box-shadow: 0 1px 0 #0a7f91; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); box-shadow: none; }
.btn.danger { background: var(--red); color: #fff; box-shadow: 0 5px 0 #8a1f2a; }
.btn:disabled { opacity: .45; cursor: wait; }
.btn:focus-visible, .tab:focus-visible, .icon-btn:focus-visible, .reroll:focus-visible, .menu-item:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 2px;
}

.icon-btn {
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--cyan);
  background: #05040a;
  border: 2px solid var(--line);
  padding: 9px 10px;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--cyan); }
.icon-btn.off { color: var(--muted); text-decoration: line-through; }

.disclaimer {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
  line-height: 1.4;
  padding: 0 16px;
}

/* ---------- schermata di caricamento ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  padding: 16px;
  overflow: hidden;
}
#loading { cursor: pointer; }
#loading .bgsplash {
  position: absolute;
  inset: -20px;
  background-size: cover;
  background-position: center;
  filter: blur(6px) brightness(.32) saturate(1.3);
  z-index: -1;
}
.load-head { font-size: clamp(12px, 1.6vw, 22px); color: var(--green-hi); text-shadow: 3px 3px 0 #000; }
.load-row { display: flex; gap: 1.1vw; justify-content: center; }
.lcard {
  width: min(17vw, 20vh, 200px);
  aspect-ratio: 308 / 560;
  position: relative;
  background: #000;
  border: 3px solid var(--line);
  overflow: hidden;
}
.row-blue .lcard { border-color: var(--blue); }
.row-red .lcard { border-color: var(--red); }
.lcard img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s; }
.lcard img.on { opacity: 1; }
.lcard .cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 6px 7px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .92) 45%);
}
.lcard .cap b { display: block; font-weight: 700; font-size: clamp(10px, 1vw, 16px); line-height: 1.1; }
.bar { height: 6px; background: #1b1830; margin-top: 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--green-hi); transition: width .15s linear; }
.vs { font-family: var(--pixel); font-size: clamp(14px, 2vw, 28px); color: var(--gold); text-shadow: 3px 3px 0 #000; }
.load-hint { font-size: clamp(8px, .9vw, 12px); color: var(--muted); }

/* ---------- menù ---------- */
#menu { gap: 1.6vh; }
#menu .logo { width: min(230px, 40vw, 25vh); filter: drop-shadow(0 0 18px rgba(124, 240, 124, .45)); }
.title { font-family: var(--pixel); font-size: clamp(26px, 6vw, 76px); margin: 0; letter-spacing: 2px; }
.subtitle { font-family: var(--pixel); font-size: clamp(9px, 1.1vw, 14px); color: var(--cyan); letter-spacing: 3px; text-align: center; }
.menu-list { display: flex; flex-direction: column; gap: 14px; width: min(620px, 100%); margin-top: 2vh; }
.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-family: var(--pixel);
  font-size: clamp(10px, 1.3vw, 17px);
  line-height: 1.5;
  padding: 16px 18px 16px 44px;
  color: var(--text);
  text-decoration: none;
  border: 3px solid var(--line);
  background: rgba(15, 13, 28, .88);
  position: relative;
  cursor: pointer;
  user-select: none;
}
.menu-item::before { content: "\25B6"; position: absolute; left: 14px; color: var(--pink); opacity: 0; }
.menu-item.sel { border-color: var(--green-hi); box-shadow: 0 0 18px rgba(124, 240, 124, .35); }
.menu-item.sel::before { opacity: 1; animation: blink .6s steps(1) infinite; }
.menu-item.locked { color: var(--muted); }
.menu-item .tag { font-size: .65em; color: var(--gold); white-space: nowrap; }
.menu-item.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.credit { font-family: var(--pixel); font-size: 12px; color: var(--gold); margin-top: 1vh; }
.mute-float { position: fixed; top: 14px; right: 14px; z-index: 50; }

/* ---------- ruota ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 3px solid var(--line);
  background: rgba(7, 6, 13, .92);
  flex-wrap: wrap;
  position: relative;
  z-index: 5;
}
.topbar .back { font-family: var(--pixel); font-size: 11px; color: var(--cyan); text-decoration: none; }
.topbar h1 { font-family: var(--pixel); font-size: clamp(10px, 1.2vw, 15px); margin: 0 auto 0 10px; color: var(--green-hi); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  font-family: var(--pixel);
  font-size: 11px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  border: 2px solid var(--line);
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.on { color: #0b0b12; background: var(--pink); border-color: var(--pink); }

.layout { display: grid; grid-template-columns: 290px 1fr; min-height: calc(100vh - 62px); }
.layout.full { grid-template-columns: 1fr; }
.layout.full .setup { display: none; }
.setup {
  padding: 16px;
  border-right: 3px solid var(--line);
  background: rgba(15, 13, 28, .75);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.setup label { font-family: var(--pixel); font-size: 10px; color: var(--cyan); }
.setup textarea {
  width: 100%;
  min-height: 320px;
  flex: 1;
  background: #05040a;
  color: var(--text);
  border: 2px solid var(--line);
  font: 600 18px/1.45 var(--sans);
  padding: 10px;
  resize: vertical;
}
.setup textarea:focus { outline: none; border-color: var(--cyan); }
.count { font-size: 16px; font-weight: 600; color: var(--muted); }
.count.warn { color: var(--red); }
.opt { display: flex; flex-direction: column; gap: 7px; }
.opt label, .opt-label { font-family: var(--pixel); font-size: 10px; color: var(--cyan); }
.stepper { display: flex; }
.stepper button {
  width: 44px;
  height: 44px;
  font-family: var(--pixel);
  font-size: 16px;
  background: #05040a;
  color: var(--green-hi);
  border: 2px solid var(--line);
  cursor: pointer;
}
.stepper button:hover { border-color: var(--green-hi); }
.stepper input {
  width: 72px;
  height: 44px;
  text-align: center;
  background: #05040a;
  color: var(--text);
  border: 2px solid var(--line);
  border-left: 0;
  border-right: 0;
  font: 700 24px var(--sans);
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; border-color: var(--cyan); }
.seg { display: flex; }
.seg button {
  flex: 1;
  font-family: var(--pixel);
  font-size: 10px;
  padding: 12px 6px;
  background: #05040a;
  color: var(--muted);
  border: 2px solid var(--line);
  cursor: pointer;
}
.seg button + button { border-left: 0; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--pink); border-color: var(--pink); color: #0b0b12; }

.stage-wrap { display: flex; flex-direction: column; gap: 18px; padding: 18px 16px 24px; min-width: 0; }
.stage-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.stage { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.empty { font-family: var(--pixel); font-size: 12px; color: var(--muted); text-align: center; line-height: 2.2; margin-top: 8vh; max-width: 560px; }
.note { font-size: 16px; color: var(--gold); text-align: center; }

.match { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; width: 100%; max-width: 1200px; }
.match.solo { grid-template-columns: minmax(0, 560px); justify-content: center; }
.match-title { grid-column: 1 / -1; font-family: var(--pixel); font-size: 12px; color: var(--gold); text-align: center; }
.vs-mid { font-family: var(--pixel); font-size: 22px; color: var(--gold); align-self: center; text-shadow: 3px 3px 0 #000; }
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; width: 100%; max-width: 1200px; }
.team { border: 3px solid var(--line); background: rgba(15, 13, 28, .9); min-width: 0; }
.team h3 { margin: 0; font-family: var(--pixel); font-size: 12px; padding: 10px 12px; color: #fff; background: #241e45; }
.team.blu { border-color: var(--blue); }
.team.blu h3 { background: var(--blue); }
.team.rosso { border-color: var(--red); }
.team.rosso h3 { background: var(--red); }
.slot { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; border-top: 2px solid #1a1630; min-height: 54px; }
.slot .name { flex: 1; font-weight: 700; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.slot .rname { font-family: var(--pixel); font-size: 10px; color: var(--gold); width: 74px; flex: none; }
.slot .role { width: 32px; height: 32px; flex: none; }
.slot .role.none { visibility: hidden; }
.spinning .name, .spinning .rname { color: var(--muted); }
.landed { animation: lock .45s; }
@keyframes lock { 0% { background-color: rgba(124, 240, 124, .5); } 100% { background-color: transparent; } }

.reroll {
  font-size: 17px;
  line-height: 1;
  width: 36px;
  height: 36px;
  flex: none;
  border: 2px solid var(--line);
  background: #05040a;
  color: var(--cyan);
  cursor: pointer;
}
.reroll:hover { border-color: var(--cyan); }

.bench { width: 100%; max-width: 1200px; border: 3px dashed var(--line); padding: 10px 12px; background: rgba(15, 13, 28, .9); }
.bench h4 { font-family: var(--pixel); font-size: 11px; color: var(--muted); margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); padding: 4px 4px 4px 10px; font-weight: 700; font-size: 19px; }

/* campioni: carte come nel caricamento di una partita */
.champ-board { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; }
.crow { display: flex; flex-direction: column; gap: 8px; align-items: center; width: 100%; }
.crow h3 { margin: 0; font-family: var(--pixel); font-size: 12px; padding: 7px 12px; color: #fff; background: #241e45; }
.crow.blu h3 { background: var(--blue); }
.crow.rosso h3 { background: var(--red); }
.cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.ccard {
  width: min(16vw, 18vh, 190px);
  min-width: 96px;
  aspect-ratio: 308 / 560;
  position: relative;
  background: #000;
  border: 3px solid var(--line);
  overflow: hidden;
}
.crow.blu .ccard { border-color: var(--blue); }
.crow.rosso .ccard { border-color: var(--red); }
.ccard .icon { position: absolute; left: 50%; top: 38%; width: 62%; transform: translate(-50%, -50%); image-rendering: pixelated; }
.ccard .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.ccard .art.on { opacity: 1; }
.ccard.spinning .art { opacity: 0 !important; }
.ccard .crole { position: absolute; top: 5px; left: 5px; width: 32px; height: 32px; padding: 3px; background: rgba(5, 4, 10, .82); border: 1px solid var(--gold); }
.ccard .reroll { position: absolute; top: 5px; right: 5px; width: 32px; height: 32px; font-size: 15px; background: rgba(5, 4, 10, .8); }
.ccard .cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 24px 6px 7px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .92) 40%);
  text-align: center;
}
.ccard .cname { display: block; font-family: var(--pixel); font-size: clamp(8px, .75vw, 11px); line-height: 1.5; color: var(--gold); }
.ccard .pname { display: block; font-weight: 700; font-size: clamp(13px, 1.1vw, 19px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard.landed { animation: cardlock .5s; }
@keyframes cardlock { 0% { box-shadow: 0 0 0 4px var(--green-hi), 0 0 30px var(--green-hi); } 100% { box-shadow: none; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 30px);
  opacity: 0;
  font-family: var(--pixel);
  font-size: 11px;
  line-height: 1.5;
  padding: 12px 16px;
  background: #0b0b12;
  border: 3px solid var(--green-hi);
  color: var(--green-hi);
  transition: opacity .2s, transform .2s;
  z-index: 60;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .setup { border-right: 0; border-bottom: 3px solid var(--line); }
  .setup textarea { min-height: 160px; }
  .match { grid-template-columns: 1fr; }
  .vs-mid { justify-self: center; }
  .topbar h1 { flex-basis: 100%; order: 3; margin: 4px 0 0; }
}
@media (max-width: 520px) {
  .load-row { gap: 4px; }
  .lcard .cap b { font-size: 9px; }
  .menu-item { padding: 14px 12px 14px 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-grid::before { animation: none; }
}
