:root {
  --bg: #1a1040;
  --panel: rgba(24, 14, 60, 0.92);
  --ink: #fff7e8;
  --muted: #b8aee0;
  --red: #ff4b4b;
  --blue: #3d7bff;
  --yellow: #ffd23d;
  --green: #3ddc6a;
  --pink: #ff5ab4;
  --pixel: 'Press Start 2P', monospace;
  --round: 'Baloo 2', 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--round); user-select: none; -webkit-user-select: none; touch-action: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

button { font-family: var(--round); cursor: pointer; border: 0; color: var(--ink); }
.big {
  display: block; width: 100%; padding: 14px 22px; margin: 8px 0; font-size: 22px; font-weight: 800; letter-spacing: 1px;
  border-radius: 16px; background: #5a3ac0; box-shadow: 0 6px 0 #2a1a70, 0 10px 20px rgba(0,0,0,.35);
  transition: transform .08s, box-shadow .08s; text-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.big:hover { transform: translateY(-2px); filter: brightness(1.1); }
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #2a1a70; }
.c1 { background: var(--red); box-shadow: 0 6px 0 #9a1a2a, 0 10px 20px rgba(0,0,0,.35); }
.c2 { background: var(--blue); box-shadow: 0 6px 0 #1a3a9a, 0 10px 20px rgba(0,0,0,.35); }
.c3 { background: #e0a020; box-shadow: 0 6px 0 #8a5a10, 0 10px 20px rgba(0,0,0,.35); }
.c5 { background: var(--pink); box-shadow: 0 6px 0 #9a1a6a, 0 10px 20px rgba(0,0,0,.35); }
.c4 { background: var(--green); box-shadow: 0 6px 0 #1a7a3a, 0 10px 20px rgba(0,0,0,.35); }
.small { padding: 8px 14px; border-radius: 12px; background: rgba(255,255,255,.14); font-size: 18px; font-weight: 700; }
.small:hover { background: rgba(255,255,255,.25); }

/* ---------- schermate ---------- */
#ui { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
#scr-title { justify-content: center; gap: 10px; }
.logo { margin: 0 0 10px; text-align: center; font-family: var(--pixel); line-height: 1.1; filter: drop-shadow(0 6px 0 rgba(0,0,0,.45)); }
.logo span { display: block; }
/* BimBam BOOM!: "BimBam" storto che rimbalza, "BOOM!" che esplode su una stella di fuoco */
.logo .bb { font-size: clamp(24px, 5.5vw, 48px); color: #7ae0ff; transform: rotate(-4deg); animation: bimbam 0.9s ease-in-out infinite; text-shadow: 3px 3px 0 #2a1a6a; }
.logo .boom { position: relative; margin-top: 6px; font-size: clamp(40px, 9.5vw, 86px); }
.logo .boom b { position: relative; color: #ffe03a; text-shadow: -2px -2px 0 #c81e1e, 2px -2px 0 #c81e1e, -2px 2px 0 #c81e1e, 4px 4px 0 #c81e1e, 7px 7px 0 #5a0a2a; display: inline-block; animation: boom 2.4s ease-in-out infinite; }
.logo .burst { position: absolute; left: 50%; top: 50%; width: 4.6em; height: 2.5em; transform: translate(-50%, -50%); background: radial-gradient(circle, #fff6a0 0, #ffb020 45%, #ff4b1a 75%); clip-path: polygon(50% 0, 58% 30%, 80% 6%, 70% 36%, 100% 26%, 77% 50%, 100% 74%, 70% 64%, 80% 94%, 58% 70%, 50% 100%, 42% 70%, 20% 94%, 30% 64%, 0 74%, 23% 50%, 0 26%, 30% 36%, 20% 6%, 42% 30%); animation: burst 2.4s ease-in-out infinite; }
@keyframes bimbam { 0%, 100% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(3deg) translateY(-4px); } }
@keyframes boom { 0%, 70%, 100% { transform: scale(1) rotate(-2deg); } 76% { transform: scale(1.25) rotate(3deg); } 82% { transform: scale(0.95) rotate(-3deg); } 88% { transform: scale(1.08) rotate(1deg); } }
@keyframes burst { 0%, 70%, 100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); } 76% { transform: translate(-50%, -50%) scale(1.35) rotate(12deg); } 90% { transform: translate(-50%, -50%) scale(1.05) rotate(-4deg); } }
@keyframes wob { 0%,100% { transform: rotate(-2deg) scale(1); } 50% { transform: rotate(2deg) scale(1.05); } }
.menu { width: min(360px, 90vw); }
.corner { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 8px; }

.panel-screen { background: rgba(10, 6, 30, .35); padding-top: 58px; }
.panel { background: var(--panel); border: 3px solid rgba(255,255,255,.12); border-radius: 24px; padding: 18px 22px 22px; width: min(480px, 100%); max-height: 100%; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.panel.wide { width: min(980px, 100%); }
.panel header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.panel h2 { margin: 0; font-family: var(--pixel); font-size: 20px; color: var(--yellow); }
.back { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.12); font-size: 18px; }
.intro, .hint { color: var(--muted); font-size: 16px; line-height: 1.35; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.row label { font-weight: 700; font-size: 17px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { padding: 8px 14px; border-radius: 12px; background: rgba(255,255,255,.1); font-size: 16px; font-weight: 700; }
.seg button.on { background: var(--yellow); color: #2a1a00; }
input { font: inherit; font-size: 17px; padding: 10px 12px; border-radius: 12px; border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.3); color: var(--ink); min-width: 200px; user-select: text; -webkit-user-select: text; }
.go { margin-top: 14px; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.gcard { background: rgba(255,255,255,.08); border-radius: 16px; padding: 12px 8px; text-align: center; border: 3px solid transparent; }
.gcard .ic { font-size: 38px; display: block; }
.gcard .nm { font-weight: 800; font-size: 15px; line-height: 1.1; display: block; margin-top: 4px; }
.gcard.on { border-color: var(--yellow); background: rgba(255,210,61,.18); }

.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 10px; }
.chapters .world { grid-column: 1 / -1; margin: 10px 0 0; font-size: 18px; color: var(--yellow); }
.chap { text-align: left; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.08); }
.chap .n { font-family: var(--pixel); font-size: 11px; color: var(--muted); }
.chap .t { display: block; font-size: 18px; font-weight: 800; margin: 4px 0; }
.chap .b { font-size: 14px; color: var(--muted); }
.chap.done { background: rgba(61,220,106,.18); }
.chap.locked { opacity: .4; cursor: not-allowed; }
.chap.next { background: rgba(255,210,61,.2); outline: 3px solid var(--yellow); }
.chap { position: relative; }
.chap .clip { position: absolute; top: 8px; right: 10px; font-size: 20px; padding: 2px 6px; border-radius: 10px; background: rgba(0,0,0,.25); }
.clip-end { margin-top: 8px; padding: 6px 12px; font-size: 14px; }
/* A Cube Story: filmati delle trasformazioni (client/js/render/cube-clips.js) */
.cube-clip { position: fixed; inset: 0; z-index: 900; background: #000; transition: opacity .3s; touch-action: none; }
.cube-clip canvas { width: 100%; height: 100%; display: block; }
.cube-clip .cap { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(720px, calc(100% - 32px)); margin: 0; padding: 10px 16px; border-radius: 14px; background: rgba(10,6,30,.72); color: #fff; font-size: 16px; line-height: 1.35; text-align: center; opacity: 0; transition: opacity .5s; pointer-events: none; }
.cube-clip .cap:empty { display: none; }
.cube-clip.cap-on .cap { opacity: 1; }
.cube-clip .skip { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); font-size: 13px; font-weight: 700; color: rgba(255,255,255,.75); background: rgba(10,6,30,.5); padding: 4px 10px; border-radius: 10px; pointer-events: none; }
.cube-clip.out { opacity: 0; }

.help { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.help > div, .help-games > div { background: rgba(255,255,255,.07); padding: 10px 14px; border-radius: 14px; }
.help h3 { margin: 4px 0; }
.help p { margin: 4px 0; color: var(--muted); line-height: 1.4; }
.help-games { display: grid; gap: 8px; margin-top: 12px; }
.help-games b { color: var(--yellow); }

.spinner { width: 54px; height: 54px; margin: 10px auto; border: 6px solid rgba(255,255,255,.2); border-top-color: var(--yellow); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#online-wait { text-align: center; }
.on-actions { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.on-help { margin-top: 10px; background: rgba(0,0,0,.25); border-radius: 14px; padding: 10px 14px; }
.on-help summary { font-weight: 800; cursor: pointer; }
.on-help p { color: var(--muted); font-size: 15px; line-height: 1.35; margin: 8px 0; }
#on-lobbies { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 50vh; overflow-y: auto; }
.lrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.12); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.lrow b { flex: 1; }
.lrow small, .lmem small { color: var(--muted); }
.badge { font-size: 13px; font-weight: 800; padding: 3px 8px; border-radius: 10px; white-space: nowrap; }
.badge.good { background: #2fae5a; } .badge.ok { background: #3a6aff; } .badge.bad { background: #d8402a; } .badge.new { background: #8a6aff; }
.ping { font-size: 13px; font-weight: 800; white-space: nowrap; } .ping.g { color: #6aff8a; } .ping.m { color: #ffd23d; } .ping.b { color: #ff6a5a; }
#lb-members { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.lmem { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.07); }
.lmem b { flex: 1; }
.lmem.empty { opacity: .45; }
select { font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 12px; border: 2px solid rgba(255,255,255,.2); background: #1a1440; color: var(--ink); max-width: 60vw; }
#on-status { font-size: 18px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
/* schede sui bordi: 1-2 sul lato sinistro, 3-4 sul destro, piccole e su due righe, fuori dal campo */
/* schede dei giocatori: una fila piccola in basso al centro (tra joystick e pulsanti), fuori dal campo di gioco */
#cards { position: absolute; left: 50%; bottom: max(3px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 4px; pointer-events: none; opacity: .88; }
#cards .card { width: 92px; flex-direction: column; align-items: flex-start; gap: 0; padding: 1px 5px 2px; border-radius: 8px; background: rgba(14, 8, 40, .42); }
.card { display: flex; align-items: center; gap: 5px; background: rgba(14, 8, 40, .5); border-radius: 9px; padding: 1px 7px; min-width: 0; flex: 0 1 auto; border-left: 4px solid; line-height: 1.25; }
.card .nm { font-weight: 800; font-size: 11px; white-space: nowrap; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
.card .nm .me { background: var(--yellow); color: #2a1a00; border-radius: 4px; padding: 0 3px; font-size: 9px; margin-right: 3px; }
.card .tr { font-size: 9px; letter-spacing: 0; white-space: nowrap; }
.card .tr:empty { display: none; }
.card .tr .off { filter: grayscale(1); opacity: .35; }
.card .st { font-size: 11px; color: #e8e0ff; white-space: nowrap; font-weight: 700; }
.card.dead { opacity: .4; }
#timer { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font-family: var(--pixel); font-size: 12px; text-shadow: 0 2px 0 #000; }
#timer.hurry { color: var(--red); }
#banner { position: absolute; top: 52px; left: 0; right: 0; text-align: center; font-family: var(--pixel); font-size: clamp(14px, 3vw, 24px); text-shadow: 0 3px 0 #000, 0 0 18px rgba(0,0,0,.6); animation: pop .3s ease-out; }
@media (max-height: 500px) { #banner { top: 44px; } }
#btn-pause { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); pointer-events: auto; width: 44px; height: 44px; padding: 0; font-size: 16px; }
#center { position: absolute; top: 38%; left: 0; right: 0; text-align: center; font-family: var(--pixel); font-size: clamp(28px, 7vw, 64px); color: var(--yellow); text-shadow: 0 5px 0 #000, 0 0 30px rgba(0,0,0,.5); line-height: 1.3; }
#center small { display: block; font-size: .4em; color: var(--ink); }
#center.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#intro, #end, #pause { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; pointer-events: auto; background: rgba(10,6,30,.45); }
#intro .panel, #end .panel { text-align: center; width: min(560px, 100%); }
#intro .ic { font-size: 64px; }
#intro h2 { font-size: 22px; margin: 6px 0 10px; }
#intro p { font-size: 17px; line-height: 1.4; margin: 8px 0; }
#intro .ctrl { color: var(--yellow); }
#intro .bar { height: 8px; background: rgba(255,255,255,.15); border-radius: 4px; overflow: hidden; margin-top: 12px; }
#intro .bar div { height: 100%; background: var(--yellow); }
#pause { background: rgba(10,6,30,.6); }
#pause .panel { width: min(360px, 100%); text-align: center; }
.podium { text-align: left; margin: 12px 0; }
.podium .pl { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; margin: 4px 0; background: rgba(255,255,255,.07); font-size: 18px; font-weight: 700; }
.podium .pl.win { background: rgba(255,210,61,.25); }
.podium .dot { width: 18px; height: 18px; border-radius: 50%; flex: none; }
.podium .pl span:last-child { margin-left: auto; }
.story-text { color: var(--muted); font-size: 16px; line-height: 1.4; }

/* ---------- comandi touch ---------- */
#touch { position: absolute; inset: 0; pointer-events: none; }
.stick-zone { position: absolute; left: 0; bottom: 0; width: 50%; height: 65%; pointer-events: auto; touch-action: none; }
.stick { position: absolute; left: 120px; top: calc(100% - 110px); width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.06) 0, rgba(255,255,255,.14) 70%); border: 2px solid rgba(255,255,255,.35); box-shadow: 0 0 18px rgba(120,180,255,.25), inset 0 0 20px rgba(255,255,255,.08); opacity: 0; transition: opacity .12s; pointer-events: none; }
.stick.on { opacity: 1; } /* il cerchio si vede solo mentre tieni il dito */
.knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255,255,255,.75); box-shadow: 0 4px 10px rgba(0,0,0,.4); }
.tbtn { position: absolute; pointer-events: auto; touch-action: none; width: 86px; height: 86px; border-radius: 50%; font-family: var(--pixel); font-size: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; --c: #ff4b6b; --c2: #ff9a3d;
  background: rgba(40, 20, 70, .75); border: 2px solid rgba(255,255,255,.6); /* per i telefoni vecchi senza color-mix */
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.35) 0, rgba(255,255,255,0) 38%), linear-gradient(145deg, color-mix(in srgb, var(--c) 55%, #1a1030) 0%, color-mix(in srgb, var(--c2) 35%, #0c0820) 100%);
  border: 2px solid color-mix(in srgb, var(--c) 80%, #fff); box-shadow: 0 0 22px color-mix(in srgb, var(--c) 55%, transparent), inset 0 -6px 14px rgba(0,0,0,.45), inset 0 2px 6px rgba(255,255,255,.25); backdrop-filter: blur(6px); text-shadow: 0 0 10px var(--c); opacity: .92; transition: transform .06s, box-shadow .06s; }
/* pulsantiera a 4 colori (Segui la Sequenza): rosso su, blu destra, giallo giù, verde sinistra */
#touch [hidden] { display: none !important; }
.cpad { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: 20px; width: 240px; height: 240px; pointer-events: none; }
.cbtn { position: absolute; width: 92px; height: 92px; border-radius: 50%; pointer-events: auto; touch-action: none; font-size: 40px; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 60%, #fff), var(--c) 60%, color-mix(in srgb, var(--c) 70%, #000));
  border: 4px solid rgba(255,255,255,.75); box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 18px color-mix(in srgb, var(--c) 70%, transparent); cursor: pointer; }
.cbtn[data-c="0"] { left: 74px; top: 0; }
.cbtn[data-c="1"] { right: 0; top: 74px; }
.cbtn[data-c="2"] { left: 74px; bottom: 0; }
.cbtn[data-c="3"] { left: 0; top: 74px; }
.cbtn.down { transform: translateY(4px) scale(.92); box-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 34px var(--c); }
@media (max-height: 460px) { .cpad { width: 200px; height: 200px; } .cbtn { width: 76px; height: 76px; font-size: 32px; } .cbtn[data-c="0"], .cbtn[data-c="2"] { left: 62px; } .cbtn[data-c="1"], .cbtn[data-c="3"] { top: 62px; } }
.tbtn small { font-family: var(--round); font-size: 10px; font-weight: 800; margin-top: 3px; letter-spacing: .5px; opacity: .9; text-shadow: none; }
.tbtn.down { transform: scale(.9); box-shadow: 0 0 34px color-mix(in srgb, var(--c) 90%, transparent), inset 0 4px 14px rgba(0,0,0,.55); opacity: 1; }
.btn-a { right: max(24px, env(safe-area-inset-right)); bottom: 40px; width: 100px; height: 100px; --c: #ff3d71; --c2: #ff9a3d; }
.btn-b { right: max(140px, calc(env(safe-area-inset-right) + 116px)); bottom: 24px; --c: #3d8bff; --c2: #3ad8ff; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(14,8,40,.92); padding: 10px 18px; border-radius: 14px; font-weight: 700; z-index: 10; max-width: 90vw; text-align: center; }

/* ---------- portafoglio, scheda gioco, negozio ---------- */
#wallet { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); pointer-events: auto; z-index: 5; display: flex; gap: 12px; align-items: center; padding: 8px 14px; border-radius: 14px; background: rgba(10,6,30,.75); border: 2px solid rgba(255,255,255,.15); font-size: 18px; font-weight: 800; }
#wallet small { font-size: 12px; color: var(--muted); }
.big small { font-size: .7em; opacity: .85; }
.gm-body { display: grid; grid-template-columns: 1fr 1.2fr; gap: 18px; align-items: start; }
.gm-ic { font-size: 64px; text-align: center; }
#gm-desc { font-size: 17px; line-height: 1.4; }
.gm-ctrl { color: var(--yellow); font-size: 15px; line-height: 1.35; }
.tabs { margin: 4px 0 10px; }
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ch { position: relative; background: rgba(255,255,255,.08); border-radius: 16px; padding: 8px; text-align: center; border: 3px solid transparent; display: flex; flex-direction: column; align-items: center; }
.ch img { width: 110px; height: 110px; }
.ch .nm { font-weight: 800; font-size: 15px; line-height: 1.1; }
.ch .bumi { font-family: var(--display); font-size: 10px; letter-spacing: 1.5px; color: #ffd23d; margin-bottom: -2px; }
.bumi-hint { grid-column: 1 / -1; }
.ch .ds { font-size: 12px; color: var(--muted); line-height: 1.2; margin: 4px 0 6px; min-height: 30px; }
.ch .act { width: 100%; padding: 6px; border-radius: 10px; font-weight: 800; font-size: 15px; background: var(--blue); }
.ch .act.buy { background: #e0a020; }
.ch .act.no { background: rgba(255,255,255,.12); color: var(--muted); }
.ch.sel { border-color: var(--yellow); background: rgba(255,210,61,.16); }
.ch.lock img { filter: brightness(.55) saturate(.6); }
.energy { display: grid; gap: 12px; }
.energy .now { font-size: 20px; font-weight: 800; text-align: center; }
.energy .pack { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,.08); font-size: 18px; font-weight: 800; }
.energy .pack button { padding: 8px 16px; border-radius: 12px; background: #e0a020; font-size: 17px; font-weight: 800; }
.reward { font-size: 22px; font-weight: 800; color: var(--yellow); margin: 6px 0; }

@media (max-width: 700px) {
  .gm-body { grid-template-columns: 1fr; }
  .card { min-width: 0; padding: 2px 8px 4px; }
  .card .nm { font-size: 12px; max-width: 80px; }
  .card .st, .card .tr { font-size: 11px; }
  #timer { font-size: 14px; }
  .big { font-size: 18px; padding: 12px 16px; }
}
@media (max-height: 500px) {
  .logo .bb { font-size: 20px; } .logo .boom { font-size: 36px; }
  .big { padding: 8px 14px; margin: 5px 0; font-size: 17px; }
  .panel { padding: 10px 14px 12px; border-radius: 18px; }
  #intro .ic { display: none; }
  #intro h2, #end h2 { font-size: 15px; margin: 2px 0 4px; }
  #intro p, .story-text { font-size: 13px; margin: 3px 0; line-height: 1.3; }
  #intro .panel, #end .panel { width: min(640px, 100%); }
  .podium .pl { font-size: 14px; padding: 3px 8px; margin: 2px 0; }
  .tbtn { width: 74px; height: 74px; font-size: 18px; }
  .btn-a { width: 86px; height: 86px; bottom: 22px; }
  .btn-b { right: max(122px, calc(env(safe-area-inset-right) + 100px)); bottom: 14px; }
  #scr-title .menu { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; width: min(560px, 92vw); }
  #scr-title .menu .big { font-size: 15px; }
  .logo { margin-bottom: 2px; }
  .gm-ic { font-size: 40px; }
  #gm-desc { font-size: 14px; }
  .ch img { width: 80px; height: 80px; }
}

/* modalità sviluppatore nel negozio */
.dev { margin-top: 14px; padding: 6px 10px; border: 2px dashed rgba(255,255,255,.15); border-radius: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; font-size: 14px; }
.dev summary { cursor: pointer; opacity: .6; width: 100%; list-style: none; text-align: right; }
.dev input { flex: 1 1 140px; min-width: 0; padding: 8px; border-radius: 8px; border: 0; font: inherit; }
.dev label { display: flex; align-items: center; justify-content: flex-start; gap: 8px; flex: 1 1 200px; margin: 0; text-align: left; }

/* ---------- rarità nel negozio ---------- */
.ch { --rc: #b8b8c8; padding-top: 20px; }
.ch.r-rare { --rc: #3d9bff; border-color: rgba(61,155,255,.45); }
.ch.r-epic { --rc: #b05aff; border-color: rgba(176,90,255,.6); background: linear-gradient(160deg, rgba(176,90,255,.22), rgba(255,255,255,.06)); }
.ch.r-legendary { --rc: #ffb020; border-color: #ffb020; background: linear-gradient(160deg, rgba(255,176,32,.3), rgba(255,90,40,.1)); animation: legend 2.2s ease-in-out infinite; }
.ch.r-mythic { --rc: #ff3a8a; border-color: transparent; background: linear-gradient(rgba(30,14,60,.92), rgba(30,14,60,.92)) padding-box, linear-gradient(90deg, #ff3a3a, #ffd23d, #3ddc6a, #3d7bff, #b05aff, #ff3a3a) border-box; background-size: 100% 100%, 300% 100%; animation: rainbow 3s linear infinite; }
.ch.sel { border-color: var(--yellow) !important; }
@keyframes legend { 0%,100% { box-shadow: 0 0 6px rgba(255,176,32,.4); } 50% { box-shadow: 0 0 22px rgba(255,176,32,.9); } }
@keyframes rainbow { to { background-position: 0 0, 300% 0; } }
.ch .rar { position: absolute; top: 4px; left: 6px; font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--rc); }
.ch.r-legendary img, .ch.r-mythic img { filter: drop-shadow(0 0 8px var(--rc)); }
.ch.r-epic img { filter: drop-shadow(0 0 5px var(--rc)); }
.ch.lock.r-legendary img, .ch.lock.r-mythic img, .ch.lock.r-epic img { filter: brightness(.6) drop-shadow(0 0 8px var(--rc)); }
.ch .btns { display: flex; gap: 6px; width: 100%; margin-top: auto; }
.ch .btns .act { flex: 1; }
.ch .btns .act.eye { flex: 0 0 40px; background: rgba(255,255,255,.18); }
.ch .big-ic { font-size: 64px; line-height: 110px; height: 110px; }
@media (max-height: 500px) { .ch .big-ic { font-size: 46px; line-height: 80px; height: 80px; } }
.coinpacks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.cpack { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px 10px; border-radius: 16px; background: linear-gradient(160deg, rgba(255,210,61,.25), rgba(255,255,255,.06)); border: 3px solid rgba(255,210,61,.5); }
.cpack.best { border-color: var(--yellow); animation: legend 2s ease-in-out infinite; }
.cpack .ic { font-size: 34px; }
.cpack b { font-size: 20px; }
.cpack small { font-size: 12px; color: var(--green); font-weight: 800; }
.cpack .price { margin-top: 6px; background: var(--green); color: #0a2a10; border-radius: 10px; padding: 4px 16px; font-weight: 800; font-size: 17px; }
.cpack .tag { position: absolute; top: -10px; background: var(--red); border-radius: 8px; padding: 1px 8px; font-size: 11px; font-weight: 800; }
/* anteprima: si vede il personaggio sul disco del menu */
body.peek .panel-screen { opacity: 0; pointer-events: none; transition: opacity .2s; }
body.peek #wallet { opacity: 0; }

/* ---------- Storia: gemme ---------- */
.gems { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.gems b { margin-right: 6px; color: var(--yellow); }
/* A Cube Story: le forme del cubo già viste (le altre spente) */
.cform { font-size: 20px; opacity: .35; filter: grayscale(1); }
.cform.on { opacity: 1; filter: none; }
/* A Cube Story: dopo uno schianto, Riprova / Esci con l'energia rimasta (un tocco e si riparte) */
#cube-crash { position: absolute; inset: 0; z-index: 7; display: flex; align-items: center; justify-content: center; padding: 16px; pointer-events: auto; background: rgba(10,6,30,.35); }
#cube-crash[hidden] { display: none; }
#cube-crash .panel { width: min(380px, 100%); text-align: center; animation: none; }
#cube-crash .pct { font-size: 15px; opacity: .85; margin: 2px 0 8px; }
#cube-crash .en { font-size: 18px; font-weight: 800; margin: 6px 0 12px; }
#cube-crash .en.zero { color: #ff6a6a; }
#cube-crash .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#cube-crash .row .big { flex: 1 1 140px; margin: 0; }
#cube-crash .big[disabled] { opacity: .45; filter: grayscale(.6); }
#cube-crash .hint { font-size: 12px; opacity: .75; margin-top: 8px; }
/* in partita ad A Cube Story i tasti non sfocano lo sfondo e non animano l'ombra: sul telefono costava un fotogramma a ogni salto */
body.cube-play .tbtn { backdrop-filter: none; transition: none; box-shadow: 0 0 14px color-mix(in srgb, var(--c) 55%, transparent); }
body.cube-play .tbtn.down { box-shadow: 0 0 14px color-mix(in srgb, var(--c) 90%, transparent); }
.gem { font-size: 22px; color: rgba(255,255,255,.15); }
.gem.on { color: var(--gc); text-shadow: 0 0 10px var(--gc); }
.chapters .world small { display: block; font-size: 13px; color: var(--muted); font-weight: 500; line-height: 1.3; margin-top: 2px; }
.wgem { font-size: 13px; color: rgba(255,255,255,.3); margin-left: 6px; }
.wgem.on { color: var(--gc); text-shadow: 0 0 8px var(--gc); }

/* ---------- vincitore del round ---------- */
.wbox { display: flex; justify-content: center; align-items: center; gap: 4px; margin-bottom: -6px; }
.wface { width: clamp(80px, 18vh, 150px); height: clamp(80px, 18vh, 150px); animation: wwig .5s ease-in-out infinite alternate; filter: drop-shadow(0 6px 0 rgba(0,0,0,.4)); }
.wemo { font-size: clamp(40px, 9vh, 72px); font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif; animation: wemo .45s ease-in-out infinite alternate; }
@keyframes wwig { from { transform: rotate(-8deg) scale(1); } to { transform: rotate(8deg) scale(1.08); } }
@keyframes wemo { from { transform: translateY(0) rotate(-10deg); } to { transform: translateY(-14px) rotate(12deg) scale(1.15); } }

/* ---------- podio finale: pannello a destra, vincitore a sinistra ---------- */
#end.final { justify-content: flex-end; background: linear-gradient(90deg, transparent 40%, rgba(10,6,30,.55)); }
#end.final .panel { width: min(440px, 50%); max-height: 100%; }
#hud.final #cards, #hud.final #timer, #hud.final #banner, #hud.final #center, #hud.final #touch, #hud.final #btn-pause { display: none; }

/* scelta della lingua */
.langs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.langs .big { margin: 0; }
@media (max-width: 500px) { .langs { grid-template-columns: 1fr; } }

/* nome del giocatore (in basso a sinistra nel menu) */
.corner-l { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); }
.namechip { width: auto !important; padding: 0 14px; font-size: 15px; font-weight: 800; max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#name-input { width: 100%; font-size: 22px; padding: 10px 14px; border-radius: 14px; border: 3px solid rgba(255,255,255,.3); background: rgba(0,0,0,.3); color: #fff; text-align: center; font-weight: 800; margin: 8px 0; box-sizing: border-box; }

/* cursori del volume */
.vol-box { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 12px; text-align: left; }
.vol-row { display: grid; grid-template-columns: 6.4em minmax(0, 1fr) 2.8em; align-items: center; gap: 8px; font-weight: 800; }
.vol-row input[type=range] { width: 100%; min-width: 0; margin: 0; accent-color: #ffd23d; height: 28px; }
.vol-row b { text-align: right; font-variant-numeric: tabular-nums; }

/* zona swipe per i lanci (Barattoli, Pesciolini): tutto lo schermo, la riga mostra direzione e forza */
.swipe-zone { position: absolute; inset: 0; pointer-events: auto; touch-action: none; cursor: crosshair; }
.swipe-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .1s; }
.swipe-zone.on .swipe-line { opacity: 1; }
.swipe-line line { stroke: #fff; stroke-width: 8; stroke-linecap: round; stroke-dasharray: 2 14; filter: drop-shadow(0 0 6px rgba(255,210,61,.9)); }
.swipe-line circle { fill: rgba(255,210,61,.8); stroke: #fff; stroke-width: 3; }
.swipe-hint { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); font-size: 46px; opacity: .55; animation: swipeHint 1.6s ease-in-out infinite; pointer-events: none; }
.swipe-zone.used .swipe-hint { display: none; }
@keyframes swipeHint { 0% { transform: translate(-50%, 40px); opacity: 0; } 30% { opacity: .7; } 100% { transform: translate(-50%, -90px); opacity: 0; } }
/* Salto in Lungo: A a sinistra, B a destra, SALTA in mezzo */
.runpad { position: absolute; inset: 0; pointer-events: none; }
.rbtn { position: absolute; bottom: max(26px, env(safe-area-inset-bottom)); pointer-events: auto; touch-action: none; width: 118px; height: 118px; border-radius: 50%; font-family: var(--pixel); font-size: 38px; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; --c: #ff3d71;
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.35) 0, rgba(255,255,255,0) 38%), rgba(40, 20, 70, .78); border: 3px solid var(--c); box-shadow: 0 0 22px var(--c), inset 0 -6px 14px rgba(0,0,0,.45); text-shadow: 0 0 10px var(--c); transition: transform .05s; }
.rbtn.down { transform: scale(.9); box-shadow: 0 0 40px var(--c), inset 0 4px 14px rgba(0,0,0,.55); }
.rbtn-a { left: max(26px, env(safe-area-inset-left)); --c: #ff3d71; }
.rbtn-b { right: max(26px, env(safe-area-inset-right)); --c: #3dd6ff; }
.rbtn-j { left: 50%; margin-left: -70px; width: 140px; height: 84px; border-radius: 42px; font-size: 18px; --c: #ffd23d; bottom: max(40px, env(safe-area-inset-bottom)); }
@media (max-height: 460px) { .rbtn { width: 96px; height: 96px; font-size: 30px; } .rbtn-j { width: 120px; height: 70px; margin-left: -60px; font-size: 15px; } }
/* il tasto pausa resta cliccabile anche sopra la zona swipe */
#btn-pause { z-index: 4; }
/* SALTA sta sopra B, centrato, così si preme col pollice destro */
.rbtn-j { left: auto; margin-left: 0; right: max(15px, calc(env(safe-area-inset-right) - 11px)); bottom: max(160px, calc(env(safe-area-inset-bottom) + 134px)); }
@media (max-height: 460px) { .rbtn-j { right: max(14px, calc(env(safe-area-inset-right) - 12px)); bottom: 136px; } }
/* pausa, presentazione e fine partita stanno SOPRA ai comandi touch (swipe compreso) */
#intro, #end, #pause { z-index: 6; }
/* titoli delle categorie nella lista Arcade: occupano tutta la riga */
.gcat { grid-column: 1 / -1; margin: 14px 4px 2px; font-size: 17px; color: var(--yellow); text-align: left; border-bottom: 2px solid rgba(255,255,255,.12); padding-bottom: 4px; }
.gcat:first-child { margin-top: 2px; }

/* pannello sviluppatore: sempre aperto, tasto ripristina grande */
.dev .dev-t { width: 100%; opacity: .6; text-align: right; }
.dev button.c2:not(.small) { flex: 1 1 100%; font-size: 18px; padding: 14px; }

/* classifiche */
.top-list { list-style: none; padding: 0; margin: 8px 0; max-height: 52vh; overflow-y: auto; }
.top-list li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; margin: 4px 0; border-radius: 12px; background: rgba(255,255,255,.07); font-weight: 700; }
.top-list li.mine { background: rgba(255,210,61,.28); }
.top-list .pos { width: 34px; text-align: center; font-family: var(--pixel); }
.top-list .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list .val { color: var(--yellow); }
.top-me { font-weight: 800; margin: 6px 0; }
#scr-top h2 { font-size: 17px; overflow-wrap: anywhere; }

/* lobby online: impostazioni dell'host (per gli altri solo da leggere) */
#lb-cfg .ro, #lb-cfg button.ro { pointer-events: none; opacity: .85; }
.lb-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.lb-list .chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 12px; background: rgba(255,255,255,.1); font-weight: 700; font-size: 14px; }
.lb-list .chip button { padding: 0 6px; background: rgba(255,80,80,.35); border-radius: 8px; font-size: 13px; }
.lb-tbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
#lb-picker { margin-top: 8px; }
.lb-pick-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; position: sticky; top: 0; z-index: 1; background: rgba(20,12,50,.95); padding: 6px; border-radius: 10px; }

/* ONLINE a tutto schermo: a sinistra i giocatori, a destra PARTITA SINGOLA / TORNEO */
.online-panel { width: min(1180px, 100%); height: 100%; display: flex; flex-direction: column; }
.on-grid { display: grid; grid-template-columns: minmax(230px, 33%) 1fr; gap: 16px; flex: 1; min-height: 0; }
.on-left, .on-right { overflow-y: auto; min-height: 0; }
.on-left { background: rgba(255,255,255,.05); border-radius: 18px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.on-left h3 { margin: 2px 0; }
.on-left .lmem { margin: 0; }
.on-namebox { display: flex; flex-direction: column; gap: 4px; font-size: 14px; opacity: .9; margin-top: 4px; }
.on-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modecard { padding: 16px 14px; border-radius: 18px; background: rgba(255,255,255,.08); border: 3px solid transparent; text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 92px; }
.modecard b { font-size: 19px; }
.modecard small { font-size: 13px; opacity: .8; font-weight: 600; }
.modecard.on { border-color: var(--yellow); background: rgba(255,210,61,.2); box-shadow: 0 0 18px rgba(255,210,61,.35); }
.modecard.ro { pointer-events: none; }
.modecard.ro:not(.on) { opacity: .45; }
.on-box { background: rgba(255,255,255,.05); border-radius: 14px; padding: 10px 12px; margin: 10px 0; }
.pickbtn { width: 100%; font-size: 18px; font-weight: 800; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.12); margin-bottom: 6px; }
.startbtn { width: 100%; }
@media (max-width: 700px) { .on-grid { grid-template-columns: 1fr; } .on-modes { grid-template-columns: 1fr; } }

/* aggiornamento dell'APK (apk-updater.js) */
#apk-update { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(10, 6, 30, 0.82); }
#apk-update[hidden] { display: none; }
#apk-update .apk-box { max-width: 460px; width: calc(100% - 32px); text-align: center; }
#apk-update .apk-notes { white-space: pre-line; opacity: 0.9; }
#apk-update .apk-size, #apk-update .apk-msg { font-size: 0.9em; opacity: 0.85; min-height: 1.2em; }
#apk-update .apk-bar { height: 14px; border-radius: 7px; background: rgba(255, 255, 255, 0.15); overflow: hidden; margin: 10px 0; }
#apk-update .apk-bar > div { height: 100%; width: 0; background: #ffd23d; transition: width 0.25s; }
#apk-update .apk-btns { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 10px; }

/* =====================================================================
   IDENTITÀ BimBam BOOM! — stile cartoon da fumetto
   Contorno "inchiostro" spesso (lo stesso colore dei contorni dei personaggi 3D), ombre piene
   sfalsate, titoli come adesivi storti, retino a puntini, nuvolette. I font sono dentro il gioco
   (client/fonts, licenza OFL): funzionano anche senza internet.
   ===================================================================== */
@font-face { font-family: 'Lilita One'; src: url('fonts/lilita-one.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Baloo 2'; src: url('fonts/baloo-2-500.woff2') format('woff2'); font-weight: 400 500; font-display: swap; }
@font-face { font-family: 'Baloo 2'; src: url('fonts/baloo-2-700.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: 'Baloo 2'; src: url('fonts/baloo-2-800.woff2') format('woff2'); font-weight: 800 900; font-display: swap; }
@font-face { font-family: 'Press Start 2P'; src: url('fonts/press-start-2p.woff2') format('woff2'); font-display: swap; }

:root {
  --line: #1a1026;                 /* inchiostro: bordi e ombre di tutto */
  --display: 'Lilita One', 'Baloo 2', 'Segoe UI', Arial, sans-serif;
  --paper: #2c1a6e;                /* fondo dei pannelli */
  --paper2: #3a2490;
  /* testo bordato d'inchiostro (come le scritte dei cartoni) */
  --outline: 2px 0 0 var(--line), -2px 0 0 var(--line), 0 2px 0 var(--line), 0 -2px 0 var(--line),
    1.5px 1.5px 0 var(--line), -1.5px 1.5px 0 var(--line), 1.5px -1.5px 0 var(--line), -1.5px -1.5px 0 var(--line), 0 4px 0 var(--line);
  --dots: radial-gradient(rgba(255,255,255,.07) 1.5px, transparent 1.6px);
}

/* ---------- pulsanti ---------- */
.big {
  font-family: var(--display); font-weight: 400; letter-spacing: .5px; font-size: 24px;
  border: 3px solid var(--line); border-radius: 18px;
  box-shadow: 0 6px 0 var(--line), 0 12px 18px rgba(0,0,0,.28);
  background-image: linear-gradient(180deg, rgba(255,255,255,.28) 0, rgba(255,255,255,.08) 45%, rgba(0,0,0,0) 46%);
  text-shadow: var(--outline);
  transition: transform .12s cubic-bezier(.3,1.6,.5,1), box-shadow .08s, filter .1s;
}
.big:hover { transform: translateY(-2px) rotate(-1.2deg) scale(1.02); filter: brightness(1.08); }
.big:active { transform: translateY(5px) scale(.99); box-shadow: 0 1px 0 var(--line), 0 4px 8px rgba(0,0,0,.25); }
.c1, .c2, .c3, .c4, .c5 { box-shadow: 0 6px 0 var(--line), 0 12px 18px rgba(0,0,0,.28); }
.c1 { background-color: var(--red); } .c2 { background-color: var(--blue); } .c3 { background-color: #f0a820; }
.c4 { background-color: var(--green); } .c5 { background-color: var(--pink); }
.big:not(.c1):not(.c2):not(.c3):not(.c4):not(.c5) { background-color: #6a44d8; }
/* il menu principale: i pulsanti ballano un po' in sequenza */
.menu .big { animation: menuIn .45s cubic-bezier(.3,1.6,.5,1) backwards; } /* backwards: finita l entrata il pulsante torna libero di abbassarsi quando lo premi */
.menu .big:nth-child(2) { animation-delay: .05s; } .menu .big:nth-child(3) { animation-delay: .1s; }
.menu .big:nth-child(4) { animation-delay: .15s; } .menu .big:nth-child(5) { animation-delay: .2s; } .menu .big:nth-child(6) { animation-delay: .25s; }
@keyframes menuIn { from { transform: translateY(18px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

.small {
  font-family: var(--round); border: 3px solid var(--line); background: var(--paper2);
  box-shadow: 0 4px 0 var(--line); transition: transform .1s;
}
.small:hover { background: #4a30b0; transform: translateY(-1px); }
.small:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.back {
  border: 3px solid var(--line); background: var(--yellow); color: var(--line); font-weight: 800;
  box-shadow: 0 4px 0 var(--line); border-radius: 14px;
}
.back:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }

/* ---------- pannelli ---------- */
.panel-screen { background: rgba(10, 6, 30, .38) var(--dots); background-size: auto, 14px 14px; }
.panel {
  background: var(--paper) var(--dots); background-size: 14px 14px;
  border: 4px solid var(--line); border-radius: 28px;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.07), 0 10px 0 var(--line), 0 26px 50px rgba(0,0,0,.45);
}
/* titolo del pannello: adesivo giallo storto */
.panel h2 {
  font-family: var(--display); font-size: 26px; color: var(--yellow); text-shadow: var(--outline);
  display: inline-block; transform: rotate(-2deg); letter-spacing: .5px;
}
.intro, .hint { color: #d8d0f8; }

/* controlli a scelta e campi */
.seg button { border: 3px solid var(--line); background: var(--paper2); box-shadow: 0 3px 0 var(--line); font-family: var(--round); }
.seg button.on { background: var(--yellow); color: var(--line); transform: translateY(1px) rotate(-1deg); }
input, select { border: 3px solid var(--line); background: #140c34; box-shadow: inset 0 3px 0 rgba(0,0,0,.35); }

/* carte (giochi, capitoli, personaggi, modalità, monete): bordo d'inchiostro col box-shadow,
   così il bordo vero resta libero per i colori di stato (scelto, rarità...) */
.gcard, .chap, .ch, .modecard, .lmem, .podium .pl, .cpack {
  background-color: var(--paper2);
  box-shadow: 0 0 0 3px var(--line), 0 6px 0 3px var(--line);
  transition: transform .12s cubic-bezier(.3,1.6,.5,1);
}
.gcard:hover, .chap:hover, .ch:hover, .modecard:hover, .cpack:hover { transform: translateY(-3px) rotate(-1deg); }
.gcard .nm, .modecard b, .ch .nm { font-family: var(--display); font-weight: 400; letter-spacing: .3px; }
.gcard .ic { filter: drop-shadow(0 3px 0 var(--line)); }

/* ---------- in partita ---------- */
#banner, #center { font-family: var(--display); letter-spacing: 1px; text-shadow: var(--outline), 0 0 24px rgba(0,0,0,.45); }
#banner { font-size: clamp(18px, 3.6vw, 32px); }
#center { font-size: clamp(42px, 9vw, 92px); color: var(--yellow); }
#timer { font-family: var(--display); font-size: 22px; text-shadow: var(--outline); }
.card { border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); }
#cards .card { background: rgba(26, 16, 38, .5); }
.card .nm { font-family: var(--display); font-weight: 400; letter-spacing: .3px; }
.tbtn { border: 4px solid var(--line); box-shadow: 0 6px 0 var(--line), 0 10px 18px rgba(0,0,0,.35); font-family: var(--display); }
.tbtn small { font-family: var(--display); font-weight: 400; }
.tbtn.down { box-shadow: 0 1px 0 var(--line); }

/* messaggi: nuvoletta da fumetto */
#toast {
  background: #fffaf0; color: var(--line); border: 3px solid var(--line); border-radius: 18px;
  box-shadow: 0 5px 0 var(--line); font-weight: 800; padding: 10px 20px;
}
#toast::after {
  content: ''; position: absolute; left: 50%; bottom: -12px; width: 18px; height: 18px; background: #fffaf0;
  border-right: 3px solid var(--line); border-bottom: 3px solid var(--line); transform: translateX(-50%) rotate(45deg);
}

/* portafoglio in alto: pillola con bordo */
#wallet { border: 3px solid var(--line); box-shadow: 0 4px 0 var(--line); background: rgba(26, 16, 38, .85); font-family: var(--display); font-weight: 400; }

/* finestra dell'aggiornamento: stessa grafica */
#apk-update .apk-bar { border: 3px solid var(--line); height: 18px; border-radius: 10px; }
#apk-update .apk-bar > div { background: repeating-linear-gradient(-45deg, #ffd23d 0 10px, #ffb020 10px 20px); }

/* pressione dei pulsanti più evidente, e sui touch screen niente "mouse sopra" (dopo un tocco resterebbe attivo
   e il pulsante rimarrebbe sollevato e storto) */
@media (hover: none) {
  .big:hover, .small:hover, .gcard:hover, .chap:hover, .ch:hover, .modecard:hover, .cpack:hover { transform: none; filter: none; }
}
.big:active { transform: translateY(6px) scale(.97); box-shadow: 0 0 0 var(--line), 0 2px 6px rgba(0,0,0,.25); filter: brightness(.95); transition-duration: .04s; }
.small:active, .back:active { transform: translateY(4px) scale(.96); box-shadow: 0 0 0 var(--line); }

/* tocco veloce: il pulsante fa giù-e-su prima che parta l'azione (vedi TAP_MS in main.js) */
.tap { animation: tapPress .16s ease-out !important; }
@keyframes tapPress {
  0% { transform: none; }
  45% { transform: translateY(6px) scale(.97); box-shadow: 0 0 0 var(--line); filter: brightness(.95); }
  100% { transform: none; }
}

/* sposta l'account: codice grande, da dettare all'altro telefono */
.acct-box { margin-top: 18px; padding-top: 14px; border-top: 3px dashed rgba(255,255,255,.18); }
.acct-box h3 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; color: var(--yellow); text-shadow: var(--outline); font-size: 22px; }
.link-code { margin: 8px 0; padding: 12px; text-align: center; background: #fffaf0; color: var(--line); border: 3px solid var(--line); border-radius: 16px; box-shadow: 0 5px 0 var(--line); }
.link-code b { display: block; font-family: var(--display); font-size: 40px; letter-spacing: 4px; }
.link-code small { font-weight: 700; }
.link-row input { flex: 1; min-width: 140px; text-transform: uppercase; letter-spacing: 2px; font-weight: 800; }
/* salvare l'account con Google (play-games.js): riquadro, finestra di scelta tra due account, invito */
.pgs-box { margin-bottom: 14px; }
.pgs-overlay { position: fixed; inset: 0; z-index: 1001; display: flex; align-items: center; justify-content: center; background: rgba(10, 6, 30, 0.82); }
.pgs-overlay[hidden] { display: none; }
.pgs-pick-box { max-width: 560px; width: calc(100% - 32px); text-align: center; }
.pgs-accts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.pgs-acct { flex: 1 1 180px; display: flex; flex-direction: column; gap: 2px; padding: 10px; background: rgba(255, 255, 255, .08); border: 3px solid var(--line); border-radius: 16px; font-weight: 700; }
.pgs-acct b { color: var(--yellow); }
.pgs-overlay .apk-btns { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 10px; }
/* schede in basso: il testo lungo va a capo invece di uscire dalla scheda; schermi stretti = schede più strette */
#cards .card .st { white-space: normal; font-size: 10px; line-height: 1.15; }
@media (max-width: 760px) { #cards .card { width: 78px; } }
/* balletto 'crash': lo schermo incrinato sopra a tutto */
.screen-crack { position: fixed; inset: 0; z-index: 60; pointer-events: none; transition: opacity .7s; animation: crack-in .12s ease-out; }
.screen-crack svg { width: 100%; height: 100%; }
.screen-crack.out { opacity: 0; }
@keyframes crack-in { from { transform: scale(1.04); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Brain Bomb (rompicapi, js/brain-bomb.js) ---------- */
.bb-btn { background: linear-gradient(135deg, #7a3aff, #ff3a8a); box-shadow: 0 6px 0 #4a1a8a, 0 10px 20px rgba(0,0,0,.35); }
.bb-btn.locked { background: #4a4070; box-shadow: 0 6px 0 #2a2050; opacity: .75; }
.bb-panel h3 { color: var(--yellow); margin: 14px 0 4px; }
.bb-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; margin: 8px 0; }
.bb-lv { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border-radius: 12px; background: rgba(255,255,255,.08); line-height: 1.1; }
.bb-lv b { font-family: var(--pixel); font-size: 12px; }
.bb-lv span { font-size: 18px; margin: 2px 0; }
.bb-lv small { font-size: 11px; color: var(--muted); min-height: 12px; }
.bb-lv.done { background: rgba(61,220,106,.2); }
.bb-lv.next { background: rgba(255,210,61,.25); outline: 3px solid var(--yellow); }
.bb-lv.locked { opacity: .35; }
.bb-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-weight: 800; font-size: 18px; }
.bb-bar small { color: var(--muted); font-size: 13px; }
#bb-hint { margin: 4px 0 8px; font-size: 14px; }
#bb-play h2 { font-size: 14px; line-height: 1.4; }
.bb-main { display: flex; flex-direction: column; gap: 12px; align-items: center; }
@media (orientation: landscape) and (min-width: 700px) { .bb-main { flex-direction: row; align-items: flex-start; justify-content: center; } .bb-pad { min-width: 260px; } }
.bb-board { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 100%; }
.bb-board.shake { animation: bbShake .35s; }
@keyframes bbShake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.bb-ans { color: var(--yellow); }
/* equazioni */
.bb-eq { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: clamp(20px, 6.5vw, 30px); padding: 4px 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.bb-eq i { font-style: normal; font-weight: 800; color: var(--muted); margin: 0 2px; }
.bb-eq b { font-family: var(--pixel); font-size: 20px; }
.bb-eq.q { outline: 3px solid var(--yellow); }
.bb-sym { line-height: 1.1; }
/* sequenze */
.bb-seq { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.bb-seq b { font-family: var(--pixel); font-size: 18px; padding: 12px 10px; border-radius: 12px; background: rgba(255,255,255,.1); min-width: 36px; text-align: center; }
/* carte (intruso, matrice) */
.bb-card { display: inline-block; font-size: 20px; letter-spacing: 1px; line-height: 1; text-shadow: 0 2px 0 rgba(0,0,0,.4); max-width: 90px; word-break: break-all; text-align: center; }
.bb-card.lg { font-size: 28px; }
.bb-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; width: min(560px, 100%); }
.bb-pick { min-height: 74px; padding: 6px; border-radius: 14px; background: rgba(255,255,255,.1); border: 3px solid transparent; display: flex; align-items: center; justify-content: center; }
.bb-pick:hover { background: rgba(255,255,255,.18); }
.bb-pick.wrong { border-color: var(--red); opacity: .5; }
.bb-pick.right { border-color: var(--green); background: rgba(61,220,106,.25); }
.bb-matrix { display: grid; grid-template-columns: repeat(3, 92px); grid-auto-rows: 80px; gap: 6px; }
.bb-matrix > div { display: flex; align-items: center; justify-content: center; border-radius: 12px; background: rgba(255,255,255,.08); }
.bb-matrix .bb-ans { font-family: var(--pixel); font-size: 26px; outline: 3px dashed var(--yellow); }
.bb-opts { display: grid; grid-template-columns: repeat(4, minmax(64px, 1fr)); gap: 6px; width: min(420px, 100%); }
.bb-pick.sym { font-size: 30px; min-height: 60px; font-family: var(--pixel); }
/* lucchetto */
.bb-clues { display: flex; flex-direction: column; gap: 6px; }
.bb-clue { display: flex; align-items: center; gap: 5px; }
.bb-clue b { font-family: var(--pixel); font-size: 18px; width: 36px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(255,255,255,.12); }
.bb-pegs { margin-left: 10px; font-size: 22px; letter-spacing: 3px; color: var(--yellow); min-width: 70px; }
.bb-code { margin-top: 6px; } .bb-code b { background: rgba(255,210,61,.25); outline: 2px solid var(--yellow); } .bb-code b.empty { color: var(--muted); }
/* griglia */
.bb-grid { display: grid; grid-template-columns: repeat(calc(var(--n) * 2 - 1), auto); align-items: center; justify-items: center; }
.bb-grid .cell { width: min(46px, 10vw); height: min(46px, 10vw); display: flex; align-items: center; justify-content: center; font-size: min(26px, 6vw); font-family: var(--pixel); border-radius: 8px; background: rgba(255,255,255,.1); }
.bb-grid .cell.bb-ans { outline: 3px dashed var(--yellow); }
.bb-grid .sg { font-weight: 800; color: var(--yellow); font-size: 16px; min-width: 12px; min-height: 12px; text-align: center; line-height: 1; }
/* tastierino */
.bb-entry { font-family: var(--pixel); font-size: 22px; text-align: center; padding: 10px; border-radius: 12px; background: rgba(0,0,0,.3); min-height: 24px; margin-bottom: 6px; }
.bb-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: min(300px, 90vw); }
.bb-keys button { font-family: var(--pixel); font-size: 20px; padding: 12px 0; border-radius: 12px; background: rgba(255,255,255,.14); }
.bb-keys button:active { transform: scale(.94); }
.bb-keys .ok { background: var(--green); grid-column: span 2; }
.bb-msg { text-align: center; margin-top: 10px; font-size: 18px; }
.bb-msg .ok { color: var(--green); } .bb-msg .ko { color: var(--red); }
.bb-end { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.bb-end .big { width: auto; }
@media (max-height: 500px) { .bb-eq { font-size: 24px; } .bb-matrix { grid-template-columns: repeat(3, 76px); grid-auto-rows: 60px; } .bb-card { font-size: 16px; } .bb-card.lg { font-size: 24px; } .bb-pick { min-height: 56px; } .bb-keys button { padding: 8px 0; font-size: 16px; } }

/* ---------- ONLINE: schermate separate (home, lista, codice, ricerca) ---------- */
.online-home header { flex-wrap: wrap; }
.online-home header .on-namebox { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 8px; }
.online-home header .on-namebox input { width: 150px; }
.on-teams { justify-content: flex-start; margin: 4px 0 10px; }
.on-home { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.on-home .modecard { position: relative; min-height: 104px; padding: 14px 14px 12px 64px; animation: menuIn .35s backwards; }
.on-home .modecard:nth-child(2) { animation-delay: .04s; } .on-home .modecard:nth-child(3) { animation-delay: .08s; } .on-home .modecard:nth-child(4) { animation-delay: .12s; }
.on-home .modecard:nth-child(5) { animation-delay: .16s; } .on-home .modecard:nth-child(6) { animation-delay: .2s; } .on-home .modecard:nth-child(7) { animation-delay: .24s; }
.mc-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%) rotate(-6deg); font-size: 38px; filter: drop-shadow(0 3px 0 var(--line)); }
.on-home .mc-quick { background-color: #e0a020; }
.on-home .mc-ranked { background-color: #5a3ac0; background-image: linear-gradient(135deg, rgba(255,210,61,.25), transparent 60%); }
.on-home .mc-quick small, .on-home .mc-ranked small { opacity: 1; }
.mc-quick .mc-ic, .mc-ranked .mc-ic { animation: wob 1.6s ease-in-out infinite; }
#on-lobbies { max-height: 60vh; }
.lrow .lr-left { font-family: var(--display); font-size: 13px; color: var(--yellow); }
.code-row { display: flex; align-items: center; gap: 6px; margin: 14px 0; }
.code-pre { font-family: var(--display); font-size: 30px; color: var(--yellow); text-shadow: var(--outline); }
.code-row input { flex: 1; min-width: 0; font-family: var(--display); font-size: 30px; letter-spacing: 6px; text-transform: uppercase; padding: 6px 12px; color: var(--ink); border-radius: 14px; }
.search-panel { text-align: center; }
.search-anim { font-size: 54px; height: 90px; display: flex; align-items: center; justify-content: center; }
.search-anim span { display: inline-block; animation: searchLoop 2.2s ease-in-out infinite; filter: drop-shadow(0 4px 0 var(--line)); }
@keyframes searchLoop { 0% { transform: translate(-30px, 0) rotate(-10deg); } 25% { transform: translate(0, -14px) rotate(0); } 50% { transform: translate(30px, 0) rotate(10deg); } 75% { transform: translate(0, 10px) rotate(0); } 100% { transform: translate(-30px, 0) rotate(-10deg); } }
.search-panel .big { margin-top: 12px; }

/* ---------- SALA D'ATTESA: palco 3D dietro, solo l'essenziale davanti ---------- */
.room-screen { padding: 0; justify-content: space-between; align-items: stretch; pointer-events: none; }
.room-screen > * { pointer-events: auto; }
.room-top { display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
.room-title { flex: 1; min-width: 0; }
.room-title h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 28px; color: var(--yellow); text-shadow: var(--outline), 0 4px 0 var(--line); transform: rotate(-2deg); display: inline-block; }
.room-title small { display: block; font-weight: 800; font-size: 15px; text-shadow: var(--outline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-code { display: flex; flex-direction: column; align-items: center; padding: 4px 14px; background: #fffaf0; color: var(--line); border: 3px solid var(--line); border-radius: 14px; box-shadow: 0 4px 0 var(--line); transform: rotate(2deg); }
.room-code small { font-weight: 800; font-size: 11px; }
.room-code b { font-family: var(--display); font-weight: 400; font-size: 24px; letter-spacing: 2px; }
.room-timer { position: relative; width: 74px; height: 74px; flex: none; transition: opacity .3s; }
.room-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); filter: drop-shadow(0 4px 0 var(--line)); }
.room-timer circle { fill: none; stroke-width: 12; }
.room-timer .bg { stroke: rgba(26,16,38,.75); fill: rgba(26,16,38,.55); }
.room-timer .fg { stroke: var(--yellow); stroke-linecap: round; stroke-dasharray: 264; transition: stroke .3s; }
.room-timer b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 400; font-size: 28px; text-shadow: var(--outline); }
.room-timer.hurry .fg { stroke: var(--red); }
.room-timer.hurry b { color: #ffd0d0; }
.room-timer.off { opacity: 0; }
/* targhette sopra i BUMI (posizionate da main.js seguendo i personaggi 3D) */
.room-plates { position: absolute; inset: 0; pointer-events: none !important; }
.plate { position: absolute; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; transition: opacity .2s; }
.plate .pn { font-family: var(--display); font-size: 18px; padding: 2px 10px; border-radius: 12px; background: rgba(26,16,38,.82); border: 3px solid var(--pc, #fff); box-shadow: 0 3px 0 var(--line); white-space: nowrap; max-width: 24vw; overflow: hidden; text-overflow: ellipsis; }
.plate .pt { font-weight: 800; font-size: 13px; text-shadow: var(--outline); white-space: nowrap; }
.plate .pr { font-family: var(--display); font-size: 15px; padding: 1px 10px; border-radius: 10px; border: 2px solid var(--line); background: rgba(26,16,38,.7); }
.plate.ready .pr { background: var(--green); color: var(--line); animation: pop .35s; }
.plate.me .pn { background: var(--yellow); color: var(--line); }
.plate.bot { opacity: .75; }
.plate.bot .pn { border-style: dashed; }
/* conto alla rovescia finale: numeri enormi */
.room-count { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); font-family: var(--display); font-size: clamp(80px, 20vw, 180px); color: var(--yellow); text-shadow: var(--outline), 0 8px 0 var(--line); pointer-events: none !important; }
.room-count.pop { animation: pop .45s; }
.room-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.room-actions { display: flex; gap: 10px; align-items: flex-end; }
.room-actions .big { width: auto; margin: 0; padding: 12px 18px; font-size: 20px; }
.ready-btn { min-width: 180px; font-size: 26px !important; animation: readyPulse 1.2s ease-in-out infinite; }
.ready-btn.done { animation: none; background: var(--paper2); box-shadow: 0 6px 0 var(--line); filter: none; }
@keyframes readyPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.emote-bar { display: flex; flex-wrap: wrap; gap: 6px; max-width: 46vw; }
.emote-bar button { padding: 6px 10px; border-radius: 12px; font-size: 20px; font-weight: 800; background: rgba(26,16,38,.82); border: 3px solid var(--line); box-shadow: 0 3px 0 var(--line); color: var(--ink); }
.emote-bar button.txt { font-family: var(--display); font-weight: 400; font-size: 15px; }
.emote-bar.cool button { opacity: .45; }
.room-drawer { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 96px; bottom: 96px; width: min(560px, calc(100% - 24px)); max-height: none; z-index: 5; animation: drawerIn .2s ease-out; }
.room-drawer header { justify-content: space-between; }
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.look-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin: 10px 0; }
.look-items button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 14px; background: var(--paper2); box-shadow: 0 0 0 3px var(--line), 0 5px 0 3px var(--line); font-weight: 800; font-size: 13px; color: var(--ink); }
.look-items button.on { background: var(--yellow); color: var(--line); transform: rotate(-2deg); }
.look-items img { width: 64px; height: 64px; object-fit: contain; }
.look-items .li-ic { font-size: 40px; line-height: 64px; height: 64px; }
/* nuvolette delle emote (sala e partita) */
#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fffaf0; color: var(--line); border: 3px solid var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--line); padding: 4px 12px; font-family: var(--display); font-size: 20px; white-space: nowrap; animation: bubbleIn .25s cubic-bezier(.3,1.6,.5,1), bubbleOut .4s 2.1s forwards; }
.bubble.emo { font-size: 34px; padding: 0 8px; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -10px; width: 14px; height: 14px; background: #fffaf0; border-right: 3px solid var(--line); border-bottom: 3px solid var(--line); transform: translateX(-50%) rotate(45deg); }
@keyframes bubbleIn { from { transform: translate(-50%, -60%) scale(.3); opacity: 0; } to { transform: translate(-50%, -100%) scale(1); opacity: 1; } }
@keyframes bubbleOut { to { transform: translate(-50%, -130%); opacity: 0; } }
/* in partita: tasto delle emote sotto la pausa */
#btn-emote { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 50px); right: max(10px, env(safe-area-inset-right)); pointer-events: auto; width: 44px; height: 44px; padding: 0; font-size: 18px; z-index: 4; }
#emote-pick { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 50px); right: calc(max(10px, env(safe-area-inset-right)) + 50px); max-width: min(380px, 70vw); justify-content: flex-end; pointer-events: auto; z-index: 4; }
#hud.final #btn-emote, #hud.final #emote-pick { display: none; }
#reconnect { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10,6,30,.55); pointer-events: auto; z-index: 8; }
#reconnect .panel { text-align: center; width: min(380px, 92vw); }
/* fasce della Classificata */
.end-rank { font-family: var(--display); font-size: 20px; margin: 4px 0 8px; }
.end-rank .up { color: var(--green); } .end-rank .down { color: var(--red); }
.top-list .tier-ic { width: 26px; text-align: center; }
@media (max-height: 500px) {
  .room-title h2 { font-size: 22px; }
  .room-timer { width: 58px; height: 58px; }
  .room-timer b { font-size: 22px; }
  .room-actions .big { padding: 8px 12px; font-size: 16px; }
  .ready-btn { min-width: 140px; font-size: 20px !important; }
  .emote-bar button { padding: 3px 7px; font-size: 16px; }
  .emote-bar button.txt { font-size: 12px; }
  .room-drawer { top: 70px; bottom: 70px; }
  .plate .pn { font-size: 15px; }
  .on-home .modecard { min-height: 84px; }
}
@media (max-width: 700px) {
  .room-bottom { flex-direction: column; align-items: stretch; }
  .emote-bar { max-width: none; justify-content: center; }
  .room-actions { justify-content: center; }
  .room-code b { font-size: 18px; }
  .online-home header .on-namebox { margin-left: 0; }
}
body.in-room #wallet { display: none; }
@media (max-height: 500px) { .plate .pt { display: none; } .plate .pr { font-size: 12px; } }

/* ---------- menu principale: tramonto, pulsanti larghi con l'icona a sinistra, scorciatoie in alto a destra ---------- */
#scr-title { isolation: isolate; overflow: hidden; justify-content: center; gap: clamp(4px, 1.6vh, 12px); padding: max(8px, env(safe-area-inset-top)) 16px max(8px, env(safe-area-inset-bottom)); }
.title-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background: linear-gradient(180deg, #4a1ab8 0, #8a2ad0 32%, #e04aa8 62%, #ff8a6a 100%); }
.title-bg::before { content: ''; position: absolute; left: 50%; top: 62%; width: 260vmax; height: 260vmax; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(rgba(255,255,255,.07) 0 6deg, transparent 6deg 18deg); animation: tbSpin 90s linear infinite; }
.title-bg .sun { position: absolute; left: 50%; top: 40%; width: min(118vh, 72vw); aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #ffe9a0 0, #ffc860 45%, #ff9a5a 80%, #ff7a6a 100%); box-shadow: 0 0 80px 30px rgba(255, 190, 120, .35); }
.title-bg .city { position: absolute; bottom: 0; width: 34vw; height: 42vh; background: #8a34d0; opacity: .95;
  clip-path: polygon(0 100%, 0 30%, 10% 30%, 10% 18%, 22% 18%, 22% 42%, 32% 42%, 32% 8%, 44% 8%, 44% 36%, 54% 36%, 54% 22%, 66% 22%, 66% 50%, 76% 50%, 76% 34%, 88% 34%, 88% 60%, 100% 60%, 100% 100%); }
.title-bg .city.l { left: 0; }
.title-bg .city.r { right: 0; transform: scaleX(-1); background: #9a3ae0; }
.title-bg .cf { position: absolute; width: 12px; height: 12px; border-radius: 2px; transform: rotate(45deg); opacity: .8; animation: tbFloat 6s ease-in-out infinite; }
.title-bg .cf:nth-of-type(4) { left: 36%; top: 22%; background: #9ad8ff; }
.title-bg .cf:nth-of-type(5) { left: 61%; top: 20%; background: #9ad8ff; width: 14px; height: 14px; animation-delay: -1s; }
.title-bg .cf:nth-of-type(6) { left: 16%; top: 58%; background: #ffd23d; width: 16px; height: 16px; animation-delay: -2s; }
.title-bg .cf:nth-of-type(7) { left: 23%; top: 46%; background: #ffb0c0; width: 9px; height: 9px; animation-delay: -3s; }
.title-bg .cf:nth-of-type(8) { left: 85%; top: 60%; background: #9ad8ff; animation-delay: -4s; }
.title-bg .cf:nth-of-type(9) { left: 87%; top: 52%; background: #ffb0c0; width: 9px; height: 9px; animation-delay: -5s; }
@keyframes tbSpin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes tbFloat { 0%, 100% { transform: translateY(0) rotate(45deg); } 50% { transform: translateY(-10px) rotate(70deg); } }

#scr-title .logo { margin: 0 0 clamp(2px, 3.5vh, 30px); }
#scr-title .menu { position: relative; z-index: 1; display: flex; flex-direction: column; gap: clamp(6px, 1.6vh, 12px); width: min(430px, 82vw); }
#scr-title .menu .big { display: flex; align-items: center; gap: 14px; margin: 0; height: clamp(38px, 9.4vh, 62px); padding: 0 22px;
  border-radius: 999px; font-size: clamp(16px, 4.2vh, 26px); text-align: left; }
#scr-title .menu .big .mi { font-style: normal; flex: 0 0 auto; width: 1.7em; text-align: center; font-size: 1.15em; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
#scr-title .menu .big span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#scr-title .menu .bb-btn { background-image: linear-gradient(180deg, rgba(255,255,255,.28) 0, rgba(255,255,255,.08) 45%, rgba(0,0,0,0) 46%); background-color: #8a44e8; }
#scr-title .menu .bb-btn.locked { background-color: #5a4a88; opacity: 1; }
#scr-title .menu .bb-btn.locked span { opacity: .75; }

.top-tiles { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: clamp(6px, 1.2vw, 12px); z-index: 2; }
.tile { width: clamp(62px, 15vh, 100px); aspect-ratio: 1 / .86; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 3px solid var(--line); border-radius: 16px; background: #3a1a7a; box-shadow: 0 4px 0 var(--line), 0 8px 14px rgba(0,0,0,.28);
  font-family: var(--display); font-size: clamp(10px, 2.4vh, 15px); line-height: 1.05; text-shadow: var(--outline); text-align: center; padding: 4px; transition: transform .1s; }
.tile i { font-style: normal; font-size: 2em; line-height: 1; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.tile:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }

/* telefono in verticale: le scorciatoie restano in alto, il logo scende un po' */
@media (max-aspect-ratio: 1/1) {
  #scr-title { justify-content: center; padding-top: calc(max(10px, env(safe-area-inset-top)) + 96px); }
  .tile { width: 78px; font-size: 12px; }
  .top-tiles { right: 50%; transform: translateX(50%); top: calc(max(10px, env(safe-area-inset-top)) + 52px); }
  #scr-title .menu .big { height: clamp(44px, 7vh, 62px); font-size: clamp(18px, 3vh, 24px); }
  .title-bg .sun { top: 48%; width: 110vw; }
  .title-bg .city { width: 50vw; height: 24vh; }
}
/* telefono in orizzontale basso: il menu non deve finire sotto i pulsanti degli angoli */
@media (min-aspect-ratio: 1/1) and (max-height: 520px) {
  #scr-title .menu { width: max(260px, min(430px, calc(100vw - 260px))); }
  #scr-title .corner { flex-direction: column; bottom: max(10px, env(safe-area-inset-bottom)); right: max(12px, env(safe-area-inset-right)); gap: 6px; }
  #scr-title .corner .small { padding: 6px 12px; }
}

/* Storia: boss di fine mondo e filmatini (client/js/render/story-clips.js) */
.chap.boss { background: linear-gradient(135deg, rgba(255,75,75,.22), rgba(138,58,255,.22)); }
.chap.boss.next { outline-color: #ff4b4b; }
.chap.boss .t { color: #ffb0b0; }
.chapters .world .wclip { margin-left: 8px; font-size: 18px; padding: 2px 6px; border-radius: 10px; background: rgba(0,0,0,.25); cursor: pointer; }
#scr-story .clip-end { background: rgba(255,255,255,.14); border-radius: 12px; font-weight: 700; }

/* ---------- Brain Bomb: il rompicapo sta tutto nello schermo, senza scorrere (telefono in orizzontale e in verticale) ----------
   Il pannello prende tutta l'altezza; il riquadro del rompicapo (.bb-board) prende lo spazio che resta e il suo contenuto
   (.bb-fit, tutto in em) viene ingrandito o rimpicciolito da fitBoard() in client/js/brain-bomb.js. */
#scr-brain .bb-panel.bb-playing { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
#scr-brain .bb-playing #bb-play { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: clamp(3px, 1vmin, 8px); }
#scr-brain #bb-play > header { margin: 0; min-width: 0; }
#scr-brain #bb-play h2 { font-size: clamp(15px, 2.2vmin + 7px, 24px); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 56px); }
#scr-brain #bb-play .bb-bar { font-size: clamp(13px, 1.4vmin + 8px, 18px); gap: 2px 12px; min-width: 0; }
#scr-brain #bb-play .bb-bar small { font-size: clamp(11px, 1vmin + 7px, 13px); }
#scr-brain #bb-play #bb-hint { margin: 0; font-size: clamp(11px, 1vmin + 8px, 14px); line-height: 1.25; }
#scr-brain #bb-play .bb-main { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; align-items: stretch; gap: clamp(4px, 1.5vmin, 12px); }
#scr-brain #bb-play .bb-board { container-type: size; min-width: 0; min-height: 0; width: 100%; height: 100%; max-width: none; overflow: hidden; justify-content: center; align-items: center; gap: 0; }
#scr-brain .bb-fit { flex: none; width: 100%; display: flex; flex-direction: column; align-items: center; gap: .35em; font-size: 16px; line-height: 1.15; transform-origin: center center; }
#scr-brain #bb-play .bb-pad { min-width: 0; min-height: 0; align-self: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(4px, 1vmin, 8px); }
#scr-brain #bb-play .bb-msg { margin: 0; font-size: clamp(14px, 1.4vmin + 9px, 18px); text-align: center; }
#scr-brain #bb-play .bb-msg:empty { display: none; }
#scr-brain #bb-play .bb-end { gap: 4px 10px; }
#scr-brain #bb-play .bb-end .big { margin: 4px 0; padding: 6px 14px; font-size: clamp(15px, 1.8vmin + 9px, 22px); }
#scr-brain #bb-play .bb-end .small { padding: 6px 12px; }
/* a rompicapo finito il messaggio prende il posto della spiegazione e del tastierino */
#scr-brain #bb-play.bb-over #bb-hint, #scr-brain #bb-play.bb-over .bb-entry, #scr-brain #bb-play.bb-over .bb-keys { display: none; }
#scr-brain #bb-play.bb-over .bb-pad:not(:has(.bb-opts)) { display: none; }
@media (orientation: landscape) {
  #scr-brain #bb-play .bb-main { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr); }
  #scr-brain #bb-play .bb-pad { width: clamp(190px, 32vw, 320px); }
  /* risposte a scelta (pezzo mancante): più larghe, così le carte non vanno a capo */
  #scr-brain #bb-play .bb-pad:has(.bb-opts) { width: clamp(220px, 44vw, 440px); }
}
/* telefono in orizzontale (poca altezza): titolo e tempo sulla stessa riga, messaggio finale in una riga */
@media (orientation: landscape) and (max-height: 560px) {
  #scr-brain .bb-playing #bb-play { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 10px; }
  #scr-brain #bb-play > header { grid-column: 1; grid-row: 1; }
  #scr-brain #bb-play .bb-bar { grid-column: 2; grid-row: 1; flex-wrap: nowrap; white-space: nowrap; }
  #scr-brain #bb-play #bb-hint, #scr-brain #bb-play .bb-main, #scr-brain #bb-play .bb-msg { grid-column: 1 / -1; }
  #scr-brain #bb-play #bb-hint { grid-row: 2; } #scr-brain #bb-play .bb-main { grid-row: 3; } #scr-brain #bb-play .bb-msg { grid-row: 4; }
  #scr-brain #bb-play .back { width: 36px; height: 36px; }
  #scr-brain #bb-play .bb-msg { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 12px; }
  #scr-brain #bb-play .bb-msg:empty { display: none; }
  #scr-brain #bb-play .bb-end .big { margin: 2px 0; padding: 4px 12px; }
}

/* contenuto dei rompicapi: tutto in em (la grandezza la decide fitBoard) */
#scr-brain .bb-fit .bb-eq { font-size: 1em; line-height: 1.35; gap: .15em; padding: .1em .45em; border-radius: .4em; flex-wrap: nowrap; white-space: nowrap; }
#scr-brain .bb-fit .bb-eq b { font-size: .7em; }
/* riquadro stretto (telefono in verticale): le equazioni lunghe vanno a capo invece di diventare minuscole */
@container (max-aspect-ratio: 1 / 1) { #scr-brain .bb-fit .bb-eq { flex-wrap: wrap; justify-content: center; white-space: normal; } }
#scr-brain .bb-fit .bb-eq.q { outline-width: 2px; }
#scr-brain .bb-fit .bb-seq { gap: .4em; width: 100%; }
#scr-brain .bb-fit .bb-seq b { font-size: 1em; padding: .6em .5em; min-width: 2em; border-radius: .5em; }
#scr-brain .bb-fit .bb-cards { width: min(100%, 34em); grid-template-columns: repeat(auto-fill, minmax(5.4em, 1fr)); gap: .45em; }
#scr-brain .bb-fit .bb-pick { min-height: 4.2em; padding: .3em; border-radius: .7em; }
#scr-brain .bb-fit .bb-card { font-size: 1.15em; max-width: 4.4em; }
#scr-brain .bb-fit .bb-card.lg { font-size: 1.6em; max-width: 3.2em; }
#scr-brain .bb-fit .bb-matrix { grid-template-columns: repeat(3, 5.4em); grid-auto-rows: 4.4em; gap: .35em; }
#scr-brain .bb-fit .bb-matrix > div { border-radius: .6em; }
#scr-brain .bb-fit .bb-matrix .bb-ans { font-size: 1.5em; }
#scr-brain .bb-fit .bb-clues { gap: .3em; }
#scr-brain .bb-fit .bb-clue { gap: .25em; }
#scr-brain .bb-fit .bb-clue b { font-size: 1em; width: 1.9em; height: 2.1em; border-radius: .4em; }
#scr-brain .bb-fit .bb-pegs { margin-left: .5em; font-size: 1.2em; letter-spacing: .1em; min-width: 3.4em; }
#scr-brain .bb-fit .bb-code { margin-top: .3em; }
/* tanti indizi e riquadro largo: due colonne */
@container (min-aspect-ratio: 5 / 4) {
  #scr-brain .bb-fit .bb-clues.many { display: grid; grid-template-columns: auto auto; column-gap: 1.4em; }
}
#scr-brain .bb-fit .bb-grid .cell { width: 2.1em; height: 2.1em; font-size: 1em; border-radius: .35em; }
#scr-brain .bb-fit .bb-grid .sg { font-size: .8em; min-width: .8em; min-height: .8em; }
#scr-brain .bb-fit .cell.row-ans { background: rgba(255,210,61,.22); outline: 2px dashed var(--yellow); outline-offset: -2px; }
#scr-brain .bb-fit .cell.row-ans b { font-family: var(--pixel); color: var(--yellow); }
#scr-brain .bb-board.reveal .row-ans b, #scr-brain .bb-board.reveal .bb-code b { color: var(--green); }
/* caccia al numero: gli indizi in una lista */
#scr-brain .bb-hunt { display: flex; flex-direction: column; align-items: stretch; gap: .4em; width: min(100%, 30em); }
#scr-brain .bb-range { font-weight: 800; color: var(--yellow); text-align: center; font-size: 1.05em; }
#scr-brain .bb-hclues { margin: 0; padding: 0 0 0 1.6em; display: flex; flex-direction: column; gap: .25em; }
#scr-brain .bb-hclues li { padding: .2em .5em; border-radius: .4em; background: rgba(255,255,255,.08); font-weight: 700; }
/* gabbie (tipo KenKen): bordi spessi tra le gabbie, risultato nell'angolo */
#scr-brain .bb-kk { display: grid; grid-template-columns: repeat(var(--n), 2.6em); grid-auto-rows: 2.6em; border: 2px solid rgba(255,255,255,.85); background: rgba(255,255,255,.08); }
#scr-brain .bb-kk .cell { position: relative; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.18); min-width: 0; }
#scr-brain .bb-kk .cell.et { border-top: 3px solid rgba(255,255,255,.85); } #scr-brain .bb-kk .cell.eb { border-bottom: 3px solid rgba(255,255,255,.85); }
#scr-brain .bb-kk .cell.el { border-left: 3px solid rgba(255,255,255,.85); } #scr-brain .bb-kk .cell.er { border-right: 3px solid rgba(255,255,255,.85); }
#scr-brain .bb-kk .cell small { position: absolute; top: .1em; left: .2em; font-size: .62em; font-weight: 800; line-height: 1; color: #fff; white-space: nowrap; }
#scr-brain .bb-kk .cell b { font-size: 1.1em; margin-top: .35em; }

/* risposta scritta: campo grande + tastierino */
#scr-brain #bb-play .bb-entry { display: block; width: min(100%, 300px); box-sizing: border-box; margin: 0; padding: .2em .4em; font-family: var(--pixel); font-size: clamp(16px, 2.6vmin + 6px, 26px); text-align: center; color: var(--yellow); letter-spacing: .12em; border-radius: 12px; min-height: 0; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
#scr-brain #bb-play .bb-entry::placeholder { color: rgba(255,255,255,.3); }
#scr-brain #bb-play .bb-keys { width: min(300px, 100%); gap: clamp(3px, .8vmin, 6px); }
#scr-brain #bb-play .bb-keys button { font-size: clamp(14px, 1.8vmin + 7px, 20px); padding: clamp(5px, 1.6vmin, 12px) 0; }
@media (orientation: landscape) and (max-height: 560px) {
  #scr-brain #bb-play .bb-keys { grid-template-columns: repeat(6, 1fr); }
  #scr-brain #bb-play .bb-keys .ok { grid-column: auto; }
}
/* scelte nel tastierino (pezzo mancante, quadrato magico) */
#scr-brain #bb-play .bb-pad .bb-opts { width: min(100%, 420px); gap: clamp(3px, .8vmin, 6px); }
#scr-brain #bb-play .bb-pad .bb-pick { min-height: clamp(38px, 10vmin, 74px); padding: 3px; }
#scr-brain #bb-play .bb-pad .bb-card { font-size: clamp(12px, 2.4vmin + 4px, 20px); max-width: 100%; overflow-wrap: anywhere; line-height: .95; letter-spacing: 0; }
#scr-brain .bb-fit .bb-card { overflow-wrap: anywhere; line-height: .95; }
#scr-brain #bb-play .bb-pad .bb-card.lg { font-size: clamp(14px, 2.8vmin + 4px, 26px); }
#scr-brain #bb-play .bb-pad .bb-pick.sym { font-size: clamp(18px, 3.6vmin + 6px, 30px); min-height: clamp(38px, 9vmin, 60px); }
