:root {
  --ink: #231B4A;
  --paper: #F1ECF9;
  --white: #fff;
  --luca: #F5B50A;
  --fucsia: #E5397A;
  --turq: #14A8A0;
  --naranja: #F26B2A;
  --violeta: #6B4FD8;
  --mute: #5E5882;
  --bd: 2.5px solid var(--ink);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 16px/1.4 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.05; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 22px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
h3 { font-size: 17px; font-weight: 700; }
small, .small { font-size: 13px; }
.mute { color: var(--mute); }
:focus-visible { outline: 3px solid var(--violeta); outline-offset: 3px; }
[hidden] { display: none !important; }

#app { max-width: 480px; margin: 0 auto; padding: 12px 16px calc(28px + env(safe-area-inset-bottom)); }
#app.wide { max-width: 980px; }
.boot { display: grid; place-items: center; min-height: 60dvh; }

/* ---------- cabecera ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: 6px 0 14px; position: relative; }
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.coin { width: 30px; height: 30px; flex: none; display: block; }
.coin.sm { width: 26px; height: 26px; }
.coin.spin { animation: spin .7s cubic-bezier(.3,.7,.3,1); }
@keyframes spin { from { transform: rotateY(0); } to { transform: rotateY(720deg); } }
.bal { margin-left: auto; display: flex; align-items: center; gap: 7px; background: var(--white); border: var(--bd); border-radius: 99px; padding: 4px 14px 4px 5px; font-variant-numeric: tabular-nums; }
.bal b { font-size: 20px; font-weight: 800; }
.bal small { color: var(--mute); }
.icon { width: 42px; height: 42px; border-radius: 50%; border: var(--bd); background: var(--white); display: grid; place-items: center; padding: 0; }
.icon svg { width: 20px; height: 20px; }
.menu { position: absolute; right: 0; top: 54px; z-index: 20; background: var(--white); border: var(--bd); border-radius: 16px; box-shadow: 0 5px 0 var(--ink); padding: 6px; min-width: 190px; display: grid; }
.menu button { background: none; border: 0; text-align: left; padding: 11px 12px; border-radius: 10px; font-weight: 600; }
.menu button:hover { background: var(--paper); }

/* ---------- botones y paneles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border: var(--bd); border-radius: 14px;
  background: var(--luca); color: var(--ink); font-weight: 700;
  box-shadow: 0 4px 0 var(--ink); transition: transform .08s, box-shadow .08s;
  text-align: center; min-height: 48px;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: 0 4px 0 var(--ink); }
.btn.sec { background: var(--white); }
.btn.bad { background: var(--fucsia); color: #fff; }
.btn.sm { padding: 8px 14px; min-height: 38px; border-radius: 12px; box-shadow: 0 3px 0 var(--ink); font-size: 15px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.panel { background: var(--white); border: var(--bd); border-radius: 18px; padding: 16px; }
.stack { display: grid; gap: 14px; }
.stack > .game { margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.back { background: none; border: 0; padding: 4px 0 10px; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }

/* ---------- acceso ---------- */
.auth { display: grid; gap: 22px; padding-top: 6vh; }
.auth .hero { display: grid; gap: 10px; justify-items: start; }
.auth .hero .coin { width: 76px; height: 76px; animation: spin 1.1s cubic-bezier(.3,.7,.3,1) .2s both; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: var(--bd); border-radius: 14px; overflow: hidden; background: var(--white); }
.tabs button { background: none; border: 0; padding: 11px; font-weight: 700; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 15px; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=tel], select {
  width: 100%; padding: 12px 14px; border: var(--bd); border-radius: 12px; background: var(--white); min-height: 48px; font-weight: 600;
}
.err { color: #B3124F; font-weight: 700; min-height: 1.4em; }

/* ---------- juegos ---------- */
.games { display: grid; gap: 14px; margin: 4px 0 18px; }
.game {
  display: grid; grid-template-columns: 62px 1fr; gap: 14px; align-items: center; text-align: left;
  background: var(--bg); color: var(--fg); border: var(--bd); border-radius: 20px;
  box-shadow: 0 5px 0 var(--ink); padding: 14px 16px; transition: transform .08s, box-shadow .08s;
}
.game:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.game svg { width: 62px; height: 62px; fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.game svg .f { fill: currentColor; stroke: none; }
.game b { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; display: block; line-height: 1.1; }
.game span { font-size: 14px; font-weight: 600; opacity: .92; }
.game em { font-style: normal; display: inline-block; margin-top: 6px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 99px; }

.bets { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.bet {
  position: relative; display: grid; gap: 0; justify-items: center; padding: 10px 6px 8px;
  background: var(--white); border: var(--bd); border-radius: 14px; box-shadow: 0 3px 0 var(--ink);
  font-variant-numeric: tabular-nums; transition: transform .08s, box-shadow .08s;
}
.bet b { font-size: 24px; font-weight: 800; line-height: 1.1; }
.bet small { color: var(--mute); font-weight: 600; }
.bet:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.bet:disabled { opacity: .4; cursor: not-allowed; }
.bet[aria-pressed="true"] { background: var(--luca); }
.bet .wait { position: absolute; top: -9px; right: -6px; background: var(--turq); color: var(--ink); border: 2px solid var(--ink); border-radius: 99px; font-size: 12px; font-weight: 800; padding: 0 7px; line-height: 1.5; }
.rule { font-size: 14px; color: var(--mute); }

/* ---------- sala de espera ---------- */
.code { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.code div { background: var(--paper); border: var(--bd); border-radius: 14px; padding: 10px 12px; }
.code small { color: var(--mute); font-weight: 600; display: block; }
.code b { font-size: 30px; font-weight: 800; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.waiting { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 10px 0 4px; }
.dots { display: flex; gap: 8px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--luca); border: 2.5px solid var(--ink); animation: bob 1.1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* ---------- partida ---------- */
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; }
.vs .p2 { text-align: right; }
.vs .pot { display: flex; align-items: center; gap: 6px; background: var(--white); border: var(--bd); border-radius: 99px; padding: 3px 12px 3px 4px; font-size: 16px; font-variant-numeric: tabular-nums; }
.vs .pot .coin { width: 24px; height: 24px; }
.turn { text-align: center; font-weight: 800; font-size: 18px; padding: 9px 12px; border: var(--bd); border-radius: 14px; background: var(--white); }
.turn.mine { background: var(--luca); }
.timer { position: relative; height: 18px; border: 2.5px solid var(--ink); border-radius: 99px; background: var(--white); overflow: hidden; }
.timer i { position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--turq); }
.timer i[data-lvl="mid"] { background: var(--naranja); }
.timer i[data-lvl="low"] { background: var(--fucsia); }
.timer span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.warn { background: #FFE9F1; border: var(--bd); border-radius: 14px; padding: 10px 14px; font-weight: 700; }
.you-tag { font-size: 13px; font-weight: 700; color: var(--mute); }

.ttt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; max-width: 340px; margin: 0 auto; width: 100%; }
.cell { aspect-ratio: 1; background: var(--white); border: var(--bd); border-radius: 16px; display: grid; place-items: center; padding: 0; box-shadow: 0 3px 0 var(--ink); transition: transform .08s; }
.cell:active:not(:disabled) { transform: translateY(2px); }
.cell:disabled { cursor: default; }
.cell.win { background: var(--luca); }
.cell svg { width: 58%; height: 58%; fill: none; stroke-width: 9; stroke-linecap: round; }
.cell .x { stroke: var(--fucsia); }
.cell .o { stroke: var(--turq); }
.cell .pop { animation: pop .28s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: scale(.3); } to { transform: scale(1); } }

.c4 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; background: var(--violeta); border: var(--bd); border-radius: 18px; padding: 8px; max-width: 400px; margin: 0 auto; width: 100%; overflow: hidden; }
.col { display: grid; gap: 5px; background: none; border: 0; padding: 0; border-radius: 10px; }
.col:not(:disabled):hover, .col:not(:disabled):active { background: rgba(255,255,255,.2); }
.col:disabled { cursor: default; }
.disc { aspect-ratio: 1; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
.disc.me { background: var(--luca); }
.disc.op { background: var(--fucsia); }
.disc.win { box-shadow: 0 0 0 3px #fff; }
.disc.drop { animation: drop .4s cubic-bezier(.5,0,.8,.5); }
@keyframes drop { from { transform: translateY(-260%); } to { transform: none; } }

.rps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rpsb { display: grid; justify-items: center; gap: 6px; padding: 14px 6px 10px; background: var(--white); border: var(--bd); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); font-weight: 700; }
.rpsb svg { width: 52px; height: 52px; fill: none; stroke: var(--ink); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.rpsb svg .f { fill: var(--luca); }
.rpsb:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.rpsb:disabled { opacity: .4; box-shadow: 0 4px 0 var(--ink); cursor: default; }
.rpsb[aria-pressed="true"] { background: var(--luca); opacity: 1; }
.score { display: flex; justify-content: center; align-items: center; gap: 16px; font-weight: 800; font-size: 20px; }
.pips { display: flex; gap: 5px; }
.pips i { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--white); }
.pips i.on { background: var(--luca); }
.reveal { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; }
.reveal > div { background: var(--paper); border: var(--bd); border-radius: 14px; padding: 10px 6px; display: grid; justify-items: center; gap: 4px; }
.reveal svg { width: 44px; height: 44px; fill: none; stroke: var(--ink); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.reveal svg .f { fill: var(--luca); }
.reveal .won { background: var(--luca); }

.table { display: flex; justify-content: center; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.side { display: grid; justify-items: center; gap: 8px; min-width: 120px; }
.side > b { font-weight: 700; font-size: 15px; }
.pcard { width: 92px; height: 130px; border: var(--bd); border-radius: 12px; background: var(--white); position: relative; display: grid; place-items: center; box-shadow: 0 4px 0 var(--ink); }
.pcard .r { position: absolute; left: 8px; top: 6px; font-weight: 800; font-size: 26px; line-height: 1; }
.pcard .s { font-size: 52px; line-height: 1; }
.pcard.red { color: var(--fucsia); }
.pcard.back { background: repeating-linear-gradient(45deg, var(--violeta) 0 8px, #5A3FC4 8px 16px); }
.pcard.empty { background: none; border-style: dashed; box-shadow: none; opacity: .5; }
.pcard.flip { animation: flip .5s ease; }
@keyframes flip { from { transform: rotateY(90deg); } to { transform: none; } }
.pcard.small { width: 52px; height: 74px; box-shadow: 0 2px 0 var(--ink); }
.pcard.small .r { font-size: 16px; left: 5px; top: 3px; }
.pcard.small .s { font-size: 28px; }
.dicebox { display: flex; gap: 10px; min-height: 70px; }
.die { width: 66px; height: 66px; }
.die rect { fill: var(--white); stroke: var(--ink); stroke-width: 3; }
.die circle { fill: var(--ink); }
.die.empty rect { stroke-dasharray: 6 5; fill: none; opacity: .5; }
.die.roll { animation: roll .55s cubic-bezier(.3,.7,.4,1); }
@keyframes roll { 0% { transform: rotate(-200deg) translateY(-30px) scale(.6); } 70% { transform: rotate(12deg); } 100% { transform: none; } }
.sum { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.tie { background: #FFF4D2; border: var(--bd); border-radius: 14px; padding: 10px 14px; font-weight: 700; text-align: center; display: grid; gap: 8px; justify-items: center; }
.tie .row { gap: 8px; }

.result { border: var(--bd); border-radius: 20px; padding: 18px 16px; display: grid; gap: 12px; box-shadow: 0 5px 0 var(--ink); }
.result.win { background: var(--luca); }
.result.lose { background: #FFE0EC; }
.result.tie { background: var(--white); }
.result h2 { font-size: 30px; font-weight: 800; }
.result .amt { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.result .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result .acts .btn { box-shadow: 0 4px 0 var(--ink); }
.result.win .acts .btn:not(.sec) { background: var(--turq); }
.result.win .acts .btn:disabled:not(.sec) { background: #CFE9E6; opacity: 1; color: var(--mute); }
.bad-text { color: #B3124F; font-weight: 800; }

/* ---------- chat ---------- */
.chat { display: grid; gap: 8px; }
.chat-head { display: flex; align-items: center; gap: 10px; }
.chat-head .btn { flex: 1; justify-content: space-between; }
.badge { background: var(--fucsia); color: #fff; border-radius: 99px; font-size: 12px; font-weight: 800; padding: 0 8px; line-height: 1.6; }
.msgs { display: grid; gap: 6px; max-height: 190px; overflow-y: auto; padding: 8px; background: var(--white); border: var(--bd); border-radius: 14px; }
.msg { max-width: 82%; padding: 6px 11px; border-radius: 14px; background: var(--paper); word-break: break-word; }
.msg.mine { justify-self: end; background: var(--luca); }
.msg small { display: block; color: var(--mute); font-weight: 700; font-size: 12px; }
.chatform { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.empty-note { color: var(--mute); text-align: center; padding: 6px; }

/* ---------- historial ---------- */
.list { display: grid; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 11px 0; border-bottom: 1.5px solid #D9D2EC; font-variant-numeric: tabular-nums; }
.item:last-child { border-bottom: 0; }
.item small { color: var(--mute); }
.item .v { font-weight: 800; text-align: right; }
.pos { color: #0B7F79; }
.neg { color: #B3124F; }

/* ---------- avisos ---------- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; z-index: 100; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; font-weight: 700; border: 2.5px solid var(--ink); box-shadow: 0 4px 0 rgba(35,27,74,.35); animation: tin .25s ease-out; max-width: 440px; }
.toast.error { background: var(--fucsia); }
.toast.ok { background: var(--turq); color: var(--ink); }
@keyframes tin { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
#offline { position: fixed; left: 0; right: 0; bottom: 0; background: var(--fucsia); color: #fff; text-align: center; font-weight: 700; padding: 8px; z-index: 90; }

/* ---------- administrador ---------- */
.adm-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; }
.adm-tabs button { flex: none; background: var(--white); border: var(--bd); border-radius: 99px; padding: 7px 16px; font-weight: 700; }
.adm-tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.fact { background: var(--white); border: var(--bd); border-radius: 16px; padding: 14px 16px; }
.fact b { display: block; font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fact.fee { background: var(--luca); }
.fact span { font-weight: 600; font-size: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; background: var(--white); border: var(--bd); border-radius: 14px; overflow: hidden; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1.5px solid #E3DDF1; font-size: 15px; vertical-align: top; }
.tbl th { background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; }
.tbl td.n, .tbl th.n { text-align: right; }
.tbl tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; border: 2px solid var(--ink); font-size: 12px; font-weight: 700; background: var(--paper); margin-right: 4px; }
.pill.on { background: var(--turq); }
.pill.bad { background: var(--fucsia); color: #fff; }
.modal { position: fixed; inset: 0; background: rgba(35,27,74,.55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal .panel { width: min(440px, 100%); box-shadow: 0 6px 0 var(--ink); max-height: 90dvh; overflow-y: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { max-width: 280px; }

@media (max-width: 380px) {
  .pcard { width: 80px; height: 114px; }
  .die { width: 56px; height: 56px; }
  h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}

.menu .pid { padding: 8px 12px; font-size: 14px; color: var(--mute); border-bottom: 1.5px solid #D9D2EC; margin-bottom: 4px; }
.check { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; font-size: 15px; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--violeta, #6B4FD8); }
.check a { color: inherit; text-decoration: underline; }

/* ---------- Lukitas, el gallinazo ---------- */
.mascot { display: block; width: 120px; height: auto; flex: none; overflow: visible; }
.say { display: flex; align-items: flex-end; gap: 10px; }
.auth .hero .say { gap: 4px; width: 100%; }
.auth .hero .mascot { width: 132px; }
.bubble { position: relative; background: var(--white); border: var(--bd); border-radius: 16px 16px 16px 4px; padding: 9px 12px; font-weight: 600; font-size: 15px; line-height: 1.35; color: var(--ink); max-width: 30ch; }
.say > .bubble, .say > div > .bubble { margin: 6px 0; }
.auth .hero .bubble { margin-bottom: 38px; }
.panel.waiting { justify-items: center; text-align: center; }
.panel.waiting .mascot { width: 110px; animation: bob 2.4s ease-in-out infinite; }
.panel.waiting .bubble { border-radius: 16px; }
.result .rhead { display: flex; align-items: flex-end; gap: 10px; }
.result .rhead .mascot { width: 104px; }
.result .rhead .bubble { border-radius: 16px 16px 16px 4px; margin-top: 6px; }
.result.win .rhead .mascot { animation: hop .7s cubic-bezier(.3,.7,.3,1) .1s both; }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes hop { 0% { transform: translateY(14px) scale(.9); } 55% { transform: translateY(-12px); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .panel.waiting .mascot, .result.win .rhead .mascot { animation: none; } }

/* ---------- soporte ---------- */
.btn.wa { background: #25D366; color: #0B3D1F; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.dot { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--fucsia, #E5397A); color: #fff; font-size: 12px; text-align: center; margin-left: 4px; }
.ticket { background: var(--white); border: var(--bd); border-radius: 16px; padding: 12px; display: grid; gap: 8px; }
.ticket .msg, .panel .msg { max-width: 92%; }
.msg.adm { background: #E7F7F5; border: 1.5px solid var(--turq, #14A8A0); justify-self: start; }
