* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #000;
}

/* Le variabili sotto vengono impostate da app.js in base al tema attivo */
body {
  --bg: #2b1055;
  --surface: #3d1a73;
  --accent: #ff9a3c;
  --text: #ffffff;
  --text-secondary: #d9c9f0;
  --control-track: rgba(255,255,255,0.25);
  --control-chip: rgba(255,255,255,0.10);
}

button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  padding: 0;
}

/* ============================= SPLASH ============================= */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.6s ease;
}
#splash.hide {
  opacity: 0;
  pointer-events: none;
}
#splash-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#splash-title {
  color: var(--text);
  font-size: 28px;
  font-weight: 500;
  text-align: center;
  padding: 0 24px;
}

/* ============================= APP SHELL ============================= */
#app {
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 20px 0;
  flex-shrink: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#topbar button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.lyrics-icon {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 0 20px;
  min-height: 0;
}

#cover-wrap {
  position: relative;
  width: 68%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface);
  cursor: pointer;
  transition: border-radius 0.3s ease;
}

#track-title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  text-align: center;
}
#track-subtitle {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

/* ============================= CONTROLS ============================= */
#controls {
  flex-shrink: 0;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  margin: 0 14px 0;
  padding: 16px 20px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.3s ease, transform 0.35s ease;
}

#progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#time-elapsed, #time-remaining {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 34px;
}
#time-remaining { text-align: right; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--control-track);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

#transport-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
}
.side-btn {
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
.side-btn.visible { display: flex; }
.side-btn.active { color: var(--accent); }

#btn-play {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#volume-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#volume-row #volume-bar {
  flex: 0 1 55%;
}
#btn-mute, #btn-download {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

#download-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
  margin: 6px 0 10px;
  display: none;
}
#download-hint.visible { display: block; }

#error-banner {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  background: #d33;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 60;
  text-align: center;
}

/* controlli nascosti al tocco */
#app.controls-hidden #topbar,
#app.controls-hidden #controls {
  opacity: 0;
  pointer-events: none;
}
#app.controls-hidden #topbar { transform: translateY(-10px); }
#app.controls-hidden #controls { transform: translateY(10px); }

/* ============================= PANNELLI LATERALI (liriche / menu) ============================= */
.side-panel {
  position: fixed;
  left: 0;
  right: 0;
  background: var(--surface);
  color: var(--text);
  padding: 16px 20px;
  transition: transform 0.32s ease;
  z-index: 80;
  display: flex;
  flex-direction: column;
}

/* menu: scorre dal basso, sopra al pannello comandi */
.side-panel.panel-bottom {
  bottom: 0;
  max-height: 78%;
  border-radius: 22px 22px 0 0;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateY(110%);
}
.side-panel.panel-bottom.open {
  transform: translateY(0);
}

/* liriche: scorre dall'alto, si ferma sopra al pannello comandi lasciandolo libero */
.side-panel.panel-top {
  top: 0;
  bottom: var(--controls-height, 190px);
  padding-top: max(18px, env(safe-area-inset-top));
  border-radius: 0 0 22px 22px;
  transform: translateY(-110%);
}
.side-panel.panel-top.open {
  transform: translateY(0);
}
.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  margin-bottom: 12px;
}
.side-panel-header p {
  margin: 0;
  font-weight: 500;
  font-size: 15px;
  flex: 1;
}
.panel-close {
  font-size: 22px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.font-size-controls {
  display: flex;
  gap: 6px;
}
.font-size-controls button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  font-size: 12px;
  color: var(--text);
}

#lyrics-content {
  overflow-y: auto;
  white-space: pre-line;
  line-height: 1.6em;
  font-size: 1em;
}

.menu-section-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 8px;
}
#theme-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  text-align: left;
  font-size: 14px;
  color: var(--text);
}
.theme-option.active {
  outline: 2px solid var(--accent);
}
.theme-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}

#panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 70;
}
#panel-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ============================= FULLSCREEN COVER ============================= */
#fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 90;
}
#fullscreen-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
#fullscreen-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ============================= STILE ICONE: variante "a pulsante" ============================= */
/* Attivo solo se appearance.iconStyle = "button" in config.js.
   Riguarda solo shuffle, autoplay, muto e download: le icone della
   barra superiore (liriche, temi) restano sempre trasparenti. */
.icon-style-button .side-btn.visible,
.icon-style-button #btn-mute,
.icon-style-button #btn-download {
  background: var(--control-chip);
  border-radius: 50%;
}
.icon-style-button .side-btn.visible {
  width: 38px;
  height: 38px;
}
.icon-style-button #btn-mute,
.icon-style-button #btn-download {
  width: 34px;
  height: 34px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
