/* bELO — stylesheet v1.1 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d1a;
  --surface:   #13132b;
  --card:      #1c1c3a;
  --border:    #2a2a4a;
  --accent:    #e94560;
  --accent2:   #c73652;
  --gold:      #f0c040;
  --gold2:     #d4a820;
  --text:      #e8e8f0;
  --muted:     #9898be;
  --green:     #3ddc84;
  --red:       #ff4d6d;
  --orange:    #ff8c42;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --transition: .18s ease;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent2); }

/* ─── SCROLLBAR ─────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── NAV ───────────────────────────────── */
nav {
  background: rgba(13,13,26,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: env(safe-area-inset-top) 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(58px + env(safe-area-inset-top));
  height: calc(58px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}
nav .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 2px;
  text-decoration: none;
}
nav .logo span { color: var(--accent); }
nav ul {
  list-style: none;
  display: flex;
  gap: 4px;
  align-items: center;
}
nav ul li a {
  color: var(--muted);
  font-size: .875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
nav ul li a:hover { background: var(--card); color: var(--text); }
nav .nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: .85rem;
}
nav .nav-right .username {
  color: var(--gold);
  font-weight: 600;
}
nav .nav-right a.logout {
  color: var(--muted);
  font-size: .82rem;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), color var(--transition);
}
nav .nav-right a.logout:hover { border-color: var(--accent); color: var(--accent); }

/* hamburger button — visibile solo su mobile */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 11px;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  transition: border-color .18s, color .18s;
  flex-shrink: 0;
}
.nav-hamburger:hover { border-color: var(--accent); color: var(--text); }

/* mobile nav */
@media (max-width: 680px) {
  nav { padding: env(safe-area-inset-top) 16px 0; }
  .nav-hamburger { display: block; }
  nav ul { display: none; }
  /* dropdown fisso — niente problemi di z-index o clipping */
  nav ul.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: calc(58px + env(safe-area-inset-top));
    left: 0;
    right: 0;
    z-index: 500;
    background: rgba(13,13,26,.98);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px 16px;
    gap: 2px;
    box-shadow: 0 8px 24px rgba(0,0,0,.55);
  }
  nav ul.open li { width: 100%; }
  nav ul.open li a {
    padding: 11px 14px;
    border-radius: 8px;
    display: block;
    font-size: .95rem;
  }
}

/* ─── LAYOUT ────────────────────────────── */
.container {
  max-width: 920px;
  margin: 36px auto;
  padding: 0 18px;
}

h1 {
  font-size: 1.65rem;
  font-weight: 800;
  margin-bottom: 24px;
  color: var(--text);
}
h1 .muted { color: var(--muted); font-weight: 400; }
h2 { font-size: 1.15rem; margin-bottom: 12px; color: var(--text); }

/* ─── CARD ──────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  transition: border-color var(--transition);
}
.card:hover { border-color: #3a3a5a; }
.card-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ─── GRID ──────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ─── FORMS ─────────────────────────────── */
.form-group { margin-bottom: 18px; }
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: .3px;
}
input[type=text],
input[type=email],
input[type=password],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233,69,96,.15);
}
textarea { resize: vertical; min-height: 80px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237878a0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ─── BUTTONS ───────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .2px;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition), background var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover  { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,.35); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 12px rgba(233,69,96,.3);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(233,69,96,.45); }

