﻿:root {
  --cream: #FDF7EB;
  --cream-2: #F6EBD3;
  --cream-3: #EFDFBC;
  --card: #FFFDF8;
  --navy: #152242;
  --navy-2: #24386f;
  --navy-soft: #e8ebf5;
  --gold: #E6BE69;
  --gold-2: #F4D993;
  --gold-deep: #b98a25;
  --muted: #65708f;
  --ok: #2c8a58;
  --ok-bg: #dff3e7;
  --danger: #c4432c;
  --danger-bg: #fbe3dd;
  --warn-bg: #fdf0cf;
  --radius: 22px;
  --shadow: 0 2px 0 rgba(21, 34, 66, .06), 0 14px 30px -14px rgba(21, 34, 66, .28);
  --font: "Baloo 2", ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--cream); color: var(--navy); font-family: var(--font);
  font-size: 17px; line-height: 1.4; min-height: 100vh; min-height: 100dvh;
  background-image: radial-gradient(circle at 12% -5%, var(--gold-2) 0, transparent 34%), radial-gradient(circle at 105% 30%, #f2e4c2 0, transparent 30%);
  background-attachment: fixed;
}
h1, h2, h3 { line-height: 1.1; margin: 0 0 .5em; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 2rem; } h2 { font-size: 1.45rem; } h3 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
a { color: var(--navy-2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hide { display: none !important; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.grow { flex: 1; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Layout app utenti ---------- */
.app { max-width: 560px; margin: 0 auto; padding: 18px 16px 110px; }
.topbar { display: flex; align-items: center; justify-content: center; padding: 6px 0 14px; }
.topbar img { height: 92px; width: auto; }
.logo-sm { height: 54px !important; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--cream) 60%, transparent);
}
.tabbar nav {
  display: flex; gap: 4px; background: var(--navy); border-radius: 999px; padding: 6px; box-shadow: var(--shadow); width: 100%; max-width: 520px;
}
.tabbar a {
  flex: 1; text-align: center; padding: 9px 4px 7px; border-radius: 999px; color: #cdd3ea; text-decoration: none; font-weight: 700; font-size: .78rem; line-height: 1.1;
}
.tabbar a b { display: block; font-size: 1.25rem; line-height: 1.2; }
.tabbar a.active { background: var(--gold); color: var(--navy); }

/* ---------- Componenti ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 2px solid var(--navy);
  position: relative;
}
.card.gold { background: var(--gold); }
.card.navy { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.card.navy .muted { color: #b5bfdf; }
.card.flat { box-shadow: none; }
.card h2 { margin-bottom: .3em; }
.suit { position: absolute; right: 16px; top: 10px; font-size: 1.6rem; opacity: .18; pointer-events: none; }

.btn {
  appearance: none; border: 2px solid var(--navy); background: var(--navy); color: var(--cream); font: inherit; font-weight: 800;
  padding: 13px 22px; border-radius: 999px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, box-shadow .08s ease, background .15s; box-shadow: 0 4px 0 rgba(21, 34, 66, .35); min-height: 50px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(21, 34, 66, .35); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.ghost { background: transparent; color: var(--navy); box-shadow: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: 0 4px 0 rgba(120, 30, 15, .35); }
.btn.sm { min-height: 38px; padding: 7px 14px; font-size: .9rem; box-shadow: 0 3px 0 rgba(21, 34, 66, .3); }
.btn.block { width: 100%; }
.btn.tiny { min-height: 30px; padding: 3px 11px; font-size: .8rem; box-shadow: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; font-weight: 800; font-size: .8rem;
  background: var(--navy-soft); color: var(--navy); border: 1.5px solid rgba(21, 34, 66, .18); white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(44, 138, 88, .3); }
.chip.bad { background: var(--danger-bg); color: var(--danger); border-color: rgba(196, 67, 44, .3); }
.chip.warn { background: var(--warn-bg); color: #8a6412; border-color: rgba(185, 138, 37, .4); }
.chip.gold { background: var(--gold); border-color: var(--navy); }

label.field { display: block; font-weight: 700; font-size: .92rem; }
.field > span { display: block; margin: 0 0 4px 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-weight: 600; color: var(--navy); background: #fff; border: 2px solid var(--navy); border-radius: 16px;
  padding: 12px 14px; min-height: 48px; outline: none;
}
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 4px var(--gold-2); }
input::placeholder { color: #a5abc0; font-weight: 500; }
input[type=checkbox] { width: 24px; height: 24px; min-height: 0; accent-color: var(--navy); flex: none; }
input[type=number] { -moz-appearance: textfield; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; font-size: .92rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 440px) { .grid2.collapse { grid-template-columns: 1fr; } }

.seg { display: flex; background: var(--cream-2); border: 2px solid var(--navy); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { flex: 1; font: inherit; font-weight: 800; border: 0; background: transparent; color: var(--navy); padding: 10px 6px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--navy); color: var(--cream); }

.progress { height: 14px; border-radius: 99px; background: var(--cream-3); border: 2px solid var(--navy); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); border-right: 2px solid var(--navy); transition: width .4s; }
.progress.big { height: 22px; }

.notice { border-radius: 18px; padding: 12px 14px; font-weight: 600; font-size: .92rem; background: var(--warn-bg); border: 2px solid var(--gold-deep); }
.notice.bad { background: var(--danger-bg); border-color: var(--danger); }
.notice.ok { background: var(--ok-bg); border-color: var(--ok); }
.notice.info { background: var(--navy-soft); border-color: var(--navy); }

.toast-wrap { position: fixed; left: 0; right: 0; top: 12px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { background: var(--navy); color: var(--cream); padding: 12px 20px; border-radius: 999px; font-weight: 700; box-shadow: var(--shadow); animation: pop .25s ease; max-width: 92vw; }
.toast.bad { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { transform: translateY(-14px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-bg { position: fixed; inset: 0; background: rgba(21, 34, 66, .55); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@media (min-width: 620px) { .modal-bg { align-items: center; } }
.modal { background: var(--cream); border: 2px solid var(--navy); border-radius: 28px 28px 0 0; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); animation: rise .2s ease; }
@media (min-width: 620px) { .modal { border-radius: 28px; } }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { transform: translateY(40px); opacity: 0; } }

/* ---------- Tabelle ---------- */
.tablewrap { overflow-x: auto; border-radius: 16px; border: 2px solid var(--navy); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th { background: var(--navy); color: var(--cream); text-align: left; padding: 9px 10px; font-weight: 800; white-space: nowrap; }
td { padding: 9px 10px; border-top: 1px solid var(--cream-3); vertical-align: middle; }
tr:nth-child(even) td { background: #fffaf0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Home / selezione ---------- */
.hero { text-align: center; }
.countdown { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.countdown div { background: var(--navy); color: var(--cream); border-radius: 16px; padding: 8px 10px; min-width: 64px; }
.countdown b { display: block; font-size: 1.6rem; line-height: 1; }
.countdown span { font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--gold-2); }

.team-list { display: grid; gap: 8px; }
.team-btn {
  font: inherit; font-weight: 800; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 2px solid var(--navy); background: #fff; color: var(--navy); border-radius: 18px; padding: 13px 16px; cursor: pointer; min-height: 54px;
}
.team-btn:active { background: var(--gold-2); }
.team-btn[disabled] { opacity: .45; background: var(--cream-2); cursor: not-allowed; text-decoration: line-through; }

.codebox { font-size: 2.6rem; font-weight: 800; letter-spacing: .18em; text-align: center; background: var(--navy); color: var(--gold); border-radius: 20px; padding: 14px 8px 14px 20px; user-select: all; }
.codeinput { text-align: center; font-size: 1.9rem; letter-spacing: .3em; text-transform: uppercase; font-weight: 800; }

/* ---------- Partita ---------- */
.timer { text-align: center; }
.timer .clock { font-size: 4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.timer.low .clock { color: var(--danger); animation: pulse 1s infinite; }
.timer.over .clock { color: var(--gold); }
@keyframes pulse { 50% { opacity: .55; } }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; text-align: center; }
.vs .team { font-weight: 800; font-size: 1.1rem; line-height: 1.15; word-break: break-word; }
.vs .team.me { color: var(--gold-deep); }
.vs .sep { font-weight: 800; background: var(--gold); border: 2px solid var(--navy); border-radius: 50%; width: 42px; height: 42px; display: grid; place-items: center; }
.turnrow { display: grid; grid-template-columns: 48px 1fr 1fr; gap: 10px; align-items: center; padding: 10px 0; border-top: 2px dashed var(--cream-3); }
.turnrow:first-of-type { border-top: 0; }
.turnrow .n { width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: var(--cream); font-weight: 800; display: grid; place-items: center; }
.turnrow input { font-size: 1.35rem; text-align: center; font-variant-numeric: tabular-nums; padding: 8px; }
.turnrow .opp { text-align: center; font-size: 1.35rem; font-weight: 800; color: var(--muted); background: var(--cream-2); border-radius: 16px; padding: 8px; min-height: 48px; }
.turnrow .opp.done { color: var(--navy); }
.turnrow input.saved { border-color: var(--ok); background: #f4fbf7; }
.turnrow input.dirty { border-color: var(--gold-deep); background: #fff9e8; }
.totals { display: grid; grid-template-columns: 48px 1fr 1fr; gap: 10px; padding-top: 10px; border-top: 3px solid var(--navy); font-weight: 800; font-size: 1.3rem; text-align: center; }
.vpbadge { display: inline-grid; place-items: center; min-width: 56px; padding: 4px 12px; border-radius: 14px; background: var(--gold); border: 2px solid var(--navy); font-weight: 800; font-size: 1.3rem; }
.result-card { display: grid; gap: 6px; }
.result-card .line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- Classifica ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 8px; align-items: end; margin: 8px 0 18px; }
.pod { text-align: center; }
.pod .name { font-weight: 800; line-height: 1.1; margin-bottom: 8px; word-break: break-word; font-size: .98rem; }
.pod .block {
  border: 2px solid var(--navy); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 14px 6px 12px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  box-shadow: var(--shadow); animation: grow .7s cubic-bezier(.2, 1.2, .4, 1) backwards;
}
.pod .medal { font-size: 2.1rem; line-height: 1; }
.pod .vp { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.pod .vp small { font-size: .7rem; display: block; letter-spacing: .06em; }
.pod.p1 .block { background: linear-gradient(#f9e2a1, var(--gold)); height: 170px; animation-delay: .35s; }
.pod.p2 .block { background: linear-gradient(#f0f2f8, #c9cfe0); height: 128px; animation-delay: .15s; }
.pod.p3 .block { background: linear-gradient(#f0cba4, #d29a63); height: 104px; animation-delay: 0s; }
@keyframes grow { from { transform: scaleY(0); opacity: 0; } to { transform: none; opacity: 1; } }
.pod .block { transform-origin: bottom; }
.rank-list { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--navy); border-radius: 18px; padding: 10px 12px; animation: rise .35s ease backwards; }
.rank-row .pos { font-weight: 800; font-size: 1.15rem; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--cream-2); border: 2px solid var(--navy); }
.rank-row .nm { font-weight: 800; line-height: 1.1; word-break: break-word; }
.rank-row .sub { font-size: .78rem; color: var(--muted); font-weight: 600; }
.rank-row .score { text-align: right; font-weight: 800; font-size: 1.35rem; line-height: 1; }
.rank-row .score small { display: block; font-size: .65rem; letter-spacing: .06em; color: var(--muted); }
.rank-row.me { background: var(--gold-2); }
canvas.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- Admin ---------- */
.admin { max-width: 1120px; margin: 0 auto; padding: 14px 16px 60px; }
.admin-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 0 14px; }
.admin-top img { height: 56px; }
.admin-top .grow { min-width: 120px; }
.admin-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs button { font: inherit; font-weight: 800; border: 2px solid var(--navy); background: #fff; color: var(--navy); padding: 8px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.admin-tabs button.on { background: var(--navy); color: var(--cream); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi { background: #fff; border: 2px solid var(--navy); border-radius: 18px; padding: 12px 14px; }
.kpi b { display: block; font-size: 1.8rem; line-height: 1.1; }
.kpi span { font-size: .8rem; color: var(--muted); font-weight: 700; }
.match-card { border: 2px solid var(--navy); border-radius: 18px; background: #fff; padding: 12px 14px; }
.match-card.bye { background: var(--cream-2); }
.match-card .tn { font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.match-card .teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-weight: 800; }
.match-card .teams > :last-child { text-align: right; }
.match-card .scores { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); font-weight: 700; }
.match-card .scores > :last-child { text-align: right; }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 2px dashed var(--cream-3); flex-wrap: wrap; }
.menu-item:first-child { border-top: 0; }
.qr-secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.15rem; letter-spacing: .12em; background: #fff; border: 2px dashed var(--navy); border-radius: 14px; padding: 12px; word-break: break-all; text-align: center; user-select: all; font-weight: 700; }
.loader { display: grid; place-items: center; padding: 60px 0; }
.loader i { width: 44px; height: 44px; border-radius: 50%; border: 6px solid var(--cream-3); border-top-color: var(--navy); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Il logo ha lo sfondo crema: multiply lo fonde con la pagina */
.topbar img, .admin-top img, .login-logo { }
.login-logo { display: block; margin: 0 auto 6px; height: 110px; }
.login-wrap { max-width: 420px; margin: 0 auto; padding: 30px 16px; }
details.round > summary { cursor: pointer; font-weight: 800; padding: 8px 0; list-style: none; }
details.round > summary::-webkit-details-marker { display: none; }
details.round > summary::before { content: '▸ '; }
details.round[open] > summary::before { content: '▾ '; }
.selectable { cursor: pointer; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.phone { color: var(--navy-2); font-weight: 700; text-decoration: none; white-space: nowrap; }

.modal p { white-space: pre-line; }


.card.navy .btn.ghost { color: var(--cream); border-color: var(--cream); }
