/* ============================================================
   VITA NEURALE — Interfaccia olografica ambientale
   Nessun menu tradizionale: pannelli di vetro, orbite di
   stato, palette che mutano con l'umore collettivo del mondo.
   ============================================================ */

:root {
  --bg: #0a0e14;
  --vetro: rgba(20, 28, 40, 0.72);
  --vetro-bordo: rgba(120, 200, 255, 0.18);
  --testo: #d8e4f0;
  --accento: #4dd0e1;
  --pericolo: #ff5470;
  --successo: #69f0ae;
  --oro: #ffd166;
  --font: 'Segoe UI', system-ui, sans-serif;
}

/* --- Stili di rendering neurale (umore collettivo) --- */
body.stile-sereno      { --accento: #4dd0e1; --bg: #0a0e14; }
body.stile-euforico    { --accento: #ffd166; --bg: #14100a; }
body.stile-malinconico { --accento: #7a8db0; --bg: #0b0d16; }
body.stile-cupo        { --accento: #5c6b7a; --bg: #05060a; }
body.stile-elettrico   { --accento: #ff2d78; --bg: #12060f; }

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--testo);
  font-family: var(--font);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 2s ease;
}

/* ============ OVERLAY E MODALI ============ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(4, 6, 12, 0.9);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.hidden { display: none !important; }

.start-card, .event-card {
  background: var(--vetro);
  border: 1px solid var(--vetro-bordo);
  border-radius: 18px;
  padding: 40px 48px;
  max-width: 560px;
  width: 92%;
  text-align: center;
  box-shadow: 0 0 60px rgba(77, 208, 225, 0.15), inset 0 0 40px rgba(255,255,255,0.02);
}

.titolo-glitch {
  font-size: 2.6rem;
  letter-spacing: 0.35em;
  background: linear-gradient(90deg, var(--accento), #fff, var(--accento));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pulsazione 3s infinite ease-in-out;
}
@keyframes pulsazione { 50% { opacity: 0.75; letter-spacing: 0.42em; } }

.sottotitolo { margin: 14px 0 26px; opacity: 0.7; font-style: italic; }

input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--vetro-bordo);
  border-radius: 10px;
  color: var(--testo);
  font-size: 1rem;
  outline: none;
  transition: border 0.3s;
}
input[type="text"]:focus { border-color: var(--accento); }

.label-tratti { margin: 20px 0 10px; font-size: 0.85rem; opacity: 0.7; }

.tratti-container { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 24px; }
.tratto-chip {
  padding: 6px 14px;
  border: 1px solid var(--vetro-bordo);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
  transition: all 0.2s;
}
.tratto-chip:hover { border-color: var(--accento); }
.tratto-chip.sel { background: var(--accento); color: #04121a; font-weight: 700; }

.btn-primario {
  padding: 14px 42px;
  background: linear-gradient(135deg, var(--accento), #7c4dff);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.3s;
}
.btn-primario:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(77,208,225,0.35); }

.nota-demo { margin-top: 16px; font-size: 0.8rem; color: var(--oro); min-height: 1em; }

/* --- Modale evento --- */
.event-badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--pericolo);
  border: 1px solid var(--pericolo);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
  animation: lampeggio 1.2s infinite;
}
@keyframes lampeggio { 50% { opacity: 0.4; } }

.event-card h2 { margin-bottom: 12px; color: var(--accento); }
.event-card p { line-height: 1.6; opacity: 0.9; margin-bottom: 22px; }

#eventScelte { display: flex; flex-direction: column; gap: 10px; }
.scelta-btn {
  padding: 12px 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--vetro-bordo);
  border-radius: 10px;
  color: var(--testo);
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
  transition: all 0.2s;
}
.scelta-btn:hover { background: rgba(77,208,225,0.15); border-color: var(--accento); transform: translateX(6px); }
#inputErede { margin-bottom: 16px; }

/* ============ HUD ============ */
#hud {
  display: flex;
  gap: 26px;
  align-items: center;
  padding: 10px 22px;
  background: var(--vetro);
  border-bottom: 1px solid var(--vetro-bordo);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}
.hud-item { display: flex; flex-direction: column; align-items: center; min-width: 70px; }
.hud-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.2em; opacity: 0.5; }
.hud-item span:last-child { font-size: 1.05rem; font-weight: 600; color: var(--accento); }
.identita { margin-left: auto; flex-direction: row; align-items: center; gap: 10px; }
#hudNome { font-size: 1.1rem; font-weight: 700; color: var(--testo) !important; }
.gen-badge { background: var(--accento); color: #04121a; border-radius: 6px; padding: 2px 8px; font-size: 0.75rem; font-weight: 800; }

/* ============ STAGE ============ */
#stage { flex: 1; display: flex; min-height: 0; }

#canvasWrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#world {
  max-width: 100%; max-height: 100%;
  border-radius: 12px;
  transition: filter 2s ease;
}
body.stile-malinconico #world { filter: saturate(0.6) blur(0.6px) brightness(0.9); }
body.stile-cupo #world        { filter: saturate(0.35) brightness(0.65) contrast(1.15); }
body.stile-elettrico #world   { filter: saturate(1.8) hue-rotate(-15deg) contrast(1.2); }
body.stile-euforico #world    { filter: saturate(1.4) brightness(1.15); }

