:root {
  --bg: #0b1020;
  --bg2: #121a33;
  --card: #17203c;
  --card2: #1e284a;
  --line: #2a3560;
  --txt: #e8ecf8;
  --muted: #94a1c4;
  --acc: #4f8cff;
  --acc2: #7c5cff;
  --ok: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;
  --gold: #f5b301;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

a { color: var(--acc); }

#app { padding: 0 0 84px; max-width: 1100px; margin: 0 auto; }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, #0e1428 0%, rgba(14,20,40,.94) 100%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
}
header.top h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: .2px; }
header.top .sub { font-size: 12px; color: var(--muted); }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--acc), var(--acc2)); box-shadow: 0 0 12px var(--acc); }
.spacer { flex: 1; }

.budget-chip {
  background: var(--card2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.budget-chip small { color: var(--muted); font-weight: 500; }

/* ---------- nav ---------- */
nav.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(14,20,40,.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav.bottom button {
  background: none; border: 0; color: var(--muted);
  font-size: 10px; font-weight: 600; letter-spacing: .2px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; border-radius: 10px; cursor: pointer; flex: 1;
  white-space: nowrap; min-width: 0;
}
@media (max-width: 400px) { nav.bottom button { font-size: 9px; } }
nav.bottom button svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; }
nav.bottom button.active { color: var(--acc); background: rgba(79,140,255,.10); }

/* ---------- layout ---------- */
main { padding: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 { margin: 14px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

.grid { display: grid; gap: 10px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }

.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 21px; font-weight: 800; margin-top: 2px; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); }

/* ---------- controlli ---------- */
button, select, input, textarea {
  font-family: inherit; font-size: 14px;
}
.btn {
  background: var(--card2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600;
  transition: .12s;
}
.btn:hover { border-color: var(--acc); }
.btn.primary { background: linear-gradient(135deg, var(--acc), var(--acc2)); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { border-color: var(--bad); color: #ffb4b4; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

input[type=text], input[type=number], select, textarea {
  background: var(--bg2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(79,140,255,.5); outline-offset: 0; }
label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; font-weight: 600;
}
.chip.on { background: rgba(79,140,255,.16); border-color: var(--acc); color: #cfe0ff; }

/* ---------- badge ruoli ---------- */
.rb {
  display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .3px;
  padding: 2px 6px; border-radius: 6px; margin-right: 3px; white-space: nowrap;
}
.rb-P { background: #f59e0b22; color: #fbbf24; border: 1px solid #f59e0b55; }
.rb-D { background: #22c55e22; color: #4ade80; border: 1px solid #22c55e55; }
.rb-C { background: #38bdf822; color: #7dd3fc; border: 1px solid #38bdf855; }
.rb-A { background: #f8717122; color: #fca5a5; border: 1px solid #f8717155; }

/* ---------- lista giocatori ---------- */
.plist { display: flex; flex-direction: column; gap: 6px; }
.prow {
  display: flex; align-items: center; gap: 10px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 11px; cursor: pointer;
}
.prow:hover { border-color: var(--acc); }
.prow.taken { opacity: .42; }
.prow.mine { border-color: var(--ok); background: rgba(34,197,94,.08); }
.prow .name { font-weight: 700; font-size: 14px; }
.prow .meta { font-size: 11.5px; color: var(--muted); }
.prow .grow { flex: 1; min-width: 0; }
.prow .num { text-align: right; }
.prow .num .big { font-weight: 800; font-size: 15px; }
.prow .num .lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag { font-size: 10px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }
.tag.t1 { border-color: var(--gold); color: var(--gold); }
.tag.t2 { border-color: var(--acc); color: var(--acc); }
.tag.t3 { border-color: var(--muted); }

/* ---------- campo ---------- */
.pitch {
  position: relative; width: 100%; aspect-ratio: 3/4; max-width: 480px; margin: 0 auto;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.05), transparent 60%),
    repeating-linear-gradient(0deg, #143a20 0 8%, #12331d 8% 16%);
  border: 2px solid rgba(255,255,255,.18); border-radius: 12px; overflow: hidden;
}
.pitch::before {
  content: ''; position: absolute; left: 8%; right: 8%; top: 50%;
  border-top: 2px solid rgba(255,255,255,.18);
}
.pitch::after {
  content: ''; position: absolute; left: 30%; right: 30%; bottom: 0; height: 16%;
  border: 2px solid rgba(255,255,255,.18); border-bottom: 0; border-radius: 4px 4px 0 0;
}
.pp {
  position: absolute; transform: translate(-50%, -50%);
  width: 74px; text-align: center;
}
.pp .circle {
  width: 40px; height: 40px; margin: 0 auto 3px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--acc);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; color: #cfe0ff;
}
.pp.malus .circle { border-color: var(--warn); }
.pp.empty .circle { border-style: dashed; border-color: var(--muted); color: var(--muted); }
.pp .nm { font-size: 10.5px; font-weight: 700; text-shadow: 0 1px 3px #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp .sl { font-size: 9px; color: #b9c6e8; text-shadow: 0 1px 3px #000; }

/* ---------- tabelle ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 6px 6px; border-bottom: 1px solid var(--line); }
td { padding: 7px 6px; border-bottom: 1px solid rgba(42,53,96,.5); }
tr.me td { background: rgba(34,197,94,.08); }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(4,8,20,.72); backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-bg { align-items: center; } }
.modal {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) { .modal { border-radius: 18px; } }

.bar { height: 7px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc2)); }
.bar.warn > i { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.ok { background: rgba(34,197,94,.16); color: #86efac; }
.pill.warn { background: rgba(234,179,8,.16); color: #fde68a; }
.pill.bad { background: rgba(239,68,68,.16); color: #fca5a5; }
.pill.info { background: rgba(79,140,255,.16); color: #bfd4ff; }

.sticky-search { position: sticky; top: 54px; z-index: 30; background: var(--bg); padding: 8px 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 13.5px; }
.kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid rgba(42,53,96,.5); font-size: 13px; }
.kv b { font-weight: 800; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.turn-now { border-color: var(--gold) !important; background: rgba(245,179,1,.10) !important; }
