/* Quiz ABTG — brand Alfio Bardolla Training Group. Colori solo qui in :root. Solo tema chiaro. */
@font-face {
  font-family: 'Open Sans';
  src: url('/fonts/OpenSans.woff2') format('woff2');
  font-weight: 400 800; font-style: normal; font-display: swap;
}

:root {
  --brand-primary: #EF7B10;
  --brand-secondary: #2C2E38;
  --brand-cta: #009C4E;
  --brand-cta-light: #31B15C;
  --brand-cta-lighter: #62CE70;
  --text: #484847;
  --muted: #666666;
  --disabled: #A3A5A9;
  --bg: #FFFFFF;
  --bg-soft: #F5F5F5;
  --bg-soft-2: #F7F7F7;
  --border: #E9EAEC;
  --primary-soft: #FFEBD7;
  --accent-light: #FC9A34;
  --accent-lighter: #FFA955;
  --ok: #009C4E;
  --ko: #D93025;
  --white: #FFFFFF;
  --on-dark-muted: #C9CACF;
  --shadow: rgba(44, 46, 56, .14);
  --shadow-strong: rgba(44, 46, 56, .28);
  --on-dark-line: rgba(255, 255, 255, .35);
  --ok-tint: rgba(0, 156, 78, .16);

  /* risposte A–D e squadre: palette ABTG */
  --a-bg: var(--brand-primary);   --a-fg: var(--brand-secondary);
  --b-bg: var(--brand-secondary); --b-fg: var(--white);
  --c-bg: var(--brand-cta);       --c-fg: var(--white);
  --d-bg: var(--primary-soft);    --d-fg: var(--brand-secondary);

  --font: 'Open Sans', system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 10px; --r-md: 16px; --r-lg: 20px; --r-pill: 25px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh; color: var(--text); background: var(--bg-soft);
  font-family: var(--font); font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
::selection { background: var(--primary-soft); color: var(--brand-secondary); }
:focus-visible { outline: 3px solid var(--brand-primary); outline-offset: 3px; }
a { color: var(--brand-primary); text-underline-offset: 3px; }

/* ---------- layout ---------- */
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 18px; }
.screen { min-height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 0 clamp(16px, 3vw, 48px) 20px; max-width: 1440px; margin: 0 auto; }
.center-block { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; margin: auto 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: auto; flex-wrap: wrap; }
.grow { flex: 1; }

/* barra superiore antracite: è la firma della schermata host */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin: 0 calc(-1 * clamp(16px, 3vw, 48px)); padding: 14px clamp(16px, 3vw, 48px);
  background: var(--brand-secondary); color: var(--white);
  font-weight: 700; font-size: clamp(15px, 1.6vw, 22px); font-variant-numeric: tabular-nums;
}
.topbar .tag { margin-left: 0; }
/* seconda barra nella stessa schermata (telefono): resta chiara */
.topbar ~ .topbar { margin: 0; padding: 0; background: none; color: var(--brand-secondary); }

/* ---------- tipografia ---------- */
.title { font-size: clamp(30px, 5vw, 64px); font-weight: 800; line-height: 1.1; letter-spacing: -.02em; text-align: center; color: var(--brand-secondary); text-wrap: balance; }
.big-text { font-size: clamp(18px, 2.4vw, 30px); font-weight: 600; }
.center-text { text-align: center; }
.muted { color: var(--muted); }
.error { color: var(--ko); font-weight: 600; min-height: 1.4em; text-align: center; }
.error:not(:empty)::before { content: "✗ "; }

/* ---------- card e input ---------- */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 24px; width: min(440px, 100%); box-shadow: 0 8px 24px var(--shadow); }
.input {
  width: 100%; font: inherit; font-size: 20px; font-weight: 600; padding: 14px 18px; min-height: 52px; border-radius: var(--r-sm);
  border: 2px solid var(--border); background: var(--bg); color: var(--brand-secondary); text-align: center;
}
.input::placeholder { color: var(--muted); font-weight: 400; }
.input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.pin-input { font-size: 30px; font-weight: 800; letter-spacing: .15em; font-variant-numeric: tabular-nums; }

