/* Crepuscolo — un solo look scuro: il buio dei carcerieri con la brace della stella e il gelo dei Riflessi. */
:root {
  --notte: #07060b;
  --brace: #f2a25a;
  --gelo: #7fd8ff;
  --viola: #c9a8ff;
  --osso: #e9e1d4;
  --cenere: #8d8396;
  --vetro: rgba(233, 225, 212, .08);
  --bordo: rgba(233, 225, 212, .2);
  --f-titolo: "Syncopate", "Arial Black", sans-serif;
  --f-testo: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--notte); color: var(--osso); font-family: var(--f-testo); }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; }
canvas#c { display: block; width: 100%; height: 100%; }

.top { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px)); pointer-events: none; z-index: 12; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand span { font-family: var(--f-titolo); font-size: 11px; letter-spacing: .32em; color: var(--brace); opacity: .85; }
.brand small { font-size: 9px; letter-spacing: .12em; color: var(--cenere); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.partner { font-size: 9px; letter-spacing: .1em; color: var(--cenere); }
.partner.on { color: var(--gelo); }
.tbtn { font: 600 10px var(--f-testo); letter-spacing: .1em; color: var(--osso); background: var(--vetro); border: 1px solid var(--bordo); border-radius: 4px; padding: 7px 10px; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gelo); outline-offset: 2px; }

.pad { position: fixed; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 14px; align-items: flex-end; z-index: 4; }
#padL { left: max(18px, calc(env(safe-area-inset-left, 0px) + 8px)); }
#padR { right: max(18px, calc(env(safe-area-inset-right, 0px) + 8px)); }
.pad button { width: 68px; height: 68px; border-radius: 50%; border: 1px solid rgba(233, 225, 212, .22); background: rgba(233, 225, 212, .06);
  color: var(--osso); font: 600 10px var(--f-testo); letter-spacing: .08em; touch-action: none; cursor: pointer; transition: background .12s, border-color .12s; }
.pad button.on { background: rgba(242, 162, 90, .22); border-color: var(--brace); }
#ba.near { border-color: var(--gelo); box-shadow: 0 0 18px rgba(127, 216, 255, .45); color: var(--gelo); }
#bj { transform: translateY(-34px); }
.pad svg { width: 22px; height: 22px; fill: currentColor; }
#keys { position: fixed; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); left: 0; right: 0; text-align: center; font-size: 10px; color: var(--cenere); letter-spacing: .08em; pointer-events: none; }
@media (pointer: fine) { .pad { display: none !important; } }
@media (pointer: coarse) { #keys { display: none !important; } }

#hint { position: fixed; left: 50%; transform: translateX(-50%); top: calc(42px + env(safe-area-inset-top, 0px)); width: min(460px, 64vw);
  text-align: center; font-size: 11px; line-height: 1.5; color: var(--gelo); text-shadow: 0 0 12px rgba(127, 216, 255, .5), 0 1px 2px #000; opacity: 0; transition: opacity .5s; pointer-events: none; z-index: 3; }
#hint.show { opacity: 1; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(7, 6, 11, .88); overflow-y: auto; z-index: 10;
  padding: calc(48px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); touch-action: pan-y; }
.card { width: min(440px, 100%); text-align: center; display: grid; gap: 14px; justify-items: center; }
.card.wide { width: min(620px, 100%); }
.card h1 { font-family: var(--f-titolo); font-size: clamp(20px, 4vw, 30px); letter-spacing: .3em; margin: 0; color: var(--brace); }
.card h2 { font-family: var(--f-titolo); font-size: 16px; letter-spacing: .24em; margin: 0; color: var(--brace); text-wrap: balance; }
.card p { margin: 0; font-size: 12px; line-height: 1.7; max-width: 58ch; }
.card p.sub { color: var(--cenere); font-size: 11px; }
.card button:not(.role):not(.key) { font: 600 11px var(--f-testo); letter-spacing: .14em; color: var(--notte); background: var(--brace); border: 0; border-radius: 4px; padding: 11px 18px; cursor: pointer; }
.card button.ghost { background: transparent !important; color: var(--osso) !important; border: 1px solid var(--bordo) !important; }
.card button:disabled { opacity: .4; cursor: default; }
.field { display: grid; gap: 6px; font-size: 11px; color: var(--cenere); width: min(280px, 100%); text-align: left; }
.field input { font: 400 14px var(--f-testo); color: var(--osso); background: var(--vetro); border: 1px solid var(--bordo); border-radius: 4px; padding: 10px 12px; }
.roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; }
.role { display: grid; gap: 6px; justify-items: center; text-align: center; padding: 14px 10px; background: var(--vetro); border: 1px solid var(--bordo); border-radius: 6px; color: var(--osso); cursor: pointer; font-family: var(--f-testo); min-width: 0; }
.role b { font-family: var(--f-titolo); font-size: 10px; letter-spacing: .2em; color: var(--brace); }
.role span { font-size: 10px; line-height: 1.5; color: var(--cenere); }
.role:hover, .role:focus-visible { border-color: var(--brace); }
.role canvas { width: 96px; height: 72px; }
.roles.one { grid-template-columns: minmax(0, 260px); justify-content: center; }
.roles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.role:disabled { opacity: .45; cursor: default; }
.role.picked { border-color: var(--gelo); opacity: 1; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.mycode { display: grid; gap: 8px; justify-items: center; padding: 12px 16px; border: 1px dashed var(--bordo); border-radius: 6px; }
.mycode span { font-size: 10px; letter-spacing: .12em; color: var(--cenere); }
#mycode { font-family: var(--f-titolo); font-size: 22px; letter-spacing: .3em; color: var(--brace); display: flex; gap: 8px; }
#mycode canvas, .entry canvas, .key canvas { width: 36px; height: 36px; }
.entry { display: flex; gap: 8px; min-height: 44px; }
.entry .slot { width: 44px; height: 44px; display: grid; place-items: center; border-bottom: 2px solid var(--bordo); font-family: var(--f-titolo); font-size: 20px; color: var(--gelo); }
.keys { display: grid; grid-template-columns: repeat(4, 52px); gap: 8px; justify-content: center; }
.keys.glyphs { grid-template-columns: repeat(6, 48px); }
.key { width: 100%; height: 48px; display: grid; place-items: center; background: var(--vetro); border: 1px solid var(--bordo); border-radius: 6px; color: var(--osso); font: 700 16px var(--f-titolo); cursor: pointer; padding: 0; }
.key:active { border-color: var(--gelo); }
.toast { position: fixed; top: calc(92px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); background: rgba(20, 18, 30, .95); border: 1px solid var(--bordo); color: var(--osso);
  font-size: 11px; padding: 8px 14px; border-radius: 4px; z-index: 20; max-width: 90vw; text-align: center; }
@media (max-width: 420px) { .keys.glyphs { grid-template-columns: repeat(3, 52px); } }
@media (max-height: 420px) { .card { gap: 10px; } .card p { font-size: 11px; line-height: 1.55; } .role { padding: 10px 8px; } }

/* durante le scene animate restano solo «Salta» e l'audio */
body.cine .pad, body.cine #keys, body.cine #hint, body.cine #where { visibility: hidden; }
@media (max-width: 760px) { .brand small { display: none; } .tbtn { padding: 6px 8px; font-size: 9px; } }

/* pulsante schermo intero */
.tbtn.icon { width: 34px; height: 30px; padding: 0; display: grid; place-items: center; }
.tbtn.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn.icon .fs-out { display: none; }
:root.is-full .tbtn.icon .fs-in { display: none; }
:root.is-full .tbtn.icon .fs-out { display: block; }
