:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --ink: #1f2430;
  --muted: #7a7f8a;
  --line: #e2ddd2;
  --accent: #1f6feb;
  --accent-ink: #fff;
  --danger: #d0453a;
  --ok: #2f9e55;
  --warn: #d98b16;
  --board: #e9f1e4;
  --cell: #fffdf6;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; max-width: 1240px; margin: 0 auto;
}
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; letter-spacing: .02em; }
.globe {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #7cc4ff, #1f6feb 70%);
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.12);
}
.me { display: flex; align-items: center; gap: 8px; }
.me-name { font-weight: 600; }

main { max-width: 1240px; margin: 0 auto; padding: 0 16px 32px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.note { background: #eef4ff; padding: 8px 12px; border-radius: 10px; font-size: 14px; }
.loading { text-align: center; color: var(--muted); margin-top: 80px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; flex: none; }
input, select {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--ink); width: 100%;
}
input[type=checkbox] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 16px;
  cursor: pointer; font-weight: 600; white-space: nowrap; transition: transform .08s, background .15s;
}
.btn:hover:not(:disabled) { background: #f6f3ec; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #1a5fd0; }
.btn.danger { color: var(--danger); }
.btn.big { padding: 11px 22px; font-size: 16px; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 0; }

.avatar, .token {
  display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 700; flex: none;
}
.avatar { width: 34px; height: 34px; font-size: 15px; }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }

