:root {
  --bg: #0b1f18;
  --bg2: #123128;
  --felt: #174034;
  --cream: #f6f2e7;
  --gold: #f5d67b;
  --ink: #14201b;
  --muted: #9fb8ac;
  --line: rgba(255, 255, 255, 0.12);
  --danger: #ef6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #eaf5ee;
  background:
    radial-gradient(1100px 700px at 15% -10%, #1d5241 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, #1a3f5c 0%, transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 32px;
}

.screen { display: none; width: 100%; }
.screen.active { display: flex; }

/* ---------- 加入页 ---------- */

#screen-join { justify-content: center; }

.join-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.join-card h1 {
  margin: 0 0 4px;
  font-size: 30px;
  letter-spacing: 1px;
}

.join-card h1 span {
  color: var(--gold);
  font-weight: 500;
  font-size: 0.6em;
  letter-spacing: 3px;
  vertical-align: middle;
  margin-left: 4px;
}

.sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder { color: #6f8a7e; }
input:focus {
  border-color: rgba(245, 214, 123, 0.6);
  box-shadow: 0 0 0 3px rgba(245, 214, 123, 0.14);
}

#code-input {
  text-transform: uppercase;
  letter-spacing: 6px;
  text-align: center;
  font-weight: 700;
}

button {
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform 0.06s, filter 0.15s, background 0.15s;
}

button:active { transform: translateY(1px); }
button:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }

.primary {
  background: linear-gradient(180deg, #ffd97a, #e8b64b);
  color: #33240a;
  font-weight: 700;
  padding: 12px 18px;
  border: none;
  box-shadow: 0 8px 20px rgba(232, 182, 75, 0.22);
}

.primary:not(:disabled):hover { filter: brightness(1.06); }

.primary.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 6px; }

.ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: #dcefe4;
  padding: 9px 14px;
  font-size: 13px;
}

.ghost:hover { background: rgba(255, 255, 255, 0.14); }
.ghost.small { padding: 6px 10px; font-size: 12px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; }
.join-row button { padding: 12px 20px; }

.error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

/* ---------- 大厅 ---------- */

#screen-lobby { justify-content: center; }

.lobby-card {
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
}

.code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

#lobby-code {
  font-size: 42px;
  letter-spacing: 10px;
  color: var(--gold);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hint { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 0 0 18px; }
.hint.center { text-align: center; margin: 10px 0 0; }

.lobby-players {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-players li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.lobby-players .avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
}

.lobby-players .name { font-weight: 600; }
.lobby-players .tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--gold);
  border: 1px solid rgba(245, 214, 123, 0.4);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ---------- 棋盘 ---------- */

#screen-game {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.board-wrap { flex: 0 1 auto; }