/* ---------- bottoni: pill, CTA verde ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 18px; padding: 12px 28px; min-height: 48px; border-radius: var(--r-pill);
  border: 2px solid var(--border); cursor: pointer; color: var(--brand-secondary); background: var(--bg);
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover:not(:disabled) { border-color: var(--brand-secondary); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--brand-cta); border-color: var(--brand-cta); color: var(--white); }
.btn.primary:hover:not(:disabled) { background: var(--brand-cta-light); border-color: var(--brand-cta-light); }
.btn.big { font-size: clamp(20px, 2vw, 26px); padding: 20px 40px; }
.btn:disabled { background: var(--bg-soft); border-color: var(--border); color: var(--disabled); cursor: not-allowed; }
.btn.link { background: none; border: 0; font-weight: 600; font-size: 15px; color: var(--muted); text-decoration: underline; padding: 8px; min-height: 44px; }
.btn.link:hover:not(:disabled) { color: var(--brand-primary); }
.topbar .btn { background: transparent; color: var(--white); border-color: var(--on-dark-line); font-size: 15px; padding: 8px 18px; min-height: 40px; }
.topbar .btn:hover:not(:disabled) { border-color: var(--white); }
.btn.quiz { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; width: 100%; border-radius: var(--r-md); }
.btn.quiz:hover:not(:disabled) { border-color: var(--brand-primary); }

/* ---------- lobby ---------- */
.pin {
  font-size: clamp(56px, 11vw, 140px); font-weight: 800; letter-spacing: .06em; line-height: 1;
  background: var(--bg); color: var(--brand-secondary); border-radius: var(--r-lg); padding: .12em .4em;
  font-variant-numeric: tabular-nums; box-shadow: 0 10px 30px var(--shadow);
}
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 8px 8px 8px 18px; font-weight: 700; font-size: 18px; color: var(--brand-secondary);
}
@media (prefers-reduced-motion: no-preference) { .chip { animation: pop .35s cubic-bezier(.2, .9, .3, 1.2); } }
.chip { padding: 4px; }
.chip-name { font: inherit; font-weight: 700; color: inherit; background: none; border: 0; padding: 6px 14px; min-height: 36px; cursor: pointer; border-radius: var(--r-pill); }
.chip-name:hover { background: var(--bg-soft); }
.chip.open { border-color: var(--brand-secondary); }
.chip-menu { display: inline-flex; gap: 6px; flex-wrap: wrap; padding-right: 4px; }
.mini { font: inherit; font-size: 14px; font-weight: 700; border: 0; border-radius: var(--r-pill); padding: 6px 12px; min-height: 36px; cursor: pointer; }
.mini.danger { background: var(--ko); color: var(--white); }

