:root {
  --bg: #08080b;
  --bg-2: #11111a;
  --bg-3: #1a1a26;
  --bg-4: #232333;
  --fg: #ececf0;
  --fg-dim: #8a8a9a;
  --fg-mute: #5a5a6a;
  --accent: #b8001c;
  --accent-2: #d80020;
  --accent-3: #ff3850;
  --blood: #5a0010;
  --gold: #c89840;
  --ok: #22c55e;
  --border: #2a1a26;
  --border-2: #3a2a3a;
  --bubble-own: #3a1218;
  --bubble-other: #1a1a26;
  --radius: 10px;
  --radius-lg: 14px;
  --glow: 0 0 14px rgba(184, 0, 28, 0.45);
  --font-head: 'Pirata One', 'UnifrakturMaguntia', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  overflow-x: clip;
}

body.theme-sat {
  background:
    radial-gradient(ellipse at top, rgba(90, 0, 16, 0.18), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(40, 0, 30, 0.12), transparent 60%),
    var(--bg);
  min-height: 100vh;
  position: relative;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--fg);
  padding: 9px 16px;
  border-radius: 8px;
  transition: background 140ms, border-color 140ms, transform 80ms, box-shadow 140ms;
  letter-spacing: 0.02em;
}
button:hover:not(:disabled) {
  background: var(--bg-4);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 14px rgba(184, 0, 28, 0.25);
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-3), var(--accent-2));
  border-color: var(--accent-3);
  box-shadow: var(--glow);
}
button.block { width: 100%; }
button.danger { color: var(--accent-3); }
button.icon {
  padding: 8px 10px;
  line-height: 1;
  font-size: 16px;
  background: var(--bg-2);
}

input[type="text"], input[type="url"] {
  font: inherit;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-2);
  padding: 9px 14px;
  border-radius: 8px;
  outline: none;
  width: 100%;
  transition: border-color 140ms, box-shadow 140ms;
}
input[type="text"]:focus, input[type="url"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(184, 0, 28, 0.18);
}

.bg-pentagrams {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bg-pent {
  position: absolute;
  width: 540px;
  height: 540px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.2;
  opacity: 0.05;
  filter: drop-shadow(0 0 18px rgba(184, 0, 28, 0.25));
}
.bg-pent-1 { top: -160px; left: -160px; }
.bg-pent-2 { bottom: -200px; right: -180px; transform: rotate(35deg); opacity: 0.06; }
.bg-pent-3 { top: 30%; right: -200px; width: 420px; height: 420px; transform: rotate(-15deg); opacity: 0.04; }
.bg-pent-4 { top: 60%; left: 4%; width: 360px; height: 360px; transform: rotate(110deg); opacity: 0.045; }

.container, .landing { position: relative; z-index: 1; }

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 32px 24px;
}
.landing-logo {
  width: 88px; height: 88px; margin-bottom: 8px;
  stroke: var(--accent-2); fill: none; stroke-width: 1.5;
  filter: drop-shadow(0 0 14px rgba(216, 0, 32, 0.55));
  animation: pulse 4s ease-in-out infinite;
}
.landing-logo svg { width: 100%; height: 100%; }
.landing h1 {
  font-family: var(--font-head);
  font-size: 64px;
  margin: 0 0 8px;
  color: var(--accent-3);
  text-shadow: 0 0 18px rgba(216, 0, 32, 0.55), 0 2px 0 #000;
  letter-spacing: 2px;
}
.landing p { color: var(--fg-dim); max-width: 540px; line-height: 1.55; margin: 0 0 4px; }
.landing .card {
  background: linear-gradient(180deg, rgba(20, 20, 26, 0.96), rgba(15, 15, 20, 0.96));
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(184, 0, 28, 0.06);
}
.landing .row { display: flex; gap: 8px; margin-top: 12px; }
.landing .row input { flex: 1; }
.landing .divider {
  color: var(--fg-dim);
  margin: 18px 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  position: relative;
  text-align: center;
}
.landing .divider::before, .landing .divider::after {
  content: ''; position: absolute; top: 50%;
  width: 30%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-2), transparent);
}
.landing .divider::before { right: 70%; }
.landing .divider::after { left: 70%; }
.landing .footer { margin-top: 28px; color: var(--fg-mute); font-size: 12px; letter-spacing: 0.4px; }
.error { color: var(--accent-3); margin-top: 8px; min-height: 18px; font-size: 13px; }

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(20, 20, 26, 0.85), rgba(15, 15, 20, 0.85));
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
.header-bar .left { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }
.header-bar h1 {
  font-family: var(--font-head);
  font-size: 0;
  margin: 0;
  color: var(--accent-3);
  text-shadow: 0 0 12px rgba(216, 0, 32, 0.4);
  letter-spacing: 1px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.header-bar h1 .logo {
  width: 36px; height: 36px; flex-shrink: 0;
  stroke: var(--accent-2); fill: none; stroke-width: 1.6;
  filter: drop-shadow(0 0 8px rgba(216, 0, 32, 0.45));
}
.header-bar h1 .logo svg { width: 100%; height: 100%; display: block; }
.header-bar .right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(184, 0, 28, 0.12);
  border: 1px solid var(--border-2);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--fg);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.share-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  background: var(--bg-2);
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--fg-dim);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border-2);
}