.board {
  width: min(74vh, 660px, 92vw);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  padding: 9px;
  background: linear-gradient(160deg, #1d5142, #123128);
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 4px 3px;
  border-radius: 7px;
  background: var(--cream);
  color: var(--ink);
  font-size: clamp(8px, 1.02vw, 11px);
  line-height: 1.15;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.15s, transform 0.15s;
}

.tile .bar {
  height: 5px;
  border-radius: 3px;
  background: #c9d3c6;
  flex: 0 0 auto;
}

.tile .tname { font-weight: 700; word-break: break-all; }
.tile .tprice { font-size: 0.88em; opacity: 0.6; }

.tile .owner {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 11px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.tile .tokens {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  font-size: clamp(10px, 1.5vw, 15px);
  line-height: 1;
}

.tile.active {
  box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(245, 214, 123, 0.35);
  transform: translateY(-1px);
  z-index: 2;
}

.tile.pending {
  box-shadow: 0 0 0 3px #7fe0b0, 0 0 20px rgba(127, 224, 176, 0.3);
}

.tile.owned { background: #efe9d8; }

.tile.corner { background: linear-gradient(160deg, #fffdf4, #ece5d2); }
.tile.type-chance { background: #eaf4ff; }
.tile.type-tax { background: #ffeceb; }
.tile.type-jail { background: #e8e8ef; }
.tile.type-goto-jail { background: #f7e5e5; }
.tile.type-free { background: #e9f7ee; }

.board-center {
  grid-row: 2 / span 5;
  grid-column: 2 / span 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 35%, rgba(245, 214, 123, 0.1), transparent 70%), rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 14px;
  text-align: center;
}

#center-title {
  font-size: clamp(14px, 2vw, 19px);
  font-weight: 700;
  letter-spacing: 1px;
  color: #eaf7ee;
}

#dice {
  font-size: clamp(30px, 5.4vw, 54px);
  letter-spacing: 6px;
  line-height: 1;
  color: var(--gold);
  min-height: 1.1em;
  text-shadow: 0 6px 24px rgba(245, 214, 123, 0.35);
}

#center-hint {
  font-size: clamp(11px, 1.4vw, 14px);
  color: var(--muted);
  line-height: 1.5;
  max-width: 92%;
}

/* ---------- 侧栏 ---------- */

.side {
  width: 330px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 60px);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-tag { font-size: 13px; color: var(--muted); }
.room-tag b {
  color: var(--gold);
  letter-spacing: 3px;
  font-size: 15px;
}

.players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.players li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  font-size: 13px;
}

.players li.me { border-color: rgba(245, 214, 123, 0.45); background: rgba(245, 214, 123, 0.07); }
.players li.turn { box-shadow: 0 0 0 2px rgba(245, 214, 123, 0.55); }
.players li.dead { opacity: 0.45; }

.players .avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
}

.players .meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.players .pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.players .cash { color: var(--gold); font-variant-numeric: tabular-nums; font-size: 12px; }
.players .props { color: var(--muted); font-size: 11px; }
.players .badge {
  margin-left: auto;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.players .badge.off { color: #ffb4b4; border: 1px solid rgba(255, 180, 180, 0.35); }
.players .badge.now { color: #33240a; background: var(--gold); font-weight: 700; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  min-height: 66px;
  justify-content: center;
}

.actions .prompt {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.act {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #ffd97a, #e8b64b);
  color: #33240a;
}

.act.sub {
  background: rgba(255, 255, 255, 0.09);
  color: #dcefe4;
  border: 1px solid var(--line);
  font-weight: 600;
}

.act.danger {
  background: rgba(239, 107, 107, 0.12);
  color: #ffc9c9;
  border: 1px solid rgba(239, 107, 107, 0.3);
  font-weight: 500;
  font-size: 12.5px;
  padding: 8px;
}

.log-box {
  flex: 1 1 auto;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  overflow: hidden;
}

.log-box h3 {
  margin: 0;
  padding: 10px 14px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.log {
  list-style: none;
  margin: 0;
  padding: 8px 14px 12px;
  overflow-y: auto;
  flex: 1;
  font-size: 12px;
  line-height: 1.65;
  color: #cddfd5;
}

.log li { padding: 2px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.05); }
.log li:last-child:not(.chat) { color: #fff; }
.log::-webkit-scrollbar { width: 6px; }
.log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 3px; }

/* ---------- 聊天 ---------- */

.log li.chat {
  margin: 4px 0;
  padding: 5px 8px;
  border: none;
  border-left: 2px solid rgba(245, 214, 123, 0.45);
  border-radius: 0 8px 8px 0;
  background: rgba(245, 214, 123, 0.07);
  color: #f2f8f4;
  word-break: break-word;
}

.log li.chat .c-name {
  color: var(--gold);
  font-weight: 600;
  margin-right: 5px;
}

.log li.chat .c-emoji { margin-right: 4px; }

.chat-bar {
  border-top: 1px solid var(--line);
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.14);
}

.emoji-row { display: flex; gap: 6px; }

.emoji-btn {
  flex: 1;
  padding: 3px 0;
  font-size: 15px;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
}

.emoji-btn:hover { background: rgba(255, 255, 255, 0.14); }

.chat-form { display: flex; gap: 6px; }

.chat-form input {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 9px;
}

.chat-form .send {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 9px;
  flex: 0 0 auto;
}

/* ---------- 浮层 ---------- */

.banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(239, 107, 107, 0.95);
  color: #2a0d0d;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 50;
}

.toast {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  max-width: min(92vw, 460px);
  background: rgba(20, 32, 27, 0.96);
  border: 1px solid rgba(239, 107, 107, 0.5);
  color: #ffd7d7;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  z-index: 60;
}

.hidden { display: none !important; }

/* ---------- 窄屏 ---------- */

@media (max-width: 980px) {
  .app { align-items: flex-start; padding: 12px 10px 24px; }
  #screen-game { flex-direction: column; align-items: center; }
  .board { width: min(94vw, 560px); }
  .side { width: min(94vw, 560px); max-height: none; }
  .log-box { max-height: 200px; }
}
