/* =====================================================================
   TWIZA FANTACALCIO — REDESIGN CSS
   Layer additivo: includere DOPO il CSS esistente.
   Scopo: mantenere markup e flussi, elevare gerarchia, dinamismo e mobile UX.
   ===================================================================== */

:root {
  --bg: #07100b;
  --bg2: #0a1710;
  --panel: #101c15;
  --panel2: #16271d;
  --inset: #08110c;
  --line: #254333;
  --line2: #3c5d49;
  --text: #f2f7f3;
  --muted: #adc4b4;
  --faint: #779486;
  --pitch: #45d984;
  --pitch-d: #1b9653;
  --pitch-deep: #0e653c;
  --neon: #9aff4b;
  --gold: #f1c65b;
  --gold-d: #b77e15;
  --crit: #ff765d;
  --good: #5bd68f;
  --info: #6cc8f1;
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-1: 0 6px 18px rgba(0,0,0,.22);
  --shadow-2: 0 16px 44px rgba(0,0,0,.42);
  --glow-green: 0 0 0 1px rgba(69,217,132,.18), 0 12px 34px rgba(20,168,86,.14);
  --glow-gold: 0 0 0 1px rgba(241,198,91,.2), 0 10px 28px rgba(241,198,91,.10);
  --ease-out: cubic-bezier(.2,.8,.2,1);
  --shield-clip: polygon(50% 0%, 94% 14%, 94% 68%, 50% 100%, 6% 68%, 6% 14%);
}

/* Motion is present only when it communicates focus or activity. */
@media (prefers-reduced-motion: no-preference) {
  .card, button.btn, .chip, nav.tabs button, .tgt, .plr, .player-face {
    transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out),
                border-color 180ms var(--ease-out), background-color 180ms var(--ease-out),
                opacity 180ms var(--ease-out);
  }
}

/* ---------------------------------------------------------------------
   1. Shell, navigation and visual language
   --------------------------------------------------------------------- */