.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 12px;
  background: var(--bg-3); color: var(--fg-dim);
  border: 1px solid var(--border-2);
  white-space: nowrap;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-dim); }
.status.connected .dot { background: var(--ok); }
.status.connected { color: var(--ok); border-color: rgba(34, 197, 94, 0.3); }
.status.connecting .dot { background: var(--gold); animation: blink 1.2s ease-in-out infinite; }
.status.connecting { color: var(--gold); }
.status.disconnected .dot { background: var(--accent-3); }
.status.disconnected { color: var(--accent-3); border-color: rgba(255, 56, 80, 0.35); }

.room-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  height: calc(100vh - 92px);
  min-height: 600px;
}
.main-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.side-col { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }

.tabs {
  display: flex;
  gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 4px;
  flex-shrink: 0;
}
.tabs .tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 9px 8px;
  font-size: 12px;
  color: var(--fg-dim);
  border-radius: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
  box-shadow: none;
  cursor: pointer;
}
.tabs .tab:hover { background: var(--bg-3); border: none; box-shadow: none; }
.tabs .tab.active {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
.tabs .tab.active:hover { background: linear-gradient(180deg, var(--accent-3), var(--accent-2)); }
.tab-count { font-size: 11px; opacity: 0.85; margin-left: 4px; }

.side-col .panel-tab { display: none; }
.side-col .panel-tab.active { display: flex; flex: 1; min-height: 0; }

.panel {
  background: linear-gradient(180deg, rgba(20, 20, 26, 0.92), rgba(15, 15, 20, 0.92));
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  background: rgba(184, 0, 28, 0.08);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--fg);
}
.panel-body { padding: 8px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.panel-body.compact { padding: 4px 0; }

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(184, 0, 28, 0.1);
}
.player-wrap > div, .player-wrap iframe { width: 100% !important; height: 100% !important; }
.player-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-dim); text-align: center; padding: 24px;
  background:
    radial-gradient(ellipse at center, rgba(90, 0, 16, 0.18), transparent 70%),
    #000;
  flex-direction: column; gap: 12px;
}
.player-empty .empty-pent {
  width: 80px; height: 80px;
  stroke: var(--accent-2); fill: none; stroke-width: 1.4;
  opacity: 0.5;
  filter: drop-shadow(0 0 12px rgba(216, 0, 32, 0.4));
  animation: pulse 4s ease-in-out infinite;
}

.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(20, 20, 26, 0.92), rgba(15, 15, 20, 0.92));
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
}
.controls .grow { flex: 1; min-width: 220px; display: flex; gap: 8px; }
.controls .group { display: flex; gap: 6px; }
.controls .group button { padding: 9px 12px; min-width: 42px; }

.members { display: flex; flex-direction: column; }
.member {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; font-size: 13px;
  transition: background 120ms;
}
.member:hover { background: rgba(184, 0, 28, 0.06); }
.member .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
}
.member .nick { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.member.you .nick { font-weight: 700; }
.member.you .nick::after { content: " (ты)"; color: var(--fg-mute); font-size: 11px; font-weight: 500; }

.chat-list {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-2);
  word-wrap: break-word;
  position: relative;
  animation: bubble-in 180ms ease-out;
}
.chat-bubble.other {
  background: var(--bubble-other);
  align-self: flex-start;
  border-top-left-radius: 4px;
}
.chat-bubble.own {
  background: linear-gradient(180deg, rgba(184, 0, 28, 0.28), rgba(184, 0, 28, 0.18));
  border-color: rgba(184, 0, 28, 0.5);
  align-self: flex-end;
  border-top-right-radius: 4px;
}
.bubble-head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px;
}
.bubble-head .from { font-weight: 700; letter-spacing: 0.2px; }
.bubble-head .ts { color: var(--fg-mute); font-size: 10px; margin-left: auto; }
.bubble-body {
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--fg);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-input {
  display: flex; gap: 6px; padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.2);
}
.chat-input input { flex: 1; }
.chat-input button { white-space: nowrap; }

