/* Magma Cup — tabelloni. Palette presa dal volantino: notte vulcanica,
   lava arancio, giallo brace per le etichette, verde lime per "Cup",
   blu del campo da padel. Un solo aspetto scuro, voluto. */

:root {
  --night: #090b15;
  --ash: #11152a;
  --card: #171c34;
  --card-hi: #1e2442;
  --line: #2c3558;
  --court: #1d3b93;
  --lava: #ff4d1a;
  --ember: #ffa51f;
  --gold: #ffc93c;
  --lime: #d4f53c;
  --text: #f6f7fc;
  --muted: #9ba3c6;
  --display: 'Montserrat', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
  --script: 'Permanent Marker', 'Comic Sans MS', cursive;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gap: 34px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font-family: var(--display);
  font-weight: 500;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  background: var(--lime);
  color: var(--night);
  padding: 8px 12px;
}
.skip:focus {
  left: 8px;
}

/* ------------------------------------------------------------ copertina */

.hero {
  position: relative;
  overflow: hidden;
  padding: calc(34px + env(safe-area-inset-top, 0px)) 0 30px;
  background:
    radial-gradient(ellipse 60% 70% at 78% -5%, rgba(255, 120, 30, 0.75), transparent 60%),
    radial-gradient(ellipse 40% 45% at 92% 18%, rgba(255, 60, 20, 0.55), transparent 70%),
    radial-gradient(ellipse 70% 60% at 10% 110%, rgba(29, 59, 147, 0.7), transparent 70%),
    linear-gradient(180deg, #1a0d10 0%, #0d0e1c 55%, var(--night) 100%);
  border-bottom: 1px solid rgba(255, 165, 31, 0.25);
}
.hero__glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* braci: piccoli punti luminosi */
  background-image:
    radial-gradient(2px 2px at 70% 22%, #ffd36b, transparent),
    radial-gradient(2px 2px at 83% 38%, #ff8a3d, transparent),
    radial-gradient(1.5px 1.5px at 62% 12%, #ffb35c, transparent),
    radial-gradient(2px 2px at 90% 8%, #ffe08a, transparent),
    radial-gradient(1.5px 1.5px at 76% 48%, #ff6a2a, transparent),
    radial-gradient(1.5px 1.5px at 55% 30%, #ffcf70, transparent);
  animation: embers 6s ease-in-out infinite alternate;
}
@keyframes embers {
  from {
    opacity: 0.55;
    transform: translateY(0);
  }
  to {
    opacity: 1;
    transform: translateY(-8px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .hero__glow {
    animation: none;
  }
}
.hero__inner {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.hero__row {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 40px);
}
.hero__brand {
  position: relative;
  isolation: isolate;
  min-width: 0;
}
/* il Vesuvio del volantino, dietro la scritta al 30% */
.hero__volcano {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  height: 165%;
  width: auto;
  max-width: none;
  transform: translate(-50%, -52%);
  opacity: 0.3;
  pointer-events: none;
  user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
}
.hero__logo {
  flex: none;
  display: block;
  width: clamp(72px, 15vw, 170px);
  height: auto;
}
.hero__title {
  position: relative;
  margin: 0;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  font-weight: 900;
  font-size: clamp(2.5rem, 11vw, 7.6rem);
  line-height: 0.85;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}
.hero__accent {
  font-family: var(--script);
  font-weight: 400;
  text-transform: none;
  color: var(--lime);
  font-size: 0.92em;
  line-height: 0.8;
  margin-left: 0.04em;
  transform: rotate(-7deg) translateY(-0.12em);
  text-shadow: 0 0 24px rgba(212, 245, 60, 0.35);
}
.hero__edition {
  position: relative;
  margin: 10px 0 0;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(1.05rem, 3.6vw, 1.6rem);
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 22px;
  margin: 26px 0 0;
  max-width: 980px;
}
@media (max-width: 760px) {
  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.fact {
  min-width: 0;
}
.fact dt {
  color: var(--gold);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.fact dd {
  margin: 3px 0 0;
  font-weight: 700;
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.fact a {
  text-decoration: underline;
  text-decoration-color: var(--lime);
  text-underline-offset: 3px;
}

.demo {
  margin: 0;
  padding: 9px var(--gutter);
  background: repeating-linear-gradient(-45deg, rgba(212, 245, 60, 0.12) 0 12px, transparent 12px 24px), #14182b;
  color: var(--lime);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------ categorie */

.cats {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(9, 11, 21, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.cats__track {
  display: flex;
  gap: 8px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.cats__track::-webkit-scrollbar {
  display: none;
}
.cat {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--ash);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background-color 0.15s;
}
.cat:hover {
  border-color: var(--ember);
}
.cat__name {
  font-weight: 800;
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.cat__prize {
  font-size: 0.74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cat[aria-selected='true'] {
  background: linear-gradient(135deg, var(--lava), var(--ember));
  border-color: transparent;
  color: #1a0b05;
}
.cat[aria-selected='true'] .cat__prize {
  color: rgba(26, 11, 5, 0.8);
}

/* ------------------------------------------------------------ tabellone */

.board {
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px 0 30px;
  outline: none;
}
.board__top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 var(--gutter);
}
.board__title {
  margin: 0;
  font-weight: 900;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  text-transform: uppercase;
  line-height: 1;
  text-wrap: balance;
}
.board__prizes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
}
.prize {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ash);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.prize strong {
  color: var(--text);
}
.prize--gold {
  border-color: rgba(255, 201, 60, 0.6);
}
.prize--gold strong {
  color: var(--gold);
}
.prize--muted {
  background: transparent;
}

.days {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.day {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.day:hover {
  border-color: var(--lime);
}
.day__date {
  font-weight: 800;
  font-size: 0.82rem;
}
.day__name {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.scroller {
  margin-top: 22px;
  overflow-x: auto;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 18px var(--gutter);
  scroll-behavior: smooth;
  scrollbar-color: var(--line) transparent;
}
@media (prefers-reduced-motion: reduce) {
  .scroller {
    scroll-behavior: auto;
  }
}
.loading {
  padding: 60px 0;
  color: var(--muted);
}

.bracket {
  display: grid;
  grid-template-columns: repeat(var(--rounds, 4), minmax(238px, 1fr));
  column-gap: var(--gap);
  min-width: calc(var(--rounds, 4) * 238px + (var(--rounds, 4) - 1) * var(--gap));
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 12px;
}
.col.is-flash {
  animation: flash 1.4s ease-out;
}
@keyframes flash {
  0%,
  30% {
    background: rgba(212, 245, 60, 0.08);
  }
  100% {
    background: transparent;
  }
}
.col__head {
  padding: 0 0 12px;
  margin-bottom: 6px;
  border-bottom: 2px solid var(--line);
}
.col__name {
  margin: 0;
  font-weight: 900;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ember);
}
.col__date {
  margin: 3px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.col__slots {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ogni turno ha la metà degli spazi del precedente: allineamento automatico */
.slot {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-height: 118px;
  padding: 7px 0;
}
.col:not(:first-child) .slot {
  min-height: 0;
}

/* linee del tabellone */
.col:not(:last-child) .slot:not(.slot--bye)::after {
  content: '';
  position: absolute;
  top: 50%;
  right: calc(var(--gap) / -2);
  width: calc(var(--gap) / 2);
  border-top: 2px solid var(--line);
}
.col:not(:last-child) .slot:not(.slot--bye)::before {
  content: '';
  position: absolute;
  right: calc(var(--gap) / -2);
  border-right: 2px solid var(--line);
}
.col:not(:last-child) .slot:nth-child(odd)::before {
  top: 50%;
  bottom: 0;
}
.col:not(:last-child) .slot:nth-child(even)::before {
  top: 0;
  bottom: 50%;
}
.col:not(:first-child) .match::before {
  content: '';
  position: absolute;
  top: 50%;
  left: calc(var(--gap) / -2 - 1px);
  width: calc(var(--gap) / 2);
  border-top: 2px solid var(--line);
}

/* partita */
.match {
  position: relative;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: visible;
  box-shadow: 0 8px 22px -14px rgba(0, 0, 0, 0.8);
}
.match.is-done {
  border-color: #39436c;
}
.match__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.match__code {
  flex: none;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(212, 245, 60, 0.12);
  color: var(--lime);
  font-weight: 800;
}
.match__when {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match__status {
  flex: none;
  font-weight: 700;
  color: var(--ember);
}
.match__status.is-done {
  color: var(--muted);
}

.side {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}
.side + .side {
  border-top: 1px solid rgba(44, 53, 88, 0.6);
}
.side:last-child {
  border-radius: 0 0 12px 12px;
}
.side__seed {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.side__name {
  min-width: 0;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.side__score {
  display: flex;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.set {
  min-width: 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.set.is-set-win {
  color: var(--text);
  font-weight: 800;
}
.side.is-win .side__name {
  font-weight: 800;
}
.side.is-win::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--ember), var(--lava));
}
.side.is-lose .side__name {
  color: var(--muted);
}
.side.is-tbd {
  cursor: default;
}
.side.is-tbd .side__name {
  font-style: italic;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.82rem;
}

/* evidenzia il percorso di una coppia */
.bracket.has-focus .side {
  opacity: 0.45;
}
.bracket.has-focus .side.is-focus {
  opacity: 1;
  background: rgba(212, 245, 60, 0.13);
}
.bracket.has-focus .side.is-focus .side__name {
  color: var(--lime);
}

/* finale e trofeo */
.col--final .match {
  border-color: rgba(255, 165, 31, 0.6);
  box-shadow: 0 0 0 1px rgba(255, 165, 31, 0.25), 0 18px 40px -18px rgba(255, 77, 26, 0.6);
}
.trophy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(50% + 72px);
  text-align: center;
}
.trophy__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  color: var(--gold);
  filter: drop-shadow(0 0 18px rgba(255, 165, 31, 0.5));
}
.trophy__icon svg {
  width: 100%;
  height: 100%;
}
.trophy__label {
  margin: 6px 0 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ember);
}
.trophy__name {
  margin: 2px 0 0;
  font-weight: 800;
  font-size: 1rem;
  color: var(--muted);
}
.trophy.has-champion .trophy__name {
  color: var(--lime);
}

.match__next {
  display: none;
}

.vtree {
  display: none;
}

.board__hint {
  margin: 6px 0 0;
  padding: 0 var(--gutter);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------------------------------------------------------------- piede */

.foot {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px var(--gutter) calc(40px + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 0.82rem;
}
.foot__updated {
  margin: 0 0 14px;
}
.offline {
  margin: 0 0 14px;
  color: var(--ember);
}
.lock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.lock:hover {
  color: var(--text);
  border-color: var(--text);
}
body.is-editing .lock,
body.is-editing .board__hint {
  display: none;
}

/* --------------------------------------------------------------- avvisi */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(92vw, 520px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--night);
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.toast--error {
  background: var(--lava);
  color: #fff;
}
.toast--ok {
  background: var(--lime);
}
.toast__act {
  flex: none;
  border: 0;
  border-radius: 8px;
  background: var(--night);
  color: var(--text);
  padding: 7px 12px;
  font-weight: 700;
  cursor: pointer;
}
body.is-editing .toast {
  bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}