.btn-success {
  background: linear-gradient(135deg, #3ddc84, #2ab86a);
  color: #0d1a10;
  box-shadow: 0 2px 12px rgba(61,220,132,.25);
}
.btn-danger {
  background: linear-gradient(135deg, var(--red), #cc2244);
  color: #fff;
  box-shadow: 0 2px 12px rgba(255,77,109,.25);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-outline:hover { border-color: var(--text); color: var(--text); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #1a1000;
  box-shadow: 0 2px 12px rgba(240,192,64,.25);
}
.btn-sm  { padding: 6px 14px; font-size: .82rem; }
.btn-block { display: flex; width: 100%; }

/* ─── ALERTS ────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left-width: 3px;
  border-left-style: solid;
}
.alert-error   { background: rgba(255,77,109,.1);  border-color: var(--red);    color: #ffaabc; }
.alert-success { background: rgba(61,220,132,.1);  border-color: var(--green);  color: #a0ffcc; }
.alert-info    { background: rgba(100,150,255,.1); border-color: #6496ff;       color: #aac4ff; }
.alert-warning { background: rgba(255,140,66,.1);  border-color: var(--orange); color: #ffc499; }

/* ─── TABLES ────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.025); }

/* ─── ELO COLORS ────────────────────────── */
.elo       { font-weight: 700; color: var(--gold); }
.elo-up    { color: var(--green);  font-weight: 600; }
.elo-down  { color: var(--red);    font-weight: 600; }

/* ─── BADGES ────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
}
.badge::before { content: ''; display:block; width:6px; height:6px; border-radius:50%; }
.badge-pending   { background: rgba(240,192,64,.12);  color: #f0c040; border: 1px solid rgba(240,192,64,.3); }
.badge-pending::before   { background: #f0c040; }
.badge-active    { background: rgba(61,220,132,.12); color: #3ddc84; border: 1px solid rgba(61,220,132,.3); }
.badge-active::before    { background: #3ddc84; animation: pulse 1.5s infinite; }
.badge-completed { background: rgba(100,150,255,.12); color: #6496ff; border: 1px solid rgba(100,150,255,.3); }
.badge-completed::before { background: #6496ff; }
.badge-disputed  { background: rgba(255,140,66,.12);  color: var(--orange); border: 1px solid rgba(255,140,66,.3); }
.badge-disputed::before  { background: var(--orange); animation: pulse 1.5s infinite; }
.badge-cancelled { background: rgba(120,120,160,.1);  color: var(--muted); border: 1px solid var(--border); }
.badge-cancelled::before { background: var(--muted); }

/* ─── ONLINE ────────────────────────────── */
.online-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.online-dot.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
  0%,100% { opacity: 1;   box-shadow: 0 0 0 0 rgba(61,220,132,.4); }
  50%      { opacity: .7; box-shadow: 0 0 0 4px rgba(61,220,132,0); }
}

/* ─── RANK ──────────────────────────────── */
.rank-1 { color: var(--gold);  font-weight: 800; font-size: 1.05rem; }
.rank-2 { color: #c8c8d8; font-weight: 700; }
.rank-3 { color: #cd7f32; font-weight: 700; }
.my-row td { background: rgba(233,69,96,.07) !important; }
.my-row td:first-child { border-left: 2px solid var(--accent); }

/* ─── STAT BOXES ─────────────────────────── */
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-box {
  flex: 1;
  min-width: 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: center;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-box:hover { border-color: #3a3a5a; transform: translateY(-2px); }
.stat-box .val {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1.1;
  letter-spacing: -1px;
}
.stat-box .lbl {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 5px;
}

/* ─── PLAYER VS ──────────────────────────── */
.vs-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px 0 18px;
  text-align: center;
}
.vs-box .player { flex: 1; }
.vs-box .player .name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.vs-box .player .elo-val {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1.1;
}
.vs-box .player small { color: var(--muted); font-size: .78rem; }
.vs-sep {
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 300;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── AUTH PAGES ─────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(233,69,96,.12) 0%, transparent 60%), var(--bg);
  padding: 24px 16px;
}
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
@media (max-width: 480px) {
  .auth-box { padding: 32px 24px; }
}
.auth-box .logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}
.auth-box .wordmark {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 3px;
  line-height: 1;
}
.auth-box .wordmark span { color: var(--accent); }
.auth-box .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 30px;
  line-height: 1.5;
}

/* ─── LOCATION PILL ──────────────────────── */
.location-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(240,192,64,.1);
  border: 1px solid rgba(240,192,64,.25);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: .8rem;
  color: var(--gold);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.location-pill a { color: var(--gold); }
.location-pill a:hover { color: var(--gold2); }

/* ─── DIVIDER ────────────────────────────── */
.divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

/* ─── UTILS ──────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.flex        { display: flex; align-items: center; }
.flex-wrap   { flex-wrap: wrap; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-8        { margin-bottom: 8px; }
.mb-16       { margin-bottom: 16px; }
.w-full      { width: 100%; }

/* ─── RESPONSIVE TABLES ─────────────────── */

/* Colonne opzionali: nascose su schermi piccoli */
@media (max-width: 600px) {
  .hide-sm { display: none !important; }
  th.hide-sm, td.hide-sm { display: none !important; }

  /* Padding ridotto su mobile */
  td, th { padding: 8px 8px; }

  /* Font più compatto */
  table  { font-size: .82rem; }

  /* Badge più piccoli */
  .badge { font-size: .68rem; padding: 2px 7px; }

  /* Container padding ridotto */
  .container { padding: 0 10px; margin-top: 20px; }
}

@media (max-width: 420px) {
  .hide-xs { display: none !important; }
  th.hide-xs, td.hide-xs { display: none !important; }
  td, th { padding: 7px 6px; }
  table  { font-size: .78rem; }
}

/* ─── PAGE FADE-IN ───────────────────────── */
.container { animation: fadeUp .3s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
