:root {
  --bg: #120e17;
  --panel: #1c1623;
  --panel-2: #251d2e;
  --line: #352a41;
  --text: #f3eef7;
  --muted: #a89bb5;
  --accent: #f472b6;
  --accent-2: #fb923c;
  --good: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --a: #ef4444; --b: #3b82f6; --c: #eab308; --d: #22c55e;
  --r: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; }
button:disabled { cursor: default; opacity: .5; }
input { font: inherit; color: inherit; }
svg.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { height: 100%; display: flex; flex-direction: column; }
.boot { margin: auto; text-align: center; color: var(--muted); }
.boot-logo { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; font-weight: 800; font-size: 32px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .8; } }

/* barra superior */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: rgba(28, 22, 35, .85); flex: none; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; white-space: nowrap; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.who { display: flex; align-items: center; margin-left: auto; }
.who img, .av { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); object-fit: cover; flex: none; }
.who img { margin-left: -8px; border: 2px solid var(--panel); }
.who .more { margin-left: 6px; color: var(--muted); font-size: 13px; }
.top .btn-ghost { padding: 6px 10px; }

.stage { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.wrap { max-width: 1100px; margin: 0 auto; }

/* botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 11px; font-weight: 650; background: var(--accent); color: #1a0d14; transition: transform .08s, filter .15s; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.alt { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.big { padding: 14px 22px; font-size: 17px; }
.btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }

h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }

/* portada */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.hello h1 { font-size: 24px; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.game { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); text-align: left; transition: transform .15s, border-color .15s; min-height: 190px; }
.game:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--g) 60%, var(--line)); }
.game::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--g) 28%, transparent), transparent 60%); pointer-events: none; }
.game .ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: color-mix(in srgb, var(--g) 22%, var(--panel-2)); color: var(--g); }
.game .ic svg { width: 24px; height: 24px; }
.game h3 { font-size: 18px; }
.game p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; flex: 1; }
.game .meta { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); }
.game .meta span { display: inline-flex; align-items: center; gap: 5px; }
.side { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; background: var(--panel-2); }
.row .n { width: 22px; text-align: center; font-weight: 700; color: var(--muted); }
.row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row b { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }
.note { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px dashed var(--line); color: var(--muted); font-size: 13px; line-height: 1.45; }

