:root {
  --bg1: #12052e;
  --bg2: #2a0b5e;
  --gold: #ffd23f;
  --gold2: #ff9f1c;
  --red: #ff2d55;
  --green: #2bff88;
  --text: #fff;
  --muted: rgba(255,255,255,.65);
  --me: #ff3b6b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg1);
  color: var(--text);
  font-family: 'Rubik', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

.bg { position: fixed; inset: 0; background: radial-gradient(circle at 50% 40%, var(--bg2), var(--bg1) 70%); overflow: hidden; z-index: -1; }
.rays {
  position: absolute; left: 50%; top: 45%; width: 260vmax; height: 260vmax; margin: -130vmax 0 0 -130vmax;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.06) 0deg 8deg, transparent 8deg 20deg);
  animation: spin 40s linear infinite;
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 45%);
          mask-image: radial-gradient(circle, #000 0%, transparent 45%);
}
@keyframes spin { to { transform: rotate(360deg); } }

.screen {
  position: fixed; inset: 0; display: none; flex-direction: column; align-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}
body[data-screen="join"] #join,
body[data-screen="lobby"] #lobby,
body[data-screen="game"] #game { display: flex; }
#join { justify-content: center; gap: 16px; overflow-y: auto; }
#lobby { justify-content: center; gap: 10px; text-align: center; }

.logo {
  font-family: 'Bungee', 'Rubik', sans-serif; font-size: 64px; line-height: 1; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff6c2 0%, var(--gold) 45%, var(--gold2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #8a3b00) drop-shadow(0 8px 18px rgba(255,160,0,.45));
  transform: rotate(-4deg);
}
.logo span { display: inline-block; background: inherit; -webkit-background-clip: text; background-clip: text; color: transparent; animation: wiggle 1.6s ease-in-out infinite; }
.logo.small { font-size: 52px; }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 50% { transform: rotate(14deg) scale(1.1); } }
.tagline { margin: -6px 0 6px; color: var(--muted); font-weight: 700; letter-spacing: 3px; text-transform: uppercase; font-size: 13px; }

/* Selfie */
.selfie {
  position: relative; width: 190px; height: 190px; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.07); border: 4px dashed rgba(255,255,255,.35);
  display: grid; place-items: center; overflow: hidden; flex-shrink: 0;
  transition: transform .2s;
}
.selfie:active { transform: scale(.96); }
.selfie input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.selfie img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.selfie-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-weight: 700; }
.selfie-redo { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px 0 14px; background: linear-gradient(transparent, rgba(0,0,0,.75)); font-weight: 700; font-size: 14px; display: none; text-align: center; }
.selfie.has-photo { border: 5px solid var(--gold); box-shadow: 0 0 30px rgba(255,210,63,.5); }
.selfie.has-photo img, .selfie.has-photo .selfie-redo { display: block; }
.selfie.has-photo .selfie-empty { display: none; }

.name-input {
  width: min(100%, 340px); padding: 16px 18px; font: 700 22px 'Rubik', sans-serif; text-align: center;
  color: #fff; background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.25); border-radius: 16px; outline: none;
  -webkit-user-select: text; user-select: text;
}
.name-input:focus { border-color: var(--gold); background: rgba(255,255,255,.14); }
.name-input::placeholder { color: rgba(255,255,255,.4); }

