:root {
  --bg: #0b0b10;
  --panel: #15151d;
  --panel-2: #1d1d28;
  --line: #2b2b3a;
  --text: #ecebf3;
  --muted: #9a98ad;
  --accent: #e8ff59;
  --accent-ink: #111;
  --s: #6ee7a8;
  --n: #8fb3ff;
  --o: #ff6b6b;
  --warn: #ffb347;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
main { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); }
main.wide { max-width: 1200px; padding: 32px 40px; }

h1, h2, h3 { margin: 0 0 12px; line-height: 1.15; }
h1 { font-size: 2rem; letter-spacing: 0.02em; }
h2 { font-size: 1.4rem; }
p { line-height: 1.5; margin: 0 0 12px; }
.kicker { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.center { text-align: center; }

.brand { font-family: var(--mono); font-weight: 700; letter-spacing: 0.3em; text-transform: uppercase; }
.brand span { color: var(--accent); }
.tagline { font-family: var(--mono); color: var(--muted); font-size: 0.85rem; letter-spacing: 0.08em; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.card.accent { border-color: var(--accent); }

button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 12px; padding: 14px 16px; width: 100%; cursor: pointer; text-align: left; display: block;
  touch-action: manipulation; transition: border-color .15s, background .15s;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); text-align: center; }
button.ghost { background: transparent; text-align: center; }
button:disabled { opacity: .45; cursor: default; }
button.selected { border-color: var(--accent); background: #24251a; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

input[type=text] {
  font: inherit; width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 1.1rem;
}
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input.code { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.4em; text-align: center; font-size: 1.6rem; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--s); }
.chip.done { border-color: var(--accent); }

/* barra risorse personali */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-family: var(--mono); font-size: 1.5rem; }
.stat small { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.stat.private small::after { content: ' · privata'; }

.timer { font-family: var(--mono); font-size: .9rem; color: var(--muted); }
.timer.big { font-size: 3rem; color: var(--text); }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 16px; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }

.choice { position: relative; padding-right: 128px; }
.choice .fx { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.choice.S { border-left: 4px solid var(--s); }
.choice.N { border-left: 4px solid var(--n); }
.choice.O { border-left: 4px solid var(--o); }
.tag-S { color: var(--s); } .tag-N { color: var(--n); } .tag-O { color: var(--o); }

.band { font-family: var(--mono); font-size: .75rem; padding: 2px 8px; border-radius: 6px; }
.band.bassa { background: #3a1d22; color: var(--o); }
.band.media { background: #20263a; color: var(--n); }
.band.alta { background: #1b3328; color: var(--s); }

.mission { cursor: pointer; }
.mission .secret { filter: blur(7px); transition: filter .2s; user-select: none; }
.mission.open .secret { filter: none; }

.qr { background: #fff; padding: 14px; border-radius: 14px; display: inline-block; }
.qr img, .qr svg { display: block; width: 260px; height: 260px; image-rendering: pixelated; }
.room-code { font-family: var(--mono); font-size: 4rem; letter-spacing: .3em; color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
td.num, th.num { text-align: right; font-family: var(--mono); }
.trace { font-family: var(--mono); letter-spacing: .15em; }

.host-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; align-items: start; }
.host-stage h1 { font-size: 3rem; }
.host-stage .question { font-size: 2.4rem; line-height: 1.2; font-weight: 700; }
.host-stage .dilemma { font-size: 1.8rem; }
.host-stage .obs { font-family: var(--mono); color: var(--warn); font-size: 1.2rem; }
.result-big { font-size: 4rem; font-weight: 800; color: var(--accent); }
.host-actions { position: fixed; right: 24px; bottom: 24px; display: flex; gap: 10px; }
.host-actions button { width: auto; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--warn); color: var(--text); padding: 12px 16px; border-radius: 12px; max-width: calc(100% - 32px); z-index: 10; }

@media (max-width: 860px) {
  main.wide { padding: 20px 16px; }
  .host-grid { grid-template-columns: 1fr; }
  .host-stage h1 { font-size: 2rem; }
  .host-stage .question { font-size: 1.6rem; }
  .host-stage .dilemma { font-size: 1.3rem; }
  .room-code { font-size: 2.6rem; }
  .qr img, .qr svg { width: 200px; height: 200px; }
  .host-actions { position: static; margin-top: 16px; }
  .host-actions button { width: 100%; }
}

@media (max-width: 600px) {
  .choice { padding-right: 16px; }
  .choice .fx { position: static; transform: none; display: block; margin-top: 6px; }
}
