
/* Sala da biliardo di sera: panno verde, sponde di noce, ottone. Tema scuro scelto di proposito. */
:root {
  color-scheme: dark;
  --room: #17120f;
  --panel: #211914;
  --panel-2: #2b2019;
  --line: #4a3728;
  --text: #efe6d6;
  --muted: #a8977f;
  --brass: #d2a64a;
  --brass-dim: #8f6f2c;
  --brass-ink: #20160c;
  --chalk: #7fb6cf;
  --good: #9bd6a6;
  --bad: #e58a77;
  --cloth: #1d6a4d;
  --cloth-hi: #2b8c64;
  --cloth-lo: #114230;
  --cushion: #14513a;
  --wood: #5a3720;
  --wood-hi: #825230;
  --wood-lo: #36200f;
  --b-white: #f0e8d2;
  --b-yellow: #e9b832;
  --b-red: #c93a2c;
  --display: 'Alfa Slab One', Georgia, 'Times New Roman', serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--room); }
body {
  color: var(--text);
  font: 400 16px/1.45 var(--body);
  padding-block: 18px 44px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background-image: radial-gradient(ellipse 80% 340px at 50% 0, rgba(210, 166, 74, 0.10), transparent);
  background-repeat: no-repeat;
}
.app { max-width: 1040px; margin: 0 auto; }
h1, h2, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--chalk); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.brand h1 { font: 400 28px/1.05 var(--display); letter-spacing: 0.01em; color: var(--text); text-wrap: balance; }
.brand p { font: 500 13px/1.2 var(--cond); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); margin-top: 4px; }
.chip { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font: 500 14px/1 var(--cond); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.chip[aria-pressed="true"] { color: var(--brass); border-color: var(--brass-dim); }

.note { background: #3a1d17; border: 1px solid #7d3a2c; color: #ffd9cf; padding: 10px 14px; border-radius: 3px; margin-bottom: 14px; }
.note.info { background: var(--panel-2); border-color: var(--line); color: var(--text); }

.eyebrow { font: 600 13px/1.2 var(--cond); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); }

.btn { background: var(--brass); color: var(--brass-ink); border: 1px solid var(--brass); border-radius: 3px; padding: 12px 20px; font: 600 17px/1.1 var(--body); min-height: 48px; }
.btn:hover:not(:disabled) { background: #e2b95a; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brass); border-color: var(--brass-dim); }
.btn.ghost:hover:not(:disabled) { background: rgba(210, 166, 74, 0.12); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; flex-wrap: wrap; }
.seg button { background: transparent; border: 0; border-right: 1px solid var(--line); padding: 10px 16px; min-height: 44px; font: 500 16px/1 var(--body); color: var(--muted); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--brass); color: var(--brass-ink); font-weight: 600; }

/* Menu */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 22px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; min-width: 0; }
.card h2 { font: 400 24px/1.1 var(--display); }
.hint { color: var(--muted); font-size: 15px; max-width: 46ch; }
.join { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.join label { font: 600 13px/1.2 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.join-row { display: flex; gap: 10px; }
.join input { flex: 1; min-width: 0; background: var(--room); border: 1px solid var(--line); border-radius: 3px; padding: 10px 14px; font: 500 22px/1 var(--cond); letter-spacing: 0.3em; text-transform: uppercase; min-height: 48px; }
.fric { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 12px 0 6px; }
.fric input[type=range] { flex: 1 1 180px; max-width: 320px; min-height: 44px; accent-color: var(--brass); }
.fric output { font: 600 18px/1 var(--body); min-width: 7.5em; color: var(--ink, inherit); }
.fric-note { flex-basis: 100%; margin: 0; }
.frtag { margin-left: 10px; opacity: .75; }
.target { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 18px 0 6px; }
.rules { margin-top: 18px; color: var(--muted); }
.rules summary { cursor: pointer; font: 600 14px/1.4 var(--cond); letter-spacing: 0.12em; text-transform: uppercase; color: var(--brass); min-height: 32px; }
.rules ul { margin: 8px 0 0; padding-left: 20px; max-width: 70ch; }
.rules li { margin-bottom: 4px; }

/* Attesa */
.wait { max-width: 560px; margin: 24px auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.code { font: 400 clamp(52px, 16vw, 92px)/1 var(--display); letter-spacing: 0.14em; padding-left: 0.14em; color: var(--brass); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding-block: 14px; width: 100%; user-select: all; }
.wait .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Partita */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pl { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px 12px; min-width: 0; }
.pl.on { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass-dim) inset; }
.pl-h { display: flex; align-items: center; gap: 4px 8px; min-width: 0; flex-wrap: wrap; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.3); }
.nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 3ch; max-width: 100%; }
.pl-h .elo { font-size: 14px; }
.tg { margin-left: auto; font: 600 12px/1 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.pl.on .tg { color: var(--brass); }
.sc { font: 400 clamp(34px, 8vw, 52px)/1.1 var(--display); font-variant-numeric: tabular-nums; margin: 4px 0 6px; }
.sc { transform-origin: left center; }
.sc.flash { color: var(--brass); animation: scBlink 0.55s ease-in-out 3; }
.sc.pop { animation: scPop 0.45s ease-out; }
@keyframes scBlink { 0%, 100% { opacity: 1; transform: scale(1.12); } 50% { opacity: 0.08; transform: scale(1); } }
@keyframes scPop { 0% { transform: scale(1.5); color: var(--brass); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .sc.flash, .sc.pop { animation: none; } }
.beads { display: flex; gap: 3px; flex-wrap: wrap; }
.bead { width: 12px; height: 7px; border-radius: 2px; background: var(--line); }
.bead.on { background: var(--brass); }

.status { margin: 12px 0 0; font: 600 19px/1.25 var(--cond); letter-spacing: 0.04em; min-height: 26px; }
.status .peer { font-weight: 500; color: var(--muted); margin-left: 8px; font-size: 15px; }
.tablewrap { position: relative; margin: 10px 0 12px; }
#cv, #cv3 { display: block; margin: 0 auto; touch-action: none; border-radius: 8px; max-width: 100%; }
.coach { background: var(--panel); border: 1px solid var(--brass-dim); border-radius: 4px; padding: 12px 16px; margin: 0 0 12px; display: grid; gap: 10px; }
.coach-h { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; }
.coach-avg { font: 600 15px/1.2 var(--cond); letter-spacing: 0.05em; color: var(--text); display: inline-flex; gap: 10px; align-items: baseline; }
.coach-avg #coach-avg-txt b { color: var(--brass); font: 400 20px/1 var(--display); }
.linkbtn { background: none; border: 0; padding: 4px 2px; color: var(--muted); font: 500 14px/1 var(--cond); letter-spacing: 0.06em; text-decoration: underline; cursor: pointer; min-height: 32px; }
.coach-h b { font: 400 20px/1.1 var(--display); color: var(--brass); }
.cuepoint[hidden] { display: none; }
.cuepoint { display: flex; gap: 10px; align-items: center; margin: 8px 0 0; width: fit-content; max-width: 100%; background: rgba(23, 18, 15, 0.9); border: 1px solid var(--brass-dim); border-radius: 4px; padding: 8px 12px; pointer-events: none; font: 600 15px/1.25 var(--cond); letter-spacing: 0.04em; }
.ballface { flex: none; width: 62px; height: 62px; border-radius: 50%; position: relative; border: 2px solid var(--line); background: radial-gradient(circle at 38% 34%, #fffdf4, var(--b-white) 55%, #b9ad8e); }
.ballface::before, .ballface::after { content: ''; position: absolute; background: rgba(32, 22, 12, 0.22); }
.ballface::before { left: 50%; top: 8%; bottom: 8%; width: 1px; }
.ballface::after { top: 50%; left: 8%; right: 8%; height: 1px; }
.ballface i { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: #2c6fd1; border: 2px solid var(--brass-ink); transform: translate(-50%, -50%); left: 50%; top: 50%; }
.acad { background: var(--panel); border: 1px solid var(--brass-dim); border-radius: 4px; padding: 12px 16px; margin: 0 0 12px; display: grid; gap: 10px; }
.acad-h { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.acad-h b { font: 400 21px/1.15 var(--display); color: var(--brass); }
.acad p { margin: 0; }
.acad-fb { padding: 8px 12px; border-radius: 3px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 600; }
.acad-fb.good { color: var(--good); border-color: #4f8a5c; }
.acad-fb.bad { color: var(--bad); border-color: #7d3a2c; }
.lvl-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.lvl { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 16px; display: grid; gap: 8px; align-content: start; }
.lvl.locked { opacity: 0.55; }
.lvl h3 { font: 400 22px/1.15 var(--display); color: var(--brass); margin: 0; }
.lvl .num { font: 400 15px/1 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.lvl .bar { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.lvl .bar i { display: block; height: 100%; background: var(--brass); }
.lessons li .tick { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); font-weight: 700; }
.lessons li .tick.done { background: var(--good); color: var(--brass-ink); border-color: var(--good); }
.diploma { max-width: 760px; margin: 12px auto; padding: 34px 28px; text-align: center; background: linear-gradient(#fbf5e4, #efe3c3); color: #3a2a12; border: 10px double #a77d2c; border-radius: 4px; }
.diploma h2 { font: 400 40px/1.1 var(--display); margin: 0 0 6px; color: #7a561a; }
.diploma .who { font: 400 34px/1.2 var(--display); margin: 14px 0; border-bottom: 2px solid #a77d2c; display: inline-block; padding: 0 20px 4px; }
.diploma p { margin: 6px 0; font-size: 18px; }
.diploma .seal { font: 400 56px/1 var(--display); color: #a77d2c; }
@media print { body * { visibility: hidden; } .diploma, .diploma * { visibility: visible; } .diploma { position: absolute; left: 0; top: 0; width: 100%; } }
.trainbar { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.trainbar .check { margin: 0; }
.coach-body { display: flex; gap: 14px; align-items: center; }
.coach .grade { min-width: 74px; text-align: center; font: 400 34px/1 var(--display); padding: 10px 8px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); }
.coach .grade.good { color: var(--good); border-color: #4f8a5c; }
.coach .grade.mid { color: var(--brass); border-color: var(--brass-dim); }
.coach .grade.bad { color: var(--bad); border-color: #7d3a2c; }
.coach #coach-text { margin: 0; min-width: 0; }
.viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; }
.viewbar .lab { font: 600 13px/1.2 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.viewbar .seg button { padding: 8px 14px; min-height: 40px; font-size: 15px; }
.banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(23, 18, 15, 0.9); border: 1px solid var(--brass-dim); padding: 8px 16px; font: 600 18px/1.2 var(--cond); letter-spacing: 0.04em; text-align: center; max-width: 92%; opacity: 0; transition: opacity 0.25s; pointer-events: none; border-radius: 3px; }
.banner.show { opacity: 1; }
.banner.good { color: var(--good); border-color: #4f8a5c; }

.controls { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; }
.ctl { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ctl > label, .ctl > .lab { font: 600 13px/1.2 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.ctl-power { flex: 1 1 200px; }
.ctl-power small { font: 500 14px/1.2 var(--cond); letter-spacing: 0.04em; color: var(--muted); }
.charge { position: relative; height: 20px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: linear-gradient(90deg, var(--cloth-hi), var(--brass) 65%, var(--b-red)); }
.sitefoot { margin: 28px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; font: 600 14px/1.4 var(--cond); letter-spacing: 0.06em; color: var(--muted); }
.sitefoot a { color: var(--brass); }
.sitefoot .guide-links { display: block; margin-bottom: 6px; }
.check.privacy { align-items: flex-start; }
.verifybar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; margin: 0 0 14px; padding: 10px 14px; border: 1px solid var(--brass-dim); border-radius: 4px; background: var(--panel); }
.verifybar[hidden] { display: none; }
.authbox .linkish { display: inline-block; margin-top: 10px; }
.charge .tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(20, 14, 6, 0.85); z-index: 2; pointer-events: none; }
.charge .tick::after { content: attr(data-n); position: absolute; top: 50%; left: 5px; transform: translateY(-50%); font: 700 12px/1 var(--cond); color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.charge i { position: absolute; top: 0; bottom: 0; right: 0; width: 100%; background: var(--panel-2); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--cloth-hi), var(--brass) 70%, var(--b-red)); }
input[type=range]::-moz-range-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--cloth-hi), var(--brass) 70%, var(--b-red)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--text); border: 3px solid var(--brass-ink); margin-top: -9px; }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--text); border: 3px solid var(--brass-ink); }
.spin { width: 88px; height: 88px; border-radius: 50%; position: relative; touch-action: none; cursor: crosshair; border: 2px solid var(--line);
  background: radial-gradient(circle at 38% 34%, #fffdf4, var(--b-white) 55%, #b9ad8e); }
.spin::before, .spin::after { content: ''; position: absolute; background: rgba(32, 22, 12, 0.22); }
.spin::before { left: 50%; top: 8%; bottom: 8%; width: 1px; }
.spin::after { top: 50%; left: 8%; right: 8%; height: 1px; }
.spin i { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--b-red); border: 2px solid var(--brass-ink); transform: translate(-50%, -50%); left: 50%; top: 50%; }
.ctl-spin small { font: 500 14px/1 var(--cond); letter-spacing: 0.06em; color: var(--text); text-transform: uppercase; min-height: 14px; }
.fine { display: flex; gap: 8px; }
.fine button { width: 48px; height: 48px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; font: 600 24px/1 var(--body); color: var(--text); }
.fine button:active { background: var(--line); }
.btn.small[aria-pressed=true] { background: var(--brass); color: var(--brass-ink); }
.btn-shoot { font-size: 20px; min-width: 132px; min-height: 58px; letter-spacing: 0.03em; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.end { background: var(--panel); border: 1px solid var(--brass-dim); border-radius: 4px; padding: 18px; display: flex; gap: 14px 20px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.end p { font: 400 24px/1.15 var(--display); }
.end .row { display: flex; gap: 10px; flex-wrap: wrap; }
.log { margin-top: 12px; color: var(--muted); min-height: 24px; }
.replay { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin: 6px 0 10px; }
.replay label { color: var(--muted); font: 500 15px/1 var(--cond); letter-spacing: 0.04em; }
.replay select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 3px; padding: 8px 10px; min-height: 40px; font: 400 15px/1.2 var(--body); max-width: 100%; }
.replay #replay-sel { flex: 1 1 220px; min-width: 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.aimhint { min-height: 22px; margin: -2px 0 10px; font: 500 16px/1.3 var(--cond); letter-spacing: 0.04em; color: var(--muted); }
.aimhint.warn { color: var(--bad); }
.aimhint.ok { color: var(--good); }
.rules a { color: var(--brass); }
.foot { margin-top: 14px; display: flex; gap: 12px 20px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.foot .rules { margin: 0; flex: 1 1 300px; }

@media (max-width: 560px) {
  .brand h1 { font-size: 23px; }
  .card { padding: 18px; }
  .pl { padding: 10px 12px; }
  .bead { width: 9px; }
  .controls { padding: 12px; gap: 14px 16px; }
  .ctl-power { flex-basis: 100%; }
  .btn-shoot { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .banner { transition: none; } }

/* ===== Versione con account e server ===== */
a { color: var(--brass); }
.top { align-items: flex-end; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 18px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.nav a { padding: 10px 16px; min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; color: var(--muted); font: 600 15px/1 var(--cond); letter-spacing: 0.12em; text-transform: uppercase; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.nav a[aria-current="page"] { color: var(--brass); border-bottom-color: var(--brass); }
.nav a:hover { color: var(--text); }
.me-chip { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; min-height: 36px; font-weight: 600; }
.me-chip small { font: 600 13px/1 var(--cond); letter-spacing: 0.08em; color: var(--brass); }

h2.sec { font: 400 22px/1.15 var(--display); margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 18px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.panel > h2 { font: 400 20px/1.15 var(--display); }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-h h2 { font: 400 20px/1.15 var(--display); }
.empty { color: var(--muted); padding: 6px 0; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; flex-wrap: wrap; }
.list > li:first-child { border-top: 0; }
.grow { flex: 1 1 140px; min-width: 0; }
.who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who a { color: var(--text); text-decoration: none; }
.who a:hover { text-decoration: underline; }
.meta { color: var(--muted); font-size: 14px; }
.elo { font: 600 15px/1 var(--cond); letter-spacing: 0.06em; color: var(--brass); font-variant-numeric: tabular-nums; }
.dotc { width: 10px; height: 10px; border-radius: 50%; background: var(--good); display: inline-block; flex: none; }
.dotc.off { background: var(--line); }
.dotc.busy { background: var(--brass); }
.btn.small { padding: 8px 14px; min-height: 40px; font-size: 15px; }
.btn.danger { background: transparent; color: var(--bad); border-color: #7d3a2c; }
.btn.danger:hover:not(:disabled) { background: rgba(229, 138, 119, 0.12); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font: 600 12px/1 var(--cond); letter-spacing: 0.12em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.go { color: var(--brass-ink); background: var(--brass); border-color: var(--brass); }
.pill.good { color: var(--good); border-color: #4f8a5c; }
.pill.bad { color: var(--bad); border-color: #7d3a2c; }

/* moduli */
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.field > label, .field > .lab { font: 600 13px/1.2 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=search], .field input[type=number], .field select {
  background: var(--room); border: 1px solid var(--line); border-radius: 3px; padding: 10px 14px; min-height: 48px; width: 100%; color: var(--text); font-size: 17px; }
.field .err { color: var(--bad); font-size: 14px; min-height: 18px; }
.field input[aria-invalid="true"] { border-color: var(--bad); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--brass); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; width: 100%; }
.authbox { max-width: 460px; margin: 10px auto 0; display: flex; flex-direction: column; gap: 16px; }
.authbox form { display: flex; flex-direction: column; gap: 14px; }
.formerr { color: var(--bad); min-height: 22px; }

/* classifica */
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font: 600 13px/1.2 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 10px; border-top: 1px solid var(--line); vertical-align: middle; }
table.tbl tr.me td { background: rgba(210, 166, 74, 0.10); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tablescroll { overflow-x: auto; }
.rank { font: 400 20px/1 var(--display); color: var(--brass); min-width: 2ch; display: inline-block; }

/* profilo */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 12px; }
.stat b { display: block; font: 400 28px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { font: 600 12px/1.2 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.spark { width: 100%; height: 90px; display: block; }
.spark polyline { fill: none; stroke: var(--brass); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* tornei */
.bracket { display: flex; gap: 18px; overflow-x: auto; padding-bottom: 8px; align-items: stretch; }
.round { display: flex; flex-direction: column; justify-content: space-around; gap: 12px; min-width: 210px; flex: 1 0 210px; }
.round h3 { font: 600 13px/1.2 var(--cond); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); margin: 0 0 4px; }
.match { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.match.live { border-color: var(--brass-dim); }
.match .side { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.match .side.win { color: var(--good); font-weight: 600; }
.match .side.lose { color: var(--muted); }
.match .side.tbd { color: var(--muted); font-style: italic; }
.match .foot2 { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 2px; }
.champion { text-align: center; padding: 18px; border: 1px solid var(--brass-dim); border-radius: 4px; background: var(--panel-2); }
.champion b { font: 400 30px/1.1 var(--display); color: var(--brass); display: block; }

/* avvisi in alto a destra */
.toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(92vw, 380px); }
.toast { background: var(--panel-2); border: 1px solid var(--brass-dim); border-radius: 4px; padding: 12px 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.toast.err { border-color: #7d3a2c; background: #3a1d17; }
.toast .row-btns { flex: none; }

/* finestra di dialogo */
.overlay { position: fixed; inset: 0; background: rgba(8, 5, 3, 0.75); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.dialog { background: var(--panel); border: 1px solid var(--brass-dim); border-radius: 6px; padding: 22px; width: min(100%, 460px); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { font: 400 22px/1.15 var(--display); }

.gameinfo { margin-top: 6px; color: var(--muted); font-size: 14px; }
.gameinfo span + span::before { content: ' · '; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 560px) {
  .pl .tg { flex-basis: 100%; margin-left: 22px; }
  .panel { padding: 14px; }
  .nav a { padding: 10px 11px; font-size: 14px; }
  .toasts { left: 12px; right: 12px; max-width: none; }
}

/* ===== Telefono: il tavolo occupa tutto lo schermo, i comandi essenziali stanno ai bordi e il resto nel pannello «Comandi» ===== */
.menu-btn, .sheet, .sheet-bd, .spin-bd, .spin-ok { display: none; }
html.mobgame, html.mobgame body { overflow: hidden; overscroll-behavior: none; height: 100%; }
html.mobgame .top, html.mobgame .nav, html.mobgame .verifybar, html.mobgame #note, html.mobgame .sitefoot, html.mobgame #main { display: none !important; }
html.mobgame #v-game {
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh; z-index: 30; box-sizing: border-box; background: var(--room);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "top" "table" "hud";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
@media (orientation: landscape) {
  html.mobgame #v-game { grid-template-columns: minmax(0, 1fr) 210px; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top top" "table hud"; }
}
html.mobgame .board { grid-area: top; display: flex; gap: 6px; padding: 4px 118px 4px 6px; margin: 0; }
html.mobgame .board .pl { flex: 1 1 0; display: flex; align-items: center; gap: 6px; padding: 2px 8px; min-width: 0; }
html.mobgame .board .pl-h { flex: 1 1 auto; flex-wrap: nowrap; min-width: 0; }
html.mobgame .board .pl-h .elo, html.mobgame .board .pl-h .tg, html.mobgame .board .beads { display: none; }
html.mobgame .board .sc { font-size: 24px; margin: 0; }
html.mobgame .menu-btn { display: block; grid-area: top; justify-self: end; align-self: center; margin-right: 6px; z-index: 6; min-height: 42px; padding: 6px 12px; font: 600 15px/1 var(--cond); letter-spacing: 0.04em; background: var(--panel); border: 1px solid var(--brass-dim); color: var(--brass); border-radius: 4px; }
html.mobgame #turn { grid-area: table; align-self: start; justify-self: center; z-index: 4; margin: 6px; max-width: calc(100% - 12px); padding: 4px 12px; border-radius: 14px; background: rgba(23, 18, 15, 0.84); font-size: 14px; min-height: 0; pointer-events: none; text-align: center; }
html.mobgame #turn:empty { display: none; }
html.mobgame #turn { transition: opacity 0.6s ease; }
html.mobgame #turn.fade { opacity: 0; }
html.mobgame .charge .tick::after { font-size: 10px; left: 3px; }
html.mobgame .aimhint { grid-area: table; align-self: end; justify-self: center; z-index: 4; margin: 6px; padding: 3px 10px; border-radius: 12px; background: rgba(23, 18, 15, 0.84); font-size: 14px; min-height: 0; pointer-events: none; text-align: center; }
html.mobgame .aimhint:empty { display: none; }
html.mobgame .cuepoint:not([hidden]) { grid-area: table; align-self: start; justify-self: start; margin: 46px 0 0 6px; z-index: 4; padding: 4px 8px; font-size: 12px; max-width: 48%; }
html.mobgame .cuepoint .ballface { width: 36px; height: 36px; }
html.mobgame .cuepoint:not([hidden]) { position: relative; pointer-events: auto; transition: opacity 0.5s ease; padding-right: 26px; }
html.mobgame .cuepoint:not([hidden])::after { content: '×'; position: absolute; top: 2px; right: 8px; font: 400 20px/1 var(--body); color: var(--muted); }
html.mobgame .cuepoint.gone { opacity: 0; pointer-events: none; }
html.mobgame #tablewrap { grid-area: table; margin: 0; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; overflow: hidden; }
html.mobgame #cv, html.mobgame #cv3 { margin: 0; border-radius: 6px; max-width: none; }
html.mobgame .banner { top: 44px; font-size: 16px; }
html.mobgame .controls { grid-area: hud; margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 6px 8px; gap: 6px 10px; align-items: center; flex-wrap: wrap; }
html.mobgame .ctl-power { order: 3; flex: 1 1 90px; }
html.mobgame .ctl-power > .lab, html.mobgame .ctl-power small, html.mobgame .ctl-spin > .lab, html.mobgame .ctl-spin small, html.mobgame .ctl-fine > .lab { display: none; }
html.mobgame .ctl-spin { order: 1; }
html.mobgame .ctl-fine { order: 2; }
html.mobgame .ctl-repo { order: 0; flex: 1 1 100%; }
html.mobgame .ctl-repo > .lab { display: none; }
html.mobgame .spin { width: 52px; height: 52px; cursor: pointer; }
html.mobgame .spin i { width: 11px; height: 11px; }
html.mobgame .fine button { width: 44px; height: 44px; }
html.mobgame .btn-shoot { order: 4; flex: 0 0 auto; min-width: 96px; min-height: 56px; font-size: 19px; }
@media (orientation: landscape) {
  html.mobgame .controls { border-top: 0; border-left: 1px solid var(--line); align-content: flex-end; padding: 8px 10px; gap: 10px; }
  html.mobgame .ctl-power { order: 1; flex: 1 1 100%; }
  html.mobgame .ctl-spin { order: 2; }
  html.mobgame .ctl-fine { order: 3; flex: 1 1 auto; }
  html.mobgame .btn-shoot { order: 4; flex: 1 1 100%; min-height: 76px; font-size: 22px; }
}
html.mobgame .spin-bd.on { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.62); z-index: 70; }
html.mobgame .spin.big { position: fixed; left: 50%; top: 44%; width: min(280px, 72vw); height: min(280px, 72vw); transform: translate(-50%, -50%); z-index: 71; cursor: crosshair; }
html.mobgame .spin.big i { width: 20px; height: 20px; }
html.mobgame .spin-ok.on { display: block; position: fixed; left: 50%; top: calc(44% + min(140px, 36vw) + 22px); transform: translateX(-50%); z-index: 71; min-width: 140px; }
html.mobgame .sheet-bd.on { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 48; }
html.mobgame .sheet { display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; max-height: 76vh; max-height: 76dvh; z-index: 50; background: var(--panel); border-top: 2px solid var(--brass-dim); border-radius: 14px 14px 0 0; transform: translateY(108%); transition: transform 0.22s ease; padding-bottom: env(safe-area-inset-bottom); }
html.mobgame .sheet.open { transform: none; }
.sheet-h { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sheet-h b { font: 400 20px/1 var(--display); color: var(--brass); }
.sheet-body { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 10px 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.sheet-body > * { margin: 0 !important; flex: none; min-width: 0; max-width: 100%; box-sizing: border-box; }
.sheet-body .log { min-height: 0; }
.sheet-body .replay select { max-width: 100%; }
html.mobgame .end { position: fixed; left: 12px; right: 12px; top: 50%; transform: translateY(-50%); z-index: 60; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6); }
@media (prefers-reduced-motion: reduce) { html.mobgame .sheet { transition: none; } }

/* ===== Replay: elenco dei salvati e barra di riproduzione ===== */
.rpbar { background: var(--panel); border: 1px solid var(--brass-dim); border-radius: 4px; padding: 10px 14px; display: grid; gap: 8px; }
.rp-info { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; min-width: 0; }
.rp-info b { font: 400 18px/1.2 var(--display); color: var(--brass); }
.rp-info #rp-pos { font: 600 14px/1 var(--cond); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.rp-info #rp-text { flex: 1 1 100%; color: var(--text); font-size: 15px; min-height: 20px; }
.rp-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rp-btns button:not(.btn) { width: 46px; height: 46px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; color: var(--text); font: 600 18px/1 var(--body); }
.rp-btns button:disabled { opacity: 0.4; }
.rp-btns select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 3px; padding: 8px 10px; min-height: 46px; font: 400 15px/1.2 var(--body); }
.rp-list li .kind { flex: none; }
html.mobgame .rpbar:not([hidden]) { grid-area: hud; margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 6px 8px; gap: 6px; }
html.mobgame .rpbar #rp-text { display: none; }
html.mobgame .rp-info b { font-size: 14px; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.mobgame .rp-info { flex-wrap: nowrap; }
html.mobgame .rp-btns { gap: 6px; }
html.mobgame .rp-btns button:not(.btn) { width: 40px; height: 40px; }
html.mobgame .rp-btns .btn { min-height: 40px; padding: 8px 12px; }
html.mobgame .rp-btns select { min-height: 40px; padding: 6px; }
@media (orientation: landscape) { html.mobgame .rpbar:not([hidden]) { border-top: 0; border-left: 1px solid var(--line); align-content: end; } }
