:root {
  --bg: #0d0b1a;
  --panel: #17142b;
  --panel-2: #211d3b;
  --line: #2f2a52;
  --text: #f2f0ff;
  --muted: #a7a2c8;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --danger: #ff4d6d;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #2a1f6b55, transparent),
              radial-gradient(900px 500px at 110% 110%, #0e6b7a44, transparent), var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); }
[hidden] { display: none !important; }

/* ---------- Botones ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, background .2s ease, opacity .2s ease;
}
.btn:hover:not(:disabled) { background: #2b2650; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5b8cff); border-color: transparent; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #8d70ff, #6b98ff); }
.btn-danger { background: transparent; border-color: #ff4d6d88; color: #ff8fa3; }
.btn-danger:hover:not(:disabled) { background: #ff4d6d22; }
.btn-big { width: 100%; padding: 16px; font-size: 1.1rem; border-radius: 14px; }
.btn.icon { min-width: 44px; padding: 10px; }
.btn.icon[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
#subsBtn[aria-pressed="true"] { background: var(--accent-2); color: #04212a; border-color: transparent; }
kbd { font: 600 .7rem/1 system-ui; padding: 3px 5px; border-radius: 5px; background: #ffffff22; }

/* ---------- Portada ---------- */
.home { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 20px; }
.home-card {
  width: 100%; max-width: 460px; background: #17142bcc; border: 1px solid var(--line);
  border-radius: 24px; padding: 28px 24px; backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px #0008;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.brand b { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
h1 { font-size: clamp(1.6rem, 5vw, 2.1rem); line-height: 1.15; margin: 18px 0 8px; letter-spacing: -.02em; }
.lead { color: var(--muted); margin: 0 0 16px; }
.perks { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; }
.perks li { padding-left: 28px; position: relative; }
.perks li::before { content: "✓"; position: absolute; left: 0; color: var(--accent-2); font-weight: 800; }
.field { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 600; }
select, input[type=text], #chatInput {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%;
}
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.home-card .btn-big { margin-top: 12px; }
.small { font-size: .85rem; color: var(--muted); margin: 10px 0 0; }
.online { text-align: center; color: var(--accent-2); font-weight: 600; margin: 12px 0 0; }
.foot { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; font-size: .85rem; }
.foot a { color: var(--muted); }

/* ---------- Sala ---------- */
.room {
  height: 100dvh; display: grid; gap: 12px; padding: 12px;
  grid-template-columns: 1fr 340px; grid-template-rows: 1fr auto;
  grid-template-areas: "stage chat" "controls chat";
}
.stage { grid-area: stage; position: relative; min-height: 0; }
.remote-wrap { position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
#remote { width: 100%; height: 100%; object-fit: cover; filter: blur(28px); transform: scale(1.1); transition: filter .4s ease, transform .4s ease; }
#remote.revealed { filter: none; transform: none; }
.curtain { position: absolute; inset: 0; display: grid; place-items: center; background: #0d0b1a99; text-align: center; padding: 16px; }
.curtain-box { max-width: 360px; display: grid; gap: 12px; justify-items: center; }
.status { font-size: 1.15rem; font-weight: 600; }
.status:not(:empty)::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent-2); margin-right: 10px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.peer-tag { position: absolute; top: 12px; left: 12px; background: #000a; padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.subs {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: 90%;
  background: #000c; padding: 8px 14px; border-radius: 10px; font-size: 1.1rem; text-align: center;
}
.subs:empty { display: none; }
.subs.interim { opacity: .6; font-style: italic; }
.local {
  position: absolute; right: 12px; bottom: 12px; width: 22%; min-width: 110px; max-width: 240px; aspect-ratio: 4/3;
  object-fit: cover; border-radius: 12px; border: 2px solid #ffffff33; background: #000; transform: scaleX(-1); z-index: 2;
}
.controls { grid-area: controls; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls #next { flex: 1 1 160px; }
.online-room { color: var(--muted); font-size: .85rem; margin-left: auto; }
.online-room:empty { display: none; }

.chat { grid-area: chat; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--panel-2); padding: 8px 12px; border-radius: 12px; max-width: 92%; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: #3a2f80; }
.msg b { display: block; font-size: .75rem; color: var(--muted); }
.msg i { color: var(--muted); font-size: .8rem; }
.orig { background: none; border: 0; color: var(--accent-2); font-size: .75rem; padding: 2px 0 0; cursor: pointer; display: block; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
#chatInput { min-width: 0; }

/* ---------- Diálogo y avisos ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px);
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px #0008;
}

/* ---------- Móvil ---------- */
@media (max-width: 820px) {
  .room {
    grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto 34dvh;
    grid-template-areas: "stage" "controls" "chat"; padding: 8px; gap: 8px;
  }
  .controls .btn { padding: 8px 12px; }
  .controls kbd, .online-room { display: none; }
  .local { width: 30%; }
}

/* ---------- Páginas legales ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }
.legal h1 { font-size: 1.8rem; }
.legal h2 { font-size: 1.2rem; margin-top: 28px; }
.legal .pending { background: #ffcc0022; border: 1px dashed #ffcc00aa; padding: 2px 6px; border-radius: 6px; }
.legal .back { display: inline-block; margin-bottom: 16px; }

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

/* ---------- Intereses y país ---------- */
.prefs { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; background: #0d0b1a66; }
.prefs summary { cursor: pointer; font-weight: 600; min-height: 28px; }
.prefs[open] summary { margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.chip {
  font: inherit; font-size: .9rem; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; min-height: 36px;
}
.chip[aria-pressed="true"] { background: linear-gradient(135deg, var(--accent), #5b8cff); border-color: transparent; }

/* ---------- Moderación, escribiendo, cámara trasera ---------- */
.mod-warn { display: grid; gap: 10px; justify-items: center; }
.mod-warn p { margin: 0; font-weight: 600; }
.mod-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.typing { padding: 0 14px 6px; font-size: .8rem; color: var(--muted); font-style: italic; }
.local.rear { transform: none; }
.peer-tag { max-width: calc(100% - 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 360px) { .two { grid-template-columns: 1fr; } }

/* ---------- Premium ---------- */
.grad { background: linear-gradient(90deg, #ffd166, #ff8fa3); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-card .back { display: inline-block; margin-bottom: 8px; color: var(--muted); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 6px; }
.plan {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 12px; cursor: pointer; display: grid; gap: 2px; justify-items: center; position: relative;
}
.plan b { font-size: 1.6rem; }
.plan span { color: var(--muted); font-size: .9rem; }
.plan em { position: absolute; top: -10px; font-style: normal; font-size: .7rem; font-weight: 700; background: #ffd166; color: #2b1d00; padding: 2px 8px; border-radius: 999px; }
.plan.best { border-color: #ffd166aa; }
.plan:disabled { opacity: .45; cursor: not-allowed; }
.notice { border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: var(--panel-2); border: 1px solid var(--line); }
.notice.ok { border-color: #22d3ee88; }
.notice.error { border-color: #ff4d6d88; color: #ffb3c1; }

/* ---------- Instalar como app ---------- */
.install-btn { margin-top: 12px; background: transparent; border-color: #22d3ee88; color: #9ee8f5; }
.ios-steps { padding-left: 0; list-style: none; display: grid; gap: 12px; margin: 12px 0; }
.ios-steps li { display: flex; gap: 10px; align-items: flex-start; }
.ios-icon { font-size: 1.3rem; line-height: 1.2; }