body {
  background:
    radial-gradient(70rem 40rem at 50% -12rem, rgba(69,217,132,.14), transparent 62%),
    radial-gradient(44rem 28rem at 100% 10%, rgba(241,198,91,.08), transparent 67%),
    linear-gradient(180deg, #09150f 0, var(--bg) 38rem);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .18;
  background-image:
    linear-gradient(30deg, transparent 47%, rgba(255,255,255,.065) 48%, rgba(255,255,255,.065) 52%, transparent 53%),
    linear-gradient(150deg, transparent 47%, rgba(255,255,255,.065) 48%, rgba(255,255,255,.065) 52%, transparent 53%);
  background-size: 42px 72px;
  mask-image: linear-gradient(to bottom, black, transparent 52%);
}

.top {
  min-height: 62px;
  padding: 10px clamp(14px, 2vw, 28px);
  gap: 14px;
  background: rgba(7,16,11,.82);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  border-bottom-color: rgba(99,161,118,.25);
}

.top::after {
  height: 2px;
  opacity: .9;
  background: linear-gradient(90deg, transparent 0 1%, var(--pitch-d) 18%, var(--pitch) 48%, var(--gold) 70%, transparent 99%);
}

.top .logobadge {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border-color: rgba(69,217,132,.30);
  box-shadow: var(--glow-green), inset 0 1px 0 rgba(255,255,255,.12);
}

.top .wm { font-size: clamp(19px, 2vw, 23px); letter-spacing: .035em; }

nav.tabs {
  top: 62px;
  min-height: 54px;
  padding: 9px clamp(14px, 2vw, 28px);
  gap: 8px;
  scrollbar-width: none;
  background: rgba(7,16,11,.68);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
nav.tabs::-webkit-scrollbar { display: none; }

nav.tabs button {
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 11px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
nav.tabs button:hover {
  color: var(--text);
  background: rgba(255,255,255,.055);
}
nav.tabs button.on {
  color: #06120a;
  background: linear-gradient(135deg, var(--neon), var(--pitch));
  box-shadow: 0 5px 16px rgba(69,217,132,.25), inset 0 1px 0 rgba(255,255,255,.35);
}
nav.tabs button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible { outline: 3px solid rgba(241,198,91,.9); outline-offset: 3px; }

.wrap { max-width: 1320px; padding: clamp(16px,2vw,28px) clamp(14px,2vw,28px) 90px; }

.card {
  border-radius: var(--radius-md);
  border-color: rgba(70,118,86,.55);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,.065);
  background:
    linear-gradient(120deg, rgba(255,255,255,.035), transparent 26%),
    linear-gradient(180deg, rgba(18,36,26,.96), rgba(9,20,13,.94));
}
.card::before {
  height: 2px;
  opacity: .65;
  background: linear-gradient(90deg, transparent, rgba(69,217,132,.66) 42%, rgba(241,198,91,.60) 62%, transparent);
}
.card:hover { border-color: rgba(82,150,103,.72); }
.card h2 { font-size: 17px; letter-spacing: .01em; }

/* Arrivo da un indirizzo diretto (#impostazioni/2): la card che il link indicava si fa
   notare per un istante. Serve perche' dopo lo scorrimento la pagina sembra uguale a se
   stessa, e chi ha aperto il link non sa se e' arrivato dove doveva. Un lampo, non una
   decorazione permanente: chi ha disattivato le animazioni vede solo il bordo. */
.card-evidenziata { border-color: rgba(241,198,91,.95); animation: cardEvidenziata 2.6s ease-out 1; }
@keyframes cardEvidenziata {
  0%, 100% { box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,.065); }
  12%, 62% { box-shadow: var(--shadow-1), 0 0 0 3px rgba(241,198,91,.34); }
}
@media (prefers-reduced-motion: reduce) { .card-evidenziata { animation: none; } }

/* ---------------------------------------------------------------------
   2. Inputs, call-to-action and information states
   --------------------------------------------------------------------- */
input, select {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  border-color: rgba(78,125,93,.72);
  background: rgba(3,10,6,.68);
}
input:hover, select:hover { border-color: rgba(69,217,132,.55); }
input:focus, select:focus {
  border-color: var(--pitch);
  box-shadow: 0 0 0 3px rgba(69,217,132,.16);
}

button.btn {
  min-height: 42px;
  padding-inline: 17px;
  border-radius: 11px;
  color: #06120a;
  background: linear-gradient(135deg, var(--neon), var(--pitch));
  box-shadow: 0 6px 18px rgba(40,188,96,.26), inset 0 1px 0 rgba(255,255,255,.4);
}
button.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(40,188,96,.34), inset 0 1px 0 rgba(255,255,255,.4); }
button.btn:active { transform: translateY(0) scale(.98); }
button.btn.ghost {
  color: var(--text);
  background: rgba(255,255,255,.025);
  border-color: rgba(83,132,99,.7);
}
button.btn.ghost:hover { color: var(--pitch); border-color: var(--pitch); background: rgba(69,217,132,.07); }

.msg.ok { color: var(--good); }
.msg.err { color: var(--crit); }

/* ---------------------------------------------------------------------
   3. Login: the only full-bleed cinematic screen
   Requires: replace .stadium SVG with .stadium img + .stadium-copy.
   --------------------------------------------------------------------- */
.login { max-width: 1040px; margin: clamp(30px,8vh,96px) auto; display: grid; grid-template-columns: 1.14fr .86fr; text-align: left; gap: 0; }
.login .stadium {
  max-width: none;
  min-height: 560px;
  margin: 0;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  border-right: 0;
  background:
    linear-gradient(90deg, rgba(7,16,11,.88) 0%, rgba(7,16,11,.35) 65%, rgba(7,16,11,.10)),
    url('/assets/stadium-night.webp') center / cover no-repeat,
    #0b2a1c;
}
.login .stadium::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(transparent, rgba(7,16,11,.78));
}
.login .card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 560px;
  margin: 0;
  padding: clamp(24px,4vw,50px);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  box-shadow: var(--shadow-2);
}
.login .logo { margin: 0 0 14px; }
.login h1 { font-size: clamp(34px,4.3vw,54px); line-height: .96; }
.login .sub { font-size: 16px; max-width: 32rem; }
.login .card button.btn { width: 100%; margin-top: 10px; }
.login .demo-cta { width: 100%; margin-top: 4px; color: var(--pitch); }

/* ---------------------------------------------------------------------
   4. Badges, faces and player rows
   Add <img class="player-photo" loading="lazy" ...> into .sh when available.
   Keep .fallback-text for failed/missing images.
   --------------------------------------------------------------------- */
.rb { border-radius: 7px; box-shadow: inset 0 1px 0 rgba(255,255,255,.24); }

