/* Controller styling: scuro, touch-friendly, pulsanti grandi. */
:root {
  --bg: #0b0f14;
  --card: #161c24;
  --accent: #2bb673;
  --accent-press: #1f8f59;
  --accent2: #3a72d6;
  --text: #e8eef3;
  --muted: #8a97a6;
  --danger: #c0392b;
  --line: #243140;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
h1 { font-size: 18px; margin: 0; }
.conn { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--card); color: var(--muted); }
.conn.ok { color: var(--accent); }
.conn.err { color: var(--danger); }
main { padding: 16px; max-width: 860px; margin: 0 auto; }

.current-card {
  background: var(--card); border-radius: 14px; padding: 16px 18px; text-align: center; margin-bottom: 14px;
}
.label { font-size: 12px; letter-spacing: .08em; color: var(--muted); }
.scene-name { font-size: 22px; font-weight: 700; margin: 6px 0 2px; line-height: 1.2; }
.scene-idx { font-size: 13px; color: var(--muted); }

.controls { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-bottom: 10px; }
.controls2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.btn {
  border: none; border-radius: 12px; padding: 18px 16px; font-size: 18px; font-weight: 700;
  color: #fff; background: var(--card); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn.small { padding: 13px 14px; font-size: 15px; }
.btn.primary { background: var(--accent); }
.btn.primary:active { background: var(--accent-press); }
.btn.secondary { background: #2a3642; }
.btn.accent2 { background: var(--accent2); }
.btn.danger { background: var(--danger); }
.btn:active { transform: translateY(1px); }

.section-title { font-size: 12px; letter-spacing: .08em; color: var(--muted); margin: 18px 0 10px; }

/* Capitoli + griglia miniature */
.chapters { display: flex; flex-direction: column; gap: 18px; }
.chapter-block { }
.chapter-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px;
  padding: 8px 10px; background: var(--card); border-radius: 10px;
}
.chapter-head.current { outline: 2px solid var(--accent); }
.chapter-head .num {
  font-size: 12px; font-weight: 700; color: #fff; background: #2a3642;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.chapter-head .title { font-size: 15px; font-weight: 600; }

.thumb-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}
.thumb {
  position: relative; border: 3px solid transparent; border-radius: 12px;
  overflow: hidden; cursor: pointer; background: #000; aspect-ratio: 3 / 4;
  -webkit-tap-highlight-color: transparent;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 11px; color: #fff; padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
}
.thumb.current { border-color: var(--accent); }
.thumb.pinned { border-color: var(--accent2); }
.thumb .badge {
  position: absolute; top: 6px; right: 6px; font-size: 11px; font-weight: 700;
  color: #fff; background: var(--accent); padding: 2px 7px; border-radius: 999px;
}
.thumb.pinned .badge { background: var(--accent2); }

.footer-controls { margin: 22px 0 40px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1f2a36; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); max-width: 90%;
}
.toast.hidden { display: none; }
.toast.err { background: var(--danger); }
