/* PingPong Ladder — tema light, minimale, senza emoji */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e6e8ec;
  --ink: #14181f;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --accent: #15a36e;        /* verde tavolo, sobrio */
  --accent-soft: #e6f6ee;
  --p1: #2563eb;            /* blu giocatore 1 */
  --p2: #e0533d;           /* arancio giocatore 2 */
  --danger: #d83a3a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 31, .04), 0 4px 16px rgba(20, 24, 31, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

a { color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* layout */
.wrap { max-width: 760px; margin: 0 auto; padding: 22px 18px 60px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 22px;
}
.brand { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 6px; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid transparent;
}
.nav a:hover { background: var(--surface); border-color: var(--line); }
.nav a.active { background: var(--ink); color: #fff; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--faint); margin: 0 0 14px;
}

/* buttons */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 11px 16px; font-weight: 600; font-size: 15px;
  transition: transform .04s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-danger { color: var(--danger); border-color: #f1c9c9; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

input, select {
  font-family: inherit; font-size: 15px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  background: var(--surface); width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ladder table */
.ladder { width: 100%; border-collapse: collapse; }
.ladder th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--faint); padding: 0 10px 10px; border-bottom: 1px solid var(--line);
}
.ladder th.r, .ladder td.r { text-align: right; }
.ladder td { padding: 13px 10px; border-bottom: 1px solid var(--line); }
.ladder tr:last-child td { border-bottom: none; }
.ladder .rank { width: 34px; color: var(--faint); font-weight: 700; }
.ladder .name { font-weight: 600; }
.ladder .pts { font-weight: 800; font-size: 17px; }
.ladder tr.top1 .rank { color: var(--accent); }
.wl { color: var(--muted); font-size: 14px; }
.win { color: var(--accent); font-weight: 700; }
.loss { color: var(--muted); }

.empty { color: var(--faint); text-align: center; padding: 30px 0; font-size: 15px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); opacity: 0;
  transition: opacity .2s ease; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }

/* recent feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.feed li:last-child { border-bottom: none; }
.feed .vs { color: var(--faint); }
.feed .res { margin-left: auto; font-weight: 700; }

/* home hub */
.hub { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 6px; }
.hub a {
  text-decoration: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.hub a:hover { border-color: var(--accent); }
.hub .h-t { font-weight: 800; font-size: 18px; }
.hub .h-d { color: var(--muted); font-size: 14px; }
.hub a.wide { grid-column: 1 / -1; }

/* ===== controller (play.html) ===== */
.score-pad { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.side {
  border-radius: var(--radius); border: 2px solid var(--line); overflow: hidden;
  display: flex; flex-direction: column; background: var(--surface);
}
.side .who { padding: 12px 14px; font-weight: 700; font-size: 16px; color: #fff; }
.side.s1 .who { background: var(--p1); }
.side.s2 .who { background: var(--p2); }
.side .sc {
  font-size: clamp(56px, 22vw, 110px); font-weight: 800; text-align: center;
  padding: 6px 0; line-height: 1;
}
.side .pm { display: flex; border-top: 1px solid var(--line); }
.side .pm button {
  flex: 1; border: none; background: transparent; font-size: 26px; font-weight: 700;
  padding: 16px 0; color: var(--ink);
}
.side .pm button.minus { color: var(--muted); border-right: 1px solid var(--line); }
.side .pm button:active { background: var(--bg); }

/* ===== TV (tv.html) ===== */
.tv-body { background: var(--bg); height: 100vh; overflow: hidden; }
.tv-wrap { height: 100vh; display: flex; flex-direction: column; padding: 3vh 4vw; }
.tv-head { display: flex; align-items: center; justify-content: space-between; }
.tv-brand { font-weight: 800; font-size: 2.2vw; letter-spacing: -.02em; }
.tv-brand span { color: var(--accent); }
.tv-tag { color: var(--faint); font-size: 1.4vw; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }

.tv-match { flex: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 2vw; }
.tv-player { text-align: center; }
.tv-player .nm { font-weight: 700; font-size: 3.4vw; margin-bottom: 1vh; }
.tv-player.p1 .nm { color: var(--p1); }
.tv-player.p2 .nm { color: var(--p2); }
.tv-player .pt { font-size: 22vw; font-weight: 800; line-height: .9; }
.tv-vs { color: var(--faint); font-size: 3vw; font-weight: 700; }

.tv-idle { flex: 1; display: grid; grid-template-columns: 1.3fr 1fr; gap: 3vw; align-items: start; padding-top: 2vh; }
.tv-idle h2 { font-size: 1.6vw; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 1.5vh; }
.tv-ladder { width: 100%; border-collapse: collapse; font-size: 1.9vw; }
.tv-ladder td { padding: 1.1vh 0; border-bottom: 1px solid var(--line); }
.tv-ladder .rk { color: var(--faint); font-weight: 700; width: 3vw; }
.tv-ladder .nm { font-weight: 600; }
.tv-ladder .pt { text-align: right; font-weight: 800; }
.tv-ladder .wl { text-align: right; color: var(--muted); font-size: 1.4vw; width: 7vw; }
.tv-foot { text-align: center; color: var(--faint); font-size: 1.3vw; padding-top: 1.5vh; }
.tv-recent { list-style: none; margin: 0; padding: 0; font-size: 1.5vw; }
.tv-recent li { padding: 1vh 0; border-bottom: 1px solid var(--line); display: flex; gap: .6vw; }
.tv-recent .res { margin-left: auto; font-weight: 800; }
