@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #172036;
  --muted: #74809b;
  --line: rgba(23,32,54,.11);
  --paper: #fbfcff;
  --surface: rgba(255,255,255,.88);
  --navy: #141b31;
  --blue: #3c7bff;
  --mint: #35b987;
  --gold: #f5b74a;
  --coral: #ed7b68;
  --shadow: 0 20px 60px rgba(31,48,88,.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: Manrope, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f4f7fc;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
.ambient { position: fixed; border-radius: 50%; filter: blur(8px); pointer-events: none; z-index: -1; }
.ambient-a { width: 52vw; height: 52vw; top: -34vw; left: -15vw; background: #dbe7ff; }
.ambient-b { width: 40vw; height: 40vw; right: -15vw; bottom: -20vw; background: #fff0d7; }

/* 动画效果 */
.float-text {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 24px; font-weight: 800; pointer-events: none; z-index: 1000;
  text-shadow: 0 2px 4px rgba(0,0,0,.2); opacity: 0;
  transition: opacity .3s ease, transform 1.5s ease;
}
.float-text.float-up {
  opacity: 1; transform: translate(-50%, -150%);
}

.path-highlight {
  box-shadow: 0 0 0 3px #f5b74a, 0 0 20px rgba(245,183,74,.5) !important;
  z-index: 5;
}

.die.rolling {
  animation: diceRoll .6s ease;
}
@keyframes diceRoll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(180deg) scale(1.2); }
  50% { transform: rotate(360deg) scale(.9); }
  75% { transform: rotate(540deg) scale(1.1); }
  100% { transform: rotate(720deg) scale(1); }
}

/* 抵押状态 */
.cell.mortgaged {
  opacity: .6; background: #f0f0f0;
}
.cell.mortgaged::after {
  content: "抵"; position: absolute; top: 2px; right: 2px;
  font-size: 8px; color: #fff; background: #ed7b68; padding: 1px 3px;
  border-radius: 3px; font-weight: 800;
}
.owner-strip.mortgaged {
  background: repeating-linear-gradient(45deg, #ed7b68, #ed7b68 2px, transparent 2px, transparent 4px) !important;
}

/* 拍卖面板 */
.auction-info {
  background: rgba(255,255,255,.9); padding: 8px 12px; border-radius: 8px;
  margin-bottom: 8px; font-size: 11px; text-align: center;
}
.auction-info div { margin: 2px 0; }
.primary-btn.gold { background: var(--gold); color: #333; }

#auctionPanel {
  position: absolute; top: 20%; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.95); padding: 20px; border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2); z-index: 100; text-align: center;
  display: none;
}
.auction-header { font-size: 14px; font-weight: 800; margin-bottom: 10px; }
.auction-current { font-size: 28px; font-weight: 800; color: var(--gold); }
.auction-timer { font-size: 12px; color: var(--muted); margin: 5px 0; }
.auction-bidders { font-size: 10px; color: var(--muted); }

