* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f2f2ee;
  color: #222;
}
h1, h2, h3, h4 { margin: 0; }
[hidden] { display: none !important; }
.muted { color: #777; }

button {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid #bbb;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #f0f0f0; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: #2f7d32; border-color: #2f7d32; color: #fff; }
button.primary:hover:not(:disabled) { background: #276a2a; }
button.danger { color: #c92a2a; }
button.link { border: 0; background: none; color: #777; text-decoration: underline; padding: 0; align-self: flex-start; }
input {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid #bbb;
  border-radius: 6px;
  min-width: 0;
}
label { display: flex; flex-direction: column; gap: 4px; color: #555; flex: 1; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row > input { flex: 1; }

#conn {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  background: #c92a2a; color: #fff; text-align: center; padding: 4px;
}

/* Главная и лобби */
.box {
  max-width: 440px;
  margin: 8vh auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#lobby-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#lobby-players li { display: flex; align-items: center; gap: 8px; }
#lobby-host { display: flex; flex-direction: column; gap: 10px; }

/* Игра */
#game { display: flex; gap: 12px; padding: 12px; justify-content: center; align-items: flex-start; }
#board-wrap { flex-shrink: 0; }
#board {
  --size: min(calc(100vh - 24px), calc(100vw - 380px));
  width: var(--size);
  height: var(--size);
  min-width: 560px;
  min-height: 560px;
  container-type: size;
  display: grid;
  grid-template-columns: 1.35fr repeat(8, 1fr) 1.35fr;
  grid-template-rows: 1.35fr repeat(8, 1fr) 1.35fr;
  gap: 2px;
  padding: 2px;
  background: #a3aba3;
  border-radius: 4px;
}

.cell {
  position: relative;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3cqw;
  padding: 1.6cqw .3cqw .9cqw;
  text-align: center;
  font-size: 1.32cqw;
  line-height: 1.15;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}
.cell:hover { filter: brightness(.96); }
.cell.sel { outline: 2px solid #222; outline-offset: -2px; z-index: 1; }
.cell .nm { font-weight: 600; overflow-wrap: anywhere; }
.cell .val { color: #666; }
.cell .bar {
  position: absolute; top: 0; left: 0; right: 0; height: 1.3cqw;
  display: flex; justify-content: center; align-items: center; gap: .3cqw;
}
.cell .bar i { width: .8cqw; height: .8cqw; background: #fff; border: 1px solid #0006; }
.cell .bar i.hotel { width: 2.4cqw; background: #fff; border-color: #000; }
.cell .own { position: absolute; left: 0; right: 0; bottom: 0; height: .7cqw; }
.cell.t-station, .cell.t-utility { background: #e3e6e9; }
.cell.t-chance { background: #fff1c2; }
.cell.t-event { background: #dbe7fb; }
.cell.t-tax, .cell.corner { background: #f1ebdc; }
.cell.corner { font-size: 1.6cqw; font-weight: 700; padding: .5cqw; }
.cell.mort {
  background: repeating-linear-gradient(45deg, #fff, #fff .8cqw, #ececec .8cqw, #ececec 1.6cqw);
}
.cell.mort .nm, .cell.mort .val { color: #999; }

.tokens { display: flex; gap: .3cqw; flex-wrap: wrap; justify-content: center; }
.tok {
  width: 2.3cqw; height: 2.3cqw;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #0007;
  color: #fff;
  font-size: 1.2cqw;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.center {
  grid-area: 2 / 2 / 10 / 10;
  background: #e6eee0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6cqw;
  padding: 3cqw;
  text-align: center;
  font-size: 1.8cqw;
}
.center .big { font-size: 2.6cqw; font-weight: 700; }
.center button { font-size: 1.8cqw; padding: .8cqw 1.8cqw; }
.center .recent { color: #555; font-size: 1.55cqw; }
.center .warn { color: #c92a2a; max-width: 70%; }
.center .note { background: #fff7d6; border: 1px solid #e8d48a; border-radius: 6px; padding: .6cqw 1.2cqw; }
.actions { display: flex; gap: 1cqw; flex-wrap: wrap; justify-content: center; }

.dice { display: flex; gap: 1.6cqw; }
.die {
  width: 6.5cqw; height: 6.5cqw;
  background: #fff;
  border: 1px solid #333;
  border-radius: 1cqw;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: .7cqw;
}
.die i { width: 1.2cqw; height: 1.2cqw; background: #222; border-radius: 50%; place-self: center; }
.card {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 1.2cqw 2cqw;
  max-width: 65%;
}
.card b { display: block; font-size: 1.3cqw; color: #888; text-transform: uppercase; letter-spacing: .05em; }

/* Боковая панель */
#side {
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 24px);
  min-height: 560px;
}
.panel { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.panel h3 { font-size: 14px; }
.room-line { display: flex; align-items: center; gap: 8px; color: #666; }
.room-line b { color: #222; }
.player { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.player.turn { background: #e6eee0; }
.player.out { color: #aaa; text-decoration: line-through; }
.player .tag { font-size: 12px; color: #888; }
.player .money { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.neg { color: #c92a2a; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.off { opacity: .35; }
.name-tag { display: inline-flex; align-items: center; gap: 5px; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }

#log { flex: 1; overflow-y: auto; min-height: 120px; font-size: 13px; gap: 3px; }
#log div { color: #444; }

.info .head { display: flex; align-items: center; gap: 8px; }
.info .sw { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.info table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.info td { padding: 1px 4px; }
.info td:last-child { text-align: right; }
.info tr.on { background: #e6eee0; font-weight: 600; }

/* Окно обмена */
#modal {
  position: fixed; inset: 0; z-index: 10;
  background: #0005;
  display: grid;
  place-items: center;
  padding: 12px;
}
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 18px;
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols > div { display: flex; flex-direction: column; gap: 8px; }
.plist { display: flex; flex-direction: column; gap: 3px; }
.pitem { flex-direction: row; align-items: center; gap: 6px; color: #222; cursor: pointer; }
.pitem.dis { color: #aaa; cursor: default; }
.pitem .sw { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.end { justify-content: flex-end; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  background: #333; color: #fff; padding: 8px 14px; border-radius: 6px;
  max-width: 90vw;
}

@media (max-width: 960px) {
  #game { flex-direction: column; align-items: stretch; padding: 6px; }
  #board-wrap { overflow-x: auto; }
  #board { --size: calc(100vw - 12px); }
  #side { width: auto; max-height: none; min-height: 0; }
  #log { max-height: 240px; }
  .cols { grid-template-columns: 1fr; }
}
