/* Geist y Geist Mono (Vercel, licencia OFL: fonts/OFL-Geist.txt). Van en
   el zip porque Twitch no deja cargar fuentes de otros sitios. */
@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* styles.css — Panel y Config. El Overlay tiene su propio overlay.css.
   Tema "Marino langosta": fondo del mar azul profundo, coral de langosta
   como color principal, turquesa y dorado de apoyo. */

:root {
  --bg: #06121f;
  --bg-2: #0a1b2d;
  --surface: #0b2033;
  --surface-2: #11304a;
  --surface-3: #173c5c;
  --border: #1c4565;
  --text: #eaf4ff;
  --muted: #8fb0cc;
  --accent: #f26a4b;
  --accent-hover: #f7876c;
  --accent-soft: rgba(242, 106, 75, 0.16);
  --sea: #2ec4b6;
  --gold: #f4c463;
  --ok: #2ee6a6;
  --warn: #f4c463;
  --err: #ff5a6e;
  --code-bg: #041019;
  /* Radios: mas suaves en contenedores, mas firmes adentro */
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 5px;
  /* Sombras teñidas de azul marino (la luz viene de arriba) */
  --shadow: 0 8px 24px rgba(1, 10, 22, 0.55), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --shadow-sm: 0 3px 10px rgba(1, 10, 22, 0.4);
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Code", "Consolas", "Menlo", monospace;
  /* Colores por fase (iguales en overlay.css) */
  --ph-none: #5f7f9c;
  --ph-paused: #ff5a6e;
  --ph-publishing: #2ec4b6;
  --ph-voting: #f4c463;
  --ph-executing: #f26a4b;
  color-scheme: dark;
  /* Iconos usados desde CSS (Phosphor, MIT), como mascaras */
  --icon-info: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20256%20256%27%3E%3Cpath%20d%3D%27M108%2C84a16%2C16%2C0%2C1%2C1%2C16%2C16A16%2C16%2C0%2C0%2C1%2C108%2C84Zm128%2C44A108%2C108%2C0%2C1%2C1%2C128%2C20%2C108.12%2C108.12%2C0%2C0%2C1%2C236%2C128Zm-24%2C0a84%2C84%2C0%2C1%2C0-84%2C84A84.09%2C84.09%2C0%2C0%2C0%2C212%2C128Zm-72%2C36.68V132a20%2C20%2C0%2C0%2C0-20-20%2C12%2C12%2C0%2C0%2C0-4%2C23.32V168a20%2C20%2C0%2C0%2C0%2C20%2C20%2C12%2C12%2C0%2C0%2C0%2C4-23.32Z%27%2F%3E%3C%2Fsvg%3E");
  --icon-ok: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20256%20256%27%3E%3Cpath%20d%3D%27M176.49%2C95.51a12%2C12%2C0%2C0%2C1%2C0%2C17l-56%2C56a12%2C12%2C0%2C0%2C1-17%2C0l-24-24a12%2C12%2C0%2C1%2C1%2C17-17L112%2C143l47.51-47.52A12%2C12%2C0%2C0%2C1%2C176.49%2C95.51ZM236%2C128A108%2C108%2C0%2C1%2C1%2C128%2C20%2C108.12%2C108.12%2C0%2C0%2C1%2C236%2C128Zm-24%2C0a84%2C84%2C0%2C1%2C0-84%2C84A84.09%2C84.09%2C0%2C0%2C0%2C212%2C128Z%27%2F%3E%3C%2Fsvg%3E");
  --icon-err: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20256%20256%27%3E%3Cpath%20d%3D%27M128%2C20A108%2C108%2C0%2C1%2C0%2C236%2C128%2C108.12%2C108.12%2C0%2C0%2C0%2C128%2C20Zm0%2C192a84%2C84%2C0%2C1%2C1%2C84-84A84.09%2C84.09%2C0%2C0%2C1%2C128%2C212Zm-12-80V80a12%2C12%2C0%2C0%2C1%2C24%2C0v52a12%2C12%2C0%2C0%2C1-24%2C0Zm28%2C40a16%2C16%2C0%2C1%2C1-16-16A16%2C16%2C0%2C0%2C1%2C144%2C172Z%27%2F%3E%3C%2Fsvg%3E");
  --icon-warn: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20256%20256%27%3E%3Cpath%20d%3D%27M180%2C232a12%2C12%2C0%2C0%2C1-12%2C12H88a12%2C12%2C0%2C0%2C1%2C0-24h80A12%2C12%2C0%2C0%2C1%2C180%2C232Zm40-128a91.51%2C91.51%2C0%2C0%2C1-35.17%2C72.35A12.26%2C12.26%2C0%2C0%2C0%2C180%2C186v2a20%2C20%2C0%2C0%2C1-20%2C20H96a20%2C20%2C0%2C0%2C1-20-20v-2a12%2C12%2C0%2C0%2C0-4.7-9.51A91.57%2C91.57%2C0%2C0%2C1%2C36%2C104.52C35.73%2C54.69%2C76%2C13.2%2C125.79%2C12A92%2C92%2C0%2C0%2C1%2C220%2C104Zm-24%2C0a68%2C68%2C0%2C0%2C0-69.65-68C89.56%2C36.88%2C59.8%2C67.55%2C60%2C104.38a67.71%2C67.71%2C0%2C0%2C0%2C26.1%2C53.19A35.87%2C35.87%2C0%2C0%2C1%2C100%2C184h56.1A36.13%2C36.13%2C0%2C0%2C1%2C170%2C157.49%2C67.68%2C67.68%2C0%2C0%2C0%2C196%2C104Zm-20.07-5.32a48.5%2C48.5%2C0%2C0%2C0-31.91-40%2C12%2C12%2C0%2C0%2C0-8%2C22.62%2C24.31%2C24.31%2C0%2C0%2C1%2C16.09%2C20%2C12%2C12%2C0%2C0%2C0%2C23.86-2.64Z%27%2F%3E%3C%2Fsvg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20256%20256%27%3E%3Cpath%20d%3D%27M232.49%2C80.49l-128%2C128a12%2C12%2C0%2C0%2C1-17%2C0l-56-56a12%2C12%2C0%2C1%2C1%2C17-17L96%2C183%2C215.51%2C63.51a12%2C12%2C0%2C0%2C1%2C17%2C17Z%27%2F%3E%3C%2Fsvg%3E");
}