.tag { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: #efebe2; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tag.ok { background: #e3f4e8; color: var(--ok); }
.tag.warn { background: #fdf0dc; color: var(--warn); }
.lock {
  display: inline-block; width: 12px; height: 14px; margin-right: 6px; vertical-align: -1px;
  background: currentColor; opacity: .7;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14'%3E%3Cpath d='M3 6V4a3 3 0 0 1 6 0v2h1a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1.5 0h3V4a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14'%3E%3Cpath d='M3 6V4a3 3 0 0 1 6 0v2h1a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1.5 0h3V4a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 登录 */
.login { max-width: 420px; margin: 48px auto 0; }
.login h1 { font-size: 26px; }
.login form { display: flex; flex-direction: column; gap: 14px; }

/* 大厅 */
.lobby { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.lobby-side { display: flex; flex-direction: column; gap: 16px; }
.tables { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.tbl { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.tbl-main { flex: 1; min-width: 0; }
.tbl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl-meta { font-size: 13px; color: var(--muted); }
.seats-pill { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; list-style: none; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 600; }

/* 等待 */
.waiting { max-width: 620px; margin: 16px auto 0; }
.wait-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.invite {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: #f6f3ec; border-radius: 12px; padding: 14px 16px; margin: 4px 0 16px;
}
.code { font-size: 30px; font-weight: 800; letter-spacing: .18em; font-variant-numeric: tabular-nums; }
.invite-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.seat-list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.seat.empty { border-style: dashed; color: var(--muted); justify-content: center; background: transparent; padding: 14px; }
.seat-name { flex: 1; font-weight: 600; }

/* 对局 */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.board-wrap { container-type: inline-size; }
.board {
  --edge: 1.55fr;
  display: grid; aspect-ratio: 21 / 15; width: 100%; max-width: 100%; margin: 0 auto;
  grid-template-columns: var(--edge) repeat(var(--cols), minmax(0,1fr)) var(--edge);
  grid-template-rows: var(--edge) repeat(var(--rows), minmax(0,1fr)) var(--edge);
  gap: 2px; padding: 2px; background: #cdd7c6; border-radius: 12px; overflow: hidden;
  font-size: 1.45cqi;
}
.cell {
  position: relative; background: var(--cell); border: 0; padding: 0; margin: 0; cursor: pointer;
  display: flex; overflow: hidden; min-width: 0; min-height: 0; text-align: center; font-size: 1em;
}
.cell:hover { filter: brightness(.97); }
.cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 2; }
.cell.owned { background: color-mix(in srgb, var(--o) 13%, var(--cell)); }
.cell.mortgaged { background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(0,0,0,.06) 4px 8px); }
.cell.mortgaged .name, .cell.mortgaged .price { opacity: .55; }
.cell.side-bottom { flex-direction: column; }
.cell.side-top { flex-direction: column-reverse; }
.cell.side-left { flex-direction: row-reverse; }
.cell.side-right { flex-direction: row; }
.cell.side-corner { background: #fbf6e8; }

.band {
  flex: 0 0 22%; background: var(--g); display: flex; align-items: center; justify-content: center; gap: 1px; flex-wrap: wrap; padding: 1px;
}
.cell.side-left .band, .cell.side-right .band { flex-direction: column; }
.house { width: .75em; height: .75em; background: #3fbf5f; border: 1px solid rgba(0,0,0,.35); border-radius: 1px; }
.hotel { width: 1.8em; height: .85em; background: #e0463c; border: 1px solid rgba(0,0,0,.35); border-radius: 1px; }
.cell.side-left .hotel, .cell.side-right .hotel { width: .85em; height: 1.8em; }

.cell-body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15em;
  padding: .2em; min-width: 0; min-height: 0;
}
.name { font-weight: 600; line-height: 1.15; word-break: break-all; }
.price { color: var(--muted); font-size: .9em; font-variant-numeric: tabular-nums; }
.icon { width: 1.8em; height: 1.8em; display: grid; place-items: center; color: #5b6170; }
.icon svg { width: 100%; height: 100%; }
.icon b { font-size: 1.6em; line-height: 1; }
.t-chance .icon { color: #d98b16; }
.t-fate .icon { color: #8e4fc9; }
.cell.side-corner .icon { width: 3em; height: 3em; }
.cell.side-corner .name { font-size: 1.15em; }
.t-go .icon { color: var(--danger); }
.t-gotojail .icon { color: var(--danger); }
.owner-mark { position: absolute; right: 3px; bottom: 3px; width: .8em; height: .8em; border-radius: 50%; background: var(--o); box-shadow: 0 0 0 1.5px #fff; }

.tokens { position: absolute; inset: auto 0 .3em 0; display: flex; justify-content: center; gap: 1px; pointer-events: none; flex-wrap: wrap; }
.token { width: 2.1em; height: 2.1em; font-size: .85em; box-shadow: 0 1px 2px rgba(0,0,0,.35), 0 0 0 1.5px #fff; }
.token.cur { animation: bob 1s ease-in-out infinite; }
.token.lg { width: 30px; height: 30px; font-size: 14px; animation: none; }
@keyframes bob { 50% { transform: translateY(-3px); } }

.center {
  grid-area: 2 / 2 / -2 / -2; background: var(--board);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1em;
  padding: 1em; text-align: center; font-size: 1.7em;
}
.center-title { font-weight: 800; font-size: 2em; letter-spacing: .1em; color: rgba(31,36,48,.14); }
.phase { font-weight: 600; max-width: 22em; }
.phase.mine { color: var(--accent); }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.timer.low { color: var(--danger); }
.acts { display: flex; gap: .6em; flex-wrap: wrap; justify-content: center; }
.acts .btn { font-size: 1em; }
.acts .btn.big { font-size: 1.15em; }
.dice { display: flex; gap: .6em; }
.die {
  width: 2.6em; height: 2.6em; background: #fff; border-radius: .45em; padding: .35em;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); box-shadow: 0 2px 0 rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.08);
}
.die i { border-radius: 50%; margin: 12%; }
.die i.on { background: var(--ink); }
.drawn { background: #fff; border-radius: 10px; padding: .6em 1em; max-width: 20em; box-shadow: 0 0 0 1px var(--line); border-top: 4px solid #d98b16; }

.panel { display: flex; flex-direction: column; gap: 12px; }
.panel .card { padding: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.players { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.pl { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; }
.pl.cur { border-color: var(--accent); background: #f1f6ff; }
.pl.out { opacity: .45; }
.pl-main { flex: 1; min-width: 0; }
.pl-name { font-weight: 600; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pl-meta { font-size: 12px; color: var(--muted); }
.pl-cash { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.owed { color: var(--danger); font-size: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin: 0 4px 0 2px; }

.detail { display: flex; flex-direction: column; gap: 8px; }
.detail-head { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--g) 18%, #fff); border-left: 6px solid var(--g); }
.rent { width: 100%; border-collapse: collapse; font-size: 13px; }
.rent td { padding: 3px 4px; border-bottom: 1px solid var(--line); }
.rent td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.rent tr.hl td { font-weight: 700; color: var(--accent); }

.log ol { list-style: none; padding: 0; margin: 0; max-height: 220px; overflow: auto; font-size: 13px; }
.log li { padding: 3px 0; border-bottom: 1px dashed var(--line); }

.overlay { position: fixed; inset: 0; background: rgba(31,36,48,.35); display: grid; place-items: center; padding: 16px; z-index: 20; }
.result { width: 100%; max-width: 380px; text-align: center; }
.result h2 { font-size: 24px; }
.rank { text-align: left; padding: 0 0 0 20px; margin: 12px 0 18px; }
.rank li { padding: 4px 0; }
.rank li span:last-child { float: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.result .row { justify-content: center; flex-wrap: wrap; }

@media (max-width: 900px) {
  .lobby, .game { grid-template-columns: 1fr; }
  .board { max-width: 100%; }
}
@media (max-width: 520px) {
  .board { --edge: 1.35fr; font-size: 1.6cqi; border-radius: 8px; gap: 1px; padding: 1px; }
  .cell .price { display: none; }
  .cell.side-corner .price { display: block; }
  .center { font-size: 2.6cqi; gap: .6em; padding: .5em; }
  .center-title { display: none; }
  .acts .btn { padding: 7px 12px; font-size: 13px; }
  .acts .btn.big { font-size: 14px; padding: 8px 14px; }
  .code { font-size: 24px; }
}

.tile-flag { width:100%; height:100%; object-fit:contain; }
.brand[href] { text-decoration:none; color:inherit; }
@media(max-width:520px){ .board { min-height:370px; } .center { overflow:auto; } }
