:root {
  --bg: #0a0f24;
  --card: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f4f6ff;
  --muted: #a9b1d0;
  --accent: #ffd166;
  --accent-ink: #2a1c00;
  --danger: #ff6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% -200px, #24306b 0%, var(--bg) 60%) fixed var(--bg);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}

header { text-align: center; margin: 8px 0 16px; }
h1 { margin: 0; font-size: 2rem; letter-spacing: 0.01em; }
h2 { margin: 0 0 8px; font-size: 1.2rem; }
h3 { margin: 18px 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.big { font-size: 1.6rem; font-weight: 700; margin: 4px 0; }
[hidden] { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}

.status { font-weight: 600; text-align: center; margin-bottom: 14px; }
.stage .small { text-align: center; margin: 12px 0 0; }

/* ---- preview: one string of bulbs per zone ---- */
.preview { display: grid; gap: 14px; }
.zone-name { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.string { display: flex; justify-content: space-between; padding: 6px 2px; border-top: 2px solid rgba(255, 255, 255, 0.18); --dur: 1.6s; }
.bulb {
  width: 12px; height: 16px; border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: currentColor;
  box-shadow: 0 0 10px 2px currentColor;
  transition: color 0.3s;
}
.anim-twinkle .bulb { animation: twinkle calc(var(--dur) * 1.6) ease-in-out infinite; animation-delay: calc(var(--r) * -4s); }
.anim-sparkle .bulb { animation: sparkle calc(var(--dur) * 2.2) linear infinite; animation-delay: calc(var(--r) * -6s); }
.anim-breathe .bulb { animation: breathe calc(var(--dur) * 2.5) ease-in-out infinite; }
.anim-chase .bulb { animation: chase var(--dur) linear infinite; animation-delay: calc(var(--i) * var(--dur) / -6); }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes sparkle { 0%, 88%, 100% { filter: none; } 94% { filter: brightness(2.2) saturate(0.3); } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes chase { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .bulb { animation: none !important; } }

/* ---- forms and buttons ---- */
label { display: block; margin-bottom: 8px; }
.row { display: flex; gap: 8px; }
input[type="text"], input[type="password"] {
  flex: 1; min-width: 0; height: 50px; padding: 0 14px;
  font: inherit; color: var(--text);
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 12px;
}
button {
  font: inherit; font-weight: 600; color: var(--text);
  min-height: 50px; padding: 0 16px;
  background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer; touch-action: manipulation;
}
button:active { transform: scale(0.97); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.ghost { background: transparent; }
button.wide { width: 100%; margin-top: 20px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.turnbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.turnbar h2 { margin: 0; }
.pill { font-size: 0.85rem; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); }
.pill.warn { background: var(--danger); color: #2a0000; font-weight: 700; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chips button { min-height: 40px; border-radius: 999px; }
.chips button.on, .fx button.on, .tab.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.fx { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fx button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; padding: 6px 4px; font-size: 0.85rem; }
.fx .icon { font-size: 1.4rem; line-height: 1; }

.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.swatches button, .swatches .custom {
  aspect-ratio: 1; min-height: 0; padding: 0; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.swatches .on { outline: 3px solid var(--text); outline-offset: 3px; }
.swatches .custom {
  position: relative; display: grid; place-items: center; margin: 0; overflow: hidden;
  font-size: 1.3rem; font-weight: 700; cursor: pointer;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
}
.swatches .custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

input[type="range"] { width: 100%; height: 44px; accent-color: var(--accent); }

/* ---- gallery ---- */
.tabs { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs h2 { margin: 0; }
.tab { min-height: 36px; padding: 0 12px; border-radius: 999px; font-size: 0.85rem; }
.gallery { display: grid; gap: 8px; }
.design { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); }
.design .who { flex: 1; min-width: 0; }
.design .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dots { display: flex; gap: 4px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.vote { min-height: 40px; min-width: 64px; padding: 0 10px; border-radius: 999px; }
.vote.on { background: #ff5d8f; border-color: transparent; color: #2a0010; }

footer { text-align: center; margin-top: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 480px); padding: 12px 16px; border-radius: 12px;
  background: #fff; color: #111; font-weight: 600; text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); z-index: 10;
}

/* ---- admin ---- */
.admin pre { overflow: auto; max-height: 50vh; padding: 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); font-size: 0.8rem; }
.admin .row { flex-wrap: wrap; margin-bottom: 10px; }
.admin table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin td { padding: 6px 4px; border-top: 1px solid var(--line); }
.admin td button { min-height: 34px; padding: 0 10px; }
.ok { color: #6be38b; }
.bad { color: var(--danger); }