/* 交易对话框 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.trade-dialog {
  background: #fff; padding: 24px; border-radius: 16px; width: min(90vw, 400px);
  max-height: 80vh; overflow-y: auto;
}
.trade-dialog h3 { margin: 0 0 16px; font-size: 18px; }
.trade-section { margin-bottom: 16px; }
.trade-section label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.trade-section input, .trade-section select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
}
.trade-cells {
  max-height: 120px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px;
}
.trade-cells label {
  display: flex; align-items: center; gap: 6px; padding: 4px 0;
  font-weight: 400; font-size: 12px; cursor: pointer;
}
.trade-actions { display: flex; gap: 10px; margin-top: 20px; }
.trade-actions button { flex: 1; }

/* 房间设置 */
.room-settings {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin: 16px 0;
}
.settings-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.settings-grid label {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.settings-grid input[type="number"], .settings-grid select {
  width: 80px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px;
}
.settings-grid input[type="checkbox"] {
  width: 16px; height: 16px;
}

/* 免狱卡标记 */
.player-item .freejail-badge {
  display: inline-block; background: var(--mint); color: #fff;
  font-size: 9px; padding: 2px 6px; border-radius: 10px; margin-left: 4px;
}
.primary-btn, .ghost-btn, .text-btn, .icon-btn {
  border: 0; transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  color: #fff; background: var(--navy); padding: 12px 18px; border-radius: 12px;
  font-weight: 800; box-shadow: 0 12px 24px rgba(20,27,49,.18);
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 28px rgba(20,27,49,.24); }
.primary-btn.blue { background: var(--blue); box-shadow: 0 12px 24px rgba(60,123,255,.25); }
.primary-btn.mint { background: var(--mint); box-shadow: 0 12px 24px rgba(53,185,135,.22); }
.primary-btn.full { width: 100%; margin-top: 12px; }
.ghost-btn { padding: 11px 14px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; font-weight: 700; }
.ghost-btn:hover { background: #f2f5fb; }
.text-btn { color: var(--muted); background: transparent; padding: 6px; }
.text-btn:hover { color: var(--ink); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.icon-btn:hover { color: var(--ink); background: #f2f5fb; }

/* login */
dialog { border: 0; padding: 0; border-radius: 26px; background: transparent; color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(17,26,48,.52); backdrop-filter: blur(8px); }
.login-card, .modal-card { width: min(92vw, 410px); padding: 38px; background: #fff; border-radius: 26px; }
.brand-mark { color: var(--blue); font-size: 34px; letter-spacing: -5px; font-weight: 800; line-height: 1; }
.brand-mark span { color: var(--gold); }
.eyebrow { margin: 12px 0 8px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 11px; letter-spacing: .14em; }
.login-card h1, .modal-card h2 { margin: 0; font-size: 30px; letter-spacing: -.05em; }
.login-copy { margin: 12px 0 26px; color: var(--muted); line-height: 1.7; font-size: 13px; }
.field-label { display: block; margin-bottom: 8px; font-weight: 800; font-size: 12px; }
.login-card input { width: 100%; border: 1px solid var(--line); background: #f7f9fd; border-radius: 12px; padding: 13px 14px; outline: 0; }
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(60,123,255,.12); }
.login-footnote { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 11px; }
.modal-card { text-align: center; }
.modal-card p:not(.eyebrow) { color: var(--muted); margin: 12px 0 22px; }

/* lobby + waiting */
.shell { width: min(1240px, calc(100vw - 48px)); margin: 0 auto; padding: 28px 0 40px; }
.top-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 44px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-lockup .brand-mark { font-size: 26px; }
.brand-name { font-weight: 800; letter-spacing: -.04em; }
.brand-sub { color: var(--muted); font-size: 11px; margin-left: 8px; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.connection-dot { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.connection-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(53,185,135,.12); }
.connection-dot.offline::before { background: var(--coral); box-shadow: 0 0 0 4px rgba(237,123,104,.12); }
.lobby-hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 42px; align-items: end; margin-bottom: 42px; }
.hero-kicker { color: var(--blue); font-family: "DM Mono", monospace; font-size: 11px; letter-spacing: .16em; }
.lobby-hero h1 { max-width: 620px; margin: 12px 0 16px; font-size: clamp(42px, 6vw, 78px); line-height: .98; letter-spacing: -.08em; }
.lobby-hero h1 em { color: var(--blue); font-style: normal; }
.hero-copy { max-width: 500px; color: var(--muted); line-height: 1.8; font-size: 14px; }
.hero-rail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric { border-top: 2px solid var(--ink); padding-top: 10px; }
.metric strong { display: block; font-size: 23px; }
.metric span { color: var(--muted); font-size: 11px; }
.section-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-line h2 { margin: 0; font-size: 15px; letter-spacing: -.02em; }
.rooms-list { display: grid; gap: 10px; }
.room-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px; padding: 15px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(31,48,88,.05); }
.room-row:hover { border-color: rgba(60,123,255,.3); transform: translateY(-1px); }
.room-name { font-weight: 800; }
.room-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.room-code { color: var(--muted); font-family: "DM Mono", monospace; font-size: 12px; }
.room-empty { padding: 42px 18px; text-align: center; color: var(--muted); border: 1px dashed rgba(23,32,54,.18); border-radius: 14px; }
.waiting-wrap { width: min(720px, calc(100vw - 48px)); margin: 9vh auto 0; }
.waiting-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.waiting-head h1 { margin: 0; font-size: clamp(30px, 5vw, 54px); letter-spacing: -.07em; line-height: 1; }
.waiting-sub { color: var(--muted); font-size: 12px; margin-top: 10px; }
.waiting-actions { display: flex; gap: 8px; }
.waiting-members { display: grid; gap: 9px; }
.member-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 12px; color: #fff; font-weight: 800; }
.member-copy { flex: 1; }
.member-name { font-weight: 800; }
.member-meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
.ready-chip { color: var(--muted); font-size: 11px; padding: 7px 10px; border-radius: 999px; background: #f0f2f7; }
.ready-chip.ready { color: #178a61; background: #e5f8f0; }
.waiting-note { margin-top: 16px; color: var(--muted); font-size: 12px; }

/* game shell */
.game-shell { width: min(1500px, calc(100vw - 26px)); margin: 0 auto; padding: 16px 0 24px; }
.game-nav { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 14px; }
.game-nav .brand-name { font-size: 15px; }
.game-nav .brand-sub { font-family: "DM Mono", monospace; }
.game-nav-right { display: flex; align-items: center; gap: 12px; }
.room-pill { color: var(--muted); font-size: 11px; font-family: "DM Mono", monospace; background: #fff; border: 1px solid var(--line); padding: 8px 10px; border-radius: 9px; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
.board-panel { min-width: 0; }
.board-frame { position: relative; width: min(88vh, 900px); max-width: 100%; aspect-ratio: 1; margin: 0 auto; padding: 14px; border-radius: 28px; background: #d7dbe8; box-shadow: 0 24px 70px rgba(35,48,83,.18), inset 0 0 0 1px rgba(255,255,255,.65); }
.board-frame::before { content: ""; position: absolute; inset: 7px; border-radius: 23px; border: 1px solid rgba(255,255,255,.8); pointer-events: none; }
.board-grid { position: absolute; inset: 14px; display: grid; grid-template-columns: repeat(11, 1fr); grid-template-rows: repeat(11, 1fr); gap: 4px; }
.cell { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; border-radius: 8px; background: #fffdf8; border: 1px solid rgba(23,32,54,.1); color: var(--ink); box-shadow: 0 3px 8px rgba(23,32,54,.07); text-align: center; transition: transform .2s ease, box-shadow .2s ease; }
.cell.highlight { box-shadow: 0 0 0 3px var(--blue), 0 6px 18px rgba(60,123,255,.32); z-index: 2; }
.cell:hover { transform: translateY(-2px); z-index: 3; }
.group-bar { width: 100%; height: 8px; flex: 0 0 auto; }
.cell-label { max-width: 95%; padding: 5px 3px 0; font-size: clamp(8px, .78vw, 12px); font-weight: 800; line-height: 1.12; word-break: break-all; }
.cell-price { color: var(--muted); font-size: clamp(8px, .7vw, 11px); margin-top: 4px; }
.house-row { display: flex; align-items: center; justify-content: center; gap: 2px; min-height: 12px; margin-top: 3px; }
.building-mark { display: inline-block; width: 11px; height: 12px; background-image: url('building-sprite.png'); background-size: 200% 100%; background-repeat: no-repeat; }
.building-mark.house { background-position: 0 0; }
.building-mark.hotel { width: 14px; height: 13px; background-position: 100% 0; }
.special { justify-content: center; background: #eff3fb; }
.special .cell-label { font-size: clamp(9px, .86vw, 13px); }
.rail { background: #f3e9dd; }
.util { background: #e7f5f2; }
.tax { background: #fff0e9; }
.owner-strip { position: absolute; width: 5px; inset: 0 auto 0 0; }
.token-area { position: absolute; right: 3px; bottom: 3px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; max-width: 75%; }
.token { display: inline-flex; align-items: center; justify-content: center; width: clamp(15px, 1.65vw, 24px); height: clamp(15px, 1.65vw, 24px); border-radius: 8px; border: 2px solid #fff; color: transparent; font-size: 0; font-weight: 800; background-color: transparent; background-image: url('pawn-sprite.png'); background-size: 200% 200%; background-repeat: no-repeat; box-shadow: 0 3px 8px rgba(23,32,54,.22); }
.token-red { background-position: 0 0; }
.token-blue { background-position: 100% 0; }
.token-green { background-position: 0 100%; }
.token-gold { background-position: 100% 100%; }
.cell-art { width: 82%; height: 52%; min-height: 22px; margin-top: 4px; background-image: url('special-sprite.png'); background-size: 200% 300%; background-repeat: no-repeat; background-position: 0 0; background-color: transparent; }
.cell-art.start { background-position: 0 0; }
.cell-art.jail { background-position: 100% 0; }
.cell-art.chance { background-position: 0 50%; }
.cell-art.chest { background-position: 100% 50%; }
.cell-art.rail { background-position: 0 100%; }
.cell-art.util { background-position: 100% 100%; }
.cell-art.tax, .cell-art.park { background-image: url('economy-sprite.png'); background-size: 200% 100%; }
.cell-art.tax { background-position: 0 0; }
.cell-art.park { background-position: 100% 0; }
.board-center { position: absolute; inset: 20%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 20px; border-radius: 20px; overflow: hidden; background: #c9d5df url('board-park.png') center/cover; box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); }
.board-center::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(19,34,62,.16), rgba(19,34,62,.46)); pointer-events: none; }
.board-center > * { position: relative; z-index: 1; }
.center-brand { margin-top: 4px; color: #fff; text-align: center; text-shadow: 0 3px 14px rgba(19,34,62,.4); }
.center-brand small { display: block; font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .15em; opacity: .8; }
.center-brand strong { display: block; margin-top: 7px; font-size: clamp(22px, 3vw, 42px); letter-spacing: -.08em; }
.turn-card { width: min(260px, 95%); padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.9); box-shadow: 0 12px 30px rgba(19,34,62,.16); }
.turn-card-label { color: var(--muted); font-size: 10px; }
.turn-card-main { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 13px; font-weight: 800; }
.turn-card-main .avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
.turn-timer { margin-left: auto; color: var(--blue); font-family: "DM Mono", monospace; font-size: 11px; }
.dice-stack { display: flex; align-items: center; gap: 9px; }
.die { display: inline-flex; align-items: center; justify-content: center; width: clamp(42px, 5vw, 62px); height: clamp(42px, 5vw, 62px); border-radius: 14px; color: var(--ink); background: #fff; font-size: clamp(26px, 3vw, 38px); box-shadow: 0 12px 22px rgba(19,34,62,.2); animation: dicePop .45s ease; }
@keyframes dicePop { from { transform: translateY(-8px) rotate(-10deg); opacity: .2; } to { transform: translateY(0) rotate(0); opacity: 1; } }
.center-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; width: 100%; }
.center-actions .primary-btn, .center-actions .ghost-btn { padding: 10px 14px; font-size: 12px; }
.debt-alert { width: min(260px, 95%); padding: 8px 10px; border-radius: 10px; color: #9f3f32; background: #fff0ed; font-size: 11px; text-align: center; }

/* sidebar */
.sidebar { display: grid; gap: 12px; }
.side-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: 0 10px 28px rgba(31,48,88,.06); }
.side-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 12px; font-weight: 800; }
.side-title span { color: var(--muted); font-size: 10px; font-family: "DM Mono", monospace; font-weight: 400; }
.player-list { display: grid; gap: 7px; }
.player-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 8px; border-radius: 10px; }
.player-item.active { background: #edf3ff; }
.player-item.me { outline: 1px solid rgba(60,123,255,.24); }
.player-item .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }
.player-copy { min-width: 0; }
.player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 800; }
.player-sub { color: var(--muted); font-size: 10px; margin-top: 2px; }
.player-money { color: #16845b; font-family: "DM Mono", monospace; font-size: 11px; font-weight: 500; }
.player-item.dead { opacity: .42; filter: grayscale(1); }
.inspect-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 11px; }
.inspect-grid dt { color: var(--muted); }
.inspect-grid dd { margin: 0; font-family: "DM Mono", monospace; font-weight: 500; }
.property-chip { display: inline-flex; align-items: center; gap: 6px; margin: 5px 4px 0 0; padding: 5px 7px; border-radius: 7px; background: #f0f3f8; color: var(--ink); font-size: 10px; }
.property-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
.event-list { display: grid; gap: 7px; max-height: 250px; overflow: auto; }
.event-row { display: grid; grid-template-columns: 52px 1fr; gap: 7px; color: #505c73; font-size: 10px; line-height: 1.45; }
.event-time { color: #a2abc0; font-family: "DM Mono", monospace; }
.event-empty { color: var(--muted); font-size: 11px; }
.status-bar { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; padding: 0 4px; color: var(--muted); font-size: 10px; }
.status-bar strong { color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 20; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; color: #fff; background: var(--navy); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 12px; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) 290px; }
  .board-frame { width: min(82vh, 760px); }
}
@media (max-width: 820px) {
  .shell, .game-shell { width: min(100% - 24px, 680px); }
  .top-nav { margin-bottom: 28px; }
  .lobby-hero { grid-template-columns: 1fr; gap: 24px; }
  .lobby-hero h1 { font-size: clamp(42px, 13vw, 68px); }
  .game-layout { grid-template-columns: 1fr; }
  .board-frame { width: min(94vw, 680px); }
  .sidebar { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .sidebar .side-panel:last-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .brand-sub, .connection-dot { display: none; }
  .room-row { grid-template-columns: 1fr auto; gap: 6px; }
  .room-code { grid-column: 1; }
  .room-row .primary-btn { grid-row: 1 / 3; grid-column: 2; }
  .waiting-wrap { margin-top: 4vh; }
  .waiting-head { align-items: flex-start; flex-direction: column; }
  .waiting-actions { width: 100%; }
  .waiting-actions button { flex: 1; }
  .sidebar { grid-template-columns: 1fr; }
  .sidebar .side-panel:last-child { grid-column: auto; }
  .board-frame { padding: 8px; border-radius: 18px; }
  .board-grid { inset: 8px; gap: 2px; }
  .board-center { inset: 19%; padding: 10px; border-radius: 12px; }
  .center-brand strong { font-size: 20px; }
  .center-brand small { font-size: 8px; }
  .turn-card { padding: 8px; }
  .center-actions .primary-btn, .center-actions .ghost-btn { padding: 8px 10px; font-size: 10px; }
}
