/* Cu fu? — TV (Fire TV Silk, Samsung Tizen, PC collegato alla TV). Tutto in vw/vh: la TV non scorre mai. */
html, body { height: 100%; overflow: hidden; }
body { background: radial-gradient(120% 90% at 30% 15%, #1b2d4d, var(--night) 70%); }
#app { position: fixed; inset: 0; }
.scr { position: absolute; inset: 0; }
.scr:not(.on) { display: none !important; }

/* ---------- avvio ---------- */
.start { display: grid; place-items: center; text-align: center; }
.start .in { display: grid; gap: 3vh; justify-items: center; }
.start .logo { width: 38vw; height: auto; }
.start p { color: var(--muted); font-size: 1.6vw; margin: 0; font-weight: 600; }
.start .btn { font-size: 1.8vw; padding: 1.4vw 3vw; min-height: 0; }

/* ---------- sala d'attesa ---------- */
.lobby { display: grid; grid-template-columns: 44vw 1fr; gap: 3vw; padding: 5vh 4vw; }
.lobby .l { display: flex; flex-direction: column; gap: 3vh; justify-content: center; }
.lobby .logo { width: 30vw; height: auto; }
.lobby .how { font: 600 1.45vw/1.5 var(--f-body); color: var(--muted); max-width: 38vw; }
.lobby .how b { color: var(--text); }
.lobby .join { display: flex; gap: 2vw; align-items: center; background: var(--night-2); border-radius: 1.6vw; padding: 1.6vw; box-shadow: inset 0 0 0 .15vw var(--line); }
.lobby .qr { width: 13vw; height: 13vw; border-radius: 1vw; background: #fff; padding: .6vw; flex: none; }
.lobby .qr img { width: 100%; height: 100%; display: block; }
.lobby .code > small { display: block; font: 800 1vw/1 var(--f-body); letter-spacing: .2em; color: var(--muted); }
.lobby .code > b { display: block; font: 900 6.2vw/1 var(--f-display); letter-spacing: .14em; color: var(--maj-yellow); margin: .6vw 0; }
.lobby .code > span { font: 700 1.25vw/1.3 var(--f-body); color: var(--text); }
.lobby .code > span b { color: var(--maj-yellow); font-weight: 800; }
.lobby .r { display: flex; flex-direction: column; gap: 2vh; justify-content: center; }
.lobby h2 { margin: 0; font: 900 italic 2.6vw/1 var(--f-display); color: var(--maj-yellow); }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2vw; }
.seat { display: flex; align-items: center; gap: 1.2vw; background: var(--night-2); border-radius: 1.4vw; padding: 1vw 1.2vw; box-shadow: inset 0 0 0 .12vw var(--line); min-height: 8.4vw; }
.seat.empty { opacity: .45; border: .15vw dashed var(--line); box-shadow: none; }
.seat .portrait { width: 6.4vw; height: 6.4vw; flex: none; }
.seat b { display: block; font: 800 1.6vw/1.1 var(--f-body); }
.seat small { display: block; font: 600 1.05vw/1.3 var(--f-body); color: var(--muted); }
.seat .tag { display: inline-block; margin-top: .4vw; padding: .2vw .7vw; border-radius: 1vw; font: 800 .85vw/1.4 var(--f-body); background: var(--night-3); color: var(--maj-yellow); letter-spacing: .06em; text-transform: uppercase; }
.lobby .wait { font: 700 1.3vw/1.4 var(--f-body); color: var(--muted); }

/* ---------- partita ---------- */
.game { display: grid; grid-template-columns: 56vw 1fr; }
.bwrap { position: relative; overflow: hidden; display: grid; place-items: center; padding: 1.2vh 0 1.2vh 1vw; }
.cam { position: relative; height: 97vh; aspect-ratio: var(--bw) / var(--bh); max-width: 100%; transition: transform 1.1s cubic-bezier(.4, 0, .2, 1); transform-origin: 0 0; will-change: transform; }
.cam > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cam .static { border-radius: 1vw; box-shadow: 0 1vw 3vw rgba(0, 0, 0, .55); }
.ov .tok { transition: transform .85s cubic-bezier(.4, 0, .2, 1); }
.ov .tok.walk { transition: transform .22s linear; }
.ov .wtok { transition: transform 1s cubic-bezier(.4, 0, .2, 1); }
.ov .mv { fill: #ffe27a; fill-opacity: .55; stroke: #b8860b; stroke-width: 2.5; animation: cf-blink 1.6s ease-in-out infinite; }
.ov .mvroom { fill: #ffe27a; fill-opacity: .18; stroke: #ffd23f; stroke-width: 6; animation: cf-blink 1.6s ease-in-out infinite; }

.side { padding: 2.2vh 2vw 2.2vh 1.2vw; display: flex; flex-direction: column; gap: 1.6vh; min-width: 0; }
.side .hd { display: flex; align-items: center; justify-content: space-between; }
.side .hd .logo { width: 11vw; height: auto; }
.side .code { font: 800 .9vw/1 var(--f-body); color: var(--muted); letter-spacing: .14em; text-align: right; }
.side .code b { display: block; font: 900 2.2vw/1 var(--f-display); color: var(--text); letter-spacing: .18em; margin-top: .3vw; }
.turnbox { display: flex; gap: 1.2vw; align-items: center; border-radius: 1.2vw; padding: 1vw 1.2vw; background: linear-gradient(90deg, var(--tc, #203252), rgba(22, 35, 58, .5) 75%); box-shadow: inset 0 0 0 .15vw rgba(233, 178, 60, .6); }
.turnbox .portrait { width: 7vw; height: 7vw; flex: none; }
.turnbox .t1 { font: 800 .9vw/1 var(--f-body); letter-spacing: .16em; color: var(--maj-yellow); text-transform: uppercase; }
.turnbox .t2 { font: 900 italic 2.4vw/1.05 var(--f-display); margin-top: .3vw; }
.turnbox .t3 { font: 600 1.1vw/1.35 var(--f-body); color: var(--muted); margin-top: .3vw; }
.turnbox .dice { margin-left: auto; display: flex; gap: .6vw; }
.turnbox .die { width: 3.8vw; height: 3.8vw; filter: drop-shadow(0 .3vw .4vw rgba(0, 0, 0, .4)); }
.turnbox .die.roll { animation: cf-roll .18s linear infinite; }
@keyframes cf-roll { 0% { transform: rotate(0) translateY(0); } 50% { transform: rotate(14deg) translateY(-.4vw); } 100% { transform: rotate(-10deg) translateY(0); } }
.timer { height: .45vw; border-radius: 1vw; background: var(--night-3); overflow: hidden; margin-top: -.6vh; }
.timer i { display: block; height: 100%; background: linear-gradient(90deg, #e9b23c, #ffd56b); transition: width .3s linear; }
.lbl2 { font: 800 .85vw/1 var(--f-body); letter-spacing: .18em; color: var(--muted); text-transform: uppercase; }
.pl { display: grid; grid-template-columns: 1fr 1fr; gap: .6vw; }
.pl > div { display: flex; align-items: center; gap: .7vw; background: var(--night-2); border-radius: .9vw; padding: .5vw .7vw; box-shadow: inset 0 0 0 .1vw var(--line); min-width: 0; }
.pl > div.on { box-shadow: inset 0 0 0 .2vw var(--maj-yellow); }
.pl > div.out { opacity: .45; }
.pl > div.off .portrait { filter: grayscale(1); }
.pl .portrait { width: 3.2vw; height: 3.2vw; flex: none; }
.pl b { display: block; font: 800 1.1vw/1.1 var(--f-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl small { display: block; font: 600 .85vw/1.2 var(--f-body); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .n { margin-left: auto; display: flex; align-items: center; gap: .3vw; font: 800 1.05vw/1 var(--f-body); color: var(--paper-2); }
.cardback { width: 1.2vw; height: 1.6vw; border-radius: .25vw; background: linear-gradient(135deg, #1f5d9e, #163f6c); box-shadow: inset 0 0 0 .12vw #e9b23c; display: inline-block; }
.inv { display: flex; flex-direction: column; gap: .5vw; min-height: 0; overflow: hidden; flex: 1; }
.inv > div { display: flex; align-items: center; gap: .6vw; background: var(--night-2); border-radius: .9vw; padding: .45vw .7vw; box-shadow: inset 0 0 0 .1vw var(--line); flex: none; }
.inv > div.new { animation: cf-in .6s ease-out; }
@keyframes cf-in { from { transform: translateX(3vw); opacity: 0; } to { transform: none; opacity: 1; } }
.inv .portrait { width: 2.6vw; height: 2.6vw; flex: none; }
.ic3 { display: flex; gap: .3vw; }
.ic3 > span { width: 2.6vw; height: 2.6vw; border-radius: .5vw; background: var(--paper); display: grid; place-items: center; overflow: hidden; }
.ic3 svg { width: 90%; height: 90%; }
.inv .arrow { color: var(--muted); font-weight: 900; font-size: 1.3vw; }
.inv .res { margin-left: auto; display: flex; align-items: center; gap: .5vw; font: 700 .9vw/1.2 var(--f-body); color: var(--muted); text-align: right; }
.inv .res .cardback { width: 1.6vw; height: 2.2vw; }
.inv .acc { color: #ff8d88; font-weight: 800; }
.say { position: absolute; z-index: 6; left: 2vw; bottom: 3vh; max-width: 48vw; display: flex; gap: 1vw; align-items: flex-end; animation: cf-pop .5s ease-out; }
.say .portrait { width: 6vw; height: 6vw; flex: none; }
.say p { margin: 0; background: var(--paper); color: var(--ink); font: 800 italic 1.7vw/1.3 var(--f-display); padding: 1vw 1.4vw; border-radius: 1.4vw 1.4vw 1.4vw .2vw; box-shadow: 0 .6vw 2vw rgba(0, 0, 0, .5); }
@keyframes cf-pop { from { transform: translateY(2vh) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.toast { position: absolute; z-index: 7; top: 3vh; left: 50%; transform: translateX(-50%); background: var(--night-2); box-shadow: inset 0 0 0 .15vw var(--maj-yellow), 0 1vw 3vw rgba(0, 0, 0, .5); border-radius: 1.4vw; padding: 1vw 1.8vw; font: 800 1.5vw/1.3 var(--f-body); animation: cf-pop .4s ease-out; }

/* ---------- scena del delitto ---------- */
.scene-ov { position: absolute; inset: 0; z-index: 10; background: #000; opacity: 0; pointer-events: none; transition: opacity .7s ease; display: grid; place-items: center; }
.scene-ov.on { opacity: 1; }
.scene-ov .scene { width: 100vw; height: 100vh; display: block; }
.scene-ov.on .sc-back { animation: sc-zoom 9s ease-out both; transform-origin: 50% 60%; }
.scene-ov.on .sc-suspect { animation: sc-enter 1s .9s cubic-bezier(.2, .8, .3, 1.1) both; }
.scene-ov.on .sc-victim { animation: sc-fade 1.2s .3s ease both; }
.scene-ov.on .sc-title { animation: sc-drop .7s .2s cubic-bezier(.2, .8, .3, 1.2) both; }
.scene-ov.on .sc-sent { animation: sc-rise .7s 1.7s ease-out both; }
.scene-ov.on .sc-stamp { animation: sc-stamp .45s cubic-bezier(.3, 1.6, .5, 1) both; transform-box: fill-box; transform-origin: center; }
@keyframes sc-zoom { from { transform: scale(1.12); } to { transform: scale(1); } }
@keyframes sc-enter { from { transform: translate(1400px, 830px) scale(1.08); opacity: 0; } }
@keyframes sc-fade { from { opacity: 0; } }
@keyframes sc-drop { from { transform: translate(800px, -80px); } }
@keyframes sc-rise { from { transform: translate(800px, 960px); opacity: 0; } }
@keyframes sc-stamp { from { transform: translate(470px, 300px) rotate(-8deg) scale(3); opacity: 0; } }
.scene-ov .res { position: absolute; left: 50%; top: 21vh; transform: translateX(-50%); display: flex; gap: 1.2vw; align-items: center; background: rgba(14, 24, 40, .9); border-radius: 1.6vw; padding: 1vw 1.8vw; box-shadow: inset 0 0 0 .15vw var(--maj-yellow); font: 800 1.8vw/1.2 var(--f-body); animation: cf-pop .5s ease-out; }
.scene-ov .res .portrait { width: 5vw; height: 5vw; }
.scene-ov .res .cardback { width: 3.4vw; height: 4.6vw; border-radius: .5vw; animation: cf-flipin .8s ease-out; }
@keyframes cf-flipin { from { transform: rotateY(90deg) translateX(-4vw); } }
.scene-ov .quip { position: absolute; right: 4vw; top: 30vh; max-width: 30vw; background: var(--paper); color: var(--ink); font: 800 italic 1.8vw/1.3 var(--f-display); padding: 1vw 1.4vw; border-radius: 1.4vw 1.4vw .2vw 1.4vw; box-shadow: 0 .6vw 2vw rgba(0, 0, 0, .5); animation: cf-pop .5s 2.2s ease-out both; }
/* busta che si apre (accusa) */
.env { position: absolute; left: 50%; top: 17vh; transform: translateX(-50%); width: 22vw; animation: cf-pop .6s ease-out; }
.env svg { width: 100%; height: auto; display: block; }

/* ---------- ricostruzione del caso ---------- */
.final { padding: 3.5vh 3vw; display: grid; grid-template-columns: 30vw 1fr; gap: 2.5vw; }
.final h1 { margin: 0; font: 900 italic 3.4vw/1 var(--f-display); color: var(--maj-yellow); }
.final .winner { display: flex; gap: 1.2vw; align-items: center; margin-top: 2vh; }
.final .winner .portrait { width: 8vw; height: 8vw; }
.final .winner b { display: block; font: 900 italic 2.4vw/1.1 var(--f-display); }
.final .winner small { font: 600 1.1vw/1.3 var(--f-body); color: var(--muted); }
.final .busta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1vw; margin-top: 3vh; }
.final .busta .card { animation: cf-deal .7s ease-out both; }
.final .busta .card:nth-child(2) { animation-delay: .5s; }
.final .busta .card:nth-child(3) { animation-delay: 1s; }
@keyframes cf-deal { from { transform: translateY(-6vh) rotateY(90deg); opacity: 0; } }
.final .busta .card .nm { font-size: 1vw; }
.final .busta .card .k { font-size: .6vw; }
.final .sum { font: 700 1.3vw/1.45 var(--f-body); color: var(--muted); margin-top: 2vh; }
.final .sum b { color: var(--text); }
.final .r { display: flex; flex-direction: column; gap: 1.6vh; min-width: 0; }
.hands { display: grid; grid-template-columns: 1fr 1fr; gap: .8vw; }
.hands > div { background: var(--night-2); border-radius: 1vw; padding: .6vw .8vw; display: flex; gap: .7vw; align-items: center; box-shadow: inset 0 0 0 .1vw var(--line); }
.hands .portrait { width: 3.6vw; height: 3.6vw; flex: none; }
.hands .cs { display: flex; gap: .3vw; flex-wrap: wrap; }
.hands .cs > span { width: 2.6vw; height: 2.6vw; border-radius: .4vw; background: var(--paper); display: grid; place-items: center; overflow: hidden; }
.hands .cs svg { width: 90%; height: 90%; }
.hands b { font: 800 1.05vw/1.1 var(--f-body); display: block; margin-bottom: .3vw; }
.story { display: flex; flex-direction: column; gap: .45vw; overflow: hidden; }
.story > div { display: flex; align-items: center; gap: .6vw; background: var(--night-2); border-radius: .8vw; padding: .35vw .7vw; font: 700 .95vw/1.2 var(--f-body); color: var(--muted); }
.story > div.key { box-shadow: inset 0 0 0 .15vw var(--maj-yellow); color: var(--text); }
.story .portrait { width: 2.3vw; height: 2.3vw; flex: none; }
.story .ic3 > span { width: 2.3vw; height: 2.3vw; }
.story .shown { margin-left: auto; display: flex; align-items: center; gap: .4vw; }
.story .shown > span { width: 2.3vw; height: 2.3vw; border-radius: .4vw; background: var(--paper); display: grid; place-items: center; overflow: hidden; }
.story .shown svg { width: 90%; height: 90%; }
.final .wait { font: 700 1.2vw/1.4 var(--f-body); color: var(--muted); }

/* ---------- pausa ---------- */
.pause-ov { position: absolute; inset: 0; z-index: 20; background: rgba(8, 12, 22, .82); display: none; place-items: center; text-align: center; }
.pause-ov.on { display: grid; }
.pause-ov h2 { font: 900 italic 4vw/1 var(--f-display); color: var(--maj-yellow); margin: 0 0 2vh; }
.pause-ov p { font: 600 1.6vw/1.4 var(--f-body); color: var(--text); margin: 0; }

/* comandi della TV (telecomando: frecce + OK) */
.tvbar { position: absolute; z-index: 30; right: 1.2vw; bottom: 1.6vh; display: flex; gap: .6vw; }
.tvbar button { width: 3.4vw; height: 3.4vw; border-radius: 50%; border: 0; background: rgba(32, 50, 82, .85); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.tvbar button:focus { outline: .25vw solid var(--maj-yellow); }
.tvbar svg { width: 55%; height: 55%; }
.tvbar.hide { opacity: .25; }
