:root {
  --bg: #0d0f17; --panel: #151927; --panel2: #1c2133; --line: #2a3048; --text: #e8ebf5; --muted: #8b93ad;
  --primary: #6c5ce7; --primary2: #8e7ff0; --ok: #2ecc71; --warn: #f39c12; --err: #e74c3c; --accent: #ffd460;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--primary2); cursor: pointer; }
code { background: #0008; padding: 1px 5px; border-radius: 4px; }
button { font: inherit; color: inherit; border: 1px solid var(--line); background: var(--panel2); padding: 8px 14px; border-radius: 9px; cursor: pointer; }
button:hover { border-color: var(--primary2); }
button:disabled { opacity: .5; cursor: wait; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 4px 9px; font-size: 12px; }
button.danger { border-color: var(--err); color: var(--err); background: transparent; }
input, select, textarea { font: inherit; color: var(--text); background: #0b0e16; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
input[type=color] { padding: 2px; height: 36px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.error { color: var(--err); }
.muted { color: var(--muted); font-size: 12.5px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }

.login { display: grid; place-items: center; height: 100%; }
.login .card { width: min(380px, 92vw); display: grid; gap: 12px; }
.login h1 { margin: 0; }

.app { display: grid; grid-template-columns: 250px minmax(0, 1fr) auto; grid-template-rows: 54px minmax(0, 1fr); grid-template-areas: "top top top" "side main prev"; height: 100%; }
body.side-hidden .app { grid-template-columns: 0 minmax(0, 1fr) auto; }
body.side-hidden .side { visibility: hidden; padding: 0; border: 0; }
.side { grid-area: side; background: var(--panel); border-right: 1px solid var(--line); padding: 10px 10px 14px; display: flex; flex-direction: column; gap: 2px; overflow: auto; min-height: 0; }
.main { grid-area: main; }
.preview { grid-area: prev; }
.brand { font-size: 17px; font-weight: 700; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Barra superior: menú, marca, buscador, nuevo juego, idioma y cuenta */
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 30; min-width: 0; }
.topbar .brand { flex: 0 1 auto; max-width: 230px; }
.icon-btn { background: transparent; border: 1px solid transparent; font-size: 18px; line-height: 1; padding: 7px 10px; }
.icon-btn:hover { background: var(--panel2); border-color: var(--line); }
.search-btn { flex: 1 1 auto; max-width: 460px; margin: 0 auto; display: flex; align-items: center; gap: 8px; text-align: left; background: #0b0e16; color: var(--muted); padding: 7px 12px; min-width: 0; }
.search-btn .search-txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd { font: 11px ui-monospace, Menlo, monospace; background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.top-new { white-space: nowrap; padding: 7px 12px; font-size: 13px; }
.top-btn { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.top-btn .caret { font-size: 10px; color: var(--muted); }
.pop-wrap { position: relative; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 14px 40px #000a; z-index: 50; display: grid; gap: 2px; }
.pop-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px 8px 4px; }
.pop-item { text-align: left; border: 1px solid transparent; background: transparent; padding: 8px 10px; border-radius: 8px; }
.pop-item:hover { background: var(--panel2); }
.pop-item.on { border-color: var(--primary2); background: color-mix(in srgb, var(--primary) 18%, transparent); }
.pop-acct { padding: 10px; gap: 10px; }
.pop-acct .side-foot { margin: 0; padding: 0; display: grid; gap: 4px; }

/* Barra lateral: filtro de juegos */
.side-games-head { display: flex; align-items: center; }
.game-filter { margin: 2px 0 4px; padding: 6px 10px; font-size: 13px; }
.gl-group.filtering .gl-items { display: block !important; }
.side nav a[hidden] { display: none; }

/* Buscador rápido (Ctrl+K) */
.palette-wrap { position: fixed; inset: 0; z-index: 200; background: #05070dcc; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 14px 14px; }
.palette { width: min(620px, 100%); max-height: 72vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 70px #000c; overflow: hidden; }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 16px; font-size: 16px; background: transparent; }
.palette input:focus { outline: none; }
.pal-list { overflow: auto; padding: 6px; display: grid; gap: 2px; }
.pal-item { display: grid; grid-template-columns: 78px 1fr; align-items: center; column-gap: 10px; text-align: left; border: 1px solid transparent; background: transparent; padding: 8px 10px; border-radius: 9px; }
.pal-item small { grid-column: 2; color: var(--muted); font-size: 11.5px; }
.pal-item.on { background: color-mix(in srgb, var(--primary) 22%, transparent); border-color: var(--primary2); }
.pal-kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); grid-row: span 2; }
.pal-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-foot { border-top: 1px solid var(--line); padding: 8px 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.side-backdrop { display: none; }
.side-section { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 12px 8px 4px; }
.side nav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.side nav a:hover, .side nav a.on { background: var(--panel2); }
.side nav a small { display: block; color: var(--muted); font-size: 11px; }
.side-foot { margin-top: auto; font-size: 11.5px; color: var(--muted); padding: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--err); }
.dot.ok { background: var(--ok); }

.main { overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; }
.bar h1 { margin: 0; font-size: 19px; }
.bar-actions { display: flex; gap: 8px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); margin-right: 6px; }
.badge.warn { border-color: var(--warn); color: var(--warn); }
.badge.ok { border-color: var(--ok); color: var(--ok); }
.tabs { display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; white-space: nowrap; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--primary2); }
.view { padding: 20px; flex: 1; }

.preview { width: min(560px, 42vw); border-left: 1px solid var(--line); display: flex; flex-direction: column; background: #000; }
.preview-bar { display: flex; gap: 6px; align-items: center; padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 12.5px; }
.preview-bar .pv-title { flex: 1; color: var(--muted); }
.preview iframe { flex: 1; border: 0; width: 100%; }

/* Agentes */
.chat { display: grid; grid-template-rows: 1fr auto; height: calc(100vh - 170px); min-height: 420px; gap: 12px; }
.log { overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.msg { padding: 10px 13px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); max-width: 92%; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--primary); border-color: var(--primary); color: #fff; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.msg.user .who { color: #fffc; }
.evt { font-size: 12px; color: var(--muted); padding: 2px 6px; }
.evt b { color: var(--text); font-weight: 600; }
.evt.err { color: var(--err); }
.evt.agent { color: var(--accent); padding-top: 8px; }
.asset-inline { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); padding: 6px; border-radius: 10px; max-width: 420px; }
.asset-inline img { width: 72px; height: 72px; object-fit: contain; background: repeating-conic-gradient(#222 0 25%, #333 0 50%) 0 0/16px 16px; border-radius: 6px; }
.composer { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; align-items: end; }
.composer textarea { font-family: inherit; font-size: 14px; resize: vertical; min-height: 46px; }
.suggestions { display: flex; gap: 6px; flex-wrap: wrap; }
.suggestions button { font-size: 12px; padding: 5px 10px; border-radius: 99px; }
.runs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }

/* Símbolos / assets */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
td img.sym { width: 54px; height: 54px; object-fit: contain; cursor: pointer; border-radius: 8px; background: #0006; }
td input { padding: 5px 7px; }
.pays { display: flex; gap: 4px; } .pays input { width: 76px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; font-size: 11.5px; display: flex; flex-direction: column; gap: 6px; }
.tile img { width: 100%; aspect-ratio: 1; object-fit: contain; background: repeating-conic-gradient(#1a1a1a 0 25%, #262626 0 50%) 0 0/16px 16px; border-radius: 8px; }
.tile audio { width: 100%; height: 32px; }
.tile .p { color: var(--muted); max-height: 3.2em; overflow: hidden; }
.picker { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; z-index: 50; padding: 20px; }
.picker .card { width: min(900px, 96vw); max-height: 86vh; overflow: auto; }
.picker .tile { cursor: pointer; } .picker .tile:hover { border-color: var(--primary2); }

.kpi { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kpi div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.kpi small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.kpi b { font-size: 20px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; z-index: 99; max-width: 90vw; }
.toast.err { border-color: var(--err); }
.secret { background: #0b0e16; border: 1px dashed var(--warn); padding: 10px; border-radius: 8px; word-break: break-all; font-family: ui-monospace, monospace; }

@media (max-width: 1100px) {
  /* Celular y tablet: una sola columna que scrollea entera */
  html, body { height: auto; }
  .app { display: block; height: auto; min-height: 100vh; }
  .main { overflow: visible; }
  /* La barra lateral es un cajón que se abre con ☰ */
  .topbar { position: sticky; top: 0; height: 54px; }
  .side { position: fixed; top: 54px; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 8px 0 30px #000a; visibility: visible !important; }
  body.side-open .side { transform: none; }
  body.side-open { overflow: hidden; }
  .side-backdrop { display: block; position: fixed; inset: 54px 0 0; background: #0009; z-index: 35; }
  /* El encabezado del juego ya no queda fijo (tapaba las pestañas); las pestañas sí quedan fijas arriba */
  .bar { position: static; flex-wrap: wrap; padding: 12px 14px; }
  .bar h1 { font-size: 17px; }
  .tabs { position: sticky; top: 54px; z-index: 5; background: var(--panel); padding: 6px 8px 0; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
  .tabs button { padding: 10px 12px; font-size: 14px; flex: none; }
  .view { padding: 14px 12px; }
  .chat { height: calc(100dvh - 144px); min-height: 380px; }
  .preview { position: fixed; inset: 0; width: 100%; z-index: 45; }
  .composer { grid-template-columns: 1fr; }
}

/* Imágenes de referencia en el chat de agentes */
.ref-thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.ref-thumbs:empty { display: none; }
.ref-thumbs .ref { position: relative; }
.ref-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.ref-thumbs .ref button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0; border-radius: 50%; font-size: 11px; background: var(--err); border: 0; color: #fff; }
.ref-thumbs.in-msg img { width: 90px; height: 90px; border-color: #fff6; }
.attach { cursor: pointer; font-size: 20px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); margin: 0; color: var(--text); }
.attach:hover { border-color: var(--primary2); }

/* Selector de interfaz del juego */
.ui-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.ui-grid.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.ui-tile { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 8px; border-radius: 14px; background: var(--panel2); border: 2px solid var(--line); color: var(--text); cursor: pointer; transition: border-color .15s, transform .15s; }
.ui-tile:hover { transform: translateY(-2px); border-color: var(--primary2, #8b5cf6); }
.ui-tile.on { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 30%, transparent); }
.ui-tile b { font-size: 14px; } .ui-tile span { font-size: 11px; }
.ui-grid.small .ui-tile b { font-size: 12px; }

/* Editor visual de la botonera */
.heditor { position: fixed; inset: 0; z-index: 60; background: #05070dcc; display: flex; flex-direction: column; }
.heditor .hebar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.heditor .hebar button { margin-left: auto; }
.heditor .hestage { flex: 1; overflow: hidden; position: relative; }
.heditor .heframe { box-shadow: 0 20px 60px #000; border-radius: 10px; overflow: hidden; background: #000; }

/* Marcas */
#gameList .brand-head { display: flex; align-items: center; gap: 8px; margin: 12px 4px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
#gameList .brand-head img { height: 20px; max-width: 60px; object-fit: contain; }
#gameList .brand-head b { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#gameList .brand-head em { font-style: normal; opacity: .7; }
.brand-select { width: auto; display: inline-block; padding: 2px 8px; font-size: 12px; border-radius: 99px; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.brand-edit { display: grid; grid-template-columns: 1fr 320px; gap: 18px; }
@media (max-width: 900px) { .brand-edit { grid-template-columns: 1fr; } }
.lp { position: relative; aspect-ratio: 16/10; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #fff; }
.lp-logo img, .lp-logo video { max-width: 70%; max-height: 90px; object-fit: contain; display: block; margin: auto; animation: lpin .6s cubic-bezier(.2,1.3,.4,1); }
.lp-logo b { font: 900 26px system-ui; letter-spacing: .05em; }
.lp.pulse .lp-logo > * { animation: lpin .6s cubic-bezier(.2,1.3,.4,1), lppulse 1.4s ease-in-out .6s infinite; }
.lp-tag { font: 600 10px system-ui; letter-spacing: .25em; text-transform: uppercase; opacity: .8; }
.lp-txt { font: 600 11px system-ui; opacity: .8; }
.lp-bar { width: 60%; height: 6px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.lp-bar i { display: block; height: 100%; width: 60%; background: var(--c); box-shadow: 0 0 10px var(--c); animation: lpfill 2s ease-in-out infinite; }
.lp-ring { width: 42px; height: 42px; border-radius: 50%; background: conic-gradient(var(--c) 65%, rgba(255,255,255,.15) 0); -webkit-mask: radial-gradient(circle, transparent 56%, #000 58%); mask: radial-gradient(circle, transparent 56%, #000 58%); animation: spinring 1.4s linear infinite; }
@keyframes lpin { from { transform: scale(.6); opacity: 0; } }
@keyframes lppulse { 50% { transform: scale(1.06); } }
@keyframes lpfill { from { width: 5%; } to { width: 100%; } }
@keyframes spinring { to { transform: rotate(360deg); } }

/* Prueba silenciosa */
.check-report { display: grid; gap: 12px; }
.check-head { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); }
.check-head .big { font-size: 34px; }
.check-head b { font-size: 18px; }
.check-head.ok { border-color: var(--ok); } .check-head.warn { border-color: var(--warn); } .check-head.fail { border-color: #ff5d6c; }
.check-fixes h3 { margin: 0 0 8px; } .check-fixes ol { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; }
.check-fixes li.fail { color: #ffb3ba; }
.check-area h4 { margin: 6px 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted, #9aa); }
.check-row { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--panel2); margin-bottom: 4px; }
.check-row.fail { outline: 1px solid #ff5d6c88; } .check-row.warn { outline: 1px solid color-mix(in srgb, var(--warn) 55%, transparent); }
.badge.fail { border-color: #ff5d6c; color: #ff5d6c; cursor: pointer; }
.badge.warn.ck, .badge.ok.ck { cursor: pointer; }

/* Vista previa de los marcadores */
.meter-prev { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: #0b0a12; justify-content: center; flex-wrap: wrap; }
.meter-prev .mp { display: flex; flex-direction: column; align-items: center; padding: 4px 14px; min-width: 110px; }
.meter-prev .mp small { font: 600 10px system-ui; letter-spacing: .12em; opacity: .8; color: #fff; }
.meter-prev .mp b { color: #fff; font-size: 16px; }

/* Importes de la tabla de pagos según moneda y apuesta */
td .amt { font-size: 11px; color: var(--accent); margin-top: 2px; white-space: nowrap; }
.pay-preview { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel2); gap: 10px; }
.pay-preview select { width: auto; }
.preview-cur { width: auto; padding: 4px 8px; font-size: 12.5px; }

/* Fichas de motores (nuevo juego y cambiar motor) */
.eng-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; max-height: 52vh; overflow: auto; padding: 2px; }
.eng-card { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); color: inherit; cursor: pointer; font: inherit; }
.eng-card:hover { border-color: color-mix(in srgb, var(--primary) 60%, transparent); }
.eng-card.sel { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }
.eng-name { font-size: 15px; } .eng-desc { font-size: 12px; opacity: .75; }
.eng-card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 0; font-size: 12px; } .eng-card dt { opacity: .6; } .eng-card dd { margin: 0; }
.eng-card ul { margin: 0; padding-left: 16px; font-size: 12px; } .eng-card li { margin: 1px 0; }
.eng-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.eng-badges i { font-style: normal; font-size: 11px; padding: 2px 7px; border-radius: 99px; background: color-mix(in srgb, var(--primary) 18%, transparent); }

/* Funciones del motor */
.fn-group { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--panel2); }
.fn-group > summary { cursor: pointer; font-weight: 700; padding: 2px 0; }
.fn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 14px; margin-top: 8px; }
.fn-field { display: flex; flex-direction: column; gap: 4px; }
.fn-field.fn-table, .fn-field.fn-kv, .fn-field.fn-multi { grid-column: 1 / -1; }
.fn-help { font-size: 11.5px; }
.fn-table { border-collapse: collapse; width: auto; font-size: 13px; }
.fn-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 6px; }
.fn-table td { padding: 2px 4px; } .fn-table input, .fn-table select { min-width: 70px; max-width: 150px; padding: 4px 6px; }

/* Lista de juegos agrupada: Motores / Borradores / Creados */
.gl-group { margin: 2px 0 6px; }
.gl-head { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 8px; border: 0; border-radius: 8px; background: none;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: pointer; text-align: left; }
.gl-head::before { content: '▾'; transition: transform .15s; }
.gl-group.closed .gl-head::before { transform: rotate(-90deg); }
.gl-head span { flex: 1; }
.gl-head em { font-style: normal; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 0 7px; font-size: 11px; }
.gl-head:hover { background: var(--panel2); }
.gl-group.closed .gl-items { display: none; }
.gl-empty { font-size: 12px; padding: 2px 10px 6px; margin: 0; }
.gl-pend { color: var(--warn); font-weight: 600; }
}

/* Inicio del panel */
.home-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.home-title { margin: 6px 0 0; display: flex; align-items: center; gap: 8px; }
.home-title em { font-style: normal; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; }
.home-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.home-game { text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; }
.home-game small { color: var(--muted); }
.home-engines { max-height: none; overflow: visible; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.home-engines .eng-card { cursor: default; }
.home-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.brand { cursor: pointer; }
@media (max-width: 1100px) {
  .home-engines { grid-template-columns: 1fr; }
  .home-games { grid-template-columns: 1fr; }
}

.gl-eng { color: var(--accent) !important; opacity: .85; }
.eng-tag { font-size: 12px; font-weight: 700; color: var(--accent); margin-top: -4px; }

/* Videos del crupier por resultado */
.cv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.cv-cell { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: var(--panel2); display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.cv-cell.has { border-color: var(--ok); }
.cv-cell .row { gap: 4px; flex-wrap: wrap; }
/* ✂ Quitar fondo: antes / después sobre cuadriculado */
.bgr { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
.bgr figure { margin: 0; display: grid; gap: 6px; justify-items: center; }
.bgr img, .bgr canvas { max-width: 100%; max-height: 260px; object-fit: contain; border-radius: 8px; padding: 8px;
  background: repeating-conic-gradient(#3a3f55 0 25%, #23263a 0 50%) 0 0 / 18px 18px; }
.bgr figcaption { font-size: 12px; color: var(--muted, #9aa); }
@media (max-width: 600px) { .bgr { grid-template-columns: 1fr; } }
/* Premios por monto: ubicar el importe sobre el video */
.tier-pos { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.tier-prev { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; display: grid; place-items: center; touch-action: none; }
.tier-prev img, .tier-prev video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.tier-prev > .muted { padding: 12px; text-align: center; }
.tp-cap { position: absolute; transform: translate(-50%, -50%) scale(var(--k, 1)); text-align: center; cursor: grab; user-select: none; white-space: nowrap;
  padding: 2px 8px; border: 1px dashed #fff8; border-radius: 8px; line-height: 1.05; }
.tp-cap:active { cursor: grabbing; }
.tp-cap small { display: block; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-shadow: 0 2px 6px #000; }
.tp-cap b { display: block; font-size: 26px; font-weight: 900; text-shadow: 0 0 12px var(--primary2, #ffd460), 0 2px 8px #000; }
@media (max-width: 700px) { .tier-pos { grid-template-columns: 1fr; } }

/* Sitio web de membresías */
.webbadge { cursor: pointer; font: inherit; font-size: 12px; }
.site-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.site-kpis .card { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.site-kpis b { font-size: 20px; }
.site-admin textarea { width: 100%; }
.site-color input[type=color] { width: 42px; height: 32px; padding: 2px; border-radius: 8px; }
.site-plans td { vertical-align: middle; }
.site-plans tr.new-plan td { border-top: 1px dashed var(--line, #333); }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; color: inherit; border: 1px solid var(--line); background: var(--panel2); padding: 8px 14px; border-radius: 9px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--primary2); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.coin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.coin { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--panel2); }
.coin small { width: 100%; }
.site-admin h4 { font-size: 14px; }

/* Selector de idioma */
.lang-box { padding: 6px 0 0; }
@media (max-width: 700px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .search-btn .search-txt, .search-btn kbd, .top-new-txt, .top-btn .caret { display: none; }
  .search-btn { flex: none; margin: 0 0 0 auto; }
  .topbar .brand { flex: 1 1 auto; font-size: 15px; }
}
.lang-box select { width: 100%; padding: 6px 8px; font-size: 13px; }
.suggestions button { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side #newGameBtn { display: none; } /* «Nuevo juego» está en la barra superior */
.bar { flex-wrap: wrap; }
.bar-actions button { white-space: nowrap; }
.warnbox { background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.rtp-game input[type=range] { flex: 1; }
.cur-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.gl-excl { color: #ffc107; font-weight: 800; }
.gl-owner { color: var(--muted); font-size: 11px; line-height: 1.35; display: block; }
.own-st { font-weight: 700; }
.own-st.draft { color: var(--warn); }
.own-st.pub { color: var(--ok); }
.own-tag { display: inline-block; font-size: 9.5px; padding: 0 5px; border-radius: 99px; border: 1px solid var(--primary2); color: var(--primary2); }
.own-tag.op { border-color: var(--accent); color: var(--accent); }
.own-badge { border-color: var(--primary2); color: var(--text); }

/* Colaboradores: interruptores de permisos */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.perm-sw { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); color: var(--text); cursor: pointer; font-size: 13px; }
.perm-sw input { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--line); position: relative; flex: none; margin: 0; cursor: pointer; transition: background .15s; }
.perm-sw input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.perm-sw input:checked { background: var(--ok); }
.perm-sw input:checked::after { left: 17px; }
.perm-sw.off { opacity: .45; cursor: not-allowed; }
.perm-help { margin: 0; padding-left: 18px; font-size: 12px; }
.staff-row { padding: 12px 0; border-top: 1px solid var(--line); }
.staff-row:first-of-type { border-top: 0; }

/* Funciones del motor: listas fijas y patrones con forma */
.fn-seq { display: grid; gap: 6px; max-width: 420px; }
.fn-pats { display: flex; flex-direction: column; gap: 10px; grid-column: 1 / -1; }
.fn-pat { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel2); }
.fn-pat-head { display: flex; gap: 8px; margin-bottom: 8px; }
.fn-pat-body { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.fn-pat-grid { display: grid; gap: 2px; }
.fn-pat-grid i { width: 16px; height: 16px; border-radius: 3px; background: #0b0e16; border: 1px solid var(--line); cursor: pointer; }
.fn-pat-grid i.on { background: var(--accent); border-color: var(--accent); }
.fn-pat-fields { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 220px; }
.fn-pat-fields > label { display: flex; flex-direction: column; font-size: 12px; width: 120px; margin: 0; }
.fn-pat-syms { display: flex; flex-wrap: wrap; gap: 6px 12px; width: 100%; }
.fn-pat-syms label { display: flex; gap: 4px; align-items: center; margin: 0; font-size: 12px; color: var(--text); }
.fn-pat-syms input { width: auto; }
.fn-field.fn-patterns { grid-column: 1 / -1; }

/* Vista previa: edición en vivo, recarga en caliente y vista de celular */
.preview-bar { flex-wrap: wrap; }
.preview-bar .pv-title { flex: 1; color: var(--muted); }
.live-btn.on { border-color: var(--ok); color: var(--ok); }
.live-state { font-style: normal; font-size: 11.5px; color: var(--ok); min-width: 64px; }
.pv-dev { display: inline-flex; gap: 2px; }
.pv-dev .on { background: var(--primary); color: #fff; border-color: var(--primary); }
.preview { position: relative; }
.preview.updating::after { content: '↻'; position: absolute; top: 52px; right: 12px; font-size: 18px; color: var(--accent); animation: pvspin .8s linear infinite; z-index: 3; }
@keyframes pvspin { to { transform: rotate(360deg); } }
.preview[data-dev="phone"] iframe { flex: none; width: min(100% - 16px, 390px, calc((100vh - 140px) * 0.462)); height: auto; aspect-ratio: 390 / 844; margin: 8px auto; border: 6px solid #222; border-radius: 28px; }
/* La barra del juego y las pestañas no se achican cuando la vista previa angosta el panel */
.main > .bar, .main > .tabs, .main > #tabs { flex-shrink: 0; }
.cx-row { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
/* Mundo del Arquitecto */
.wr-in { display: inline-flex; align-items: center; gap: 3px; margin: 0; font-size: 15px; }
.wr-in input { width: 70px; padding: 5px 6px; }
.wr-row { flex-wrap: wrap; gap: 8px; }
.wr-b { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.warn-text { display: block; margin-top: 4px; color: #ffb547; font-size: 12px; line-height: 1.35; }

/* Campanita: alertas de riesgo y soporte */
.bell { position: relative; }
.bell-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #e74c3c; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.bell-count.warn { background: var(--warn, #f0a500); color: #111; }
/* Riesgo */
.sev { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.sev.critical { background: #e74c3c; color: #fff; }
.sev.warn { background: color-mix(in srgb, var(--warn, #f0a500) 85%, transparent); color: #111; }
.sev.info { background: var(--panel2); color: var(--muted); }
/* Soporte */
.chat { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 14px; min-height: 480px; }
.chat-list { display: grid; gap: 6px; align-content: start; max-height: 70vh; overflow: auto; }
.chat-item { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px; display: grid; gap: 3px; }
.chat-item.on { border-color: var(--primary2); }
.chat-item .unread { background: var(--primary); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.chat-msgs { display: grid; gap: 8px; align-content: start; max-height: 55vh; overflow: auto; padding: 4px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 12px; background: var(--panel2); white-space: pre-wrap; word-break: break-word; }
.msg.mine { justify-self: end; background: color-mix(in srgb, var(--primary) 22%, var(--panel)); }
.msg.system { justify-self: center; background: transparent; color: var(--muted); font-size: 12px; }
.msg small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
@media (max-width: 760px) { .chat { grid-template-columns: 1fr; } }

/* Chat de los agentes en celular: las sugerencias van en una sola fila deslizable y el chat se queda con el espacio */
.agents-chat { grid-template-columns: minmax(0, 1fr); }
.agents-chat > *, .agents-chat .stack, .agents-chat .composer > * { min-width: 0; }
.ai-busy { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ai-busy .ring { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spinring 0.9s linear infinite; flex: none; }
@media (max-width: 760px) {
  .agents-chat { height: auto; min-height: 0; grid-template-rows: auto auto; }
  .agents-chat .log { height: 58dvh; min-height: 300px; }
  .agents-chat .suggestions { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .agents-chat .suggestions::-webkit-scrollbar { display: none; }
  .agents-chat .suggestions button { flex: none; max-width: 70vw; }
  .agents-chat .runs { flex-wrap: wrap; }
}

/* Celular y tablet: la vista previa del juego ocupa toda la pantalla (la regla «.preview { position: relative }» de más
   arriba la dejaba al final de la página, chica y negra) */
@media (max-width: 1100px) {
  .preview { position: fixed; inset: 0; width: 100vw; height: 100dvh; z-index: 45; border-left: 0; }
}
