:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #05070a;
  color: #f8fafc;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(circle at 20% 0%, rgba(244, 185, 66, .16), transparent 32rem),
    linear-gradient(145deg, #111923, #05070a 60%);
}

main { width: min(100%, 1440px); margin: 0 auto; padding: 18px; }

.cabecera { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.cabecera h1 { margin: 2px 0 0; font-size: clamp(1.35rem, 3vw, 2.25rem); }
.etiqueta { margin: 0; color: #f4b942; font-size: .74rem; font-weight: 800; letter-spacing: .14em; }
.acciones { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

button {
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 10px;
  padding: 10px 14px;
  background: #b62a22;
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

#escenas,
#sonido,
#pantalla-completa { background: #283544; }
button:disabled { cursor: wait; opacity: .55; }
button:hover, button:focus-visible { outline: 3px solid #f4b942; outline-offset: 2px; }

.marco {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 18px;
  background: #05070a;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .45);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #05070a;
  touch-action: none;
  user-select: none;
}

canvas:focus-visible { outline: 4px solid #f4b942; outline-offset: -4px; }

#estado {
  position: absolute;
  inset: auto 12px 12px auto;
  margin: 0;
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(5, 7, 10, .82);
  color: #dbe4ee;
  font-size: .78rem;
  pointer-events: none;
}

.ayuda { display: flex; flex-wrap: wrap; gap: 8px 24px; color: #b8c3cf; font-size: .88rem; }
.ayuda p { margin: 13px 0 0; }

#selector-escenas {
  width: min(92vw, 760px);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 20px;
  padding: 0;
  background: #111923;
  color: #f8fafc;
  box-shadow: 0 30px 100px rgba(0, 0, 0, .72);
}

#selector-escenas::backdrop {
  background: rgba(2, 5, 8, .84);
  backdrop-filter: blur(6px);
}

.selector-escenas-panel { padding: 24px; }
.selector-escenas-cabecera { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.selector-escenas-cabecera h2 { margin: 3px 0 0; font-size: clamp(1.55rem, 4vw, 2.25rem); }
.selector-escenas-ayuda { margin: 12px 0 20px; color: #b8c3cf; }
.cerrar-selector { min-width: 44px; min-height: 44px; padding: 2px 12px 7px; background: #283544; font-size: 1.9rem; line-height: 1; }
.selector-escenas-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.selector-escenas-grid button {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(145deg, #253547, #19232e);
  text-align: left;
  font-size: 1.05rem;
}
.selector-escenas-grid button:last-child { grid-column: 2; }
.selector-escenas-grid span { color: #f4b942; font-size: .78rem; letter-spacing: .12em; }

canvas:fullscreen { width: 100vw; height: 100vh; object-fit: contain; background: black; }

@media (max-width: 680px) {
  main { padding: 10px; }
  .cabecera { align-items: flex-start; }
  .acciones { max-width: 11rem; }
  button { padding: 8px 10px; font-size: .78rem; }
  .ayuda { display: block; }
  .selector-escenas-panel { padding: 18px; }
  .selector-escenas-grid { grid-template-columns: repeat(2, 1fr); }
  .selector-escenas-grid button:last-child { grid-column: auto; }
}

@media (orientation: landscape) and (max-height: 620px) {
  main { width: 100%; padding: 0; }
  .cabecera, .ayuda { display: none; }
  .marco { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 0; background: black; }
  canvas { width: min(100vw, 177.778vh); height: auto; object-fit: fill; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
