:root {
  --rosa: #e4007c; --turq: #00a6a6; --naranja: #ff7a00; --amarillo: #ffc93c;
  --talavera: #1b3f8b; --crema: #fbf3e4; --tierra: #3a2418; --ink: #24170f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #ffe1b8, transparent 40%), radial-gradient(circle at 90% 80%, #ffd0e6, transparent 40%), #f7e7cf;
  min-height: 100vh;
}
.hidden { display: none !important; }
.picado {
  height: 34px; position: relative; z-index: 2;
  background:
    linear-gradient(135deg, transparent 75%, #f7e7cf 75%) 0 0 / 24px 34px,
    linear-gradient(225deg, transparent 75%, #f7e7cf 75%) 0 0 / 24px 34px,
    repeating-linear-gradient(90deg, var(--rosa) 0 96px, var(--turq) 96px 192px, var(--naranja) 192px 288px, var(--amarillo) 288px 384px, #7b2cbf 384px 480px);
  -webkit-mask: radial-gradient(circle 4px at 12px 12px, transparent 98%, #000) 0 0 / 24px 24px;
          mask: radial-gradient(circle 4px at 12px 12px, transparent 98%, #000) 0 0 / 24px 24px;
}

/* ---------- lobby ---------- */
.screen { padding: 16px; }
.hero { max-width: 760px; margin: 4vh auto; text-align: center; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(40px, 8vw, 72px); margin: 0; color: var(--talavera); letter-spacing: 1px; text-shadow: 3px 3px 0 var(--amarillo); }
h1 span { color: var(--rosa); }
.tag { font-size: 18px; opacity: .85; }
.cards { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; margin-top: 28px; }
.panel { background: #fff; border: 3px solid var(--talavera); border-radius: 16px; padding: 22px; width: 320px; box-shadow: 6px 6px 0 var(--talavera); display: flex; flex-direction: column; gap: 10px; }
.panel h2 { margin: 0 0 6px; color: var(--rosa); font-family: Georgia, serif; }
input { font: inherit; padding: 10px 12px; border: 2px solid #c9b79c; border-radius: 10px; background: #fffdf8; width: 100%; }
input:focus { outline: none; border-color: var(--turq); }
.btn { font: inherit; font-weight: 700; cursor: pointer; border: none; border-radius: 10px; padding: 9px 16px; background: var(--rosa); color: #fff; box-shadow: 0 3px 0 #9c0055; transition: transform .05s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #9c0055; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.alt { background: var(--turq); box-shadow: 0 3px 0 #006b6b; }
.btn.orange { background: var(--naranja); box-shadow: 0 3px 0 #a64f00; }
.btn.gray { background: #8a7a6a; box-shadow: 0 3px 0 #5a4c40; }
.btn.blue { background: var(--talavera); box-shadow: 0 3px 0 #0e214a; }
.btn.big { padding: 13px 20px; font-size: 18px; }
.btn.tiny { padding: 3px 9px; font-size: 12px; box-shadow: 0 2px 0 #9c0055; }
.err { color: #c00; font-weight: 700; min-height: 1.2em; }
.share { display: flex; gap: 8px; max-width: 520px; margin: 0 auto; }
.waitlist { list-style: none; padding: 0; margin: 26px auto; max-width: 360px; }
.waitlist li { background: #fff; margin: 8px 0; padding: 10px 14px; border-radius: 12px; border: 2px solid #e5d3b8; display: flex; align-items: center; gap: 10px; font-size: 18px; }
.waitlist .tok { font-size: 26px; }

/* ---------- game layout ---------- */
#game.screen { padding: 10px; }
.layout { display: flex; gap: 14px; align-items: flex-start; justify-content: center; }
.boardwrap { flex: 0 0 auto; }
.board {
  --S: min(calc(100vh - 70px), calc(100vw - 380px), 920px);
  width: var(--S); height: var(--S);
  display: grid; grid-template-columns: 1.55fr repeat(9, 1fr) 1.55fr; grid-template-rows: 1.55fr repeat(9, 1fr) 1.55fr;
  background: var(--talavera); gap: 2px; padding: 2px; border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  font-size: calc(var(--S) / 92);
}
.cell { background: var(--crema); position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; overflow: hidden; cursor: pointer; padding: 0 1px 2px; }
.cell:hover { filter: brightness(1.05); outline: 2px solid var(--amarillo); z-index: 3; }
.cell .band { width: 100%; height: 22%; flex: 0 0 auto; position: relative; display: flex; align-items: center; justify-content: center; gap: 1px; }
.cell .nm { font-weight: 700; line-height: 1.05; padding: 1px; font-size: 1.05em; }
.cell .pr { font-size: 1em; opacity: .8; }
.cell .ic { font-size: 2.4em; line-height: 1; }
.cell .owner { position: absolute; inset: auto 0 0 0; height: 5px; }
.cell.mort { background: repeating-linear-gradient(45deg, #eee, #eee 6px, #ddd 6px, #ddd 12px); }
.cell.mort::after { content: "HIPOTECA"; position: absolute; top: 45%; left: 0; right: 0; font-size: .9em; font-weight: 800; color: #b00; transform: rotate(-20deg); }
.house { width: .9em; height: .9em; background: #2bb24c; border: 1px solid #0b4; border-radius: 1px; }
.hotel { width: 2.2em; height: 1em; background: #d61f1f; border: 1px solid #900; border-radius: 1px; }
.corner { justify-content: center; font-weight: 800; }
.corner .ic { font-size: 3.6em; }
.corner .nm { font-size: 1.35em; color: var(--rosa); }
.corner .sub { font-size: .95em; opacity: .7; }
/* side orientation: band on inner edge */
.cell.left { flex-direction: row-reverse; padding: 1px 2px 1px 0; }
.cell.right { flex-direction: row; padding: 1px 0 1px 2px; }
.cell.left .band, .cell.right .band { width: 22%; height: 100%; flex-direction: column; }
.cell.left .body, .cell.right .body { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.cell.top { flex-direction: column-reverse; padding: 2px 1px 0; }
.cell .body { display: flex; flex-direction: column; align-items: center; justify-content: space-between; flex: 1; width: 100%; }
.cell.left .owner { inset: 0 0 0 auto; width: 5px; height: auto; }
.cell.right .owner { inset: 0 auto 0 0; width: 5px; height: auto; }
.cell.top .owner { inset: 0 0 auto 0; }
#tokenLayer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.board { position: relative; }
.tkw { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.tk { position: absolute; left: 0; top: 0; translate: -50% -50%; font-size: 2em; line-height: 1; width: 1.45em; height: 1.45em; display: flex; align-items: center; justify-content: center; background: #fff; border: .18em solid; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,.45); }
.tk.me { box-shadow: 0 0 0 .12em #fff, 0 0 .5em .15em rgba(255,201,60,.9), 0 2px 4px rgba(0,0,0,.45); }
@keyframes hop { 0% { transform: translateY(0) scale(1); } 45% { transform: translateY(-.75em) scale(1.12); } 85% { transform: translateY(0) scale(.96, 1.04); } 100% { transform: translateY(0) scale(1); } }
@keyframes bigjump { 0% { transform: translateY(0) scale(1); } 15% { transform: translateY(.1em) scale(1.1, .9); } 50% { transform: translateY(-3.2em) scale(1.55); } 88% { transform: translateY(0) scale(1.05, .92); } 100% { transform: translateY(0) scale(1); } }
.jailcell { position: absolute; right: 4%; top: 4%; width: 52%; height: 52%; background: repeating-linear-gradient(90deg, #ffb48a 0 5px, #333 5px 7px); border: 2px solid #333; display: flex; align-items: center; justify-content: center; }

.center {
  grid-column: 2 / 11; grid-row: 2 / 11; position: relative;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.8), rgba(255,255,255,0) 60%),
    repeating-conic-gradient(from 0deg, #fbe9cf 0 15deg, #f8dcb7 15deg 30deg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6em; font-size: 1.5em; padding: 1em;
}
.logo { font-family: Georgia, serif; font-weight: 900; font-size: 4.2em; color: var(--talavera); transform: rotate(-8deg); text-shadow: .06em .06em 0 var(--amarillo); background: #fff; padding: .05em .4em; border: .08em solid var(--rosa); border-radius: .25em; }
.logo span { color: var(--rosa); }
.turnbanner { font-size: 1.4em; font-weight: 800; padding: .3em .9em; border-radius: 999px; background: #fff; border: 3px solid currentColor; }
.dice { display: flex; gap: 1.4em; }
.die { width: 5em; height: 5em; position: relative; perspective: 22em; }
.die::after { content: ""; position: absolute; left: 8%; right: 8%; bottom: -.9em; height: .7em; border-radius: 50%; background: radial-gradient(rgba(0,0,0,.35), transparent 70%); z-index: -1; }
.cube { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; }
.face { position: absolute; inset: 0; background: linear-gradient(145deg, #ffffff, #ececec); border: 1px solid #d6d6d6; border-radius: .7em; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: .65em; box-shadow: inset 0 0 .5em rgba(0,0,0,.12); backface-visibility: hidden; }
.face i { width: 1em; height: 1em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #4a3a30, var(--ink)); align-self: center; justify-self: center; }
.f1 i { background: radial-gradient(circle at 35% 35%, #ff5aa8, var(--rosa)); width: 1.35em; height: 1.35em; }
.f1 { transform: translateZ(2.5em); }
.f2 { transform: rotateY(90deg) translateZ(2.5em); }
.f3 { transform: rotateX(90deg) translateZ(2.5em); }
.f4 { transform: rotateX(-90deg) translateZ(2.5em); }
.f5 { transform: rotateY(-90deg) translateZ(2.5em); }
.f6 { transform: rotateY(180deg) translateZ(2.5em); }
.die.toss { animation: toss 1.5s cubic-bezier(.3,.6,.4,1); }
#d2.toss { animation-delay: .06s; }
@keyframes toss { 0% { transform: translateY(0); } 22% { transform: translateY(-3.2em); } 48% { transform: translateY(0); } 62% { transform: translateY(-1.1em); } 76% { transform: translateY(0); } 86% { transform: translateY(-.3em); } 100% { transform: translateY(0); } }
.actions { display: flex; flex-wrap: wrap; gap: .6em; justify-content: center; min-height: 3em; }
.actions .btn { font-size: 1.2em; }
.actions .hint { font-size: 1.1em; opacity: .75; }
.btn.roll { font-size: 1.6em !important; padding: .4em 1.4em; background: linear-gradient(var(--rosa), #b30062); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 3px 0 #9c0055, 0 0 0 .4em rgba(228,0,124,.25); } }
.cardview { background: #fff; border: 4px solid var(--naranja); border-radius: .6em; padding: .7em 1em; max-width: 26em; text-align: center; font-size: 1.1em; box-shadow: 0 .3em .8em rgba(0,0,0,.2); animation: pop .3s; }
.cardview b { display: block; color: var(--naranja); margin-bottom: .3em; letter-spacing: 1px; }
.cardview.comunidad { border-color: var(--turq); }
.cardview.comunidad b { color: var(--turq); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.auction { background: #fff; border: 4px solid var(--talavera); border-radius: .6em; padding: .8em 1em; text-align: center; font-size: 1.1em; display: flex; flex-direction: column; gap: .5em; align-items: center; }
.auction .row { display: flex; gap: .4em; flex-wrap: wrap; justify-content: center; }
.auction input { width: 7em; padding: .3em .5em; }
.auction .timer { height: .4em; background: var(--rosa); border-radius: 9px; transition: width .25s linear; align-self: stretch; }

/* ---------- side ---------- */
.side { width: 340px; flex: 0 0 340px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 60px); }
.roomline { background: #fff; border-radius: 10px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.players { display: flex; flex-direction: column; gap: 6px; }
.pl { background: #fff; border-radius: 10px; padding: 7px 10px; display: flex; align-items: center; gap: 10px; border-left: 7px solid; }
.pl.turn { outline: 3px solid var(--amarillo); }
.pl.out { opacity: .4; text-decoration: line-through; }
.pl .tok { font-size: 24px; }
.pl .nm { flex: 1; font-weight: 700; }
.pl .nm small { font-weight: 400; opacity: .7; display: block; font-size: 11px; }
.pl .money { font-weight: 800; font-size: 18px; }
.pl .money.neg { color: #c00; }
.sidehead { font-weight: 800; display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.myprops { background: #fff; border-radius: 10px; padding: 8px 10px; max-height: 26vh; overflow: auto; }
#myProps { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 3px 7px; border-radius: 6px; color: #fff; cursor: pointer; font-weight: 700; text-shadow: 0 1px 1px rgba(0,0,0,.4); }
.chip.m { opacity: .45; text-decoration: line-through; }
.logbox { background: #fff; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; flex: 1; min-height: 160px; }
.log { overflow-y: auto; flex: 1; font-size: 13px; line-height: 1.35; max-height: 32vh; }
.log div { padding: 2px 0; border-bottom: 1px dashed #eee; }
#chatForm input { margin-top: 6px; padding: 6px 10px; }
.tradebox { background: #fff7d6; border: 2px solid var(--amarillo); border-radius: 10px; padding: 8px 10px; font-size: 14px; margin-bottom: 6px; }
.tradebox .row { display: flex; gap: 6px; margin-top: 6px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(30,15,5,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modalbox { background: #fff; border-radius: 14px; padding: 18px; max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.deed { width: 280px; margin: 0 auto; border: 2px solid #222; padding: 6px; background: #fff; }
.deed .hd { color: #fff; text-align: center; padding: 10px 6px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.deed .hd small { display: block; font-size: 11px; letter-spacing: 2px; opacity: .9; }
.deed .hd div { font-size: 20px; font-weight: 800; font-family: Georgia, serif; }
.deed table { width: 100%; font-size: 14px; margin-top: 6px; border-collapse: collapse; }
.deed td { padding: 2px 4px; }
.deed td:last-child { text-align: right; }
.deed .cur td { background: #fff3b0; font-weight: 700; }
.modal .btnrow { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.tradegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tradegrid h3 { margin: 4px 0; }
.tradegrid label { display: block; font-size: 14px; padding: 2px 0; }
.tradegrid .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; font-weight: 700; }
.winner { font-size: 2em; font-weight: 900; color: var(--rosa); text-align: center; }

@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: center; }
  .board { --S: min(calc(100vw - 20px), 92vh); }
  .side { width: 100%; flex: none; max-height: none; }
}