.player-face,
.plr .sh {
  position: relative;
  overflow: hidden;
  clip-path: var(--shield-clip);
  border: 0;
  border-radius: 0;
  background: linear-gradient(145deg, #244a35, #07110b);
  box-shadow: 0 0 0 2px var(--pitch), 0 4px 12px rgba(0,0,0,.38);
}
.player-face { width: 42px; height: 48px; display: inline-grid; place-items: center; vertical-align: middle; }
.player-face.gk, .plr.gk .sh { box-shadow: 0 0 0 2px var(--gold), 0 4px 12px rgba(0,0,0,.38); }
.player-face img, .plr .sh img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.player-face .fallback-text, .plr .sh .fallback-text { font-family: var(--fm); font-weight: 800; color: var(--text); font-size: 11px; }

.player-row { display: inline-flex; gap: 9px; align-items: center; min-width: 170px; }
.player-row .name { font-weight: 700; }

/* ---------------------------------------------------------------------
   5. Auction: preserve information density; use rich visuals only for targets
   --------------------------------------------------------------------- */
.credits {
  min-width: 164px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(66,50,10,.95), rgba(23,17,4,.95));
  border-color: rgba(241,198,91,.78);
  box-shadow: var(--glow-gold);
}
.credits .v { font-size: 24px; }

