/* Telefono: controlli grandi, una mano sola, verticale prima di tutto. Stile «Quaderno». */
html, body.phone { height: 100%; overscroll-behavior: none; }
body.phone { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
input { -webkit-user-select: text; user-select: text; }
#app { max-width: 560px; margin: 0 auto; padding: 10px 14px calc(20px + env(safe-area-inset-bottom)); }
.scr { display: flex; flex-direction: column; gap: 14px; }
.center { text-align: center; }
.sect { font-size: 1.5rem; margin: 6px 0 0; }
.lbl { font-weight: 900; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.hint-s { text-align: center; color: var(--ink-2); font-weight: 800; margin: 0; }
.foot { text-align: center; }
.foot a { color: var(--ink-2); font-weight: 800; }

/* intestazione */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: rgba(251, 247, 236, .96); border-bottom: 3px dashed var(--ink); backdrop-filter: blur(6px); }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.me .avbox { width: 44px; height: 44px; border-width: 2.5px; padding: 2px; }
.me-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.me-t b { font-family: var(--f-hand); font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-t small { font-weight: 900; color: var(--ink-2); }
.role-badge { font-weight: 900; font-size: .9rem; padding: 6px 12px; border-radius: var(--wob); border: 2.5px solid var(--ink); background: #fff; white-space: nowrap; }
.role-badge:empty { display: none; }
.role-badge.draw { background: var(--postit-1); }
.role-badge.guess { background: var(--postit-4); }
.top-r { display: flex; gap: 8px; }
.ibtn { width: 46px; height: 46px; border-radius: var(--wob); border: 2.5px solid var(--ink); background: #fff; font-size: 1.3rem; cursor: pointer; }

/* ingresso */
.join-logo { text-align: center; margin: 18px 0 8px; }
.join-logo .logo { font-size: clamp(2.6rem, 13vw, 4rem); }
.form { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 900; }
.form label small { font-weight: 700; color: var(--ink-2); }
input { font: inherit; font-size: 1.25rem; font-weight: 800; padding: 14px 16px; border-radius: var(--wob); border: 3px solid var(--ink); background: #fff; color: var(--ink); width: 100%; min-height: 56px; }
.code-in { font-family: var(--f-display); font-size: 2.2rem; letter-spacing: .3em; text-transform: uppercase; text-align: center; }
.av-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.av-pick { aspect-ratio: 1; border-radius: 50%; border: 3px solid var(--line); background: #fff; padding: 6px; cursor: pointer; position: relative; }
.av-pick[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 4px var(--yellow); transform: scale(1.06); }
.av-pick[aria-checked="true"]::after { content: '✓'; position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 900; display: grid; place-items: center; border: 2px solid var(--ink); }
.av-pick:disabled { opacity: .25; }
.err-msg { color: var(--bad); font-weight: 900; min-height: 1.2em; text-align: center; }

/* sala d'attesa */
.lobby-head { padding: 14px 16px; display: flex; align-items: center; gap: 16px; }
.room-code { font-family: var(--f-display); font-size: 2.2rem; letter-spacing: .12em; line-height: 1; }
.l-players { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 1; }
.l-players .avbox { width: 46px; height: 46px; border-width: 2.5px; padding: 2px; }
.l-players .avbox.off { opacity: .4; }
.wait { padding: 16px; text-align: center; font-weight: 900; font-size: 1.1rem; }
.settings { gap: 18px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.set-row > span { font-weight: 900; }
.set-row > span small { display: block; font-weight: 700; color: var(--ink-2); font-size: .85rem; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 46px; height: 46px; border-radius: var(--wob); border: 3px solid var(--ink); background: var(--yellow); font-size: 1.4rem; font-weight: 900; cursor: pointer; }
.stepper output { min-width: 3.2ch; text-align: center; font-family: var(--f-display); font-size: 1.5rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.tog { cursor: pointer; padding: .55em .9em; min-height: 44px; background: #fff; opacity: .55; }
.chip.tog[aria-pressed="true"] { opacity: 1; background: var(--postit-1); }
.chip.tog[aria-pressed="true"]::before { content: '✓'; color: var(--ok); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 3px solid var(--ink); border-radius: var(--wob); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 12px 4px; font-weight: 900; cursor: pointer; min-height: 48px; }
.seg button + button { border-left: 3px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--blue); color: #fff; }
.switch { width: 64px; height: 38px; border-radius: 999px; border: 3px solid var(--ink); background: #ddd; position: relative; cursor: pointer; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: left .15s; }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { left: 29px; }

/* messaggi */
.msg { padding: 26px 20px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 10px; }
.msg .big-e { font-size: 4rem; line-height: 1; }
.msg h2 { font-size: 1.9rem; line-height: 1.1; }
.msg p { margin: 0; font-weight: 800; font-size: 1.1rem; }
.msg .avbox { width: 110px; height: 110px; }
.msg .word { font-family: var(--f-hand); font-size: 2.5rem; color: var(--coral); text-shadow: 0 3px 0 #ffd84d; line-height: 1.05; }
.msg .pts { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.msg .pts div { display: flex; justify-content: space-between; font-weight: 900; padding: 8px 12px; border-radius: var(--wob); background: var(--paper); }
.msg .btn { width: 100%; }
.mode-card { background: var(--postit-4); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--wob); padding: 14px 16px; box-shadow: var(--shadow); text-align: center; }
.mode-card b { display: block; font-family: var(--f-hand); font-size: 1.5rem; }
.mode-card span { font-weight: 800; }

/* scelta parola */
.opts { display: flex; flex-direction: column; gap: 12px; }
.opt { text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 16px 18px; border-radius: var(--wob); border: 3px solid var(--ink); background: #fff; box-shadow: 4px 5px 0 var(--ink); cursor: pointer; min-height: 84px; }
.opt:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.opt:nth-child(1) { background: var(--postit-1); } .opt:nth-child(2) { background: var(--postit-2); } .opt:nth-child(3) { background: var(--postit-3); } .opt:nth-child(4) { background: var(--postit-4); }
.opt b { font-family: var(--f-hand); font-size: 1.7rem; line-height: 1.05; grid-column: 1; }
.opt small { font-weight: 800; color: var(--ink-2); grid-column: 1; }
.opt .chip { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.bar { height: 10px; border-radius: var(--wob); background: #e3ebf6; overflow: hidden; border: 2px solid var(--ink); }
.bar i { display: block; height: 100%; background: var(--coral); width: 100%; transition: width .2s linear; }

/* disegnatore */
#sDraw { gap: 8px; }
.wordbar { display: flex; align-items: stretch; gap: 8px; }
.word-btn { flex: 1; text-align: left; border: 3px solid var(--ink); background: var(--postit-1); border-radius: var(--wob); padding: 6px 12px; cursor: pointer; min-width: 0; }
.word-btn small { display: block; font-weight: 900; font-size: .75rem; }
.word-btn span { display: block; font-family: var(--f-hand); font-size: 1.6rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.word-btn.veiled span { letter-spacing: .1em; color: var(--ink-2); font-size: 1.1rem; }
.wb-r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.dtimer, .gtimer { font-family: var(--f-display); font-size: 1.9rem; line-height: 1; min-width: 2.2ch; text-align: center; padding: 4px 10px; border-radius: var(--wob); border: 3px solid var(--ink); background: #fff; }
.dtimer.danger, .gtimer.danger { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
.dchips { display: flex; gap: 4px; }
.dchips .chip { font-size: .72rem; padding: .2em .5em; border-width: 2px; }
.dmode { background: var(--postit-4); color: var(--ink); font-weight: 900; text-align: center; border-radius: var(--wob); padding: 6px 10px; border: 2.5px solid var(--ink); font-size: .95rem; }
.cv-box { position: relative; display: grid; place-items: center; }
#dcv { display: block; background: #fff; border: 3px solid var(--ink); border-radius: var(--wob); touch-action: none; box-shadow: var(--shadow); }
#dcv.flip { transform: rotate(180deg); }
#dcv.locked { opacity: .9; }
.dcount, .dlock { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-family: var(--f-hand); pointer-events: none; }
.dcount { font-family: var(--f-display); font-size: 8rem; color: var(--coral); text-shadow: 0 6px 0 #ffd84d; }
.dlock { inset: auto 10px 10px 10px; font-size: 1.2rem; color: #fff; background: var(--ok); border-radius: var(--wob); padding: 8px; border: 3px solid var(--ink); }
.dlock small { font-size: 1rem; }
.tools-ph { display: flex; flex-direction: column; gap: 8px; }
.palette { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.sw { aspect-ratio: 1; max-height: 46px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; position: relative; padding: 0; }
.sw[aria-checked="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); transform: scale(1.06); }
.sw[aria-checked="true"]::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 900; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.toolrow { display: flex; gap: 6px; align-items: stretch; }
.sizes { display: flex; gap: 4px; background: #fff; border: 3px solid var(--ink); border-radius: var(--wob); padding: 2px; }
.sz { width: 40px; border: 0; background: transparent; display: grid; place-items: center; border-radius: 10px; cursor: pointer; }
.sz i { display: block; border-radius: 50%; background: var(--ink); }
.sz[aria-checked="true"] { background: var(--yellow); }
.tool { flex: 1; min-width: 0; border: 3px solid var(--ink); background: #fff; border-radius: var(--wob); font-size: 1.3rem; line-height: 1; padding: 4px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; }
.tool small { font-size: .62rem; font-weight: 900; }
.tool[aria-pressed="true"] { background: var(--yellow); }
.tool:disabled { opacity: .3; }
.tool.danger { background: #ffe1e5; }

/* indovinatore */
.g-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.g-head .avbox { width: 56px; height: 56px; }
.g-who { flex: 1; min-width: 0; line-height: 1.15; }
.g-who small { font-weight: 800; color: var(--ink-2); }
.g-who b { display: block; font-family: var(--f-hand); font-size: 1.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gtimer { font-size: 2.6rem; }
.g-info { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.g-info .letters { width: 100%; text-align: center; font-family: ui-monospace, 'Courier New', monospace; font-weight: 900; font-size: 1.35rem; letter-spacing: .1em; }
.g-form { display: flex; gap: 8px; }
.g-form input { flex: 1; min-width: 0; font-size: 1.3rem; }
.g-form .btn { flex: none; padding: .6em 1em; }
.g-feed { min-height: 1.6em; text-align: center; font-weight: 900; font-size: 1.15rem; }
.g-feed.bad { color: var(--bad); }
.g-feed.good { color: var(--ok); }
.g-tries { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.g-tries span { padding: 4px 10px; border-radius: var(--wob); background: #fff; border: 2px solid var(--line); font-weight: 800; text-decoration: line-through; color: var(--ink-2); }
.g-got { background: var(--green); color: #fff; border: 3px solid var(--ink); border-radius: var(--wob); padding: 16px; text-align: center; font-weight: 900; font-size: 1.2rem; }
.g-got b { display: block; font-family: var(--f-hand); font-size: 2rem; }
.mirror canvas { width: 100%; aspect-ratio: 1; display: block; background: #fff; border: 3px solid var(--ink); border-radius: var(--wob); }
.mirror-btn { font-size: 1rem; min-height: 46px; }
.mirror-btn[aria-pressed="true"] { background: var(--postit-4); }

/* fine partita */
.fin h2 { font-size: 2rem; text-align: center; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rk { display: grid; grid-template-columns: 34px 48px 1fr auto; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--wob); background: #fff; border: 3px solid var(--ink); }
.rk.me { outline: 4px dashed var(--coral); outline-offset: 3px; }
.rk .avbox { width: 48px; height: 48px; border-width: 2px; padding: 2px; }
.rk b { font-family: var(--f-hand); font-size: 1.2rem; }
.rk .sc { font-family: var(--f-display); font-size: 1.6rem; }
.rk .pos { font-family: var(--f-display); font-size: 1.3rem; text-align: center; }
.fin-hl { padding: 12px 16px; font-weight: 800; }
.fin-hl b { font-family: var(--f-display); }
.fin-btns { display: flex; flex-direction: column; gap: 10px; }

/* menu e dialoghi */
.sheet { position: fixed; inset: 0; background: rgba(31, 47, 86, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 12px; }
.sheet-in { width: 100%; max-width: 520px; padding: 20px; display: flex; flex-direction: column; gap: 12px; animation: pop .25s ease-out both; margin-bottom: env(safe-area-inset-bottom); }
.sheet-in p { margin: 0; font-weight: 800; }
.dlg-b { display: flex; gap: 10px; }
.dlg-b .btn { flex: 1; }
.net { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); background: var(--bad); color: #fff; font-weight: 900; padding: 8px 18px; border-radius: 999px; z-index: 60; border: 3px solid #fff; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 900; padding: 12px 20px; border-radius: 16px; z-index: 60; max-width: 90vw; text-align: center; }

/* telefono in orizzontale mentre disegna: tela a sinistra, strumenti a destra */
@media (orientation: landscape) and (max-height: 560px) {
  #app { max-width: none; padding-top: 6px; }
  .top { padding-top: 4px; padding-bottom: 4px; }
  #sDraw { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto 1fr; gap: 6px 12px; }
  #sDraw .cv-box { grid-column: 1; grid-row: 1 / 4; }
  #sDraw .wordbar, #sDraw .dmode, #sDraw .tools-ph { grid-column: 2; }
}
