:root {
  --bg: #0e2219;
  --bg-2: #050c09;
  --board: #13432f;        /* tapete de casino */
  --board-line: #b8933f;   /* filetes dorados */
  --board-ink: #f1e3bc;    /* letra de las casillas */
  --gold: #e3c26b;
  --neon: #ff4fd8;
  --panel: #fbfaf5;
  --ink: #1d1d1b;
  --muted: #6b6b66;
  --accent: #c62828;
  --primary: #1f6f4a;
  --primary-ink: #fff;
  --radius: 8px;
  --sidebar-w: 360px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 30% 20%, var(--bg), var(--bg-2));
}
[hidden] { display: none !important; }

/* ---------- Botones ---------- */
.btn {
  font: inherit;
  border: 0;
  border-radius: var(--radius);
  padding: 0.6em 1em;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s, transform 0.05s;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-secondary { background: #e4e2d8; color: var(--ink); }
.btn-danger { background: var(--accent); color: #fff; }
.btn-small { padding: 0.3em 0.7em; font-size: 0.85em; background: #e4e2d8; }
.btn-big { font-size: 1.15em; padding: 0.8em 1.2em; width: 100%; }

/* ---------- Pantalla inicial ---------- */
.setup {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.setup-card {
  background: var(--panel);
  border-radius: 14px;
  padding: 32px;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.35);
}
.setup-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9em; }
.setup-card input, .setup-card select {
  font: inherit; padding: 0.55em; border: 1px solid #ccc; border-radius: var(--radius);
}
/* Letrero de neón: el título en la portada, el panel y el centro del tablero */
.logo, .logo-small, .center-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff6fd;
  background: #17111d;
  text-align: center;
  text-shadow: 0 0 0.08em #fff, 0 0 0.2em var(--neon), 0 0 0.45em var(--neon);
  box-shadow: inset 0 0 0 0.06em color-mix(in srgb, var(--neon) 70%, transparent), 0 0 0.35em color-mix(in srgb, var(--neon) 45%, transparent);
}
.logo { margin: 0; padding: 0.3em 0; border-radius: var(--radius); font-size: 2.4em; }
.subtitle { margin: 0; text-align: center; color: var(--muted); }
.setup-buttons { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Disposición de la partida ---------- */
.game {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  height: 100vh;
  gap: 12px;
  padding: 12px;
}
.board-wrap { display: grid; place-items: center; min-width: 0; min-height: 0; }

/* ---------- Tablero ---------- */
.board {
  --size: min(calc(100vh - 24px), calc(100vw - var(--sidebar-w) - 36px));
  width: var(--size);
  height: var(--size);
  display: grid;
  grid-template-columns: 1.6fr repeat(9, 1fr) 1.6fr;
  grid-template-rows: 1.6fr repeat(9, 1fr) 1.6fr;
  background: var(--board-line);
  gap: 1px;
  border: 2px solid var(--board-line);
  font-size: calc(var(--size) / 95);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.45);
  user-select: none;
}

.sq {
  position: relative;
  background: var(--board);
  color: var(--board-ink);
  display: flex;
  overflow: hidden;
  cursor: default;
}
.type-street, .type-rail, .type-utility { cursor: pointer; }
.type-street:hover, .type-rail:hover, .type-utility:hover { filter: brightness(1.18); }
.side-bottom { flex-direction: column; }
.side-top { flex-direction: column-reverse; }
.side-left { flex-direction: row-reverse; }
.side-right { flex-direction: row; }

.bar { flex: 0 0 24%; display: flex; align-items: center; justify-content: center; }
.side-left .bar, .side-right .bar { flex-direction: column; }

.sq-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2px;
  gap: 0.2em;
  line-height: 1.1;
}
.sq .name { font-weight: 600; font-size: 1em; }
.sq .price { font-size: 0.95em; color: var(--gold); }
.sq .icon { font-size: 1.6em; line-height: 1; }
.side-corner .icon { font-size: 3em; }
.side-corner .name { font-size: 1.25em; text-transform: uppercase; }
.type-go, .type-parking { background: #3b3214; }
.type-goToJail, .type-jail { background: #3d1717; }

.sq.mortgaged .sq-body { opacity: 0.45; }
.sq.mortgaged::after {
  content: 'EMPEÑADO';
  position: absolute; inset: auto 0 40% 0;
  text-align: center; font-size: 0.8em; font-weight: 800; color: #ff6b6b;
  transform: rotate(-20deg);
}
.owner-mark {
  position: absolute;
  width: 0.9em; height: 0.9em;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 0.7);
}
.sq:not(.owned) .owner-mark { display: none; }
.side-bottom .owner-mark { bottom: 3px; right: 3px; }
.side-top .owner-mark { top: 3px; right: 3px; }
.side-left .owner-mark { left: 3px; bottom: 3px; }
.side-right .owner-mark { right: 3px; bottom: 3px; }

.buildings { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.side-left .buildings, .side-right .buildings { flex-direction: column; }
.house { width: 0.9em; height: 0.9em; background: #15161a; border: 1px solid #9aa3ad; border-radius: 2px; }
.hotel { width: 1.8em; height: 1.1em; background: #2c2933; border: 1px solid #ff4fd8; border-radius: 2px; box-shadow: 0 0 0.4em #ff4fd8; }

/* Capa de fichas animables, encima de las casillas */
.board { position: relative; }
.token-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.token-piece { position: absolute; left: 0; top: 0; will-change: transform; }
.token-piece.active .token { box-shadow: 0 0 0 3px #ffbf00, 0 3px 6px rgb(0 0 0 / 0.5); }
.token-piece.hop .token { animation: hop var(--hop-ms, 120ms) ease-out; }
@keyframes hop {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-45%) scale(1.12); }
  100% { transform: translateY(0) scale(1); }
}

.token {
  width: 2.2em; height: 2.2em;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 1em;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.5);
}
.sq.current { box-shadow: inset 0 0 0 3px #ffbf00, inset 0 0 1.2em rgb(255 191 0 / 0.35); }

/* ---------- Centro del tablero ---------- */
.center {
  grid-row: 2 / 11;
  grid-column: 2 / 11;
  background: radial-gradient(circle at 50% 45%, #1a5a3f, #0c3122 75%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2em;
  padding: 1.5em;
  overflow: hidden;
}
.center-title {
  font-size: 3.8em;
  padding: 0.05em 0.5em;
  border-radius: 0.15em;
  transform: rotate(-6deg);
  animation: neon-flicker 7s infinite;
}
@keyframes neon-flicker {
  0%, 91%, 93%, 96%, 100% { opacity: 1; }
  92%, 95% { opacity: 0.55; }
}
.center-city { font-size: 1.4em; font-style: italic; color: var(--gold); margin-top: -0.3em; letter-spacing: 0.05em; }

.dice { display: flex; gap: 1em; min-height: 5em; }
.die {
  width: 5em; height: 5em;
  background: #fff;
  border-radius: 0.8em;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 0.6em;
  box-shadow: 0 0.2em 0.5em rgb(0 0 0 / 0.3);
}
.die span { display: grid; place-items: center; }
.die .pip::before { content: ''; width: 0.9em; height: 0.9em; border-radius: 50%; background: #222; }
.die.rolling { animation: tumble 190ms linear infinite; }
.die.rolling:nth-child(2) { animation-direction: reverse; }
.die.landed { animation: land 350ms ease-out; }
@keyframes tumble {
  0% { transform: rotate(0) translateY(0); }
  50% { transform: rotate(180deg) translateY(-12%); }
  100% { transform: rotate(360deg) translateY(0); }
}
@keyframes land {
  0% { transform: scale(1.25); }
  60% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

.flip-in { animation: flip-in 510ms ease-out; }
@keyframes flip-in {
  0% { transform: perspective(600px) rotateY(90deg) scale(0.8); opacity: 0; }
  100% { transform: perspective(600px) rotateY(0) scale(1); opacity: 1; }
}

.actions.busy { opacity: 0.55; pointer-events: none; }

/* ---------- Billetes ---------- */
.note {
  --line: color-mix(in srgb, var(--ink) 16%, transparent);
  position: relative;
  width: 9em;
  height: 4.5em;
  flex: none;
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  border-radius: 0.3em;
  background:
    repeating-radial-gradient(circle at 50% 48%, var(--line) 0 0.06em, transparent 0.06em 0.28em),
    repeating-linear-gradient(60deg, var(--line) 0 0.05em, transparent 0.05em 0.4em),
    repeating-linear-gradient(-60deg, var(--line) 0 0.05em, transparent 0.05em 0.4em),
    var(--paper);
  box-shadow:
    inset 0 0 0 0.28em var(--paper),
    inset 0 0 0 0.36em color-mix(in srgb, var(--ink) 70%, transparent),
    inset 0 0 0 0.46em var(--paper),
    inset 0 0 0 0.5em color-mix(in srgb, var(--ink) 45%, transparent),
    0 0.12em 0.35em rgb(0 0 0 / 0.3);
  overflow: hidden;
}
.note-value { position: absolute; font-weight: 900; font-size: 1.15em; line-height: 1; }
.note-value.tl { top: 0.55em; left: 0.6em; }
.note-value.br { bottom: 0.55em; right: 0.6em; }
.note-seal {
  position: absolute;
  left: 50%; top: 54%;
  transform: translate(-50%, -50%);
  width: 2.3em; height: 2.3em;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    repeating-conic-gradient(var(--line) 0 4deg, transparent 4deg 12deg),
    var(--paper);
  box-shadow: 0 0 0 0.1em var(--ink), 0 0 0 0.2em var(--paper), 0 0 0 0.26em var(--ink);
}
.note-seal span { font-weight: 900; font-size: 1em; background: var(--paper); border-radius: 0.3em; padding: 0 0.15em; }
.note-bank {
  position: absolute;
  top: 0.62em; left: 0; right: 0;
  text-align: center;
  font-size: 0.42em;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Cartera del jugador */
.wallet { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 8px 0 2px 34px; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.stack-notes { position: relative; width: 58px; height: 31px; }
.stack .note { position: absolute; font-size: 5.8px; left: calc(var(--k) * 2px); top: calc(4px - var(--k) * 2px); }
.stack .note-seal span { font-size: 1.5em; }
.note-bank.bottom { top: auto; bottom: 0.62em; left: 0.7em; right: auto; text-align: left; }
.stack .note-bank { display: none; }
.stack-count { font-size: 0.72em; font-weight: 700; color: var(--muted); }

/* Billetes en vuelo durante un pago */
.flight { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; will-change: transform, opacity; }
.flight .note { font-size: 9px; box-shadow: inset 0 0 0 0.28em var(--paper), inset 0 0 0 0.36em var(--ink), 0 0.4em 1em rgb(0 0 0 / 0.4); }
.flying-amount {
  background: #1d1d1b;
  color: #fff;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.4);
}

.featured { width: 60%; font-size: 1.3em; }
.card-drawn {
  background: #fff;
  border-radius: 0.6em;
  padding: 1em 1.2em;
  box-shadow: 0 0.3em 0.8em rgb(0 0 0 / 0.25);
  border-top: 0.6em solid;
}
.card-drawn.deck-chance { border-color: #f28c28; }
.card-drawn.deck-chest { border-color: #3b82f6; }
.card-deck { font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.card-drawn p { margin: 0.5em 0; }
.card-player { text-align: right; color: var(--muted); font-size: 0.85em; }

/* ---------- Título de propiedad ---------- */
.deed {
  background: #fff;
  border: 1px solid #222;
  padding: 0.5em;
  box-shadow: 0 0.3em 0.8em rgb(0 0 0 / 0.25);
}
.deed-head {
  color: #fff;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
  text-align: center;
  padding: 0.5em;
  border: 1px solid #222;
  display: flex; flex-direction: column;
}
.deed-head small { font-size: 0.65em; text-transform: uppercase; letter-spacing: 0.1em; }
.deed-head strong { font-size: 1.2em; text-transform: uppercase; }
.deed table { width: 100%; border-collapse: collapse; margin-top: 0.4em; font-size: 0.85em; }
.deed td { padding: 0.15em 0.2em; }
.deed td:last-child { text-align: right; white-space: nowrap; }
.deed .deed-note td { font-size: 0.85em; color: var(--muted); text-align: center !important; white-space: normal; }
.deed-status { margin-top: 0.4em; font-size: 0.8em; text-align: center; }

/* ---------- Panel lateral ---------- */
.sidebar {
  background: var(--panel);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto; /* último recurso en pantallas muy bajas */
}
/* Con poca altura, encogen (con su propia barra) la lista de jugadores y el
   registro; la cabecera, los avisos y los botones de acción no se encogen nunca. */
.sidebar > * { flex: none; }
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e3e1d6;
}
.logo-small { font-size: 1.1em; padding: 0.15em 0.5em; border-radius: 4px; }
.sidebar-header { flex-wrap: wrap; justify-content: space-between; }
.settings { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.speed { font-size: 0.8em; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.speed select { font: inherit; }
.sound-controls { display: flex; align-items: center; gap: 6px; }
.sound-controls .btn { padding: 0.2em 0.5em; }
#volume { width: 80px; accent-color: var(--primary); }

.sidebar > .players { flex: 0 1 auto; min-height: 110px; overflow-y: auto; }
.players { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.player { border: 2px solid transparent; border-radius: var(--radius); padding: 6px 8px; background: #f1efe6; }
.player.current { border-color: #ffbf00; }
.player.acting { background: #fff6d6; }
.player.out { opacity: 0.45; }
.player-row { display: flex; align-items: center; gap: 8px; }
.player-row .token { width: 26px; height: 26px; font-size: 13px; }
.player-name { font-weight: 700; flex: 1; }
.player-cash { font-weight: 800; font-variant-numeric: tabular-nums; }
.player-sub { font-size: 0.78em; color: var(--muted); margin: 2px 0 4px 34px; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; margin-left: 34px; }
.chip {
  width: 20px; height: 20px;
  border: 1px solid rgb(0 0 0 / 0.35);
  border-radius: 3px;
  background: var(--chip);
  color: #fff; font-size: 11px; font-weight: 800;
  padding: 0; cursor: pointer;
  text-shadow: 0 1px 1px rgb(0 0 0 / 0.6);
}
.chip.mortgaged { opacity: 0.35; }

.actions {
  padding: 12px;
  border-top: 1px solid #e3e1d6;
  border-bottom: 1px solid #e3e1d6;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 120px;
}
.actions p { margin: 0; }
.headline { font-weight: 800; font-size: 1.05em; }
.muted { color: var(--muted); font-size: 0.85em; }
.bid-row { display: flex; gap: 6px; }
.bid-row input { flex: 1; font: inherit; padding: 0.5em; border: 1px solid #ccc; border-radius: var(--radius); }
.quick-bids { display: flex; gap: 6px; }

.sidebar > .log-wrap { flex: 1 1 0; min-height: 110px; }
.log-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 12px; }
.log-wrap h3 { margin: 0 0 6px; font-size: 0.8em; text-transform: uppercase; color: var(--muted); letter-spacing: 0.08em; }
.log { list-style: none; margin: 0; padding: 0; overflow-y: auto; font-size: 0.82em; }
.log li { padding: 3px 0; border-bottom: 1px dashed #e3e1d6; }
.log li:first-child { font-weight: 700; }

/* ---------- Diálogo y avisos ---------- */
.dialog {
  border: 0;
  border-radius: 12px;
  padding: 16px;
  width: min(340px, calc(100vw - 32px));
  font-size: 16px;
}
.dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.dialog-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.dialog-close { display: block; margin: 12px auto 0; }

.dialog-wide { width: min(680px, calc(100vw - 32px)); }
.dialog h3 { margin: 0 0 10px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.trade-partners { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.trade-partners .btn { border-left: 6px solid var(--chip); }
.trade-partners .btn.selected { background: #fff6d6; outline: 2px solid #ffbf00; }
.trade-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.trade-side { background: #f1efe6; border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.trade-side h4 { margin: 0; }
.trade-props { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.trade-prop { display: flex; align-items: center; gap: 6px; font-size: 0.85em; cursor: pointer; padding: 2px; border-radius: 4px; }
.trade-prop:hover { background: #e4e2d8; }
.trade-prop.blocked { opacity: 0.45; cursor: not-allowed; }
.swatch { width: 12px; height: 12px; border-radius: 2px; flex: none; border: 1px solid rgb(0 0 0 / 0.3); }
.trade-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8em; font-weight: 600; }
.trade-field input { font: inherit; padding: 0.4em; border: 1px solid #ccc; border-radius: 6px; }
.trade-error { min-height: 1.2em; margin: 8px 0 0; color: var(--accent); }
.offer { background: #f1efe6; border-radius: var(--radius); padding: 8px; font-size: 0.9em; }
.offer p { margin: 2px 0; }

@media (max-width: 600px) {
  .trade-sides { grid-template-columns: 1fr; }
}

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #222; color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.4);
  z-index: 10;
}

/* ---------- Vista 3D ---------- */
.board-wrap.mode-3d { display: block; position: relative; }
.stage3d { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.stage3d:active { cursor: grabbing; }
.stage3d .css3d-layer, .stage3d .webgl-layer { position: absolute; inset: 0; }
.stage3d .webgl-layer { pointer-events: none; }
.board.mode-3d { box-shadow: none; }
.board.mode-3d .sq { cursor: inherit; }
.board.mode-3d .buildings { display: none; }
.board.mode-3d .dice { visibility: hidden; }
.view-controls { display: flex; align-items: center; gap: 4px; }
.view-controls select { font: inherit; font-size: 0.8em; }
.view-controls .btn { padding: 0.2em 0.5em; }

/* ---------- Pantallas estrechas ---------- */
@media (max-width: 900px) {
  .game { grid-template-columns: 1fr; height: auto; padding: 8px; }
  .board { --size: calc(100vw - 16px); }
  .sidebar { max-height: none; overflow: visible; }
  .sidebar > .players { overflow: visible; }
  .log-wrap { max-height: 300px; }
  .board-wrap.mode-3d { height: 75vh; }
}

/* ---------- Partidas online ---------- */
.setup-section { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid #e4e2d8; padding-top: 14px; }
.setup-section h2, .lobby-card h2 { margin: 0; font-size: 1em; }
.setup-message { margin: 0; padding: 8px 10px; border-radius: var(--radius); background: #fff3cd; font-size: 0.9em; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.15em; }

.lobby-code-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lobby-code { font-size: 1.8em; font-weight: 900; letter-spacing: 0.2em; font-variant-numeric: tabular-nums; }
.lobby-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lobby-seat { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius); background: #f1efe6; }
.lobby-seat .token { width: 28px; height: 28px; font-size: 13px; flex: none; }
.lobby-seat.empty .token { opacity: 0.4; }
.lobby-seat.away { opacity: 0.6; }
.lobby-name { flex: 1; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.lobby-name .muted { font-weight: 400; }

.player-badge { font-size: 0.72em; color: var(--muted); white-space: nowrap; }
.online-status {
  background: var(--panel); border-radius: var(--radius); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px; font-size: 0.9em;
}
.online-status p { margin: 0; }
.online-warning { color: var(--accent); font-weight: 700; }
.online-takeover .btn { background: var(--primary); color: var(--primary-ink); }
.online-takeover { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.countdown { font-variant-numeric: tabular-nums; margin-left: 4px; }
.countdown.urgent { color: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.join-row input::placeholder { text-transform: none; letter-spacing: normal; }