/* lobby: PIN e QR affiancati, squadre in colonne */
.join { display: flex; align-items: center; justify-content: center; gap: clamp(20px, 4vw, 56px); flex-wrap: wrap; margin-top: 8px; }
.join .center-block { margin: 0; }
.qr { width: clamp(160px, 18vw, 240px); height: auto; image-rendering: pixelated; background: var(--white); border-radius: var(--r-md); padding: 10px; box-shadow: 0 10px 30px var(--shadow); }
.teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.team-col { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.team-col .chips { padding: 0 10px; justify-content: flex-start; }
.team-head { margin: 0; padding: 10px 16px; font-size: 18px; font-weight: 800; }
.team-c0 { background: var(--brand-primary); color: var(--brand-secondary); }
.team-c1 { background: var(--brand-secondary); color: var(--white); }
.team-c2 { background: var(--brand-cta); color: var(--white); }
.team-c3 { background: var(--accent-light); color: var(--brand-secondary); }
.team-c4 { background: var(--brand-cta-lighter); color: var(--brand-secondary); }
.team-c5 { background: var(--primary-soft); color: var(--brand-secondary); }
.actions { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* impostazioni e setup partita */
.settings { position: fixed; top: 84px; right: clamp(16px, 3vw, 48px); z-index: 10; width: min(520px, calc(100vw - 32px)); box-shadow: 0 16px 40px var(--shadow-strong); }
.panel-title { font-size: 20px; font-weight: 800; color: var(--brand-secondary); }
.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 600; }
.switch input { width: 22px; height: 22px; accent-color: var(--brand-cta); flex: none; }
.setup { width: min(520px, 100%); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg .btn.on { background: var(--brand-secondary); border-color: var(--brand-secondary); color: var(--white); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; color: var(--brand-secondary); }
.field .input, .setup .input { text-align: left; font-size: 18px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

.count { font-size: clamp(32px, 5vw, 64px); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand-secondary); line-height: 1; }
.count.small { font-size: 32px; }

/* ---------- domanda ---------- */
.timerbar { height: 12px; background: var(--border); border-radius: 99px; overflow: hidden; }
.timerbar.slim { height: 8px; }
.timerfill { height: 100%; width: 100%; background: var(--brand-primary); }
.qtext {
  font-size: clamp(24px, 3.8vw, 52px); font-weight: 800; text-align: center; line-height: 1.15; padding: 12px 20px;
  color: var(--brand-secondary); background: var(--bg); border-radius: var(--r-md); box-shadow: 0 4px 16px var(--shadow); text-wrap: balance;
}
.qtext.small { font-size: clamp(20px, 5vw, 28px); }
.qtext.xl { font-size: clamp(30px, 5vw, 72px); background: none; box-shadow: none; }
.qimg { display: block; max-width: 100%; max-height: 30vh; object-fit: contain; border-radius: var(--r-md); margin: 0 auto; background: var(--bg); }
.tag { display: inline-block; margin-left: 10px; padding: 2px 12px; border-radius: 99px; background: var(--brand-primary); color: var(--brand-secondary); font-size: .8em; font-weight: 800; }

/* colori risposte A–D */
.c0 { background: var(--a-bg); color: var(--a-fg); }
.c1 { background: var(--b-bg); color: var(--b-fg); }
.c2 { background: var(--c-bg); color: var(--c-fg); }
.c3 { background: var(--d-bg); color: var(--d-fg); box-shadow: inset 0 0 0 3px var(--brand-primary); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; flex: 1; align-content: stretch; }
.tiles.two { grid-template-columns: 1fr 1fr; }
.tile {
  display: flex; align-items: center; gap: 16px; border: 0; border-radius: var(--r-md); font: inherit;
  font-weight: 700; font-size: clamp(18px, 2.6vw, 34px); line-height: 1.2; padding: 16px 22px; text-align: left;
  min-height: clamp(72px, 12vh, 110px); word-break: break-word; box-shadow: 0 6px 14px var(--shadow);
}
.tile.c3 { box-shadow: inset 0 0 0 3px var(--brand-primary), 0 6px 14px var(--shadow); }
button.tile { cursor: pointer; transition: transform .1s ease, box-shadow .1s ease, opacity .2s ease; }
button.tile:active:not(:disabled) { transform: translateY(3px) scale(.99); }
.shape { flex: none; width: 1.25em; height: 1.25em; display: inline-grid; place-items: center; }
.shape-ico { width: 100%; height: 100%; fill: currentColor; }
.tile.dim { opacity: .3; }
.tile.picked, .tile.sel { outline: 5px solid var(--brand-secondary); outline-offset: 3px; }
.tile[aria-pressed="true"]::after { content: "✓"; margin-left: auto; font-size: 1.2em; }
@media (max-width: 520px) { .tiles { grid-template-columns: 1fr; } .tile { min-height: 72px; } }

/* ---------- risultati ---------- */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 56px 1fr 80px; align-items: center; gap: 14px; }
.row.wrong { opacity: .5; }
.row.text { grid-template-columns: 1fr 80px; }
.badge { display: grid; place-items: center; height: 56px; border-radius: var(--r-sm); padding: 14px; }
.badge .shape-ico { width: 26px; height: 26px; }
.rowbar { position: relative; height: 56px; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.rowfill { position: absolute; inset: 0 auto 0 0; width: 0; opacity: .3; transition: width .8s cubic-bezier(.16, 1, .3, 1); }
.row.right .rowfill { opacity: .55; }
.rowfill.c3 { box-shadow: none; }
.rowfill.good { background: var(--ok); } .rowfill.bad { background: var(--border); }
.rowlabel { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 16px; font-weight: 700; font-size: clamp(16px, 2vw, 26px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--brand-secondary); mix-blend-mode: normal; }
.rowcount { font-size: clamp(20px, 2.6vw, 32px); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; color: var(--brand-secondary); }
.row.right .rowcount::before { content: "✓ "; color: var(--ok); }
.row.right .rowbar { box-shadow: inset 0 0 0 3px var(--ok); }

/* ---------- classifica ---------- */
.board { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.board.scroll { max-height: 30vh; overflow: auto; }
.lb {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 22px;
  font-weight: 700; font-size: clamp(17px, 2vw, 28px); color: var(--brand-secondary); font-variant-numeric: tabular-nums;
}
.board:not(.scroll) .lb:first-child { background: var(--brand-secondary); color: var(--white); border-color: var(--brand-secondary); }
.lb .gain { color: var(--ok); font-size: .8em; margin-left: 10px; }
.board:not(.scroll) .lb:first-child .gain { color: var(--brand-cta-lighter); }

/* ---------- podio ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; height: clamp(220px, 42vh, 400px); }
.pod {
  width: clamp(96px, 22vw, 240px); border-radius: var(--r-md) var(--r-md) 0 0; display: flex; flex-direction: column;
  align-items: center; padding-top: 14px; gap: 6px; text-align: center; font-weight: 800; overflow: hidden;
}
.pod .pname { font-size: clamp(15px, 2vw, 28px); padding: 0 8px; word-break: break-word; line-height: 1.15; }
.pod .medal { font-size: clamp(28px, 4.5vw, 56px); line-height: 1; font-variant-numeric: tabular-nums; }
.pod.p1 { height: 100%; background: var(--brand-primary); color: var(--brand-secondary); }
.pod.p2 { height: 76%; background: var(--brand-secondary); color: var(--white); }
.pod.p3 { height: 56%; background: var(--primary-soft); color: var(--brand-secondary); box-shadow: inset 0 0 0 3px var(--brand-primary); }

/* ---------- telefono: esito ---------- */
.result { border-radius: var(--r-lg); padding: 30px 18px; text-align: center; display: flex; flex-direction: column; gap: 8px; color: var(--white); }
.result .title { color: inherit; }
.result.ok { background: var(--ok); }
.result.ko { background: var(--ko); }
.result.none { background: var(--muted); }
.result.near { background: var(--brand-primary); color: var(--brand-secondary); }
.result.poll { background: var(--brand-secondary); }
.stats { align-self: center; display: flex; flex-direction: column; gap: 6px; font-size: 19px; text-align: center; font-variant-numeric: tabular-nums; }

.status { position: fixed; top: 0; left: 0; right: 0; background: var(--brand-primary); color: var(--brand-secondary); font-weight: 700; text-align: center; padding: 8px; font-size: 14px; z-index: 9; }

/* ---------- logo, slider, istogramma ---------- */
.logo { height: 40px; width: auto; max-width: 240px; object-fit: contain; align-self: center; }
.logo.big { height: 64px; max-width: min(360px, 100%); }
.bigvalue { font-size: clamp(40px, 12vw, 72px); font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; color: var(--brand-secondary); }
.range { width: 100%; height: 44px; accent-color: var(--brand-primary); }
.axis { display: flex; justify-content: space-between; gap: 12px; width: 100%; font-weight: 700; }
.hist { position: relative; height: clamp(160px, 28vh, 280px); border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--border); padding: 12px 10px 0; }
.hbars { position: relative; height: 100%; display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: 100%; gap: 6px; align-items: end; }
.hbar { background: var(--brand-primary); color: var(--brand-secondary); border-radius: 8px 8px 0 0; height: 0; transition: height .8s cubic-bezier(.16, 1, .3, 1); text-align: center; font-weight: 800; min-height: 0; }
.band { position: absolute; top: 0; bottom: 0; background: var(--ok-tint); }
.mark { position: absolute; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: var(--ok); }

@media print {
  body { background: var(--white); print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---------- host: audio, classifica, podio ---------- */
.audio { display: inline-flex; align-items: center; gap: 10px; }
.vol { width: 110px; accent-color: var(--brand-primary); }
.unlock { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; box-shadow: 0 12px 30px var(--shadow-strong); }
.talk { font-size: clamp(18px, 2.2vw, 28px); font-weight: 800; color: var(--brand-secondary); background: var(--primary-soft); border-radius: var(--r-pill); padding: 10px 24px; }
.messages { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }
.message { background: var(--primary-soft); color: var(--brand-secondary); font-weight: 800; font-size: clamp(17px, 2vw, 26px); border-radius: var(--r-pill); padding: 10px 24px; }
.lb-name { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.up { font-size: .7em; font-weight: 800; color: var(--brand-secondary); background: var(--brand-cta-lighter); border-radius: var(--r-pill); padding: 2px 10px; }
.dot { width: 18px; height: 18px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--white); }
.small { font-size: .7em; font-weight: 600; }
.board:not(.scroll) .lb:first-child .muted { color: var(--on-dark-muted); }
.pscore { font-variant-numeric: tabular-nums; font-size: clamp(16px, 2vw, 26px); }
.pod { transition: transform .7s cubic-bezier(.16, 1, .3, 1), opacity .5s ease; transform-origin: bottom; }
.pod.hidden { transform: scaleY(.05); opacity: 0; }

/* ---------- telefono: ingresso, forme, esito ---------- */
.tiles.shapes { grid-template-columns: 1fr 1fr; }
.tiles.shapes .tile { justify-content: center; min-height: clamp(130px, 28vh, 220px); }
.tiles.shapes .shape { width: clamp(56px, 16vw, 96px); height: clamp(56px, 16vw, 96px); }
.team-pick { font: inherit; font-weight: 800; font-size: 18px; border: 0; border-radius: var(--r-pill); padding: 12px 20px; min-height: 52px; cursor: pointer; }
.team-pick[aria-pressed="true"] { outline: 4px solid var(--brand-secondary); outline-offset: 3px; }
.team-pick[aria-pressed="true"]::after { content: " ✓"; }
.nick-big { font-size: clamp(28px, 8vw, 40px); font-weight: 800; color: var(--brand-secondary); line-height: 1.1; }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .mini { min-height: 28px; padding: 3px 10px; box-shadow: inset 0 0 0 1px var(--on-dark-line); }
.ahead { color: var(--brand-secondary); }
.medal-big { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; font-size: 56px; font-weight: 800; font-variant-numeric: tabular-nums; }
.medal-big.m1 { background: var(--brand-primary); color: var(--brand-secondary); }
.medal-big.m2 { background: var(--brand-secondary); color: var(--white); }
.medal-big.m3 { background: var(--primary-soft); color: var(--brand-secondary); box-shadow: inset 0 0 0 4px var(--brand-primary); }
