:root {
  --bg: #0e1626; --card: #17233a; --card2: #1f2f4d; --line: #2c4068;
  --text: #f3f6ff; --dim: #93a4c7; --go: #ffb627; --go-ink: #3a2300;
  --cash: #2fd08a; --cash-ink: #05301d; --half: #54a8ff; --bad: #ff5d6c;
  --font: ui-rounded, 'Arial Rounded MT Bold', 'Trebuchet MS', 'Helvetica Neue', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }

#app { display: grid; grid-template-columns: 300px 1fr; gap: 12px; height: 100%; padding: 12px; }
main { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }

/* ---- jugadores ---- */
#players { background: var(--card); border-radius: 16px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#players header, .row { display: grid; grid-template-columns: 1.5fr 1fr .9fr 1fr; gap: 6px; padding: 9px 14px; align-items: center; }
#players header { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); }
#players header span:not(:first-child), .row span:not(:first-child) { text-align: right; }
#playerList { flex: 1; overflow-y: auto; }
.row { font-size: 14px; font-variant-numeric: tabular-nums; border-bottom: 1px solid rgba(255,255,255,.04); }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.row.me .name::after { content: ' (tú)'; color: var(--dim); font-weight: 400; }
.row.won { background: rgba(47,208,138,.14); } .row.won .prize { color: var(--cash); font-weight: 800; }
.row.lost { opacity: .5; } .row.lost .amount { text-decoration: line-through; }
.row.idle { color: var(--dim); }
#players footer { padding: 10px 14px; font-size: 13px; color: var(--dim); border-top: 1px solid var(--line); }

/* ---- barra superior ---- */
#topbar { display: flex; gap: 10px; align-items: center; }
#history { flex: 1; display: flex; gap: 6px; overflow: hidden; min-width: 0; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.chip { flex: none; padding: 5px 10px; border-radius: 8px; font-size: 13px; font-weight: 800; background: var(--card2); color: var(--dim); font-variant-numeric: tabular-nums; }
.chip.mid { background: #1d4a7a; color: #cfe6ff; } .chip.high { background: #7a4b00; color: #ffe2a3; } .chip.low { background: #4a1f2b; color: #ffb3bb; }
#wallet { display: flex; gap: 10px; align-items: baseline; background: var(--card); padding: 7px 14px; border-radius: 10px; white-space: nowrap; }
#wallet span { color: var(--dim); font-size: 13px; } #wallet strong { font-size: 18px; font-variant-numeric: tabular-nums; }
#mute, #home { background: var(--card); border-radius: 10px; width: 40px; height: 36px; }
#home { flex: none; display: grid; place-items: center; text-decoration: none; }

/* ---- escena ---- */
#stage { flex: 1; min-height: 180px; border-radius: 18px; overflow: hidden; background: #3aa0e8; position: relative; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- paneles de apuesta ---- */
#panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel { background: var(--card); border-radius: 16px; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 132px; }
.amount-box { display: grid; grid-template-rows: 1fr 1fr; gap: 8px; }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; background: var(--bg); border-radius: 10px; overflow: hidden; }
.stepper button { background: var(--card2); font-size: 22px; font-weight: 800; }
.stepper output { display: grid; place-items: center; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick button { background: var(--card2); border-radius: 10px; font-size: 14px; font-weight: 700; }
.actions { display: grid; gap: 8px; }
.actions.two { grid-template-columns: 1fr 1fr; }
.act { border-radius: 12px; display: grid; place-content: center; gap: 2px; text-align: center; font-weight: 900; font-size: 20px; line-height: 1.1; padding: 6px; }
.act small { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; opacity: .85; }
.act.bet { background: var(--go); color: var(--go-ink); }
.act.cancel { background: #3a4660; color: var(--text); }
.act.cash { background: var(--cash); color: var(--cash-ink); }
.act.half { background: var(--half); color: #04213f; }
.act.info { background: var(--bg); color: var(--dim); font-size: 16px; }
.act.info.win { color: var(--cash); } .act.info.lose { color: var(--bad); }

/* ---- entrada ---- */
#join { position: fixed; inset: 0; background: rgba(8,13,24,.86); display: grid; place-items: center; padding: 20px; z-index: 5; }
#join.hidden { display: none; }
#joinForm { background: var(--card); border: 2px solid var(--go); border-radius: 22px; padding: 28px; width: min(420px, 100%); display: grid; gap: 12px; }
#joinForm h1 { margin: 0; font-size: 34px; color: var(--go); }
#joinForm p { margin: 0; color: var(--dim); line-height: 1.4; }
#joinForm label { font-size: 13px; color: var(--dim); margin-top: 6px; }
#joinForm input { font: inherit; font-size: 20px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--text); }
#joinForm input:focus { outline: none; border-color: var(--go); }
#joinForm button { background: var(--go); color: var(--go-ink); font-size: 20px; font-weight: 900; padding: 14px; border-radius: 12px; }
#joinError { color: var(--bad) !important; min-height: 1.2em; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2a1620; color: #ffd0d5; border: 1px solid var(--bad); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 6; }
#toast.show { opacity: 1; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; height: auto; min-height: 100%; }
  #players { order: 2; max-height: 260px; }
  #stage { flex: none; aspect-ratio: 16 / 10; }
  #wallet span { display: none; }
}
@media (max-width: 560px) {
  #panels { grid-template-columns: 1fr; }
}