.queue-list { display: flex; flex-direction: column; }
.now-playing {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(184, 0, 28, 0.18), rgba(184, 0, 28, 0.06));
  border-left: 3px solid var(--accent);
}
.now-playing .now-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-3);
  font-weight: 700;
}
.now-playing .now-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.queue-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background 120ms;
}
.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: rgba(184, 0, 28, 0.05); }
.queue-item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .meta { color: var(--fg-dim); font-size: 11px; flex-shrink: 0; }
.queue-item.current {
  background: linear-gradient(90deg, rgba(184, 0, 28, 0.18), transparent);
  border-left: 3px solid var(--accent);
  font-weight: 600;
}
.queue-item.current .title { color: var(--accent-3); }
.queue-empty { padding: 14px; text-align: center; color: var(--fg-mute); font-size: 12px; }

.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  max-width: calc(100vw - 40px);
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  animation: slide-in 200ms ease-out;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--accent-3); background: linear-gradient(90deg, rgba(184, 0, 28, 0.18), var(--bg-3)); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(184, 0, 28, 0.12);
  position: relative;
  overflow: hidden;
}
.modal .modal-pent {
  position: absolute; top: -50px; right: -50px;
  width: 200px; height: 200px;
  stroke: var(--accent); fill: none; stroke-width: 1.2;
  opacity: 0.08;
  transform: rotate(15deg);
  pointer-events: none;
}
.modal h2 {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-size: 28px;
  color: var(--accent-3);
  text-shadow: 0 0 12px rgba(216, 0, 32, 0.4);
  letter-spacing: 1.5px;
  position: relative;
}
.modal p { color: var(--fg-dim); margin: 0 0 16px; font-size: 13px; }
.modal .row { display: flex; gap: 8px; }
.modal .row input { flex: 1; }
.modal .col { display: flex; flex-direction: column; gap: 12px; }

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  justify-content: flex-start;
}
.color-swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 120ms, box-shadow 120ms, border-color 120ms;
}
.color-swatch:hover { transform: scale(1.08); border-color: var(--fg-dim); }
.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 0 14px rgba(184, 0, 28, 0.5);
  transform: scale(1.05);
}
.color-swatch.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

@keyframes pulse {
  0%, 100% { opacity: 0.85; filter: drop-shadow(0 0 8px rgba(216, 0, 32, 0.4)); }
  50% { opacity: 1; filter: drop-shadow(0 0 18px rgba(216, 0, 32, 0.7)); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (max-width: 1100px) {
  .room-layout { grid-template-columns: 1fr 300px; }
}
@media (max-width: 860px) {
  .room-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 0;
  }
  .main-col { order: 1; }
  .side-col { order: 2; }
  .header-bar {
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(8px);
  }
  .header-bar h1 .logo { width: 30px; height: 30px; }
  .share-link { display: none; }
  .container { padding: 10px; }

  .player-wrap {
    position: fixed;
    top: 52px;
    left: 10px;
    right: 10px;
    z-index: 10;
    aspect-ratio: 16 / 9;
    max-height: 40vh;
  }
  .main-col {
    padding-top: calc(min((100vw - 20px) * 9 / 16, 40vh) + 12px);
  }

  .side-col { gap: 8px; }
  .side-col .panel-tab.active { min-height: 55vh; }
}
@media (max-width: 600px) {
  body { font-size: 14px; }
  .header-bar { gap: 6px; padding: 8px 10px; }
  .header-bar .left { gap: 8px; }
  .header-bar .right { gap: 6px; }
  .room-code { font-size: 11px; padding: 4px 8px; max-width: 140px; }
  .status { padding: 4px 10px; font-size: 11px; }
  .container { padding: 8px; }
  .controls { padding: 10px; gap: 8px; }
  .controls .grow { min-width: 100%; }
  .controls .group { width: 100%; justify-content: center; }
  .controls .group button { flex: 1; padding: 12px 8px; }
  .toast-container { left: 8px; right: 8px; bottom: 8px; max-width: none; }
  .toast { max-width: none; }
  .landing h1 { font-size: 44px; }
  .landing .card { padding: 20px; }
  .side-col .panel-tab.active { min-height: 55vh; }
  .chat-bubble { max-width: 86%; }
}
@media (max-width: 380px) {
  .landing-logo { width: 64px; height: 64px; }
  .room-code { display: none; }
  .btn-copy-link { font-size: 14px; padding: 6px 8px; }
}
