/* Telefono: una colonna a tutta altezza, azioni in basso a portata di pollice, niente scroll durante il gioco */
html, body.phone { height: 100%; overscroll-behavior: none; }
body.phone { font-size: 16px; }
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 560px; margin: 0 auto; }
main { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 0 16px; }
.screen { padding: 14px 0 18px; }

/* intestazione */
.top { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; background: rgba(6, 10, 28, .85); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.top .avbox { width: 40px; height: 40px; }
.me-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.me-t b { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role { font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.role.conc { color: var(--lo); } .role.sens { color: var(--gold); }
.me-sc { font-size: 1.15rem; color: var(--gold-hi); white-space: nowrap; }
.ibtn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: var(--cream); display: grid; place-items: center; font-size: 1.15rem; cursor: pointer; flex: none; touch-action: manipulation; }

/* barra del tempo */
.tbar { position: relative; height: 22px; background: rgba(255, 255, 255, .05); }
.tbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--gold-lo), var(--gold)); transition: width .25s linear; }
.tbar.low i { background: linear-gradient(90deg, #8c0c22, var(--bad)); }
.tbar span { position: absolute; right: 10px; top: 0; line-height: 22px; font-size: .85rem; color: var(--cream); text-shadow: 0 1px 2px #000; }

/* ingresso */
.join { display: flex; flex-direction: column; gap: 10px; }
.join-logo { text-align: center; margin-top: 10px; }
.join-logo .logo { font-size: 3.6rem; }
.lead { text-align: center; color: var(--muted); margin: 0 0 6px; font-weight: 700; }
.join-form { display: flex; flex-direction: column; gap: 8px; }
.lbl { font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
input { font: inherit; color: var(--cream); background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; width: 100%; }
.code-in { font-size: 2.3rem; text-align: center; letter-spacing: .3em; text-transform: uppercase; color: var(--gold-hi); padding: 8px; }
.name-in { font-size: 1.15rem; font-weight: 700; }
.av-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.av-pick { appearance: none; border: 0; background: rgba(255, 255, 255, .04); border-radius: 18px; padding: 10px; aspect-ratio: 1; cursor: pointer; transition: transform .1s, background .2s; }
.av-pick[aria-checked="true"] { background: rgba(245, 196, 81, .22); box-shadow: inset 0 0 0 2px var(--gold); transform: scale(1.04); }
.av-pick:disabled { opacity: .2; }
.err-t { color: var(--bad); font-weight: 800; min-height: 1.3em; }

/* sala d'attesa */
.lobby-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.lobby-h h2 { font-size: 1.9rem; }
.room-code { font-family: var(--f-num); font-size: 1.4rem; letter-spacing: .2em; color: var(--gold-hi); }
.plist { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 14px; }
.pcard { padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.pcard .avbox { width: 64px; height: 64px; }
.pcard b { font-size: 1.05rem; }
.pcard small { color: var(--muted); font-weight: 700; font-size: .78rem; }
.pcard.empty { border-style: dashed; color: var(--muted); justify-content: center; min-height: 124px; font-weight: 700; }
.set { padding: 16px; display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.set h3 { font-size: 1.3rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row .t { display: flex; flex-direction: column; }
.row .t b { font-size: 1rem; } .row .t small { color: var(--muted); font-size: .8rem; font-weight: 600; }
.seg { display: inline-flex; background: rgba(255, 255, 255, .06); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--cream); font-weight: 800; padding: 8px 16px; border-radius: 999px; min-height: 38px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--gold); color: #2a1a00; }
.sw { appearance: none; border: 0; width: 56px; height: 32px; border-radius: 999px; background: rgba(255, 255, 255, .15); position: relative; cursor: pointer; flex: none; transition: background .2s; }
.sw::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.sw[aria-checked="true"] { background: var(--ok); } .sw[aria-checked="true"]::after { transform: translateX(24px); }
.sw:disabled { opacity: .35; }
.wait-note { text-align: center; color: var(--muted); font-weight: 700; padding: 10px; }
.mini-av { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.mini-av .av-pick { padding: 4px; border-radius: 12px; }

/* partita */
.play { display: flex; flex-direction: column; gap: 12px; }
.pinfo { display: flex; flex-direction: column; gap: 10px; }
.kick { font-size: .72rem; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.headline { font-size: 1.75rem; line-height: 1.1; }
.headline em { color: var(--gold); }
.muted { color: var(--muted); font-weight: 600; margin: 0; }
.hero { padding: 16px; display: flex; align-items: center; gap: 14px; }
.hero .box { width: 74px; flex: none; }
.hero .hx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero .bigv { font-family: var(--f-num); font-size: 2.1rem; font-weight: 600; line-height: 1.05; }
.bigv.lo { color: var(--lo); } .bigv.hi { color: var(--hi); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats > div { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; }
.stats small { font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stats b { font-family: var(--f-num); font-weight: 600; font-size: 1.05rem; }
.counter { display: flex; align-items: center; gap: 10px; }
.counter .n { font-family: var(--f-num); font-size: 3rem; color: var(--gold-hi); line-height: 1; }
.counter .t { font-family: var(--f-title); font-style: italic; font-weight: 900; font-size: 1.5rem; line-height: 1.05; }
.pgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pgrid:empty { display: none; }
.pgrid .box.sel { box-shadow: 0 0 0 3px #fff, 0 0 18px rgba(255, 255, 255, .6); transform: scale(1.05); }
.pgrid button.box:disabled:not(.open):not(.own) { opacity: .55; }
.pgrid .box.open { cursor: default; }

/* offerta / cambio sul telefono del concorrente */
.offer { padding: 22px 16px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.offer .amount { font-family: var(--f-num); font-size: 3.6rem; font-weight: 700; line-height: 1; }
.offer .quip { font-family: var(--f-title); font-style: italic; font-size: 1.2rem; }
.offer .quip::before { content: '« '; color: var(--gold); } .offer .quip::after { content: ' »'; color: var(--gold); }
.ring-ic { font-size: 4rem; color: var(--gold); animation: ring 1.4s ease-in-out infinite; }

/* compositore del Sensale */
.secret { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: linear-gradient(180deg, rgba(179, 18, 46, .35), rgba(18, 28, 70, .9)); }
.secret small { font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #ffb3ba; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: rgba(255, 255, 255, .06); border-radius: 999px; padding: 4px; gap: 4px; }
.tabs button { appearance: none; border: 0; background: transparent; color: var(--cream); font-weight: 800; min-height: 44px; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.tabs button[aria-pressed="true"] { background: var(--gold); color: #2a1a00; }
.tabs button:disabled { opacity: .35; }
.composer { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.amt-row { display: flex; align-items: center; gap: 10px; }
.amt-row .amount { flex: 1; text-align: center; font-family: var(--f-num); font-weight: 700; font-size: 2.6rem; color: var(--gold-hi); line-height: 1; }
.step { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .07); color: var(--cream); font-size: 1.6rem; font-weight: 800; cursor: pointer; touch-action: manipulation; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 40px; background: transparent; padding: 0; border: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--lo-2), var(--gold), var(--hi)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 34px; height: 34px; margin-top: -12px; border-radius: 50%; background: var(--cream); box-shadow: 0 0 0 4px var(--gold), 0 4px 10px rgba(0, 0, 0, .5); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--lo-2), var(--gold), var(--hi)); }
input[type=range]::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: var(--cream); border: 4px solid var(--gold); }
.range-l { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); font-weight: 700; margin-top: -6px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick .chip { min-height: 36px; padding: .4em .8em; font-size: .85rem; }
.gain { text-align: center; font-weight: 800; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
.gain b { font-family: var(--f-num); font-weight: 600; font-size: 1.15rem; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.quips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.quips::-webkit-scrollbar { display: none; }
.quips .chip { white-space: nowrap; scroll-snap-align: start; font-weight: 600; font-style: italic; }

/* domanda */
.thr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thr .chip { justify-content: center; font-family: var(--f-num); font-weight: 600; font-size: 1.05rem; min-height: 50px; }
.truth { padding: 10px 14px; border-radius: 12px; background: rgba(179, 18, 46, .25); font-weight: 800; }

/* risultati */
.result { padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.result .verdict { font-family: var(--f-title); font-style: italic; font-weight: 900; font-size: 1.6rem; line-height: 1.1; }
.rgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.rgrid > div { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.rgrid small { font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.rgrid b { font-family: var(--f-num); font-weight: 600; font-size: 1.35rem; }
.lie { color: var(--bad); font-weight: 800; }
.final-t { text-align: center; font-size: 2.3rem; margin: 6px 0 12px; }
.rank { display: flex; flex-direction: column; gap: 10px; }
.rk { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.rk .avbox { width: 52px; height: 52px; }
.rk b { flex: 1; font-size: 1.1rem; }
.rk .tot { font-family: var(--f-num); font-size: 1.5rem; color: var(--gold-hi); }
.rk.win { box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(245, 196, 81, .3); }
.hist { margin-top: 12px; padding: 10px 14px; font-size: .9rem; }
.hist div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.hist div:last-child { border: 0; }

/* barra delle azioni */
.action { display: flex; gap: 10px; padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px); background: linear-gradient(180deg, rgba(6, 10, 28, 0), rgba(6, 10, 28, .95) 30%); }
.action .btn { flex: 1; min-height: 58px; padding: .7em .8em; font-size: 1.05rem; }
.action .btn.narrow { flex: 0 0 auto; }

/* fogli e dialoghi */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-in { width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; background: var(--night-2); border-radius: 24px 24px 0 0; border-top: 1px solid var(--line); padding: 14px 16px calc(env(safe-area-inset-bottom) + 18px); animation: up .25s ease-out; display: flex; flex-direction: column; gap: 12px; }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.sheet-h { display: flex; align-items: center; justify-content: space-between; }
.sheet-h h3 { font-size: 1.5rem; }
.mboard { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mcol { display: grid; grid-auto-rows: 38px; gap: 6px; }
.mcol .val { font-size: 1.1rem; }
.menu-list { display: flex; flex-direction: column; gap: 10px; }
.rules { font-size: .95rem; line-height: 1.45; color: var(--muted); }
.rules b { color: var(--cream); }
.sheet.center { align-items: center; padding: 20px; }
.dlg-in { padding: 22px 18px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; animation: pop .25s; }
.dlg-in h3 { font-size: 1.5rem; }
.dlg-in p { margin: 0; color: var(--muted); font-weight: 600; }
.dlg-b { display: flex; gap: 10px; margin-top: 8px; } .dlg-b .btn { flex: 1; }

/* lampo (pacco aperto, esiti) */
.pflash { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; background: rgba(6, 10, 28, .82); pointer-events: none; }
.pflash .in { display: flex; flex-direction: column; align-items: center; gap: 6px; animation: pop .3s; text-align: center; padding: 20px; }
.pflash .v { font-family: var(--f-num); font-weight: 700; font-size: 4rem; line-height: 1; }
.pflash .v.lo { color: var(--lo); } .pflash .v.hi { color: var(--hi); }
.pflash .stamp { font-family: var(--f-num); font-weight: 700; font-size: 2.8rem; text-transform: uppercase; padding: 6px 22px; border: 6px solid currentColor; border-radius: 16px; animation: stamp .45s both; }
.stamp.ok { color: var(--ok); } .stamp.no { color: var(--bad); } .stamp.gold { color: var(--gold); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%); background: var(--cream); color: var(--night); padding: 12px 20px; border-radius: 999px; font-weight: 800; z-index: 60; max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.net { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translateX(-50%); background: var(--gold); color: #2a1a00; padding: 8px 18px; border-radius: 999px; font-weight: 800; z-index: 70; }

/* schermi molto bassi: pacchi più compatti */
@media (max-height: 700px) {
  .headline { font-size: 1.45rem; }
  .pgrid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .pgrid .box { aspect-ratio: 1.3; }
  .join-logo .logo { font-size: 2.8rem; }
  .join { gap: 4px; } .lead { font-size: .9rem; }
  .av-grid { gap: 6px; } .av-pick { padding: 6px; }
  .code-in { font-size: 1.9rem; padding: 4px; }
  .hero { padding: 10px 12px; }
  .offer .amount { font-size: 3rem; }
}

/* tasto Sala */
.sala-row { display: flex; }
#salaMenu .sala { justify-content: center; width: 100%; min-height: 54px; font-size: .9rem; }
