/* Lupus in Fabula — design system condiviso */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap');

:root {
  --bg: #10142e;
  --bg-2: #181e45;
  --bg-3: #232b5e;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-2: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.14);
  --text: #f2f4ff;
  --muted: #9fa8d4;
  --accent: #ffcf5c;       /* luna dorata */
  --accent-2: #ff8f5c;
  --wolf: #ff6b6b;
  --village: #7ed491;
  --ok: #4caf7d;
  --warn: #ffd54f;
  --danger: #ef5350;
  --info: #64b5f6;
  --night: #0d1130;
  --day-1: #ffb74d;
  --day-2: #ff8a65;
  --radius: 18px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
  --font: 'Fredoka', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 600px at 85% -10%, #2c3672 0%, transparent 55%),
    radial-gradient(900px 550px at 0% 0%, #34245c 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }

h1, h2, h3 { margin: 0 0 0.5em; font-weight: 600; letter-spacing: 0.2px; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { margin: 0 0 0.6em; color: var(--muted); text-transform: uppercase; letter-spacing: 1.4px; font-size: 0.72rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.hidden { display: none !important; }

.container { max-width: 720px; margin: 0 auto; padding: 16px; position: relative; z-index: 1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 14px; }

/* cielo stellato (riempito da L.stars()) */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.sky .star { position: absolute; border-radius: 50%; background: #fff; opacity: 0.7; animation: twinkle 3s ease-in-out infinite; }
.sky .moon {
  position: absolute; top: 26px; right: 30px; width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8e1, #ffe082 55%, #f5c948);
  box-shadow: 0 0 44px rgba(255, 224, 130, 0.5);
}
@keyframes twinkle { 0%, 100% { opacity: 0.75; } 50% { opacity: 0.18; } }
@media (prefers-reduced-motion: reduce) { .sky .star { animation: none; } }

/* pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: transform 0.08s, background 0.15s, opacity 0.15s; min-height: 48px;
}
.btn:hover { background: rgba(255, 255, 255, 0.18); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, #ffd76b, #ff9d5c); border-color: transparent; color: #3a2410; text-shadow: none; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.wolf { background: linear-gradient(135deg, #ff7b7b, #d84343); border-color: transparent; color: #fff; }
.btn.ok { background: var(--ok); border-color: transparent; color: #fff; }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 0.85rem; min-height: 34px; border-radius: 11px; }
.btn.lg { padding: 15px 24px; font-size: 1.12rem; border-radius: 18px; }
.btn.block { width: 100%; }

/* input */
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28); color: var(--text); outline: none;
}
.input:focus { border-color: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.code-input { font-size: 1.6rem !important; letter-spacing: 10px; text-align: center; font-weight: 700; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

/* avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  width: 38px; height: 38px; font-size: 21px; flex: 0 0 auto; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.3);
}
.avatar-sm { width: 27px; height: 27px; font-size: 15px; }
.avatar-lg { width: 58px; height: 58px; font-size: 33px; }
.avatar-xl { width: 84px; height: 84px; font-size: 48px; }
.avatar.dead { filter: grayscale(1) brightness(0.6); }

/* carta ruolo */
.role-card {
  position: relative; border-radius: 22px; padding: 20px;
  background: linear-gradient(160deg, var(--bg-3), var(--bg-2));
  border: 2px solid var(--rc, var(--accent));
  box-shadow: 0 0 0 4px rgba(255,255,255,0.05), var(--shadow);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
}
.role-card .rc-emoji {
  width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 52px; background: rgba(255,255,255,0.08); box-shadow: inset 0 0 0 3px var(--rc, var(--accent));
}
.role-card .rc-name { font-size: 1.5rem; font-weight: 700; color: var(--rc, var(--accent)); }
.role-card .rc-power { font-size: 0.95rem; line-height: 1.45; }
.role-card .rc-tip { font-size: 0.85rem; color: var(--muted); font-style: italic; }
.team-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.5px;
}
.team-pill.lupi { background: rgba(255, 107, 107, 0.22); color: #ffb3b3; }
.team-pill.villaggio { background: rgba(126, 212, 145, 0.2); color: #b1e8bd; }

/* chip ruolo (composizione) */
.role-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 8px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); font-weight: 600; font-size: 0.9rem;
}
.role-chip .rc-dot { font-size: 1.15rem; }

/* toast */
.toast-root { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 440px); }
.toast { background: #252e63; color: #fff; padding: 11px 16px; border-radius: 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); transition: 0.25s; font-weight: 600; text-align: center; border-left: 4px solid var(--info); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }

/* pill */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; background: var(--panel-2); font-size: 0.8rem; font-weight: 600; }
.pill.ok { background: rgba(76,175,125,0.25); color: #a9dcc0; }
.pill.warn { background: rgba(255,213,79,0.2); color: #ffe9a6; }
.pill.danger { background: rgba(239,83,80,0.25); color: #f4a9a8; }
.pill.info { background: rgba(100,181,246,0.22); color: #a8d4fa; }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: #555; display: inline-block; }
.dot-online.on { background: #58d68d; box-shadow: 0 0 6px #58d68d; }

/* liste */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 15px; background: var(--panel-2); border: 1px solid var(--border); }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: rgba(255,255,255,0.16); }
.empty { padding: 14px; text-align: center; color: var(--muted); font-size: 0.92rem; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 8, 25, 0.72); display: flex; align-items: center; justify-content: center; z-index: 5000; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px; padding: 20px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: rgba(5, 8, 25, 0.4); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(10px); }
.brand { font-weight: 700; letter-spacing: 0.6px; display: flex; align-items: center; gap: 9px; font-size: 1.05rem; }
.brand .logo { font-size: 1.45rem; }
.hello { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }

/* timer */
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.urgent { color: var(--accent-2); animation: pulse 0.8s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes pop { 0% { transform: scale(0.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop 0.22s ease-out; }
@keyframes rise { 0% { transform: translateY(12px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.rise { animation: rise 0.35s ease-out; }

/* log narrazione */
.story { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.story .entry { padding: 9px 12px; border-radius: 13px; background: rgba(0,0,0,0.22); line-height: 1.45; font-size: 0.92rem; border-left: 3px solid var(--info); }
.story .entry.intro { border-left-color: var(--accent); }
.story .entry.night, .story .entry.phase { border-left-color: #7986cb; }
.story .entry.dawn, .story .entry.lynch, .story .entry.hunter_shot { border-left-color: var(--danger); }
.story .entry.dawn.saved, .story .entry.no_lynch { border-left-color: var(--ok); }
.story .entry.end { border-left-color: var(--accent); font-weight: 600; }

/* responsive */
@media (max-width: 480px) {
  .container { padding: 12px; }
  h1 { font-size: 1.4rem; }
}
