:root {
  --bg: #0d1424;
  --bg2: #141d33;
  --panel: #1a2540;
  --line: #2a3658;
  --text: #eef2fb;
  --muted: #93a0bf;
  --accent: #ffcc33;
  --ok: #22c55e;
  --bad: #ef4444;
  --B: #2f6cf2; --I: #e23d3d; --N: #d9dee8; --G: #1fae55; --O: #f39c12;
  --radius: 14px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #22305a 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* encabezado */
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.brand { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: -.5px; margin: 0; flex: 1; min-width: 0; }
.brand small { display: block; font: 500 13px system-ui; color: var(--muted); letter-spacing: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); padding: 5px 11px; border-radius: 99px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

/* bolas */
.ball {
  --c: var(--N);
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: radial-gradient(circle at 32% 28%, #fff 0 8%, transparent 9%), radial-gradient(circle at 50% 50%, var(--c) 0 100%);
  box-shadow: inset -6px -8px 14px rgba(0,0,0,.35), 0 4px 14px rgba(0,0,0,.35);
  position: relative;
}
.ball::after { content: ""; position: absolute; inset: 20%; border-radius: 50%; background: #fff; box-shadow: inset 0 -2px 4px rgba(0,0,0,.15); }
.ball span { position: relative; z-index: 1; color: #111; font-family: var(--display); font-weight: 800; line-height: .9; text-align: center; font-size: 18px; }
.ball span i { display: block; font-style: normal; font-size: .55em; opacity: .7; }
.ball.big { width: 170px; height: 170px; }
.ball.big span { font-size: 54px; }
.ball[data-col="0"] { --c: var(--B); } .ball[data-col="1"] { --c: var(--I); } .ball[data-col="2"] { --c: #9aa3b5; }
.ball[data-col="3"] { --c: var(--G); } .ball[data-col="4"] { --c: var(--O); }
.ball.empty { --c: #2a3658; }
.ball.empty::after { background: #33405f; }
.ball.pop { animation: pop .6s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.3) rotate(-120deg); opacity: 0; } to { transform: none; opacity: 1; } }

.hero { display: flex; align-items: center; gap: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.hero .info { flex: 1; min-width: 0; }
.hero h2 { margin: 0 0 4px; font-family: var(--display); font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.hero .count { font-family: var(--display); font-size: 30px; font-weight: 800; }
.recent { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.recent .ball { width: 46px; height: 46px; }
.recent .ball span { font-size: 15px; }

/* figura del juego */
.figure { display: flex; gap: 12px; align-items: center; margin-top: 6px; font-size: 14px; color: var(--text); }
.figure .small { color: var(--muted); }
.fig { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; width: 62px; flex: none; padding: 3px; background: #0f1628; border-radius: 6px; }
.fig i { aspect-ratio: 1; border-radius: 2px; background: #f4efe1; }
.fig i.R { background: var(--I); } .fig i.Y { background: #ffd21f; }
.fig.lg { width: 120px; gap: 3px; padding: 5px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw.R { background: var(--I); } .sw.Y { background: #ffd21f; }
.cell.off { opacity: .45; }
.cell.fY { box-shadow: inset 0 0 0 3px #ffd21f; }
.cell.fR { box-shadow: inset 0 0 0 3px rgba(226, 61, 61, .85); }
body.tv .fig { width: 7vw; min-width: 70px; }
body.tv .figure { font-size: 1.3vw; }

/* menú de productos */
.menu { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.menu-cat { font-family: var(--display); font-size: 18px; margin: 4px 2px 10px; color: var(--accent); }
.menu-cat:not(:first-child) { margin-top: 20px; }
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.menu-list li { display: flex; align-items: center; gap: 10px; background: var(--bg2); border-radius: 10px; padding: 9px 12px; }
.menu-e { font-size: 22px; width: 28px; text-align: center; flex: none; }
.menu-n { flex: 1; min-width: 0; font-weight: 600; }
.menu-n small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.menu-p { font-variant-numeric: tabular-nums; background: var(--accent); color: #1a1300; padding: 3px 10px; border-radius: 8px; white-space: nowrap; }

/* tablero 1-75 */
.board { display: grid; grid-template-columns: 38px repeat(15, 1fr); gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.board .h { font-family: var(--display); font-weight: 800; font-size: 20px; display: grid; place-items: center; border-radius: 8px; color: #fff; }
.board .h[data-col="2"] { color: #111; }
.board .h[data-col="0"] { background: var(--B); } .board .h[data-col="1"] { background: var(--I); } .board .h[data-col="2"] { background: var(--N); }
.board .h[data-col="3"] { background: var(--G); } .board .h[data-col="4"] { background: var(--O); }
.board .n { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; background: var(--bg2); color: #56627f; font-weight: 700; font-variant-numeric: tabular-nums; border: 0; padding: 0; font-size: clamp(11px, 1.9vw, 18px); transition: background .25s, color .25s, transform .25s; }
.board .n.on { background: var(--accent); color: #1a1300; }
.board .n.last { outline: 3px solid #fff; transform: scale(1.12); z-index: 1; }

/* pestañas */
.tabs { display: flex; gap: 6px; margin: 18px 0 12px; }
.tab { flex: 1; background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: var(--muted); font-weight: 600; }
.tab.on { background: var(--panel); color: var(--text); border-color: var(--accent); }

/* botones */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.btn.primary { background: var(--accent); color: #1a1300; border-color: transparent; }
.btn.danger { background: transparent; border-color: #5a2a33; color: #ff8a8a; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* cartones */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; transition: border-color .3s, box-shadow .3s; }
.card.win { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,204,51,.25), 0 0 40px rgba(255,204,51,.2); }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head b { flex: 1; font-family: var(--display); }
.card-head button { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 4px 6px; }
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.grid5 .h { text-align: center; font-family: var(--display); font-weight: 800; font-size: 18px; padding: 2px 0; border-radius: 6px; color: #fff; }
.grid5 .h:nth-child(1) { background: var(--B); } .grid5 .h:nth-child(2) { background: var(--I); } .grid5 .h:nth-child(3) { background: var(--N); color: #111; }
.grid5 .h:nth-child(4) { background: var(--G); } .grid5 .h:nth-child(5) { background: var(--O); }
.cell { aspect-ratio: 1; display: grid; place-items: center; background: #f4efe1; color: #1c2233; border-radius: 8px; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; position: relative; overflow: hidden; }
.cell.free { font-size: 11px; color: #7a6b3a; }
.cell.on::before { content: ""; position: absolute; inset: 10%; border-radius: 50%; background: rgba(226, 61, 61, .78); animation: dab .35s ease-out; }
.cell.on span { position: relative; color: #fff; }
.cell.hit::before { background: rgba(255, 170, 0, .92); }
@keyframes dab { from { transform: scale(2); opacity: 0; } to { transform: none; opacity: 1; } }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 13px; color: var(--muted); }
.claim { margin-top: 10px; width: 100%; font-size: 18px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.03); box-shadow: 0 0 24px rgba(255,204,51,.6); } }

.add-card { border: 2px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; gap: 10px; padding: 22px; text-align: center; min-height: 220px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(5,8,16,.75); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 50; }
.sheet { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px; }
.sheet h3 { margin: 0 0 6px; font-family: var(--display); font-size: 22px; }
.tips { margin: 8px 0 14px; padding-left: 18px; color: var(--muted); font-size: 14px; }
.preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px; background: #000; margin: 6px 0 10px; }
.progress { height: 8px; background: var(--panel); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.edit5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin: 10px 0; }
.edit5 input { width: 100%; text-align: center; padding: 10px 0; border-radius: 8px; border: 2px solid transparent; background: #f4efe1; color: #1c2233; font-weight: 800; font-size: 20px; -moz-appearance: textfield; }
.edit5 input::-webkit-outer-spin-button, .edit5 input::-webkit-inner-spin-button { -webkit-appearance: none; }
.edit5 input.err { border-color: var(--bad); background: #ffe1e1; }
.edit5 input.guess { border-color: #e7b416; }
.edit5 .free { display: grid; place-items: center; background: #f4efe1; color: #7a6b3a; border-radius: 8px; font-size: 11px; font-weight: 700; }
.field { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }

.banner { background: linear-gradient(90deg, #ffcc33, #ff9f1a); color: #1a1300; border-radius: var(--radius); padding: 12px 16px; font-weight: 700; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #fff; color: #111; padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 60; max-width: calc(100% - 32px); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
footer { text-align: center; color: #56627f; font-size: 12px; padding: 30px 0 10px; }

/* modo pantalla grande (?tv) */
body.tv .wrap { max-width: none; padding: 1.5vh 2vw; }
body.tv .hero { padding: 2vw; }
body.tv .ball.big { width: min(22vw, 36vh); height: min(22vw, 36vh); }
body.tv .ball.big span { font-size: min(8vw, 13vh); }
body.tv .top { margin-bottom: 1.2vh; }
body.tv .hero { margin-bottom: 1.5vh; padding: 1.5vh 2vw; }
body.tv .board .n { aspect-ratio: auto; padding: .7vh 0; }
body.tv .board { padding: 1vh 1vw; gap: .6vh .4vw; }
body.tv .banner { margin-bottom: 1.2vh; padding: 1vh 16px; }
body.tv .hero .count { font-size: 4vw; }
body.tv .recent .ball { width: 5vw; height: 5vw; }
body.tv .recent .ball span { font-size: 1.6vw; }
body.tv .board .n { font-size: 2.2vw; }
body.tv .board .h { font-size: 2.4vw; }
body.tv .player-only { display: none !important; }
.tv-only { display: none; }
body.tv .tv-only { display: block; }
.tv-qr { background: #fff; padding: 10px; border-radius: 12px; width: 12vw; min-width: 130px; }
.tv-qr img { width: 100%; display: block; }

@media (max-width: 640px) {
  .wrap { padding: 12px; }
  .hero { gap: 14px; padding: 14px; }
  .ball.big { width: 116px; height: 116px; }
  .ball.big span { font-size: 38px; }
  .hero .count { font-size: 22px; }
  .recent .ball { width: 36px; height: 36px; }
  .recent .ball span { font-size: 12px; }
  .board { grid-template-columns: repeat(5, 1fr); grid-auto-flow: column; grid-template-rows: auto repeat(15, auto); padding: 8px; gap: 3px; }
  .board .n { aspect-ratio: auto; padding: 5px 0; font-size: 15px; }
  .board .h { padding: 4px 0; }
}