.budget-hero {
  display: grid;
  grid-template-columns: auto minmax(160px,1fr) auto;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 120px;
  z-index: 8;
  padding: 13px 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(241,198,91,.32);
  border-radius: var(--radius-md);
  background: rgba(15,27,18,.88);
  backdrop-filter: blur(14px);
}
.budget-hero .bar { height: 12px; border: 0; background: rgba(255,255,255,.08); }
.budget-hero .bar > i { border-radius: inherit; background: linear-gradient(90deg, var(--pitch), var(--neon) 50%, var(--gold) 82%, var(--crit)); }
.budget-hero .budget-label { font-family: var(--fm); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.planrole { border-radius: var(--radius-sm); border-color: rgba(74,126,92,.52); background: rgba(4,12,7,.30); }
.planrole .hd { margin-bottom: 10px; }
.tgt {
  min-height: 62px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
}
.tgt:hover { transform: translateX(3px); border-color: rgba(69,217,132,.24); background: linear-gradient(90deg, rgba(69,217,132,.11), transparent 70%); }
.tgt .mini-face { width: 36px; height: 41px; flex: 0 0 auto; }
.tgt .nm { font-size: 15px; }
.tgt .pr { margin-left: auto; font-weight: 800; color: var(--gold); }
.tgt .btn { flex: 0 0 auto; min-height: 34px; padding: 6px 11px; }

/* Keep long listone compact and performant. */
.card > div[style*="overflow-x:auto"] { border-radius: var(--radius-sm); }
table { font-size: 13px; }
/* Sticky solo nel viewport del listone: le tabelle nelle card non devono sovrapporsi ai propri dati. */
.table-scroll th,
.card > div[style*="overflow-x:auto"] th { position: sticky; top: 0; z-index: 2; background: #122117; color: var(--muted); }
tbody tr { transition: background 120ms ease; }
tbody tr:hover { background: rgba(69,217,132,.055); }
th, td { border-bottom-color: rgba(69,116,84,.38); }

/* ---------------------------------------------------------------------
   6. Pitch and team selection
   --------------------------------------------------------------------- */
.pitch {
  max-width: 470px;
  border-radius: 18px;
  border-color: rgba(103,186,131,.75);
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255,255,255,.07), transparent 58%),
    repeating-linear-gradient(0deg, #126c49 0 11.11%, #105d40 11.11% 22.22%);
  box-shadow: inset 0 0 58px rgba(0,0,0,.33), 0 20px 34px rgba(0,0,0,.28);
}
.pitch::after { content: ""; position:absolute; inset:0; pointer-events:none; background: linear-gradient(180deg, rgba(255,255,255,.05), transparent 18%, transparent 78%, rgba(0,0,0,.25)); }
.plr { width: 78px; z-index: 1; cursor: pointer; }
.plr .sh { width: 48px; height: 54px; margin-bottom: 2px; }
.plr .nm { font-size: 10px; font-weight: 800; }
.plr .pv { font-size: 11px; color: var(--neon); font-weight: 800; }
.plr:hover { transform: translate(-50%, -53%) scale(1.08); z-index: 4; }
.plr:hover .sh { box-shadow: 0 0 0 2px var(--neon), 0 0 18px rgba(154,255,75,.42); }

/* ---------------------------------------------------------------------
   7. Agent, stats, leagues
   --------------------------------------------------------------------- */
.agentbox { border-radius: var(--radius-sm); border-left-width: 4px; background: linear-gradient(90deg, rgba(69,217,132,.10), rgba(3,12,7,.18) 42%); }
.seg { gap: 6px; padding: 4px; border-radius: 12px; background: var(--inset); border: 1px solid var(--line); }
.seg button { min-height: 38px; border-radius: 8px; }
.seg button.on { color: #06120a; background: linear-gradient(135deg, var(--neon), var(--pitch)); }

.kpi-card, .reparti .rep {
  background: linear-gradient(145deg, rgba(69,217,132,.075), rgba(9,20,13,.75));
  border-color: rgba(78,136,98,.5);
}
.kpi-value { font-family: var(--fm); font-weight: 800; font-size: clamp(26px,4vw,38px); letter-spacing: -.06em; color: var(--text); }
.sparkbar:hover { filter: brightness(1.28); transform: translateY(-2px); }

/* ---------------------------------------------------------------------
   8. Responsive: no horizontal “desktop squeezed into mobile”.
   --------------------------------------------------------------------- */
@media (max-width: 900px) {
  .login { max-width: 640px; grid-template-columns: 1fr; }
  .login .stadium { min-height: 238px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .login .card { min-height: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
  .budget-hero { top: 108px; }
  .player-face { width: 38px; height: 43px; }
}

@media (max-width: 720px) {
  .top { min-height: 56px; padding: 8px 14px; }
  .top .wm { font-size: 18px; }
  .top .chip { min-height: 34px; padding-inline: 9px; }
  nav.tabs { top: 56px; min-height: 52px; padding: 8px 12px; }
  nav.tabs button { flex: 0 0 auto; min-height: 35px; padding: 7px 10px; }
  .wrap { padding: 16px 12px 92px; }
  .card { padding: 14px; margin-bottom: 12px; border-radius: 14px; }
  .card h2 { font-size: 16px; }
  .login { margin: 16px 12px; }
  .login .stadium { min-height: 190px; }
  .login .card { padding: 22px 18px; }
  .login h1 { font-size: 33px; }

  /* Dense tables become a controlled scroll region. Include an explicit visual cue in markup. */
  .table-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
  .table-scroll table { min-width: 620px; }
  .hide-mobile { display: none !important; }
  th { top: 104px; }

  .budget-hero { grid-template-columns: 1fr auto; gap: 10px; top: 104px; padding: 11px 12px; }
  .budget-hero .bar { grid-column: 1 / -1; }
  .budget-hero .budget-label:last-child { display: none; }
  .credits { min-width: 0; padding: 7px 10px; }
  .credits .v { font-size: 21px; }

  .tgt { align-items: center; flex-wrap: wrap; }
  .tgt .pr { margin-left: 0; }
  .tgt .btn { flex: 1 1 88px; }
  .alts { margin-left: 0; }

  .pitch { max-width: 100%; transform: none; }
  .plr { width: 64px; }
  .plr .sh { width: 40px; height: 45px; }
  .plr .nm { font-size: 9px; }
  .plr .pv { font-size: 10px; }

  .reparti { grid-template-columns: repeat(2, 1fr); }
  .agentbox { padding: 11px; }
}

@media (max-width: 390px) {
  /* I chip della topbar tenevano l'etichetta a `font-size:0` e mostravano un glifo `☼`
     al suo posto. Reggeva quando il chip era uno solo — «Esci»; da quando ce ne sono due
     l'utente vedeva due soli identici e doveva indovinare quale lo faceva uscire.
     Le etichette restano scritte: lo spazio lo trova il layout a due righe della topbar
     (twiza-v2-integration.css §topbar mobile). */
  .plr { width: 56px; }
  .plr .sh { width: 36px; height: 40px; }
  .plr .nm { max-width: 58px; }
}

/* Keyboard, motion and contrast safeguards. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
@media (forced-colors: active) {
  .card, button.btn, input, select { border: 1px solid CanvasText; }
  button.btn { forced-color-adjust: none; background: ButtonFace; color: ButtonText; }
}
