:root {
  --bg: #07070b;
  --bg-soft: #0d0d14;
  --card: #11111a;
  --line: #23232f;
  --fg: #f2f2f7;
  --muted: #9a9aae;
  --accent: #00e6a2;
  --accent-2: #a45cff;
  --danger: #ff5d6c;
  --radius: 16px;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

.icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  pointer-events: none;
}

button:has(> .icon):not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* El atributo hidden debe ganar siempre a los display de las clases. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 12% -10%, #1a1030 0%, transparent 60%),
    radial-gradient(900px 500px at 95% 0%, #06251f 0%, transparent 55%),
    var(--bg);
  color: var(--fg);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

.accent {
  color: var(--accent);
}

.mono {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---------------- topbar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 7, 11, 0.72);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 93, 108, 0.12);
  transition: background 0.3s ease, box-shadow 0.3s ease;
  flex: none;
}

.dot.on {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 230, 162, 0.14);
}

.brand-name {
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.15rem;
}

.tag {
  color: var(--muted);
  font-size: 0.75rem;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: 18px;
  font-size: 0.78rem;
  color: var(--muted);
}

.stat strong {
  color: var(--fg);
  font-family: var(--mono);
  font-weight: 600;
}

/* ---------------- layout ---------------- */

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: clamp(16px, 2.2vw, 28px);
  padding: clamp(16px, 2.5vw, 32px) clamp(16px, 3vw, 36px);
  max-width: 1560px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .tag {
    display: none;
  }
}

/* ---------------- pantalla ---------------- */

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.screen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.screen.locked video {
  cursor: none;
}

.screen.remote-active { scroll-margin-top: 76px; }
body.pseudo-fs { overflow: hidden; }
body.pseudo-fs .topbar { visibility: hidden; }
body.pseudo-fs .layout { z-index: 1000; }
body.pseudo-fs .screen,
.screen:fullscreen {
  width: 100vw;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}
body.pseudo-fs .screen { position: fixed; inset: 0; z-index: 1000; }
.screen:-webkit-full-screen { width: 100vw; height: 100vh !important; border: 0; border-radius: 0; }
@media (pointer: coarse) and (orientation: landscape) {
  .screen.remote-active { height: calc(100dvh - 92px); aspect-ratio: auto; }
}

.screen-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 10px),
    radial-gradient(circle at 50% 40%, #14141f, #08080c 70%);
}

.screen-placeholder[hidden] {
  display: none;
}

.ph-inner {
  max-width: 480px;
  text-align: center;
}

.ph-kicker {
  margin: 0 0 6px;
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
}

.ph-inner h2 {
  margin: 0 0 8px;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  letter-spacing: -0.02em;
}

.ph-text {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.ph-text code {
  font-family: var(--mono);
  background: #1b1b26;
  padding: 2px 6px;
  border-radius: 5px;
}

.live-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.turn-banner {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(8, 8, 12, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
}

.turn-who {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.turn-label {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.turn-who strong {
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-time {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.overlay-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(5, 5, 8, 0.78);
  backdrop-filter: blur(6px);
  text-align: center;
  font-size: clamp(0.95rem, 2vw, 1.2rem);
}

.overlay-msg[hidden] {
  display: none;
}

.overlay-msg p {
  max-width: 520px;
  margin: 0;
  line-height: 1.5;
}

.sound-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.6);
  color: var(--fg);
  font-size: 0.75rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.sound-btn:hover {
  border-color: var(--accent);
}

/* ---------------- controles ---------------- */

.controls {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(0, 230, 162, 0.28);
  background: linear-gradient(180deg, rgba(0, 230, 162, 0.08), rgba(0, 230, 162, 0.02));
}

.controls[hidden] {
  display: none;
}

.controls-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.controls-head strong {
  color: var(--accent);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

.hint {
  font-size: 0.72rem;
  color: var(--muted);
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.76rem;
  color: var(--muted);
}

.keys span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: #171721;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.2;
}

.controls-note {
  margin: 10px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.8;
}

/* ---------------- panel ---------------- */

.panel {
  display: grid;
  gap: 14px;
}

.card {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #12121b, #0e0e16);
}

.card-kicker {
  margin: 0 0 8px;
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.card h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.turn-pill {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.turn-pill.hot {
  border-color: rgba(0, 230, 162, 0.4);
  color: var(--accent);
  background: rgba(0, 230, 162, 0.08);
}

.progress {
  height: 4px;
  border-radius: 999px;
  background: #1d1d29;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7af5ce);
  transition: width 0.95s linear;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.fine {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
  opacity: 0.85;
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a0a11;
  color: var(--fg);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: rgba(0, 230, 162, 0.6);
  box-shadow: 0 0 0 3px rgba(0, 230, 162, 0.1);
}

.btn {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #16161f;
  color: var(--fg);
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #1d1d29;
  border-color: #34344a;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, #00e6a2, #00c78c);
  border-color: transparent;
  color: #04120d;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #14f3b0, #00d697);
}

.btn.ghost {
  background: transparent;
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.queue {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.queue li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: #0c0c13;
  border: 1px solid transparent;
  font-size: 0.82rem;
  animation: slide-in 0.25s ease both;
}

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

.queue li.me {
  border-color: rgba(0, 230, 162, 0.35);
  background: rgba(0, 230, 162, 0.06);
}

.queue .pos {
  flex: none;
  width: 20px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.queue .who {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue .wait {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.queue .off {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.4;
}

.empty {
  margin: 8px 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.empty[hidden] {
  display: none;
}

.play-card,
#play-card {
  border-color: rgba(0, 230, 162, 0.3);
}

.foot {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 3vw, 36px) 28px;
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 12px;
}

@media (max-width: 640px) {
  .stats .stat:nth-child(3) {
    display: none;
  }
  .keys {
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
