/* =========================================================
 * Bố cục kiểu opolyx: cột trái gọn (người chơi, tài sản, thao tác nhanh)
 * + bàn cờ lớn, đứng yên khi cuộn trang. Nạp sau style.css để ghi đè.
 * ========================================================= */
#game { gap: 18px; padding: 10px 14px; }
#side {
  width: 300px; max-height: none; overflow: visible; background: transparent; box-shadow: none; padding: 0; gap: 10px;
}
#board-wrap { position: sticky; top: 10px; align-self: flex-start; }
body.narrow #game { flex-direction: column; }
body.narrow #board-wrap { order: -1; position: static; }
body.narrow #side { width: min(var(--S), 100%); }

/* Thẻ người chơi – gọn */
#players { gap: 8px; }
.pcard {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 2px 10px; align-items: center;
  background: #fff; border-radius: 14px; padding: 8px 10px; border: 2px solid transparent;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.pcard.cur { border-color: var(--pc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 22%, transparent), 0 6px 16px rgba(0,0,0,.16); }
.pav {
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: color-mix(in srgb, var(--pc) 16%, white); border: 2.5px solid var(--pc); flex: none;
}
.pinfo { min-width: 0; }
.pcard .pname { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .ptag { font-size: 10.5px; padding: 0 5px; }
.pcard .pmoney { font-size: 18px; font-weight: 900; line-height: 1.15; }
.phouse { color: #8f9aa5; font-weight: 700; font-size: 13px; align-self: start; padding-top: 2px; }
.pcard .pprops { grid-column: 1 / -1; margin-top: 2px; }
.pcard .pprops:empty { display: none; }
.pcard .pstat { grid-column: 1 / -1; margin-top: 0; font-size: 11px; }
.odot { width: 8px; height: 8px; border-radius: 50%; background: #c3c9c6; display: inline-block; flex: none; }
.odot.on { background: #2bb673; box-shadow: 0 0 0 3px rgba(43,182,115,.18); }

/* Quản lý tài sản – gọn */
.apanel { border-radius: 14px; padding: 12px; gap: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.ap-h { font-size: 15px; }
.ap-hint { font-size: 12.5px; }
.ap-trade { padding: 9px; font-size: 14px; }
.side-actions { display: flex; justify-content: space-between; align-items: center; }
.side-actions .btn.ghost { background: rgba(255,255,255,.92); }
.room-badge { font-weight: 800; color: #fff; opacity: .9; }

/* Giữa bàn cờ: lượt chơi, xúc xắc, nút, trò chuyện (không còn logo & chồng bài) */
#center { justify-content: flex-start; padding: calc(var(--S) * 0.02); gap: calc(var(--S) * 0.011); }
.c-top { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.turn-info { font-size: calc(var(--S) * 0.017); }
.wait-info { font-size: calc(var(--S) * 0.015); color: var(--muted); min-height: 1.3em; font-weight: 600; }
.wait-info.urgent { color: var(--red); font-weight: 800; }
.chatbox {
  flex: 1; min-height: 0; width: 100%; background: #fff; border-radius: 14px; display: flex; flex-direction: column;
  box-shadow: 0 4px 14px rgba(0,0,0,.08); overflow: hidden; margin-top: calc(var(--S) * 0.004);
}
.chat-h { padding: 8px 14px; font-weight: 800; font-size: 14px; border-bottom: 1px solid #edf0ee; flex: none; }
.chat-list, #log {
  flex: 1; min-height: 0; max-height: none; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px;
  background: transparent; border-radius: 0; font-size: 13px;
}
.msg.sys { align-self: center; background: #f1f3f2; color: #66706b; border-radius: 99px; padding: 3px 12px; font-size: 12px; text-align: center; max-width: 96%; line-height: 1.35; }
.msg.chat { align-self: flex-start; background: #eef5ff; border-radius: 14px 14px 14px 4px; padding: 5px 10px; max-width: 85%; display: flex; flex-direction: column; font-size: 13.5px; }
.msg.chat.me { align-self: flex-end; background: #e5f7ec; border-radius: 14px 14px 4px 14px; }
.msg .who { font-size: 11px; font-weight: 800; color: #5b6560; }
.chat-form { display: flex; gap: 8px; padding: 7px 9px; border-top: 1px solid #edf0ee; flex: none; }
.chat-form .inp { flex: 1; border-radius: 12px; padding: 7px 10px; }
.chat-form .btn { width: 40px; padding: 0; font-size: 18px; border-radius: 12px; }
body.narrow .chatbox { min-height: 80px; }

/* Màn hình chính: chơi online */
.online-box { background: #f3f8ff; border: 1px solid #d6e6ff; border-radius: 16px; padding: 14px 16px; margin-top: 14px; }
.online-box h3 { margin: 0 0 10px; }
.on-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.on-actions > .btn { flex: 1 1 160px; }
.on-join { display: flex; gap: 6px; flex: 1 1 220px; }
.on-join .inp { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .15em; font-weight: 800; }
#on-note { margin-top: 8px; }
#on-note code { background: #fff; padding: 1px 5px; border-radius: 5px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #e0e5e2; }

/* Phòng chờ */
.lobby-card { width: min(720px, 100%); }
.lb-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.lb-code { font-size: 36px; font-weight: 900; letter-spacing: .18em; color: var(--red); line-height: 1.1; }
.lb-code.sm { font-size: 22px; }
.lockbtn { font-size: 15px; padding: 10px 16px; }
.lockbtn.locked { background: #fdecea; color: #b71c1c; box-shadow: inset 0 0 0 2px #f2b8b5; }
.lockbtn:disabled { opacity: .85; cursor: default; }
.lb-invite { display: flex; gap: 16px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.lb-qr {
  width: 156px; height: 156px; background: #fff; border: 1px solid #e3e7e4; border-radius: 14px; padding: 6px;
  display: flex; align-items: center; justify-content: center; flex: none; text-align: center;
}
.lb-qr svg { width: 100%; height: 100%; }
.lb-link { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lb-seat { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #f6f7f6; border-radius: 14px; margin-bottom: 8px; border-left: 5px solid var(--pc); }
.pav.sm { width: 40px; height: 40px; font-size: 22px; border-radius: 12px; border-width: 2px; }
.pav[data-mytoken] { cursor: pointer; }
.lb-name { flex: 1; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ptag.host { background: #fff3c4; color: #8a6d00; }
.inp.sm { padding: 5px 6px; font-size: 12.5px; }
#lb-host-tools { margin-bottom: 4px; }
.lb-chatbox { height: 210px; border: 1px solid #e3e7e4; box-shadow: none; }
#lb-wait { width: 100%; padding: 8px; }

/* Ô Jackpot */
.type-jackpot { background: linear-gradient(135deg, #fff8e1, #fce4ec); }
.type-jackpot .c-name { color: #8e24aa; }
.jp-m { width: min(440px, 100%); }
.jp-nums { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 12px 0; }
.die.jp-n { --d: 52px; width: 100%; height: auto; aspect-ratio: 1; border: 0; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.die.jp-n:hover { transform: translateY(-2px); }
.die.jp-n.sel { transform: translateY(-5px); box-shadow: 0 0 0 3px #ffb300, 0 10px 18px rgba(0,0,0,.25); background: radial-gradient(circle at 30% 25%, #fffdf3, #ffe9a8); }
.jp-table { display: flex; gap: 8px; }
.jp-table div { flex: 1; text-align: center; background: #f6f7f6; border-radius: 12px; padding: 8px 4px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.jp-table div span { font-weight: 800; color: #2e7d32; }
.jp-table div.on { background: #fff3c4; box-shadow: inset 0 0 0 2px #ffb300; }
.jp-pop { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 45; pointer-events: none; background: rgba(0,0,0,.28); animation: fade .15s; }
.jp-card { background: linear-gradient(160deg, #4a148c, #880e4f); color: #fff; border-radius: 20px; padding: 18px 28px 20px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.45); min-width: 270px; animation: pop .2s; }
.jp-h { font-weight: 900; letter-spacing: .04em; color: #ffd600; }
.jp-picks { margin-top: 8px; }
.jp-picks b { display: inline-block; width: 28px; height: 28px; line-height: 28px; border-radius: 7px; background: #fff; color: #4a148c; margin: 0 2px; }
.die.jp-die { --d: 86px; margin: 16px auto 10px; }
.jp-res { font-size: 22px; font-weight: 900; min-height: 1.3em; }
.jp-res.win { color: #ffd600; text-shadow: 0 0 14px rgba(255,214,0,.6); }
.jp-res.lose { color: #ffcdd2; }

/* Căn giữa màn hình vào phòng & phòng chờ */
#join, #lobby { min-height: 100%; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; }
#join .setup-card { margin-top: 6vh; }

/* Bảng luật chơi */
.rules-form { display: flex; flex-direction: column; gap: 2px; }
.rf-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14.5px; }
.rf-row > span { flex: 1; }
.rf-row .inp { flex: none; max-width: 62%; }
.rf-row .inp.num { width: 90px; }
.rf-chk { cursor: pointer; }
.rf-chk input { width: 22px; height: 22px; flex: none; accent-color: var(--red); }
.rf-pass { margin-top: 8px; }
.rf-pass .rf-row .inp { flex: 1; max-width: none; }
.jn-pass { width: 100%; margin-top: 4px; }
.type-jackpot .c-sub { font-weight: 800; color: #6a1b9a; }

.turn-info { white-space: nowrap; }
.turn-info b { white-space: nowrap; }

/* Vay ngân hàng */
.loan-box { margin-top: 4px; border-radius: 12px; padding: 10px; background: #f4efff; border: 1px solid #e0d4ff; display: flex; flex-direction: column; gap: 6px; }
.loan-box.on { background: #fff4e5; border-color: #ffd8a8; }
.loan-h { font-weight: 800; color: #5b2bbf; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.loan-box.on .loan-h { color: #b85c00; }
.loan-due { font-size: 11.5px; background: #fff; border-radius: 99px; padding: 1px 8px; }
.loan-btn { background: #9c6bff; color: #fff; padding: 9px; font-size: 14px; }
.loan-box.on .loan-btn { background: #fb8c00; }
.loan-btn:disabled { opacity: .5; }

/* Khung vay tiền (3 cơ chế) */
.loan-box { background: #faf8ff; border-color: #e6ddff; gap: 8px; }
.loan-h { color: #4a2a9e; }
.ln-row { background: #fff; border: 1px solid #ece6ff; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.ln-row.on { background: #fff6ea; border-color: #ffd8a8; }
.ln-t { font-weight: 800; font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.loan-btn.sm { padding: 7px; font-size: 13px; }
.ln-row.on .loan-btn { background: #fb8c00; }

/* Menu ở đầu cột trái */
.side-actions { order: -1; }
.menu-btn { background: #fff; color: var(--ink); font-size: 15px; padding: 9px 16px; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.menu-btn:hover { background: #fff8e1; }

/* Màu nền riêng: bến/ga, điện/nước, thuế */
.tile.type-station { background: #dbe8f6; }
.tile.type-utility { background: #fff1c9; }
.tile.type-tax { background: #fbdcdc; }
.tile.type-station .nm { color: #1f4e79; }
.tile.type-utility .nm { color: #8a5a00; }
.tile.type-tax .nm { color: #a31515; }

/* Ô đã có chủ: viền dày + dải màu chủ ở mép ngoài, có quân cờ */
.tile.owned { box-shadow: inset 0 0 0 calc(var(--S) * 0.0045) var(--own); }
.owner-bar {
  display: none; position: absolute; z-index: 2; background: var(--own); color: #fff;
  align-items: center; justify-content: center; font-size: calc(var(--E) * 0.2); line-height: 1;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.tile.owned .owner-bar { display: flex; }
.side-bottom .owner-bar { left: 0; right: 0; bottom: 0; height: 21%; }
.side-top .owner-bar { left: 0; right: 0; top: 0; height: 21%; }
.side-left .owner-bar { top: 0; bottom: 0; left: 0; width: 19%; }
.side-right .owner-bar { top: 0; bottom: 0; right: 0; width: 19%; }
.tile.mortgaged .owner-bar { background: repeating-linear-gradient(45deg, var(--own) 0 5px, #9e9e9e 5px 9px); }

/* Danh sách tài sản theo nhóm màu trong vùng cuộn riêng */
.ap-groups { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; margin-right: -4px; }
.ap-groups::-webkit-scrollbar { width: 6px; }
.ap-groups::-webkit-scrollbar-thumb { background: #c9cfcc; border-radius: 3px; }

/* Màn hình nhập code & đăng nhập */
.auth-screen { min-height: 100%; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 12px 24px; }
.auth-card { width: min(420px, 100%); }
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.auth-label { font-weight: 800; font-size: 15px; text-align: center; }
.auth-inp { font-size: 16px; padding: 12px 14px; border-radius: 12px; }
.code-inp { text-align: center; letter-spacing: .18em; font-weight: 800; text-transform: uppercase; }
.auth-msg { margin-top: 12px; color: var(--red); font-weight: 600; text-align: center; min-height: 1.2em; font-size: 14px; }
.auth-msg code { background: #f3f5f4; padding: 1px 5px; border-radius: 5px; color: var(--ink); }
.auth-tabs { display: flex; gap: 6px; margin-top: 16px; background: #f1f3f2; padding: 4px; border-radius: 12px; }
.auth-tab { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 9px; font: inherit; font-weight: 700; cursor: pointer; color: var(--muted); }
.auth-tab.on { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.user-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; margin: -6px 0 8px; }
.user-bar:empty { display: none; }
.pname-in[readonly] { background: #f6f7f6; }
