:root {
  --red: #9b1c1c;
  --red-dark: #6e1010;
  --gold: #c9a227;
  --gold-soft: #e8d48b;
  --wood: #3a2414;
  --wood-2: #5c3a1e;
  --cream: #f3e6c8;
  --stone: #d9c7a4;
  --ink: #1c120c;
  --paper: #fff8ea;
  --ok: #1e8449;
  --warn: #c0392b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Alegreya", Georgia, serif;
  color: var(--cream);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(201, 162, 39, .18), transparent 50%),
    linear-gradient(180deg, #1a0f08 0%, #2a1810 40%, #140c08 100%);
  background-attachment: fixed;
}

h1, h2, h3, .brand, .logo-title { font-family: "Cinzel", serif; }

a { color: var(--gold-soft); }
button, input, select, textarea { font-family: inherit; }

.btn {
  appearance: none;
  border: 1px solid var(--gold);
  background: linear-gradient(#b22222, #7a1212);
  color: #fff8ea;
  padding: .65rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: .04em;
  box-shadow: 0 2px 0 #4a0c0c;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--gold-soft);
}
.btn.gold {
  background: linear-gradient(#e8d48b, #c9a227);
  color: #3a2414;
  border-color: #8a7010;
}
.btn.ok { background: linear-gradient(#2ecc71, #1e8449); border-color: #145a32; }
.btn.warn { background: linear-gradient(#e74c3c, #922b21); }

.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-size: .85rem; color: var(--gold-soft); }
.field input, .field select, .field textarea {
  background: #fff8ea;
  color: var(--ink);
  border: 1px solid #c9a227;
  border-radius: 8px;
  padding: .6rem .7rem;
  font-size: 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.2rem;
  background: linear-gradient(#4a2a16, #2b180e);
  border-bottom: 2px solid var(--gold);
}
.logo-title {
  margin: 0;
  color: #e23b3b;
  text-shadow: 0 1px 0 #fff, 0 0 12px rgba(255, 220, 120, .35);
  letter-spacing: .12em;
  font-size: 1.6rem;
}
.logo-sub { color: var(--gold-soft); font-size: .8rem; letter-spacing: .18em; text-transform: uppercase; }

/* Lobby */
.hero {
  max-width: 1100px;
  margin: 1.4rem auto;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 1.2rem;
  padding: 0 1rem 2rem;
}
.hero-art {
  position: relative;
  border: 3px solid var(--gold);
  border-radius: 16px;
  overflow: hidden;
  min-height: 420px;
  box-shadow: var(--shadow);
  background: #111;
}
.hero-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-art .caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 1rem 1.1rem;
  background: linear-gradient(transparent, rgba(20, 10, 6, .92));
}
.panel {
  background: linear-gradient(#4a2e1a, #2c1a10);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 .8rem; color: var(--gold-soft); font-size: 1.15rem; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.tabs button {
  flex: 1;
  background: #2a1810;
  color: var(--cream);
  border: 1px solid #7a5a30;
  padding: .5rem;
  border-radius: 8px;
  cursor: pointer;
}
.tabs button.on { background: var(--red); border-color: var(--gold); }
.piece-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: .45rem;
}
.piece {
  background: #1c120c;
  border: 1px solid #7a5a30;
  border-radius: 10px;
  padding: .45rem .3rem;
  text-align: center;
  cursor: pointer;
  color: var(--cream);
}
.piece.on { border-color: var(--gold); background: #5a3018; }
.piece .em { font-size: 1.5rem; display: block; }
.rooms { display: flex; flex-direction: column; gap: .45rem; max-height: 220px; overflow: auto; }
.room {
  display: flex; justify-content: space-between; align-items: center;
  background: #1c120c; padding: .5rem .7rem; border-radius: 8px; border: 1px solid #5a3a20;
}
.hint { color: #d7c4a0; font-size: .92rem; line-height: 1.4; }
.err { color: #ffb4a8; min-height: 1.2em; font-size: .92rem; }

/* Game layout */
.game-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  padding: 10px;
  height: calc(100vh - 62px);
}
.board-col { display: flex; align-items: center; justify-content: center; min-width: 0; }
.board-stage {
  position: relative;
  width: min(92vh, 100%);
  aspect-ratio: 1;
}
.side {
  display: flex; flex-direction: column; gap: 8px; overflow: auto;
}

.board {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: 1.45fr repeat(9, 1fr) 1.45fr;
  grid-template-rows: 1.45fr repeat(9, 1fr) 1.45fr;
  background: #6b4423;
  border: 8px solid #c9a227;
  outline: 4px solid #5c3a1e;
  box-shadow: var(--shadow);
  border-radius: 6px;
  position: relative;
}

.cell {
  position: relative;
  background: var(--cream);
  color: var(--ink);
  border: 1px solid #8a6a3a;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.1;
}
.cell.corner { background: #efe0c0; }
.cell .name {
  padding: 3px 4px 14px;
  font-weight: 700;
  text-align: center;
  font-size: .62rem;
}
.cell.side-left .name, .cell.side-right .name {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 100%;
  padding: 14px 3px 3px;
}
.cell.side-right .name { transform: none; writing-mode: vertical-rl; }
.cell .price {
  position: absolute; bottom: 1px; left: 0; right: 0;
  text-align: center; font-size: .58rem; color: #5a3a18;
}
.cell.side-left .price, .cell.side-right .price {
  writing-mode: horizontal-tb; transform: none;
  bottom: 2px;
}
.band {
  height: 14px; width: 100%;
  border-bottom: 1px solid #5a3a18;
}
.cell.side-left .band, .cell.side-right .band {
  position: absolute; top: 0; bottom: 0; width: 14px; height: auto;
  border: 0;
}
.cell.side-left .band { right: 0; border-left: 1px solid #5a3a18; }
.cell.side-right .band { left: 0; border-right: 1px solid #5a3a18; }
.cell.side-top .band {
  position: absolute; left: 0; right: 0; bottom: 0; top: auto; height: 14px; width: auto;
  border: 0; border-top: 1px solid #5a3a18;
}
.cell .price { z-index: 2; }
.cell-extras { position: absolute; inset: 0; pointer-events: none; }

.cell.transport { background: #e8eef5; }
.cell.utility { background: #e9f6ef; }
.cell.tax { background: #f8e6d8; }
.cell.chance { background: #f4d7b0; }
.cell.chest { background: #d9e8f8; }
.cell.special { background: #efe0c0; }

.token-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  overflow: visible;
}
.tok {
  position: absolute;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  margin-top: -22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 3px 7px rgba(0, 0, 0, .45), 0 0 0 1px rgba(0, 0, 0, .2);
  z-index: 2;
  will-change: left, top;
  transition: left .2s cubic-bezier(.2, .8, .2, 1), top .2s cubic-bezier(.2, .8, .2, 1);
}
.tok .tok-body {
  display: block;
  transform-origin: 50% 80%;
}
.tok.you { box-shadow: 0 3px 8px rgba(0,0,0,.5), 0 0 0 2px #1c120c; }
.tok.hopping .tok-body {
  animation: pawn-hop .2s ease;
}
.tok.teleport {
  transition: left .45s cubic-bezier(.4, 0, .2, 1), top .45s cubic-bezier(.4, 0, .2, 1);
}
.tok.hidden { opacity: 0; }
@keyframes pawn-hop {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-11px) scale(1.18); }
  100% { transform: translateY(0) scale(1); }
}

.builds {
  position: absolute; top: 1px; left: 2px; right: 2px;
  display: flex; justify-content: center; gap: 2px; pointer-events: none;
}
.house { width: 8px; height: 7px; background: #1e8449; border: 1px solid #0e3d20; }
.hotel { width: 14px; height: 8px; background: #c0392b; border: 1px solid #5a1010; }

.owner-dot {
  position: absolute; top: 16px; right: 2px;
  width: 8px; height: 8px; border-radius: 50%; border: 1px solid #fff;
}
.mortgage {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(0,0,0,.12), rgba(0,0,0,.12) 6px, transparent 6px, transparent 12px);
}

.center {
  grid-column: 2 / 11;
  grid-row: 2 / 11;
  position: relative;
  background:
    linear-gradient(rgba(40, 20, 10, .28), rgba(40, 20, 10, .45)),
    center/cover no-repeat;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff;
  overflow: hidden;
}
.center::before {
  content: "";
  position: absolute; inset: 18px;
  border: 2px solid rgba(201,162,39,.55);
  pointer-events: none;
}
.center-title {
  font-family: "Cinzel", serif;
  font-size: clamp(1.8rem, 4.5vw, 3.4rem);
  color: #e23b3b;
  text-shadow: 0 2px 0 #f5f5f5, 0 0 18px rgba(0,0,0,.6);
  letter-spacing: .12em;
  margin: 0;
  z-index: 1;
}
.center-sub {
  z-index: 1; letter-spacing: .28em; text-transform: uppercase;
  font-size: .72rem; color: #f3e6c8;
}
.decks {
  position: absolute; inset: 0; pointer-events: none;
}
.deck {
  position: absolute; width: 22%; height: 14%;
  border: 2px solid #c9a227; border-radius: 6px;
  display: grid; place-items: center;
  font-family: "Cinzel", serif; font-size: .62rem; letter-spacing: .06em;
  text-align: center; padding: 4px; color: #fff; text-shadow: 0 1px 2px #000;
}
.deck.chance { left: 8%; bottom: 14%; background: rgba(180, 80, 20, .78); transform: rotate(8deg); }
.deck.chest { right: 8%; top: 16%; background: rgba(25, 70, 130, .78); transform: rotate(-10deg); }
.jackpot-chip {
  position: absolute; left: 50%; top: 72%; transform: translateX(-50%);
  background: rgba(0,0,0,.55); border: 1px solid var(--gold);
  padding: .25rem .7rem; border-radius: 999px; z-index: 2; font-size: .8rem;
}

.corner-label {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; font-family: "Cinzel", serif; font-weight: 800; padding: 6px;
  font-size: .72rem;
}
.corner-label small { font-family: Alegreya, serif; font-weight: 400; display: block; margin-top: 4px; }

/* Sidebar cards */
.card {
  background: linear-gradient(#4a2e1a, #2c1a10);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: .7rem .8rem;
}
.card h3 { margin: 0 0 .5rem; font-size: .95rem; color: var(--gold-soft); }
.plist { display: flex; flex-direction: column; gap: 6px; }
.pitem {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center;
  background: #1c120c; border-radius: 8px; padding: 6px 8px;
}
.pitem.turn { outline: 2px solid var(--gold); }
.pitem.me { background: #3a2410; }
.pitem.dead { opacity: .45; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.money { font-variant-numeric: tabular-nums; color: #f7e7b0; font-weight: 700; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions .btn { flex: 1 1 46%; }
.dice-box { display: flex; gap: 8px; justify-content: center; margin: .4rem 0; }
.die {
  width: 42px; height: 42px; border-radius: 8px;
  background: #fff; color: #111; display: grid; place-items: center;
  font-weight: 800; font-size: 1.3rem; border: 2px solid #333;
}
.log, .chatbox {
  max-height: 140px; overflow: auto; font-size: .85rem;
  background: #1c120c; padding: 6px 8px; border-radius: 8px;
}
.log div, .chatbox div { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.chat-row { display: flex; gap: 6px; margin-top: 6px; }
.chat-row input { flex: 1; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(10,6,4,.72);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--paper); color: var(--ink);
  width: min(520px, 100%);
  border-radius: 14px; border: 4px solid var(--gold);
  padding: 1rem 1.1rem; max-height: 90vh; overflow: auto;
}
.modal h2 { margin: 0 0 .6rem; color: var(--red); }
.deed .band { height: 28px; }
.options { display: flex; flex-direction: column; gap: 6px; }
.options button {
  text-align: left; padding: .6rem .7rem; border-radius: 8px;
  border: 1px solid #c9a227; background: #fff; cursor: pointer;
}
.timer { font-size: .8rem; color: #f3e6c8; }

.code-pill {
  background: #1c120c; border: 1px dashed var(--gold);
  padding: .2rem .55rem; border-radius: 999px; letter-spacing: .18em; font-weight: 800;
  cursor: pointer;
}

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .game-wrap { grid-template-columns: 1fr; height: auto; }
  .board-stage { width: 100%; }
  .cell .name { font-size: .5rem; }
  .tok { width: 26px; height: 26px; margin-left: -13px; margin-top: -20px; font-size: 15px; }
}