/* cabecera de juego */
.ghead { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.ghead h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pill.hot { color: var(--text); border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.ghead .sp { flex: 1; }
.bar { height: 6px; border-radius: 6px; background: var(--panel-2); overflow: hidden; margin-bottom: 16px; }
.bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; transition: transform .2s linear; }

/* trivial */
.tv { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
.qbox { text-align: center; padding: 26px 18px; }
.qbox .cat { display: inline-block; margin-bottom: 12px; font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.qbox h1 { font-size: clamp(20px, 3.2vw, 28px); line-height: 1.3; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.ans { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px; min-height: 64px; border-radius: 14px; text-align: left; font-weight: 650; font-size: 16px; background: color-mix(in srgb, var(--k) 20%, var(--panel)); border: 2px solid color-mix(in srgb, var(--k) 45%, transparent); transition: transform .08s, opacity .2s; }
.ans:hover:not(:disabled) { background: color-mix(in srgb, var(--k) 30%, var(--panel)); }
.ans .l { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--k); color: #fff; font-weight: 800; flex: none; }
.ans.mine { outline: 3px solid #fff; outline-offset: 2px; }
.ans.dim { opacity: .35; }
.ans.ok { background: color-mix(in srgb, var(--good) 30%, var(--panel)); border-color: var(--good); opacity: 1; }
.ans .cnt { margin-left: auto; font-size: 13px; color: var(--muted); }
.ans:disabled { opacity: 1; cursor: default; }
.ans.dim:disabled { opacity: .35; }
.gain { margin-top: 16px; text-align: center; font-size: 18px; font-weight: 700; }
.gain.good { color: var(--good); }
.gain.bad { color: var(--bad); }
.scores .row.me { outline: 1px solid var(--accent); }
.tick { color: var(--good); }

/* dibuja */
.dv { display: grid; grid-template-columns: 1fr 280px; gap: 14px; align-items: start; }
.board { position: relative; }
.canvas-wrap { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: #fff; touch-action: none; }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.canvas-wrap.drawing canvas { cursor: crosshair; }
.over { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; background: rgba(18, 14, 23, .82); color: var(--text); border-radius: 14px; }
.over h2 { font-size: 22px; margin-bottom: 12px; }
.choices { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.word { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: .32em; margin-bottom: 10px; font-variant-numeric: tabular-nums; white-space: pre-wrap; }
.word small { display: block; font-size: 12px; letter-spacing: 0; color: var(--muted); font-weight: 500; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--c); }
.sw.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.tool { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); }
.tool.on { border-color: var(--accent); color: var(--accent); }
.sz { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); }
.sz i { display: block; border-radius: 50%; background: var(--text); }
.sz.on { border-color: var(--accent); }
.chat { display: flex; flex-direction: column; height: 360px; }
.chat .msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; user-select: text; -webkit-user-select: text; }
.msg { font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.msg b { color: var(--accent); font-weight: 650; }
.msg.win { color: var(--good); font-weight: 650; }
.msg.reveal { color: var(--warn); font-weight: 650; }
.msg.info { color: var(--muted); font-style: italic; }
.msg.secret { opacity: .75; }
.chat form { display: flex; gap: 6px; margin-top: 8px; }
.chat input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); outline: none; user-select: text; -webkit-user-select: text; }
.chat input:focus { border-color: var(--accent); }

/* siete y media */
.sv { display: flex; flex-direction: column; gap: 14px; }
.table { background: radial-gradient(120% 120% at 50% 0%, #1f5141, #123328 70%); border: 1px solid #2c6b56; border-radius: 22px; padding: 18px; }
.bankrow { display: flex; align-items: center; gap: 14px; justify-content: center; flex-wrap: wrap; }
.bankrow .lbl { text-align: center; }
.hand { display: flex; gap: 8px; justify-content: center; min-height: 104px; flex-wrap: wrap; }
.pc { width: 70px; height: 104px; border-radius: 9px; background: #fbf8f1; color: #222; position: relative; box-shadow: 0 4px 12px rgba(0, 0, 0, .35); animation: deal .25s ease-out; flex: none; }
.pc.back { background: repeating-linear-gradient(45deg, #b03a6c, #b03a6c 6px, #c24d7e 6px, #c24d7e 12px); border: 3px solid #fbf8f1; }
.pc .num { position: absolute; top: 5px; left: 7px; font-weight: 800; font-size: 17px; line-height: 1; }
.pc .num.b { top: auto; left: auto; bottom: 5px; right: 7px; transform: rotate(180deg); }
.pc svg { position: absolute; inset: 0; margin: auto; width: 42px; height: 42px; }
.pc .fig { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 700; text-transform: uppercase; color: #666; }
@keyframes deal { from { transform: translateY(-14px) scale(.9); opacity: 0; } }
.total { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, .35); font-weight: 750; font-variant-numeric: tabular-nums; }
.total.bust { background: var(--bad); color: #fff; }
.total.top { background: var(--warn); color: #222; }
.mine-seat { text-align: center; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.seat { padding: 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.seat .h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.seat .h .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.seat .hand { justify-content: flex-start; min-height: 0; gap: 4px; }
.seat .pc { width: 34px; height: 50px; border-radius: 5px; }
.seat .pc .num { font-size: 11px; top: 3px; left: 4px; }
.seat .pc .num.b, .seat .pc .fig { display: none; }
.seat .pc svg { width: 20px; height: 20px; }
.seat.win { border-color: var(--good); }
.seat.lose, .seat.bust { border-color: color-mix(in srgb, var(--bad) 60%, var(--line)); }
.out { font-size: 12.5px; font-weight: 700; }
.out.win { color: var(--good); }
.out.lose, .out.bust { color: var(--bad); }
.chips { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }

/* rueda */
.rv { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.wheel-box { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 22px; }
.wheel { position: relative; width: min(380px, 78vw); aspect-ratio: 1; }
.wheel svg.w { width: 100%; height: 100%; transition: transform 5s cubic-bezier(.12, .7, .1, 1); filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .45)); }
.wheel .pin { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent; border-top: 26px solid #fff; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); z-index: 2; }
#spin-zone { text-align: center; }
.big-result { font-size: 22px; font-weight: 800; text-align: center; }
.big-result.good { color: var(--good); }

/* resultados */
.res { max-width: 560px; margin: 0 auto; text-align: center; }
.res h1 { font-size: 26px; margin: 6px 0 4px; }
.podium { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; text-align: left; }
.podium .row { padding: 10px 12px; }
.podium .row.p1 { background: color-mix(in srgb, #fbbf24 22%, var(--panel-2)); }
.podium .row.p2 { background: color-mix(in srgb, #cbd5e1 16%, var(--panel-2)); }
.podium .row.p3 { background: color-mix(in srgb, #d97706 18%, var(--panel-2)); }
.coins { display: inline-flex; align-items: center; gap: 5px; color: var(--warn); font-weight: 700; white-space: nowrap; }

/* avisos */
#toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; width: min(92vw, 420px); }
.toast { padding: 11px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); font-size: 14px; animation: tin .2s ease-out; display: flex; gap: 8px; align-items: center; }
.toast.warn { border-color: var(--warn); }
.toast.error { border-color: var(--bad); }
.toast.win { border-color: var(--good); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.offline { position: fixed; top: 0; left: 0; right: 0; padding: 6px; text-align: center; font-size: 13px; background: var(--warn); color: #222; z-index: 60; }

@media (max-width: 760px) {
  .tv, .dv, .rv { grid-template-columns: 1fr; }
  .chat { height: 240px; }
  .answers { grid-template-columns: 1fr; }
  .stage { padding: 10px; }
  .brand span { display: none; }
  .pc { width: 56px; height: 84px; }
  .pc svg { width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
