:root {
  --bg: #05070e;
  --ink: #c2cee2;
  --ink-dim: #7d8aa8;
  --ink-soft: #93a1bb;
  --line: #1b2338;
  --accent: #3f7bff;
  --fisica: #33adff;
  --matematica: #bd52ff;
  --mente: #ffa838;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  height: 100dvh;
}

/* ------------------------------------------------------------------ scena */
.stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #0b0f1c 0%, #05070e 70%);
  touch-action: none;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay { pointer-events: none; }

.sound-gate {
  position: absolute;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border: 1px solid #2b3a60;
  border-radius: 999px;
  background: rgba(10, 14, 24, 0.82);
  color: #cfe0ff;
  font: 600 11px/1 inherit;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color .2s, background .2s, opacity .3s;
}

.sound-gate:hover { border-color: #4d7fd6; background: rgba(18, 26, 44, 0.92); }
.sound-gate[hidden] { opacity: 0; pointer-events: none; }

.sound-gate__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mente);
  box-shadow: 0 0 10px var(--mente);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ------------------------------------------------------------------ pannello */
.panel {
  overflow-y: auto;
  padding: 22px 20px 18px 22px;
  border-left: 1px solid var(--line);
  background: #0a0d16;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scrollbar-width: thin;
  scrollbar-color: #1d2740 transparent;
}

.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #1d2740; border-radius: 4px; }

.kicker {
  margin: 2px 0 0;
  color: #6f7d9c;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #eaf1ff;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 7px;
}

.thesis {
  margin: 2px 0 0;
  color: #eaf1ff;
  font-size: 13px;
  line-height: 1.45;
}

.body {
  margin: 0;
  color: #9aa8c2;
  font-size: 11px;
  line-height: 1.55;
}

.body b { color: #cfdcf5; font-weight: 600; }
.body.small { font-size: 10.5px; }

.poles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poles li {
  display: grid;
  grid-template-columns: 14px 1fr;
  grid-template-areas: "dot name" ". role";
  align-items: center;
  font-size: 10.5px;
}

.poles .dot {
  grid-area: dot;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}

.poles b { grid-area: name; color: #e3ecff; letter-spacing: 1.2px; font-size: 11px; }
.poles i { grid-area: role; color: var(--ink-soft); font-style: italic; font-size: 10px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.buttons .btn {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid #26324e;
  border-radius: 5px;
  background: #111a2c;
  color: #cfdcf5;
  font: 500 11px/1 inherit;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.buttons .btn:hover { background: #16233d; border-color: #3a4c75; }
.buttons .btn:active { background: #0d1526; }
.buttons .btn.on { background: #2a4a86; border-color: #4d7fd6; color: #eaf1ff; }

.slider { gap: 10px; }
.slider .kicker { width: 66px; flex: none; }
.slider input { flex: 1; }
.slider output, .audio output { width: 30px; text-align: right; color: #dbe6ff; font-size: 11px; font-weight: 600; }

.toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 11px;
  color: #b6c2d8;
}

.toggles label, .audio label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

input[type="checkbox"] {
  appearance: none;
  width: 13px;
  height: 13px;
  border: 1px solid #2b3654;
  border-radius: 3px;
  background: #0d1220;
  cursor: pointer;
  position: relative;
}

input[type="checkbox"]:checked { background: var(--accent); border-color: #6fa0ff; }

input[type="range"] {
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--p, 50%), #1c263c var(--p, 50%));
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #cfdcf5;
  border: 1px solid var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: #cfdcf5;
}

.audio .kicker { width: 52px; flex: none; }

.stats, .evo { margin: 0; display: flex; flex-direction: column; gap: 5px; }

.stats div, .evo div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stats dt, .evo dt {
  color: #6f7d9c;
  font-size: 10px;
  letter-spacing: 1px;
}

.stats dd {
  margin: 0;
  color: #dbe6ff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats dd.violet { color: #bd8fff; }
.stats dd.amber { color: var(--mente); }

.evo dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 55%;
  min-width: 120px;
}

.evo .bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: #131a2b;
  overflow: hidden;
}

.evo .bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--bar, #4b7fd8);
  transition: width .3s linear;
}

.evo b {
  width: 26px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

#vExp { color: var(--fisica); }
#vTor { color: #7452ff; }
#vCry { color: var(--mente); }
#vPre { color: #7fd0c0; }
#vDri { color: #ff7a9c; }
#vDep { color: #b0bed8; }
#vStr { color: #9fe0ff; }

.hint-text {
  margin: 4px 0 0;
  color: #55627e;
  font-size: 9px;
  line-height: 1.6;
  letter-spacing: .6px;
}

/* ------------------------------------------------------------------ mobile */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(52dvh, 1fr) auto;
    height: auto;
    min-height: 100dvh;
  }

  .stage { min-height: 52dvh; }
  .panel { border-left: none; border-top: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .sound-gate { bottom: 16px; }
}
