@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Mountains+of+Christmas:wght@700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #0b0a0d;
  --bg2: #15121a;
  --card: #1c1822;
  --line: #2e2836;
  --ink: #ece4d0;
  --muted: #9a90a3;
  --gold: #c9a25a;
  --red: #a3283a;
  --red-deep: #5c1420;
  --green: #4f8a6b;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, sans-serif; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(163, 40, 58, .18), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(201, 162, 90, .08), transparent 60%),
    var(--bg);
}
h1, h2, h3, .display { font-family: Cinzel, Georgia, serif; letter-spacing: .04em; font-weight: 700; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.red { color: #e0566a; }
.center { text-align: center; }
.hidden { display: none !important; }

.wrap { max-width: 520px; margin: 0 auto; padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
.brand { font-family: Cinzel, serif; font-size: .9rem; letter-spacing: .2em; color: var(--gold); text-transform: uppercase; }
.pill { font-size: .78rem; padding: 5px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card.hero { text-align: center; padding: 28px 18px; }
.phase-title { font-family: Cinzel, serif; font-size: .78rem; letter-spacing: .25em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }

label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 6px; }
input, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 13px 14px; outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
input.code { text-transform: uppercase; letter-spacing: .4em; font-size: 1.4rem; text-align: center; font-family: Cinzel, serif; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1rem Inter, sans-serif; color: var(--bg); background: var(--gold);
  border: none; border-radius: 12px; padding: 14px 18px; cursor: pointer; width: 100%;
  transition: transform .08s ease, opacity .15s;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--red); color: var(--ink); }
button.small { width: auto; padding: 8px 12px; font-size: .85rem; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 10px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  background: var(--bg2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 10px; font-weight: 500; text-align: center; width: 100%;
}
.choice.sel { border-color: var(--gold); background: rgba(201, 162, 90, .14); color: var(--gold); }

.plist { list-style: none; padding: 0; margin: 0; }
.plist li { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 8px; }
.dot.off { background: #555; }
.dead { color: var(--muted); text-decoration: line-through; }

.role-card {
  border-radius: 18px; padding: 34px 18px; text-align: center; cursor: pointer; user-select: none;
  border: 1px solid var(--line); background: linear-gradient(160deg, #221c29, #141118);
}
.role-card .big { font-family: Cinzel, serif; font-size: 2.1rem; margin: 10px 0; }
.role-card.faithful .big { color: var(--gold); }
.role-card.traitor { background: linear-gradient(160deg, #3a0f18, #170a0e); border-color: var(--red-deep); }
.role-card.traitor .big { color: #e0566a; }

.badge { display: inline-block; font-size: .75rem; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--gold); color: var(--gold); }
.badge.red { border-color: var(--red); color: #e0566a; }

.timer { font-family: Cinzel, serif; font-size: 3rem; text-align: center; margin: 6px 0; }
.timer.low { color: #e0566a; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--red); color: var(--ink); padding: 12px 18px; border-radius: 12px; font-size: .9rem;
  max-width: 90vw; z-index: 50; box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--red-deep); color: var(--ink); text-align: center; font-size: .8rem; padding: 6px; z-index: 40; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fade { animation: fadeUp .45s ease both; }

/* ---------- Tema Natale ---------- */
body[data-theme="xmas"] {
  --bg: #0a1a14;
  --bg2: #0f241b;
  --card: #132c21;
  --line: #224636;
  --ink: #f6efe2;
  --muted: #a9bfb2;
  --gold: #f0c75e;
  --red: #c8323f;
  --red-deep: #6e1820;
  --green: #5fbf7f;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(200, 50, 63, .22), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(95, 191, 127, .12), transparent 60%),
    var(--bg);
}
body[data-theme="xmas"] h1, body[data-theme="xmas"] h2,
body[data-theme="xmas"] .role-card .big, body[data-theme="xmas"] .bigcode,
body[data-theme="xmas"] .timer, body[data-theme="xmas"] .potbig {
  font-family: 'Mountains of Christmas', Cinzel, Georgia, serif; letter-spacing: .02em;
}
body[data-theme="xmas"] .role-card.faithful { background: linear-gradient(160deg, #1b4a33, #0f241b); border-color: #2e6b4b; }
body[data-theme="xmas"] .role-card.faithful .big { color: #8fe0a8; }
body[data-theme="xmas"] .role-card.traitor { background: linear-gradient(160deg, #3d5a12, #1b2a08); border-color: #6c8f1f; }
body[data-theme="xmas"] .role-card.traitor .big { color: #b9e24a; }
body[data-theme="xmas"] .red { color: #ff6b6b; }
body[data-theme="xmas"] button:not(.ghost):not(.choice):not(.danger) { background: var(--red); color: #fff; }
body[data-theme="xmas"] .choice.sel { border-color: var(--gold); background: rgba(240, 199, 94, .14); }
body[data-theme="xmas"] .card { background: repeating-linear-gradient(90deg, var(--red) 0 14px, #f6efe2 14px 28px, #2e8b57 28px 42px) top / 100% 4px no-repeat, var(--card); }

/* neve */
body[data-theme="xmas"]::before, body[data-theme="xmas"]::after {
  content: ''; position: fixed; inset: -10% 0 0 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff, transparent),
    radial-gradient(3px 3px at 80px 120px, rgba(255,255,255,.8), transparent),
    radial-gradient(2px 2px at 150px 60px, #fff, transparent),
    radial-gradient(3px 3px at 220px 200px, rgba(255,255,255,.7), transparent),
    radial-gradient(2px 2px at 300px 90px, #fff, transparent),
    radial-gradient(2px 2px at 360px 260px, rgba(255,255,255,.8), transparent);
  background-size: 400px 300px;
  animation: snow 14s linear infinite; opacity: .55;
}
body[data-theme="xmas"]::after { background-size: 260px 220px; animation-name: snow2; animation-duration: 22s; opacity: .35; }
@keyframes snow { to { background-position: 30px 300px, 30px 300px, 30px 300px, 30px 300px, 30px 300px, 30px 300px; } }
@keyframes snow2 { to { background-position: -20px 220px, -20px 220px, -20px 220px, -20px 220px, -20px 220px, -20px 220px; } }
body[data-theme="xmas"] .wrap, body[data-theme="xmas"] .hwrap { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { body[data-theme="xmas"]::before, body[data-theme="xmas"]::after { animation: none; } }