.cta {
  width: min(100%, 340px); padding: 18px; border: 0; border-radius: 18px; cursor: pointer;
  font: 400 22px 'Bungee', 'Rubik', sans-serif; letter-spacing: 1px; color: #3a1600;
  background: linear-gradient(180deg, #fff1a8, var(--gold) 40%, var(--gold2));
  box-shadow: 0 6px 0 #a34d00, 0 12px 24px rgba(255,150,0,.35);
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.cta:active { transform: translateY(5px); box-shadow: 0 1px 0 #a34d00, 0 4px 10px rgba(255,150,0,.3); }
.cta:disabled { opacity: .4; }
.error { color: #ff8099; font-weight: 700; min-height: 1em; margin: 0; text-align: center; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font: 500 15px 'Rubik', sans-serif; margin-top: 18px; padding: 10px; }

/* Avatar */
.avatar { border-radius: 50%; background: var(--me) center/cover no-repeat; border: 4px solid var(--me); display: grid; place-items: center; font-weight: 900; color: #fff; flex-shrink: 0; }
.avatar.xl { width: 170px; height: 170px; font-size: 70px; box-shadow: 0 0 0 6px rgba(255,255,255,.08), 0 0 50px var(--me); animation: float 3s ease-in-out infinite; }
.avatar.sm { width: 48px; height: 48px; font-size: 20px; border-width: 3px; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.me-big { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 16px 0 6px; }
.me-name { font: 400 30px 'Bungee', 'Rubik', sans-serif; }
#lobby h2 { margin: 6px 0 0; font-size: 28px; font-weight: 900; }
.hint { color: var(--muted); font-size: 18px; margin: 4px 0; line-height: 1.4; }
.count { color: var(--gold); font-weight: 700; margin: 6px 0 0; }
.pop-in { animation: popin .6s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes popin { from { transform: scale(0); opacity: 0; } }

/* Gioco */
#game { padding-left: 14px; padding-right: 14px; touch-action: none; }
.topbar { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: rgba(0,0,0,.25); border-radius: 18px; }
.who { flex: 1; min-width: 0; }
.who-name { font-weight: 900; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-q { color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.score { text-align: right; font: 400 28px 'Bungee', 'Rubik', sans-serif; color: var(--gold); line-height: 1; }
.score small { display: block; font: 700 11px 'Rubik', sans-serif; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.score.bump { animation: bump .6s cubic-bezier(.2,1.8,.4,1); }
@keyframes bump { 40% { transform: scale(1.5); } }

.buzz-area { flex: 1; width: 100%; display: grid; place-items: center; position: relative; min-height: 0; }
.ring {
  position: absolute; width: min(86vw, 52vh); height: min(86vw, 52vh); border-radius: 50%;
  border: 3px solid rgba(255,255,255,.08);
}
.buzzer {
  --c1: #ff6a88; --c2: #ff1744; --c3: #9e0026;
  position: relative; width: min(78vw, 46vh); height: min(78vw, 46vh); border-radius: 50%; border: 0; padding: 0;
  background: #2a0b18; cursor: pointer; touch-action: none; outline: none;
  box-shadow: 0 0 0 10px rgba(0,0,0,.35), 0 0 0 14px rgba(255,255,255,.08), 0 30px 60px rgba(0,0,0,.6);
}
.buzzer-cap {
  position: absolute; left: 6%; right: 6%; top: 3%; bottom: 9%; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--c1) 0%, var(--c2) 45%, var(--c3) 100%);
  box-shadow: inset 0 -14px 30px rgba(0,0,0,.35), inset 0 10px 20px rgba(255,255,255,.35), 0 14px 0 var(--c3), 0 18px 30px rgba(0,0,0,.5);
  transition: transform .05s, box-shadow .05s, filter .2s;
  font: 400 clamp(36px, 13vw, 68px) 'Bungee', 'Rubik', sans-serif; color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.buzzer-cap::after {
  content: ''; position: absolute; left: 18%; top: 8%; width: 45%; height: 25%; border-radius: 50%;
  background: linear-gradient(rgba(255,255,255,.55), rgba(255,255,255,0)); transform: rotate(-20deg);
}
#buzzerLabel { position: relative; z-index: 1; line-height: 1; text-align: center; }
.buzzer.down .buzzer-cap { transform: translateY(12px); box-shadow: inset 0 -8px 20px rgba(0,0,0,.4), inset 0 10px 20px rgba(255,255,255,.25), 0 2px 0 var(--c3), 0 4px 10px rgba(0,0,0,.5); }

/* Stati del buzzer */
body[data-state="locked"] .buzzer, body[data-state="wrong"] .buzzer, body[data-state="done"] .buzzer { --c1: #6d6a80; --c2: #4a4760; --c3: #24223a; }
body[data-state="locked"] .buzzer-cap, body[data-state="done"] .buzzer-cap { font-size: clamp(22px, 8vw, 40px); color: rgba(255,255,255,.6); }
body[data-state="arming"] .buzzer { --c1: #ffe08a; --c2: #ffb300; --c3: #a35a00; }
body[data-state="arming"] .buzzer-cap { animation: throb .35s ease-in-out infinite alternate; }
body[data-state="open"] .ring, body[data-state="queue-open"] .ring { animation: pulse-ring 1s ease-out infinite; border-color: rgba(255,45,85,.7); }
body[data-state="open"] .buzzer-cap { animation: glow 0.8s ease-in-out infinite alternate; }
body[data-state="queue-open"] .buzzer { --c1: #ff9fb3; --c2: #ff4d73; --c3: #8c1032; }
body[data-state="queue-open"] .buzzer-cap { font-size: clamp(26px, 9vw, 46px); }
body[data-state="sent"] .buzzer { --c1: #ffffff; --c2: #ffd0dc; --c3: #c6496b; }
body[data-state="sent"] .buzzer-cap { color: var(--red); }
body[data-state="first"] .buzzer, body[data-state="correct"] .buzzer { --c1: #fff6c2; --c2: #ffd23f; --c3: #b36b00; }
body[data-state="first"] .buzzer-cap, body[data-state="correct"] .buzzer-cap { color: #5a2a00; font-size: clamp(28px, 10vw, 52px); }
body[data-state="first"] .ring { animation: pulse-ring .7s ease-out infinite; border-color: var(--gold); }
body[data-state="first"] .buzz-area { animation: shake .4s; }
body[data-state="correct"] .buzzer { --c1: #b8ffd6; --c2: #2bff88; --c3: #00803a; }
body[data-state="correct"] .buzzer-cap { color: #00401d; }
body[data-state="queued"] .buzzer { --c1: #9fd9ff; --c2: #2ec4ff; --c3: #00618f; }
body[data-state="queued"] .buzzer-cap { font-size: clamp(30px, 11vw, 56px); }
body[data-state="wrong"] .buzzer-cap { font-size: clamp(60px, 22vw, 110px); color: #ff5470; }

@keyframes throb { to { transform: scale(1.03); filter: brightness(1.15); } }
@keyframes glow { from { filter: brightness(1); } to { filter: brightness(1.25) drop-shadow(0 0 30px rgba(255,45,85,.8)); } }
@keyframes pulse-ring { from { transform: scale(.92); opacity: 1; } to { transform: scale(1.18); opacity: 0; } }
@keyframes shake { 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }

.status { min-height: 92px; text-align: center; padding-bottom: 6px; }
.status-main { font: 400 26px 'Bungee', 'Rubik', sans-serif; letter-spacing: .5px; }
.status-sub { color: var(--muted); font-size: 17px; font-weight: 500; margin-top: 4px; }

.offline {
  position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translate(-50%, -150%);
  background: #ff2d55; color: #fff; font-weight: 700; padding: 10px 18px; border-radius: 999px; transition: transform .3s; z-index: 20;
}
body.disconnected .offline { transform: translate(-50%, 0); }

.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 10; }
.flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }

/* ---------- Pannelli del gioco ---------- */
.panels { flex: 1; width: 100%; min-height: 0; display: flex; flex-direction: column; }
.panel { display: none; flex: 1; min-height: 0; flex-direction: column; align-items: center; width: 100%; }
body[data-panel="info"] .p-info, body[data-panel="setup"] .p-setup, body[data-panel="topic"] .p-topic,
body[data-panel="pads"] .p-pads, body[data-panel="buzz"] .p-buzz, body[data-panel="judge"] .p-judge { display: flex; }

.p-info { justify-content: center; text-align: center; gap: 12px; padding: 10px; }
.info-emoji { font-size: 72px; line-height: 1; }
.info-emoji:empty, .p-info .avatar.lg.hidden { display: none; }
.info-emoji.spin { animation: spin 1.2s linear infinite; }
.info-emoji.bounce { animation: popin .6s cubic-bezier(.2,1.6,.4,1) both, float 2s .6s ease-in-out infinite; }
.avatar.lg { width: 130px; height: 130px; font-size: 54px; box-shadow: 0 0 0 6px rgba(255,255,255,.08), 0 0 40px var(--me); }
.info-title { font: 400 28px 'Bungee', 'Rubik', sans-serif; line-height: 1.15; }
.info-title.big { font-size: 40px; }
.info-title.ok { color: var(--green); }
.info-title.ko { color: #ff5470; }
.info-title.gold { color: var(--gold); }
.info-sub { color: var(--muted); font-size: 17px; font-weight: 500; line-height: 1.4; margin: 0; }
.info-sub b { color: #fff; }

.panel-title { font: 400 24px 'Bungee', 'Rubik', sans-serif; text-align: center; margin: 14px 0 6px; color: var(--gold); }
.p-setup, .p-topic { gap: 8px; overflow-y: auto; padding: 0 4px 10px; justify-content: flex-start; }
.p-topic { justify-content: center; }
.field-label { align-self: stretch; color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; margin-top: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.seg.two { grid-template-columns: 1fr 1fr; }
.seg button {
  padding: 14px 6px; border-radius: 14px; border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07); color: #fff;
  font: 400 22px 'Bungee', 'Rubik', sans-serif; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.seg button small { font: 500 12px 'Rubik', sans-serif; color: var(--muted); }
.seg button b { font-weight: 400; }
.seg button.on { border-color: var(--gold); background: rgba(255,210,63,.18); box-shadow: 0 0 18px rgba(255,210,63,.35); }
.warn { color: #ffb36b; font-weight: 700; font-size: 14px; text-align: center; margin: 6px 0 0; }
.warn.hidden { display: none; }
.p-setup .cta, .p-topic .cta { margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 360px; }
.chips button { padding: 8px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; font: 500 14px 'Rubik', sans-serif; }

/* Pad A/B/C/D */
.p-pads { gap: 10px; padding-top: 10px; }
.pads-head { min-height: 22px; text-align: center; font-weight: 700; color: var(--muted); }
.pads-head b { color: #fff; }
.pads { flex: 1; width: 100%; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 10px; }
.pad {
  --pc: #e21b3c; --pd: #8f0f25; position: relative; border: 0; border-radius: 20px; color: #fff; padding: 10px; touch-action: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 85%, #fff), var(--pc));
  box-shadow: 0 8px 0 var(--pd), 0 12px 24px rgba(0,0,0,.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: transform .06s, box-shadow .06s, opacity .25s, filter .25s;
}
.pad.pb { --pc: #1368ce; --pd: #0a3a75; }
.pad.pc { --pc: #d89e00; --pd: #7d5b00; }
.pad.pd { --pc: #26890c; --pd: #134706; }
.pad .pl { font: 400 54px 'Bungee', 'Rubik', sans-serif; line-height: 1; text-shadow: 0 4px 0 rgba(0,0,0,.25); }
.pad .pt { font: 700 15px 'Rubik', sans-serif; line-height: 1.2; text-align: center; max-height: 3.6em; overflow: hidden; }
.pad.down { transform: translateY(7px); box-shadow: 0 1px 0 var(--pd), 0 4px 10px rgba(0,0,0,.4); }
body[data-state="reading"] .pad { filter: grayscale(.85) brightness(.55); }
body[data-state="reading"] .pad .pt { visibility: hidden; }
body[data-state="answered"] .pad:not(.chosen), body[data-state="closed"] .pad:not(.chosen) { opacity: .25; filter: grayscale(.8); }
.pad.chosen { outline: 5px solid #fff; outline-offset: 3px; transform: scale(1.03); }
.pads-foot { min-height: 40px; text-align: center; font: 400 20px 'Bungee', 'Rubik', sans-serif; }

/* Giudizio del conduttore */
.p-judge { gap: 12px; padding-top: 12px; overflow-y: auto; }
.judge-q { font-weight: 700; font-size: 18px; line-height: 1.35; text-align: center; }
.judge-a { width: 100%; background: rgba(255,210,63,.12); border: 2px dashed var(--gold); border-radius: 16px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.judge-a small { color: var(--muted); font-weight: 700; letter-spacing: 1px; font-size: 11px; }
.judge-a b { font: 400 24px 'Bungee', 'Rubik', sans-serif; color: var(--gold); }
.judge-a i { color: var(--muted); font-size: 14px; }
.judge-who { font: 400 22px 'Bungee', 'Rubik', sans-serif; text-align: center; min-height: 28px; }
.judge-who small { display: block; font: 500 14px 'Rubik', sans-serif; color: var(--muted); }
.judge-btns { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 1; max-height: 200px; min-height: 110px; }
.jb { border: 0; border-radius: 20px; font: 400 22px 'Bungee', 'Rubik', sans-serif; color: #fff; transition: opacity .2s, transform .06s; }
.jb:active { transform: translateY(4px); }
.jb.ok { background: linear-gradient(180deg, #4dffa0, #0fae55); box-shadow: 0 6px 0 #06602e; color: #00331a; }
.jb.ko { background: linear-gradient(180deg, #ff6b88, #d4123b); box-shadow: 0 6px 0 #7a0020; }
.jb:disabled { opacity: .25; }

/* Dock del conduttore */
.dock { width: 100%; display: none; gap: 8px; padding-top: 10px; flex-wrap: wrap; justify-content: center; }
body.is-controller .dock:not(:empty) { display: flex; }
.dock button {
  flex: 1 1 30%; min-height: 52px; padding: 10px 8px; border-radius: 14px; border: 2px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1); color: #fff; font: 700 15px 'Rubik', sans-serif;
}
.dock button.primary { flex-basis: 100%; border: 0; color: #3a1600; font: 400 20px 'Bungee', 'Rubik', sans-serif; background: linear-gradient(180deg, #fff1a8, var(--gold) 40%, var(--gold2)); box-shadow: 0 5px 0 #a34d00; }
.dock button:active { transform: translateY(3px); }
.tag { display: inline-block; font: 700 11px 'Rubik', sans-serif; letter-spacing: 1px; padding: 2px 8px; border-radius: 99px; background: var(--gold); color: #3a1600; vertical-align: 2px; margin-left: 6px; }

/* ---------- Disegna e indovina ---------- */
body[data-panel="draw"] .p-draw, body[data-panel="guess"] .p-guess,
body[data-panel="impwrite"] .p-impwrite, body[data-panel="impvote"] .p-impvote { display: flex; }
.p-draw, .p-guess { gap: 10px; padding-top: 10px; }
.draw-head { width: 100%; display: flex; align-items: baseline; gap: 8px; font-weight: 700; color: var(--muted); }
.draw-head b { font: 400 26px 'Bungee', 'Rubik', sans-serif; color: var(--gold); text-transform: uppercase; }
.draw-head i { margin-left: auto; font: 400 22px 'Bungee', 'Rubik', sans-serif; font-style: normal; color: #fff; }
.draw-head i.urgent { color: #ff5470; }
.sketch-wrap { width: 100%; display: flex; justify-content: center; }
.sketch { width: 100%; max-height: 52vh; aspect-ratio: 4 / 3; background: #fff; border-radius: 14px; touch-action: none; box-shadow: 0 0 0 4px var(--gold), 0 10px 30px rgba(0,0,0,.4); }
.sketch-wrap.small .sketch { width: 82%; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
.tools { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.colors, .sizes { display: flex; gap: 6px; }
.colors button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); }
.colors button.on, .sizes button.on { border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
.sizes button { width: 40px; height: 40px; border-radius: 12px; border: 3px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); display: grid; place-items: center; }
.sizes button span { display: block; border-radius: 50%; background: #fff; }
.tool { width: 46px; height: 40px; border-radius: 12px; border: 2px solid rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #fff; font-size: 20px; }
#guessHint { font: 400 24px 'Bungee', 'Rubik', sans-serif; letter-spacing: 2px; white-space: pre; text-align: center; color: var(--gold); } /* word pattern while guessing a drawing */
.guess-row { width: 100%; display: flex; gap: 8px; }
.guess-row .name-input { flex: 1; min-width: 0; font-size: 20px; padding: 14px; }
.cta.small { width: auto; padding: 14px 18px; font-size: 18px; }
.guess-done { font: 400 20px 'Bungee', 'Rubik', sans-serif; text-align: center; min-height: 24px; }
.guess-done small { display: block; font: 500 15px 'Rubik', sans-serif; color: var(--muted); }

/* ---------- Impostore ---------- */
.p-impwrite, .p-impvote { gap: 14px; justify-content: center; }
.role-card { width: 100%; border-radius: 22px; padding: 22px 16px; text-align: center; background: linear-gradient(160deg, #2a0b66, #12052e); border: 3px solid var(--gold); box-shadow: 0 0 30px rgba(255,210,63,.3); animation: popin .6s cubic-bezier(.2,1.6,.4,1) both; }
.role-card small { display: block; color: var(--muted); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: 12px; }
.role-card b { display: block; font: 400 34px 'Bungee', 'Rubik', sans-serif; color: var(--gold); margin: 8px 0; text-transform: uppercase; }
.role-card.imp { border-color: #ff2d55; background: linear-gradient(160deg, #5e0b2a, #12052e); box-shadow: 0 0 40px rgba(255,45,85,.45); }
.role-card.imp b { color: #ff5470; }
.role-card p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.timer-line { font: 400 22px 'Bungee', 'Rubik', sans-serif; text-align: center; }
.vote-list { width: 100%; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.vote-list button { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07); color: #fff; text-align: left; }
.vote-list button .avatar { width: 44px; height: 44px; font-size: 18px; border-width: 3px; }
.vote-list button b { display: block; font-weight: 900; font-size: 17px; }
.vote-list button span { color: var(--gold); font-weight: 700; }
.vote-list button.on { border-color: #ff2d55; background: rgba(255,45,85,.2); }
.vote-list.done button:not(.on) { opacity: .35; }
.seg.two { grid-template-columns: 1fr 1fr; }
body.mode-draw .count-field { display: none; }
body:not(.mode-quiz) .quiz-only { display: none; }

/* ---------- Modalità a modulo ---------- */
body[data-panel="play"] .p-play { display: flex; }
.p-play { gap: 12px; padding-top: 10px; overflow-y: auto; justify-content: flex-start; }
.p-play.center { justify-content: center; }
.pl-head { width: 100%; display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-weight: 700; }
.pl-head i { margin-left: auto; font: 400 22px 'Bungee', 'Rubik', sans-serif; font-style: normal; color: #fff; }
.pl-head i.urgent { color: #ff5470; }
.pl-card { width: 100%; border-radius: 20px; padding: 18px 16px; text-align: center; background: linear-gradient(180deg, #fff, #ece4ff); color: #1a0840; box-shadow: 0 0 0 4px var(--gold), 0 10px 30px rgba(0,0,0,.4); animation: popin .5s cubic-bezier(.2,1.6,.4,1) both; }
.pl-card b { display: block; font-size: 21px; font-weight: 900; line-height: 1.25; }
.pl-card small { display: block; font-size: 14px; font-style: italic; color: #6a5a93; margin-top: 6px; }
.pl-text { width: 100%; min-height: 90px; padding: 14px; border-radius: 16px; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.1); color: #fff; font: 700 20px 'Rubik', sans-serif; resize: none; outline: none; -webkit-user-select: text; user-select: text; }
.pl-text:focus { border-color: var(--gold); }
.pl-note { color: var(--muted); font-size: 15px; text-align: center; margin: 0; }
.pl-err { color: #ff8099; font-weight: 700; text-align: center; min-height: 20px; margin: 0; }
.pl-choices { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.pl-choice { width: 100%; padding: 16px; border-radius: 18px; border: 3px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; font: 700 19px 'Rubik', sans-serif; text-align: left; line-height: 1.25; overflow-wrap: anywhere; transition: opacity .25s, border-color .25s; }
.pl-choice.on { border-color: var(--gold); background: rgba(255,210,63,.18); }
.pl-choices.done .pl-choice:not(.on) { opacity: .35; }
.pl-choice:disabled { opacity: .35; }
.pl-choice small { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }

body.mode-quiplash .count-field, body.mode-gartic .count-field { display: none; }
.cta:disabled { opacity: .4; }

.blank { display: inline-block; min-width: 54px; padding: 0 8px; border-radius: 8px; background: #1a0840; color: var(--gold); font-style: normal; }
.blank.filled { background: var(--green); color: #003d1c; }
.p-play .name-input { width: 100%; }

.pl-people { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pl-person { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 16px; border: 3px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); color: #fff; font: 700 14px 'Rubik', sans-serif; min-width: 0; }
.pl-person .avatar { width: 64px; height: 64px; font-size: 26px; border-width: 3px; }
.pl-person span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-person.on { border-color: var(--gold); background: rgba(255,210,63,.18); }
.pl-people.done .pl-person:not(.on) { opacity: .35; }

.wl-labels { width: 100%; display: flex; justify-content: space-between; gap: 10px; }
.wl-labels span { font: 400 20px 'Bungee', 'Rubik', sans-serif; line-height: 1.05; max-width: 48%; }
.wl-labels .l { color: #2ec4ff; } .wl-labels .r { color: #ff5c7a; text-align: right; }
.wl-labels small { display: block; font: italic 500 12px 'Rubik', sans-serif; color: var(--muted); }
.wl-track { position: relative; width: 100%; height: 84px; border-radius: 20px; background: linear-gradient(90deg, #2ec4ff, #b46bff, #ff3b6b); box-shadow: inset 0 0 0 3px rgba(255,255,255,.3); touch-action: none; margin: 10px 0 14px; }
.wl-track.locked { opacity: .6; }
.wl-thumb { position: absolute; top: 50%; left: 50%; width: 64px; height: 100px; margin-left: -32px; margin-top: -50px; border-radius: 18px; background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.45); display: grid; place-items: center; pointer-events: none; }
.wl-thumb span { font: 400 22px 'Bungee', 'Rubik', sans-serif; color: #1a0840; }
.wl-track.static { overflow: hidden; }
.wl-band { position: absolute; top: 0; bottom: 0; }
.wl-band.b2 { background: rgba(255,210,63,.85); } .wl-band.b3 { background: rgba(255,159,28,.95); } .wl-band.b4 { background: #2bff88; }
.wl-target { position: absolute; top: -6px; bottom: -6px; width: 6px; margin-left: -3px; background: #fff; border-radius: 3px; box-shadow: 0 0 10px #fff; }

.tl-list { width: 100%; display: flex; flex-direction: column; gap: 8px; touch-action: none; }
.tl-item { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; border-radius: 16px; background: linear-gradient(180deg, #fff, #ece4ff); color: #1a0840; box-shadow: 0 4px 0 #8b7cc0; transition: transform .15s; touch-action: none; user-select: none; }
.tl-item.dragging { transition: none; z-index: 2; box-shadow: 0 12px 30px rgba(0,0,0,.5), 0 0 0 3px var(--gold); }
.tl-item .grip { font-size: 22px; color: #8b7cc0; }
.tl-item .lbl { flex: 1; min-width: 0; font: 900 17px 'Rubik', sans-serif; line-height: 1.2; }
.tl-item .lbl small { display: block; font: italic 500 12px 'Rubik', sans-serif; color: #6a5a93; }
.tl-item .arrows { display: flex; flex-direction: column; gap: 4px; }
.tl-item .arrows button { width: 40px; height: 30px; border: 0; border-radius: 8px; background: #1a0840; color: #fff; font-size: 14px; }
.tl-list.locked .tl-item { opacity: .6; }

.bet-amount { text-align: center; }
.bet-amount b { display: block; font: 400 54px 'Bungee', 'Rubik', sans-serif; color: var(--gold); line-height: 1; }
.bet-amount small { color: var(--muted); font-weight: 700; }
.bet-range { width: 100%; height: 44px; accent-color: #ffd23f; }
.bet-quick { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bet-quick button { padding: 12px; border-radius: 14px; border: 2px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; font: 400 18px 'Bungee', 'Rubik', sans-serif; }

.ga-board { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.ga-board .sketch { box-shadow: 0 0 0 4px var(--gold), 0 10px 30px rgba(0,0,0,.4); }
.ga-what { color: var(--gold); }
.p-play .link { margin: -4px 0 0; }

/* Setup del conduttore in due passi */
.setup-step { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; border: 2px solid rgba(255,255,255,.15); background: rgba(255,255,255,.07); color: #fff; text-align: left; }
.game-item:active { transform: scale(.98); }
.game-item .ge { font-size: 32px; width: 40px; text-align: center; }
.game-item .gx { flex: 1; min-width: 0; }
.game-item .gx b { display: block; font: 400 19px 'Bungee', 'Rubik', sans-serif; line-height: 1.1; }
.game-item .gx small { display: block; color: var(--muted); font-size: 13px; }
.game-item .gp { text-align: right; font: 700 15px 'Rubik', sans-serif; color: var(--gold); white-space: nowrap; }
.game-item .gp small { display: block; font-size: 11px; color: var(--muted); }
.game-item.short { opacity: .55; }
.game-item.short .gp { color: #ff8099; }
.link.back { align-self: flex-start; margin: 4px 0 0; padding: 4px 0; }
.gd-head { display: flex; align-items: center; gap: 12px; }
.gd-head .gd-emoji { font-size: 46px; width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #5a2bb0, #1d0850); box-shadow: 0 0 0 3px var(--gold); }
.gd-head b { display: block; font: 400 26px 'Bungee', 'Rubik', sans-serif; color: var(--gold); line-height: 1.05; }
.gd-head small { color: var(--muted); font-weight: 700; }
.p-setup .gd-steps { margin: 4px 0 0; padding: 0; list-style: none; counter-reset: st; display: flex; flex-direction: column; gap: 8px; }
.p-setup .gd-steps li { counter-increment: st; display: flex; gap: 10px; font-size: 15px; line-height: 1.35; }
.p-setup .gd-steps li::before { content: counter(st); flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #3a1600; font: 400 13px 'Bungee', 'Rubik', sans-serif; }
.p-setup .gd-players { padding: 10px 12px; border-radius: 14px; background: rgba(0,0,0,.25); font-size: 15px; line-height: 1.5; }
.p-setup .gd-players b { color: var(--gold); }
.p-setup .gd-players .ok { color: var(--green); font-weight: 700; } .p-setup .gd-players .ko { color: #ff8099; font-weight: 700; }
.p-setup .gd-param { display: flex; flex-direction: column; gap: 6px; }

/* Scelta dello sfondo della lavagna (lontana dai colori) */
.bg-pick { align-self: flex-end; display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; font-size: 13px; }
.bg-pick button { width: 34px; height: 26px; border-radius: 8px; border: 3px solid rgba(255,255,255,.3); }
.bg-pick button[data-bg="#ffffff"] { background: #fff; }
.bg-pick button[data-bg="#111111"] { background: #111; }
.bg-pick button.on { border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
/* Numero e testo delle istruzioni centrati verticalmente */
.p-setup .gd-steps li { align-items: center; }
.p-setup .gd-steps li::before { line-height: 1; padding-top: 1px; }

/* Lingua del telefono */
.lang-pick { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; display: flex; gap: 6px; z-index: 5; }
.lang-pick button { padding: 6px 10px; border-radius: 99px; border: 2px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; font: 700 13px 'Rubik', sans-serif; }
.lang-pick button.on { border-color: var(--gold); background: rgba(255,210,63,.2); }
.lang-mini { flex-shrink: 0; padding: 6px 8px; border-radius: 10px; border: 2px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; font: 700 13px 'Rubik', sans-serif; }

/* Niente zoom sul telefono: il doppio tocco non ingrandisce (i tocchi restano immediati). */
html, body, button, input, textarea, label, .screen, .panel { touch-action: manipulation; }
input, textarea { font-size: max(16px, 1em); } /* sotto i 16px iOS ingrandisce quando si scrive */

/* Giochi non ancora possibili, staccati sotto */
.locked-head { margin: 10px 0 2px; padding-top: 12px; border-top: 2px dashed rgba(255,255,255,.25); color: #ffb36b; font: 400 15px 'Bungee', 'Rubik', sans-serif; text-align: center; line-height: 1.25; }
.game-list.locked .game-item { padding: 7px 12px; opacity: .55; }
.game-list.locked .game-item .ge { font-size: 24px; }
.game-list.locked .game-item .gx small { display: none; }
.game-list.locked .game-item .gp { color: #ff8099; }

.who-name .tag { margin: 0 6px 0 0; padding: 1px 6px; font-size: 13px; vertical-align: 1px; }

/* Entrata progressiva delle voci della lista giochi */
.game-item { animation: item-in .4s calc(var(--i, 0) * 50ms) cubic-bezier(.2,.9,.3,1) both; }
.game-list.locked .game-item { animation-delay: calc(300ms + var(--i, 0) * 50ms); }
@keyframes item-in { from { opacity: 0; transform: translateY(14px); } }

/* Pulsanti di conferma a tutta larghezza nelle schermate di gioco */
.panel .cta, .setup-step .cta { width: 100%; }
.panel .cta.small { width: auto; }

/* Mystery phrase */
#playPanel .wh-worth { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#playPanel .wh-worth b { font: 400 26px 'Bungee', sans-serif; color: var(--gold); }
#playPanel .wh-worth small { color: var(--muted); font-size: 13px; }
#playPanel .buzzer.wh-buzz { --c1: #ff6a88; --c2: #ff1744; --c3: #9e0026; width: min(70vw, 40vh); height: min(70vw, 40vh); }
#playPanel .buzzer.wh-buzz.off { --c1: #6d6a80; --c2: #4a4760; --c3: #24223a; }
#playPanel .wh-buzz .buzzer-cap { font-size: clamp(32px, 12vw, 60px); color: #fff; animation: none; }
#playPanel .wh-buzz.off .buzzer-cap { color: rgba(255,255,255,.6); }
#playPanel .wh-label { position: relative; z-index: 1; line-height: 1; }

/* Ghigliottina */
#playPanel .gh-picks { width: 100%; display: flex; flex-direction: column; gap: 14px; }
#playPanel .gh-pick {
  position: relative; width: 100%; min-height: 110px; padding: 14px 16px; border: 0; border-radius: 20px; cursor: pointer;
  background: linear-gradient(180deg, #fff, #ece4ff); color: #1a0840; box-shadow: 0 0 0 4px var(--gold), 0 8px 0 #a3780a, 0 14px 26px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; touch-action: manipulation; transition: transform .08s;
}
#playPanel .gh-pick:active { transform: translateY(5px); box-shadow: 0 0 0 4px var(--gold), 0 3px 0 #a3780a; }
#playPanel .gh-pick span { position: absolute; left: 14px; top: 10px; font: 400 18px 'Bungee', sans-serif; color: #8a7ab3; }
#playPanel .gh-pick b { font: 400 clamp(24px, 9vw, 38px) 'Bungee', sans-serif; line-height: 1.05; word-break: break-word; }
#playPanel .gh-pick b small { display: block; font: italic 600 15px 'Rubik', sans-serif; color: #6a5a93; margin-top: 4px; }
#playPanel .gh-found { width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#playPanel .gh-found small { width: 100%; text-align: center; color: var(--muted); font-size: 13px; }
#playPanel .gh-found span { padding: 4px 10px; border-radius: 99px; background: rgba(255,210,63,.18); border: 2px solid var(--gold); color: var(--gold); font: 400 14px 'Bungee', sans-serif; }
#playPanel .gh-found.big span { font-size: 18px; padding: 8px 14px; }