#meteoOverlay { position: absolute; inset: 0; pointer-events: none; }

.ologramma {
  position: absolute;
  bottom: 18px; left: 18px;
  background: var(--vetro);
  border: 1px solid var(--vetro-bordo);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.85rem;
  backdrop-filter: blur(8px);
  animation: fluttua 4s infinite ease-in-out;
}
@keyframes fluttua { 50% { transform: translateY(-4px); } }

/* ============ PANNELLO ============ */
#panel {
  width: 320px;
  background: var(--vetro);
  border-left: 1px solid var(--vetro-bordo);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#tabs { display: flex; }
.tab {
  flex: 1;
  padding: 12px 4px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--testo);
  opacity: 0.55;
  cursor: pointer;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tab.active { opacity: 1; border-bottom-color: var(--accento); color: var(--accento); }

.tab-content { display: none; padding: 16px; overflow-y: auto; flex: 1; }
.tab-content.active { display: block; }
.tab-content h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.2em; opacity: 0.5; margin: 16px 0 8px; }
.tab-content h3:first-child { margin-top: 0; }

/* Orbe psicologiche: anelli al posto delle barre */
.orbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.orb { text-align: center; }
.orb-ring {
  width: 58px; height: 58px;
  border-radius: 50%;
  margin: 0 auto 4px;
  background: conic-gradient(var(--accento) 0deg, rgba(255,255,255,0.08) 0deg);
  display: flex; align-items: center; justify-content: center;
  transition: background 1s;
}
.orb span { font-size: 0.65rem; opacity: 0.6; display: block; }
.orb b { font-size: 0.8rem; }

.emozione-label {
  margin-top: 14px;
  padding: 10px;
  text-align: center;
  border: 1px dashed var(--vetro-bordo);
  border-radius: 10px;
  font-style: italic;
  color: var(--accento);
}

.mini-bars { display: flex; flex-direction: column; gap: 6px; }
.mini-bar { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.mini-bar label { width: 78px; opacity: 0.7; }
.mini-bar .track { flex: 1; height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.mini-bar .fill { height: 100%; border-radius: 3px; background: var(--accento); transition: width 0.8s; }
.mini-bar .val { width: 30px; text-align: right; opacity: 0.6; }

.ambizione-box { font-size: 0.85rem; line-height: 1.5; padding: 10px; background: rgba(255,255,255,0.04); border-radius: 8px; }
.dna-box { display: flex; flex-wrap: wrap; gap: 6px; }
.dna-box span { font-size: 0.7rem; padding: 3px 10px; border: 1px solid var(--vetro-bordo); border-radius: 999px; opacity: 0.8; }

/* Timeline della memoria */
.timeline { display: flex; flex-direction: column; gap: 8px; }
.ricordo {
  font-size: 0.82rem;
  line-height: 1.45;
  padding: 8px 12px;
  border-left: 3px solid var(--accento);
  background: rgba(255,255,255,0.03);
  border-radius: 0 8px 8px 0;
}
.ricordo.neg { border-left-color: var(--pericolo); }
.ricordo.pos { border-left-color: var(--successo); }
.echi .ricordo { opacity: 0.65; font-style: italic; border-left-style: dashed; }

/* Relazioni ed economia */
.rel-card, .eco-row, .az-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  font-size: 0.82rem;
}
.rel-tipo { font-size: 0.65rem; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.1); }
.rel-tipo.alleato { background: var(--successo); color: #04121a; }
.rel-tipo.traditore { background: var(--pericolo); color: #fff; }
.trend-up { color: var(--successo); }
.trend-down { color: var(--pericolo); }
#quartiereBox, #lavoroBox { font-size: 0.85rem; line-height: 1.5; opacity: 0.9; }

/* ============ BARRA AZIONI ============ */
#actionBar {
  background: var(--vetro);
  border-top: 1px solid var(--vetro-bordo);
  backdrop-filter: blur(10px);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.azioni { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-azione {
  padding: 8px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--vetro-bordo);
  border-radius: 999px;
  color: var(--testo);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.btn-azione:hover { background: var(--accento); color: #04121a; transform: translateY(-2px); }

.architetto { display: flex; gap: 8px; }
.architetto input { flex: 1; font-size: 0.85rem; }
#btnCostruisci, #btnTick {
  padding: 8px 16px;
  background: linear-gradient(135deg, #7c4dff, var(--accento));
  border: none; border-radius: 10px;
  color: #fff; font-weight: 700; font-size: 0.78rem;
  cursor: pointer; white-space: nowrap;
}
#btnTick { background: rgba(255,255,255,0.1); }

#logFeed {
  max-height: 74px;
  overflow-y: auto;
  font-size: 0.78rem;
  line-height: 1.5;
  opacity: 0.85;
  padding-right: 6px;
}
#logFeed .log-riga { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
#logFeed .log-tradimento, #logFeed .log-sistema { color: var(--pericolo); }
#logFeed .log-alleanza, #logFeed .log-denaro { color: var(--successo); }
#logFeed .log-evento, #logFeed .log-ambiente { color: var(--oro); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

@media (max-width: 900px) {
  #stage { flex-direction: column; }
  #panel { width: 100%; max-height: 40vh; }
}