* { box-sizing: border-box; }

/* Iconos SVG (icons.js): heredan el color del texto */
.i { width: 1.15em; height: 1.15em; flex: none; fill: currentColor; vertical-align: -0.2em; }
button .i { margin-right: 6px; }
button { display: inline-flex; align-items: center; justify-content: center; }
.with-icon .i, summary .i, h3 .i, label .i, .pill .i, .me-chip .i, .save-bar .i, td .i { margin-right: 5px; }
.pill .i { width: 1.05em; height: 1.05em; margin-right: 4px; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  color: var(--text);
  font: 13px/1.5 var(--sans);
  font-weight: 450;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
html { background: var(--bg); }
/* Fondo del mar: degradado y unas burbujas quietas (sin animacion) */
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% 14%, rgba(255, 255, 255, 0.07) 0 5px, transparent 6px),
    radial-gradient(circle at 93% 22%, rgba(255, 255, 255, 0.05) 0 3px, transparent 4px),
    radial-gradient(circle at 8% 62%, rgba(255, 255, 255, 0.05) 0 4px, transparent 5px),
    radial-gradient(circle at 14% 70%, rgba(255, 255, 255, 0.04) 0 2px, transparent 3px),
    radial-gradient(ellipse at 50% -10%, rgba(46, 196, 182, 0.16), transparent 60%),
    radial-gradient(ellipse at 100% 110%, rgba(255, 107, 74, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  background-attachment: fixed;
}

/* Grano muy sutil para que el fondo no se vea plano */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.offline body::before {
  content: attr(data-offline); /* lo pone common.js, con la URL del servidor */
  overflow-wrap: anywhere;
  display: block;
  padding: 6px 10px;
  background: var(--err);
  color: #fff;
  font-weight: 600;
  text-align: center;
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; margin: 14px 0 6px; color: var(--accent-hover); }
p { margin: 6px 0; text-wrap: pretty; }
a { color: var(--accent-hover); }
strong { color: #fff; font-weight: 650; }
/* Numeros que cambian (tiempos, votos, contadores): ancho fijo */
.timer, .votes, #code-count, .round-card .small, td, .status-timer { font-variant-numeric: tabular-nums; }

code, pre, textarea.code { font-family: var(--mono); font-size: 12px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: var(--radius-xs); font-size: 0.92em; }
pre {
  margin: 6px 0 0;
  padding: 10px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
}

/* ---------------- Botones y campos ---------------- */

button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  touch-action: manipulation;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background-color 150ms, border-color 150ms, transform 80ms, box-shadow 150ms;
}
button:hover:not(:disabled) { border-color: #3c6a91; background: var(--surface-3); transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0) scale(0.98); }
button.primary {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(242, 106, 75, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #fa9d86, var(--accent-hover)); border-color: var(--accent-hover); box-shadow: 0 6px 18px rgba(242, 106, 75, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
button.danger { background: var(--err); border-color: var(--err); color: #fff; }
button.danger:hover:not(:disabled) { background: #ff7385; border-color: #ff7385; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}
.btn-big { width: 100%; padding: 11px 14px; font-size: 14px; }

input, textarea, select {
  font: inherit;
  width: 100%;
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color 150ms;
}
input:hover, select:hover { border-color: #2a5a80; }
select { background-color: var(--code-bg); color: var(--text); }
input::placeholder, textarea::placeholder { color: #4d6a85; }
textarea.code { resize: vertical; min-height: 150px; tab-size: 2; line-height: 1.5; }
label { font-weight: 600; }
.mt-xs { margin-top: 5px; }
.mt-sm { margin-top: 8px; }

/* ---------------- Editor (editor.js) ----------------
   Cuidado: la capa de colores (.hl) tiene que medir igual que el textarea.
   No usar negrita ni cursiva en los colores de Lua. */

.editor { position: relative; }
/* El borde va en .editor-body para que los numeros queden dentro de la caja */
.editor-body {
  display: flex;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
}
.editor-body:focus-within { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
.editor-body textarea.code {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 6px 8px;
  white-space: pre;
  overflow: auto;
}
.editor-body textarea.code:focus-visible { outline: none; }
/* Colores: el textarea queda encima con el texto transparente (se ve el
   cursor y la seleccion) y la capa .hl dibuja el mismo texto con colores. */
.code-area { position: relative; flex: 1; min-width: 0; display: flex; }
.code-area textarea.code { display: block; }
.editor-body textarea.code.hl-on { color: transparent; caret-color: var(--text); }
.editor-body textarea.code.hl-on::placeholder { color: #4d6a85; }
.editor-body textarea.code.hl-on::selection { color: transparent; background: rgba(255, 107, 74, 0.35); }
.hl {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  pointer-events: none;
  white-space: pre;
}
.hl code { display: inline-block; min-width: 100%; background: none; padding: 0; border-radius: 0; font: inherit; color: var(--text); }

/* Colores de Lua (como el tema oscuro de Visual Studio) */
.lua { color: var(--text); }
.lua .tk-comment { color: #6a9955; }
.lua .tk-string { color: #ce9178; }
.lua .tk-number { color: #b5cea8; }
.lua .tk-control { color: #c586c0; }
.lua .tk-keyword, .lua .tk-constant { color: #569cd6; }
.lua .tk-lobster { color: #ff8a65; }
.lua .tk-builtin { color: #4ec9b0; }
.lua .tk-call { color: #dcdcaa; }
.lua .tk-var, .lua .tk-prop { color: #9cdcfe; }
.lua .tk-op { color: #d4d4d4; }
.gutter {
  flex: none;
  overflow: hidden;
  padding: 6px 6px 6px 0; /* mismo padding vertical que el textarea */
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: #3f5f7c;
  background: rgba(17, 48, 74, 0.45);
  border-right: 1px solid var(--border);
  user-select: none;
}
.gutter .active { color: var(--text); }
.gutter .error { color: #fff; background: var(--err); border-radius: 0 3px 3px 0; margin-right: -6px; padding-right: 6px; font-weight: 700; }
.editor-body { position: relative; }
.editor-body .gutter, .editor-body textarea.code { position: relative; z-index: 1; }
.error-band {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(255, 90, 110, 0.16);
  border-top: 1px solid rgba(255, 90, 110, 0.35);
  border-bottom: 1px solid rgba(255, 90, 110, 0.35);
}
.ac {
  position: absolute;
  z-index: 10;
  margin: 0;
  padding: 4px;
  list-style: none;
  min-width: 170px;
  max-width: 100%;
  max-height: 172px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-family: var(--mono);
  font-size: 12px;
}
.ac li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.ac li:hover { background: var(--surface-3); }
.ac li[aria-selected="true"] { background: var(--accent); color: #fff; }
.ac li img { width: 16px; height: 16px; object-fit: contain; }
.ac .ac-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ac .ac-kind { font-family: system-ui, sans-serif; font-size: 10px; opacity: 0.7; }
.ac .ac-fn .ac-label { color: #ff8a65; }
.ac .ac-name .ac-label { color: var(--gold); }
.ac li[aria-selected="true"] .ac-label { color: #fff; }
.ac-help {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  padding: 6px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--muted);
  box-shadow: var(--shadow);
}

/* ---------------- Piezas comunes ---------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.publishing, .pill.voting, .pill.executing, .pill.paused { color: #06121f; }
.pill.publishing { background: var(--ph-publishing); }
.pill.voting { background: var(--ph-voting); }
.pill.executing { background: var(--ph-executing); color: #fff; }
.pill.paused { background: var(--ph-paused); color: #fff; }
.pill.soft { background: var(--surface-3); color: var(--text); font-weight: 600; border-radius: var(--radius-xs); }
.pill.gold { background: var(--gold); color: #3a2600; border-radius: var(--radius-xs); }

.muted { color: var(--muted); }
.small { font-size: 11px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

.notice {
  position: relative;
  padding: 9px 12px 9px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.notice::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 10px;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--icon-info) center / contain no-repeat;
  mask: var(--icon-info) center / contain no-repeat;
}
.notice.ok { border-color: rgba(46, 230, 166, 0.55); background: rgba(46, 230, 166, 0.10); color: #c6fbe7; }
.notice.ok::before { -webkit-mask-image: var(--icon-ok); mask-image: var(--icon-ok); background: var(--ok); }
.notice.err { border-color: rgba(255, 90, 110, 0.6); background: rgba(255, 90, 110, 0.10); color: #ffd0d6; }
.notice.err::before { -webkit-mask-image: var(--icon-err); mask-image: var(--icon-err); background: var(--err); }
.notice.warn { border-color: rgba(255, 200, 87, 0.6); background: rgba(255, 200, 87, 0.10); color: #ffe9b8; }
.notice.warn::before { -webkit-mask-image: var(--icon-warn); mask-image: var(--icon-warn); background: var(--warn); }
.notice:empty { display: none; }

.card {
  background: linear-gradient(180deg, rgba(23, 60, 92, 0.35), rgba(11, 32, 51, 0.6)), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 12px 13px;
  box-shadow: var(--shadow-sm);
}
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 6px 18px rgba(255, 107, 74, 0.2); }
.card.winner { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 6px 22px rgba(255, 200, 87, 0.22); }

details > summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; }
details > summary:hover { color: var(--text); }

/* Barra de progreso: --p de 0 a 1 (lo que ya paso de la fase) */
.progress {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress > span {
  position: absolute;
  inset: 0;
  transform-origin: left;
  transform: scaleX(calc(1 - var(--p, 0)));
  background: var(--phase-color, var(--accent));
  border-radius: inherit;
  transition: transform 1s linear;
}

/* Estado vacio: emoji grande + frase */
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.empty .icon { display: block; margin-bottom: 8px; color: #3c6a91; }
.empty .icon .i { width: 34px; height: 34px; }
.empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }

/* ---------------- Tarjeta de estado de la ronda (Panel y Config) ---------------- */

.round-card {
  --phase-color: var(--ph-none);
  border: 1px solid var(--border);
  border-left: 4px solid var(--phase-color);
  border-radius: var(--radius);
  padding: 9px 11px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--phase-color) 14%, transparent), transparent 70%), var(--surface);
  transition: border-color 300ms, background-color 300ms;
}
.round-card[data-phase="paused"] { --phase-color: var(--ph-paused); }
.round-card[data-phase="publishing"] { --phase-color: var(--ph-publishing); }
.round-card[data-phase="voting"] { --phase-color: var(--ph-voting); }
.round-card[data-phase="executing"] { --phase-color: var(--ph-executing); }
.round-card .round-top { display: flex; align-items: center; gap: 8px; }
.round-card .timer { margin-left: auto; font-family: var(--mono); font-weight: 700; font-size: 16px; color: var(--phase-color); }
.round-card .progress { margin-top: 7px; }

/* Pasos 1 Escribe, 2 Vota, 3 Mira */
.steps { display: flex; gap: 4px; margin: 0 0 8px; padding: 0; list-style: none; }
.steps li {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 2px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  transition: background-color 250ms, color 250ms;
}
.steps .num {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font-size: 10px;
  background: var(--surface-3);
  color: var(--text);
}
.steps li.active { color: #06121f; background: var(--phase-color); }
.steps li.active .num { background: rgba(0, 0, 0, 0.18); color: #06121f; }
.round-card[data-phase="executing"] .steps li.active,
.round-card[data-phase="executing"] .steps li.active .num { color: #fff; }
.steps li.done { color: var(--ok); }
.steps li.done .num { background: rgba(46, 230, 166, 0.2); color: var(--ok); font-size: 0; }
.steps li.done .num::before {
  content: "";
  width: 10px;
  height: 10px;
  background: currentColor;
  -webkit-mask: var(--icon-check) center / contain no-repeat;
  mask: var(--icon-check) center / contain no-repeat;
}

/* "Que hago ahora?" */
.next-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  line-height: 1.35;
}
.next-step .icon { display: inline-flex; color: var(--phase-color, var(--accent)); }
.next-step .icon .i { width: 17px; height: 17px; vertical-align: 0; }
.next-step:empty { display: none; }

/* ---------------- Panel ---------------- */

.panel { max-width: 318px; margin: 0 auto; display: flex; flex-direction: column; min-height: 100vh; }
.panel header { padding: 10px 10px 8px; }
.panel header .title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.brand .logo {
  display: grid;
  place-items: center;
  font-size: 16px; /* mismo tamano que el titulo */
  color: var(--accent);
}
.brand .logo .i { width: 1.25em; height: 1.25em; vertical-align: 0; }
.panel header h1 { font-size: 16px; font-weight: 750; letter-spacing: -0.03em; }
.panel header h1 .dot { color: var(--accent); }
.me-chip {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
}
.me-chip.known { color: var(--text); }

/* Solo las pestanas quedan fijas arriba (el panel de Twitch mide 500 px) */
.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 2px;
  padding: 4px 4px 0;
  background: rgba(6, 18, 31, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.tabs button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
  background: none;
  color: var(--muted);
  padding: 6px 2px 5px;
  font-size: 11px;
  position: relative;
}
.tabs button .ico { width: 18px; height: 18px; margin: 0 0 1px; }
.tabs button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.04); }
.tabs button[aria-selected="true"] { color: #fff; border-bottom-color: var(--accent); background: var(--accent-soft); }
.tabs .badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 6px);
  min-width: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.panel main { padding: 12px 10px 16px; flex: 1; }
.section-title { display: flex; align-items: center; gap: 8px; }
.section-title h2 { flex: 1; }
.hint-row { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); }
.kbd { font-family: var(--mono); font-size: 10px; padding: 0 4px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.chip-select { width: auto; padding: 4px 8px; font-size: 12px; border-radius: 999px; background: var(--surface-2); }

/* Tarjetas de codigos (votar, mod) */
.sub-head { display: flex; gap: 8px; align-items: center; }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #06121f;
  background: hsl(var(--hue, 200) 70% 65%);
}
.sub-head .author { min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-comment { margin: 8px 0; font-size: 13.5px; line-height: 1.4; }
.votes { font-family: var(--mono); font-weight: 800; color: var(--gold); white-space: nowrap; }
.vote-bar { margin-top: 8px; }
.vote-bar .progress > span { transform: scaleX(var(--p, 0)); background: var(--gold); transition: transform 600ms ease-out; }
.vote-btn { margin-top: 10px; width: 100%; }

/* Resultado */
.result-hero { text-align: center; padding: 16px 12px; }
.result-hero .trophy { color: var(--gold); line-height: 1; }
.result-hero .trophy .i { width: 44px; height: 44px; }
.result-hero .trophy.fail { color: var(--muted); }
.result-hero .who { margin-top: 6px; font-size: 20px; font-weight: 750; letter-spacing: -0.02em; color: #fff; overflow-wrap: anywhere; }
.result-hero .what { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.result-hero .meta { margin-top: 8px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* Ayuda */
.guide { display: grid; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.guide li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.guide .icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-hover); }
.guide .icon .i { width: 18px; height: 18px; }
.guide strong { display: block; }
.help-section {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.help-section > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  list-style: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 650;
}
.help-section > summary::-webkit-details-marker { display: none; }
.help-section > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform 200ms; }
.help-section[open] > summary::after { transform: rotate(180deg); }
.help-section[open] > summary { border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.03); }
.help-body { padding: 4px 12px 12px; }
.help-body ul, .help-body ol { padding-left: 18px; margin: 6px 0; }
.help-body li { margin: 3px 0; }

.fn-list { list-style: none; margin: 0; padding: 0; }
.fn-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.fn-list li:last-child { border-bottom: none; }
.fn-list .sig { font-family: var(--mono); font-weight: 700; }
.fn-list button { padding: 1px 8px; font-size: 12px; margin-left: 4px; border-radius: 999px; }
.fn-list .off { opacity: 0.45; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips code { font-size: 11px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; }
.chips .pose-thumb { width: 20px; height: 20px; object-fit: contain; }
.easing-list { list-style: none; margin: 6px 0; padding: 0; }
.easing-list li { padding: 3px 0; font-size: 12px; }

/* ---------------- Dialogo propio (common.js: ask) ---------------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 8, 16, 0.7);
  backdrop-filter: blur(3px);
  overscroll-behavior: contain;
}
.dialog {
  width: min(360px, 100%);
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 18px 44px rgba(1, 10, 22, 0.7);
}
.dialog-text { margin: 0 0 14px; white-space: pre-wrap; font-size: 14px; }
.dialog-input { margin: 0 0 12px; }
.dialog-buttons { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------- Panel: pestana Moderar ---------------- */

.switch-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(46, 230, 166, 0.45);
  background: rgba(46, 230, 166, 0.08);
}
/* Punto de estado: verde = activa, rojo = pausada */
.status-dot { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(46, 230, 166, 0.18), 0 0 12px rgba(46, 230, 166, 0.6); }
.status-dot.off { background: var(--err); box-shadow: 0 0 0 4px rgba(255, 90, 110, 0.18), 0 0 12px rgba(255, 90, 110, 0.5); }
.switch-card .text { flex: 1; min-width: 0; }
.switch-card strong { display: block; font-size: 14px; font-weight: 700; }
.switch-card.on { border-color: rgba(255, 90, 110, 0.6); background: rgba(255, 90, 110, 0.1); }
.mod-kill { display: flex; flex-direction: column; gap: 4px; }
.mod-kill button { width: 100%; margin-top: 4px; }
.mod-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mod-actions button { width: 100%; padding: 8px 6px; white-space: nowrap; font-size: 12.5px; }
.mod-actions .wide { grid-column: 1 / -1; }
.mod-sub pre { max-height: 200px; overflow: auto; }

/* ---------------- Config ---------------- */

.config { max-width: 1040px; margin: 0 auto; padding: 18px 16px 90px; }
.config > header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.config > header .brand .logo { font-size: 24px; }
.config > header h1 { font-size: 24px; font-weight: 750; letter-spacing: -0.03em; }
.config > header .subtitle { color: var(--muted); font-size: 12px; font-weight: 500; }
.config .round-card { flex: 1 1 320px; max-width: 440px; }
.config .card h2 { margin-bottom: 4px; }
.sec-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 4px; }
.sec-title .num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.sec-title h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; flex: 1; }
.sec-desc { margin: 0 0 12px 36px; max-width: 68ch; color: var(--muted); }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.field { display: grid; grid-template-columns: 1fr 96px; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(28, 69, 101, 0.6); }
.field:last-of-type { border-bottom: none; }
.field .hint { grid-column: 1 / -1; }
.field .human { grid-column: 1 / -1; font-size: 11px; color: var(--sea); font-weight: 700; }
.card-sub { margin: 0 0 8px; color: var(--muted); font-size: 12px; }

/* Listas de "Que puede usar el chat": mosaicos que se prenden y apagan */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; margin-bottom: 12px; }
.checks > span { grid-column: 1 / -1; }
.checks label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
  overflow: hidden;
  transition: border-color 150ms, background-color 150ms, opacity 150ms;
}
.checks label:hover { border-color: var(--muted); }
.checks label:has(input:checked) { border-color: rgba(46, 230, 166, 0.55); background: rgba(46, 230, 166, 0.09); }
.checks label:not(:has(input:checked)) { opacity: 0.6; }
.checks label:has(input:disabled) { cursor: default; }
.checks input { width: 16px; height: 16px; flex: none; accent-color: var(--ok); }
.checks .thumb { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: var(--code-bg); flex: none; }
.checks .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.checks .tag { font-size: 10px; color: var(--sea); }
.checks .play { padding: 2px 8px; font-size: 11px; border-radius: 999px; }
.checks .lock { display: inline-flex; color: var(--muted); }
.list-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; }
.list-head h3 { margin: 0; flex: 1; }

.sub-row { display: flex; gap: 10px; align-items: flex-start; }
.sub-row > button { flex: none; }
.sub-row pre { max-height: 260px; overflow: auto; }

/* Interruptor grande de pausa */
.kill {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(46, 230, 166, 0.45);
  background: linear-gradient(90deg, rgba(46, 230, 166, 0.12), transparent 70%), var(--surface);
  box-shadow: var(--shadow-sm);
}
.kill .status-dot { width: 16px; height: 16px; margin: 0 4px; }
.kill.on { border-color: rgba(255, 90, 110, 0.6); background: linear-gradient(90deg, rgba(255, 90, 110, 0.16), transparent 70%), var(--surface); }
.kill .grow strong { display: block; font-size: 16px; font-weight: 700; }

/* Barra fija de guardado */
.save-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 20;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(560px, calc(100% - 24px));
  padding: 10px 12px 10px 16px;
  border-radius: 999px;
  background: rgba(11, 32, 51, 0.95);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  transition: border-color 200ms, box-shadow 200ms;
}
.save-bar .state { flex: 1; font-weight: 600; color: var(--muted); }
.save-bar.dirty { border-color: var(--gold); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--gold); }
.save-bar.dirty .state { color: var(--gold); }
.save-bar button { border-radius: 999px; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: rgba(255, 255, 255, 0.03); }
tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
td.ok { color: var(--ok); }
td.err { color: var(--err); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 8px; }
.table-wrap table tr:last-child td { border-bottom: none; }

@media (max-width: 560px) {
  .config { padding: 12px 10px 90px; }
  .config > header h1 { font-size: 18px; }
  .config .round-card { max-width: none; }
  .field { grid-template-columns: 1fr 84px; }
  .sec-desc { margin-left: 0; }
  .kill { flex-wrap: wrap; }
  .kill button { width: 100%; }
}

/* Animaciones solo de interfaz: fuera si el sistema pide menos movimiento */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel main > section:not([hidden]) { animation: rise 220ms ease-out; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================================================================
   Tema oscuro tipo Google (Material dark). Va al final y cambia los
   colores del tema marino de arriba: grises neutros (#202124 / #303134),
   texto #e8eaed, azul #8ab4f8 como color principal y superficies planas
   (sin degradados ni brillos). Colores por fase: azul publicando,
   amarillo votando, verde en escena, rojo pausado (iguales en overlay.css).
   ================================================================ */
html:root {
  --bg: #202124;
  --bg-2: #202124;
  --surface: #28292c;
  --surface-2: #303134;
  --surface-3: #3c4043;
  --border: #3c4043;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #8ab4f8;
  --accent-hover: #aecbfa;
  --accent-soft: rgba(138, 180, 248, 0.16);
  --sea: #81c995;
  --gold: #fdd663;
  --ok: #81c995;
  --warn: #fdd663;
  --err: #f28b82;
  --code-bg: #1b1c1e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 8px 3px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --ph-none: #5f6368;
  --ph-paused: #f28b82;
  --ph-publishing: #8ab4f8;
  --ph-voting: #fdd663;
  --ph-executing: #81c995;
  color-scheme: dark;
}

/* Fondo plano (solo Panel y Config: el overlay sigue transparente) */
html:root body:has(.panel),
html:root body:has(.config) { background: var(--bg); }
html:root body::after { display: none; }

/* Superficies planas, sin degradados ni brillos */
html:root .card { background: var(--surface); box-shadow: none; }
html:root .card.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
html:root .card.winner { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
html:root .round-card { background: var(--surface); }
html:root .kill { background: var(--surface); box-shadow: none; border-color: var(--border); }
html:root .kill.on { background: var(--surface); border-color: var(--err); }
html:root .switch-card { background: var(--surface); border-color: var(--border); }
html:root .switch-card.on { border-color: var(--err); }
html:root .status-dot { box-shadow: none; }
html:root .tabs { background: var(--bg); backdrop-filter: none; }
html:root .save-bar { background: var(--surface-2); backdrop-filter: none; box-shadow: var(--shadow); }
html:root .save-bar.dirty { box-shadow: var(--shadow); }
html:root .dialog-backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: none; }
html:root .dialog { background: var(--surface-2); box-shadow: var(--shadow); }
html:root .editor-body { box-shadow: none; }
html:root .gutter { color: #5f6368; background: var(--surface); }
html:root .next-step,
html:root .steps li:not(.active) { background: var(--surface-2); }
html:root .empty .icon { color: #5f6368; }
html:root button:hover:not(:disabled) { border-color: #5f6368; transform: none; }
html:root input:hover,
html:root select:hover { border-color: #5f6368; }
html:root input::placeholder,
html:root textarea::placeholder,
html:root .editor-body textarea.code.hl-on::placeholder { color: #80868b; }
html:root .field { border-bottom-color: var(--border); }

/* Boton principal: azul de Google plano, texto oscuro */
html:root button.primary { background: var(--accent); border-color: var(--accent); color: #202124; box-shadow: none; }
html:root button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: none; }
html:root button.danger { background: var(--err); border-color: var(--err); color: #202124; }
html:root button.danger:hover:not(:disabled) { background: #f6aea9; border-color: #f6aea9; }
html:root .ac li[aria-selected="true"] { background: var(--accent); color: #202124; }
html:root .ac li[aria-selected="true"] .ac-label { color: #202124; }
html:root .tabs .badge { background: var(--accent); color: #202124; }
html:root .tabs button[aria-selected="true"] { color: var(--accent); }
html:root .brand .logo { color: var(--accent); }

/* Etiquetas de fase: texto oscuro sobre el color (estilo Material) */
html:root .pill.executing,
html:root .pill.paused { color: #202124; }
html:root .round-card[data-phase="executing"] .steps li.active,
html:root .round-card[data-phase="executing"] .steps li.active .num { color: #202124; }
html:root .steps li.active { color: #202124; }

/* Avisos */
html:root .notice { background: var(--surface-2); }
html:root .notice.ok { color: #ceead6; background: rgba(129, 201, 149, 0.12); border-color: rgba(129, 201, 149, 0.45); }
html:root .notice.err { color: #fad2cf; background: rgba(242, 139, 130, 0.12); border-color: rgba(242, 139, 130, 0.45); }
html:root .notice.warn { color: #feefc3; background: rgba(253, 214, 99, 0.1); border-color: rgba(253, 214, 99, 0.45); }
