:root {
  --bg-grad-start: #0a1f4f;
  --bg-grad-end:   #1a3a8e;
  --accent:        #d62828;
  --accent-hover:  #b81f1f;
  --fg:            #ffffff;
  --fg-muted:      #cdd6f4;
  --card-bg:       rgba(255, 255, 255, 0.06);
  --card-border:   rgba(255, 255, 255, 0.12);
  --shadow:        0 6px 18px rgba(0, 0, 0, 0.35);
  --radius:        12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg-grad-start), var(--bg-grad-end));
  background-attachment: fixed;
  color: var(--fg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--fg); text-decoration: underline; text-decoration-color: rgba(255,255,255,.4); }
a:hover { text-decoration-color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(0,0,0,.18);
  backdrop-filter: blur(6px);
}
.header-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  flex-shrink: 0;
}
.site-title {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 1rem;
}

/* ---------- Layout containers ---------- */
.hero, .form-wrap, .wizard, .admin-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}
.admin-wrap { max-width: 720px; }
.hero { text-align: center; }
.hero-logo {
  display: block;
  max-width: 160px;
  width: 60%;
  margin: 1rem auto 1.25rem;
  border-radius: 50%;
  background: #fff;
  padding: 6px;
  box-shadow: var(--shadow);
}
.tagline {
  opacity: .85;
  margin: 0 0 1.5rem;
  font-size: 1.05rem;
}

h1 {
  margin: 0 0 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-size: 1.5rem;
}
h2 {
  margin: 0 0 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  opacity: .9;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: .9rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s, transform .15s, background .15s;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(214, 40, 40, .45);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.45);
  color: #fff;
}
.btn-secondary:hover { background: rgba(255,255,255,.08); filter: none; }
.btn-secondary:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.25); }

/* ---------- Forms ---------- */
form label {
  display: block;
  text-align: left;
  margin: 1rem 0;
  font-weight: 600;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .9;
}
form select, form input[type=text], form input[type=password], form input[type=number] {
  display: block;
  width: 100%;
  padding: .8rem .9rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  margin-top: .4rem;
  background: var(--card-bg);
  color: var(--fg);
  font-family: inherit;
}
form input:focus, form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(214,40,40,.25);
}

/* ---------- Messages ---------- */
.msg {
  padding: .8rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.msg-warn { background: rgba(214, 40, 40, .15); color: #ffbcbc; border-color: rgba(214, 40, 40, .4); }
.msg-info { background: rgba(94, 145, 255, .15); color: #c8d8ff; border-color: rgba(94, 145, 255, .4); }
.msg-ok   { background: rgba(46, 175, 96, .15); color: #b8f0c8;  border-color: rgba(46, 175, 96, .4); }

.back-home {
  margin-top: 2rem;
  text-align: center;
  opacity: .75;
  font-size: .9rem;
}

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  padding: 0;
  margin: 0 0 1.75rem;
  gap: .4rem;
}
.step-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  flex: 1;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .5;
  position: relative;
  font-weight: 700;
}
.step-indicator span {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  font-size: .9rem;
}
.step-indicator.active {
  opacity: 1;
}
.step-indicator.active span {
  background: var(--accent);
  border-color: var(--accent);
}
.step-indicator.done {
  opacity: .85;
}
.step-indicator.done span {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.step-indicator + .step-indicator::before {
  content: '';
  position: absolute;
  height: 2px;
  background: var(--card-border);
  top: 14px;
  left: -50%;
  right: 50%;
  z-index: -1;
}

/* ---------- Step 1: categoria ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.cat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 2rem 1rem;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  color: inherit;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  transition: transform .15s, background .15s, border-color .15s;
}
.cat-tile svg { color: var(--accent); }
.cat-tile:hover {
  background: rgba(255,255,255,.1);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.cat-tile:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(214,40,40,.4);
}

/* ---------- Step 2: griglia squadre ---------- */
.team-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  margin-bottom: 1rem;
}
.team-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: .3rem;
  min-height: 120px;
  padding: 1rem .4rem .55rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: inherit;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  overflow: hidden;
}
.team-card .team-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 10px;
  border-radius: 10px 10px 0 0;
  display: block;
}
.team-card.has-border .team-bar {
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.25);
}
.team-card img.team-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
  margin-top: .3rem;
}
.team-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.team-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(214,40,40,.4);
}

/* ---------- Step 3: maglia ---------- */
.summary {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .9rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-weight: 700;
  margin: 0 0 1rem;
  font-size: .85rem;
}
.summary .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.4);
  display: inline-block;
}
.actions {
  display: flex;
  gap: .6rem;
  margin-top: 1.5rem;
}
.actions .btn { flex: 1; }

/* ---------- Admin ---------- */
.admin-bar {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 1rem 0 1.25rem;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 1rem;
}
.results-table th,
.results-table td {
  padding: .65rem .8rem;
  border-bottom: 1px solid var(--card-border);
  text-align: left;
  font-size: .92rem;
}
.results-table th {
  background: rgba(0,0,0,.25);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .75rem;
}
.results-table tr:last-child td { border-bottom: 0; }
.team-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: .5rem;
  vertical-align: middle;
}
.team-dot.has-border {
  outline: 1px solid rgba(255,255,255,.4);
}

/* ---------- Responsive ---------- */
@media (max-width: 360px) {
  .team-grid { grid-template-columns: repeat(2, 1fr); }
  .team-card { font-size: .85rem; min-height: 130px; }
}
