/* =========================================================
 * 墨韵大富翁 3D —— 界面皮肤（水墨 / 宣纸）
 * 3D 画面由 canvas 负责，这里只做 DOM 浮层，绝不挡住拖拽
 * ========================================================= */
:root {
  --ink: #2E2A24;
  --ink-soft: #5E564A;
  --paper: #F3EBD9;
  --paper-a: rgba(243, 235, 217, .92);
  --line: rgba(46, 42, 36, .18);
  --seal: #B03A2E;
  --font: "STKaiti", "KaiTi", "楷体", "STSong", "SimSun", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: #E3D8C0;
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed; inset: 0;
  display: block;
  width: 100%; height: 100%;
  touch-action: none;
}

/* ---------------- HUD 通用 ---------------- */
.hud {
  position: fixed;
  z-index: 10;
  pointer-events: none;
}
.hud.tl { top: 18px; left: 20px; }
.hud.tr { top: 18px; right: 20px; text-align: right; }
.hud.bl { bottom: 18px; left: 20px; }
.hud.br { bottom: 18px; right: 20px; text-align: right; }

.title {
  font-size: 26px; font-weight: 700;
  letter-spacing: 4px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}
.sub {
  margin-top: 2px;
  font-size: 13px; color: var(--ink-soft);
  letter-spacing: 1px;
}
.phase {
  color: var(--seal);
  border-bottom: 1px solid rgba(176, 58, 46, .5);
}

/* ---------------- 按钮 ---------------- */
.btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 8px; }
.hud.bl .btn-row, .hud.br .btn-row { justify-content: flex-start; }
.hud.br .btn-row { justify-content: flex-end; }

button {
  pointer-events: auto;
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--ink);
  background: var(--paper-a);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  backdrop-filter: blur(2px);
}
button:hover { background: #FFFDF6; border-color: rgba(46, 42, 36, .4); }
button:active { transform: translateY(1px); }
button.on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
button:disabled {
  opacity: .42;
  cursor: not-allowed;
  filter: grayscale(.5);
}
button:disabled:hover { background: var(--paper-a); border-color: var(--line); }
button.primary:disabled:hover { background: var(--seal); }
button.primary {
  background: var(--seal);
  color: #FBF3E2;
  border-color: var(--seal);
  font-size: 15px;
  padding: 7px 18px;
}
button.primary:hover { background: #C24336; }
button.ghost { color: var(--ink-soft); }

/* ---------------- 玩家卡 ---------------- */
.round {
  font-size: 13px; color: var(--ink-soft);
  margin-bottom: 6px; letter-spacing: 1px;
}
#hud-players { display: flex; flex-direction: column; gap: 6px; }
.pcard {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-a);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 12px;
  font-size: 14px;
  min-width: 208px;
  transition: box-shadow .2s, background .2s;
}
.pcard.active {
  background: #FFFDF4;
  box-shadow: 0 0 0 2px rgba(176, 58, 46, .35);
}
.pcard .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pcard .pname { min-width: 42px; font-weight: 700; }
.pcard .pmoney { min-width: 62px; color: var(--ink-soft); }
.pcard .ppos { margin-left: auto; color: var(--ink-soft); font-size: 13px; }

/* ---------------- 格子信息卡 ---------------- */
.card {
  position: fixed;
  z-index: 11;
  left: 20px; top: 50%;
  transform: translateY(-50%) translateX(-14px);
  width: 220px;
  background: var(--paper-a);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  backdrop-filter: blur(3px);
  box-shadow: 0 6px 20px rgba(60, 48, 30, .12);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.card.show { opacity: 1; transform: translateY(-50%) translateX(0); }
.card .ct {
  font-size: 22px; font-weight: 700;
  letter-spacing: 3px;
  padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.card .cr {
  display: flex; justify-content: space-between;
  font-size: 13px; line-height: 1.9;
  color: var(--ink-soft);
}
.card .cr b { color: var(--ink); font-weight: 700; }

/* ---------------- 提示气泡 ---------------- */
.toast {
  position: fixed;
  z-index: 12;
  left: 50%; bottom: 84px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(46, 42, 36, .9);
  color: #F6EFDF;
  font-size: 14px; letter-spacing: 1px;
  padding: 8px 20px; border-radius: 3px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 加载遮罩 ---------------- */
.loading {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  background: #EDE4CE;
  transition: opacity .5s;
}
.loading.gone { opacity: 0; pointer-events: none; }
.loading .ink {
  width: 68px; height: 68px;
  display: flex; align-items: center; justify-content: center;
  background: var(--seal); color: #F6EFDF;
  font-size: 40px; font-weight: 700;
  animation: pulse 1.4s ease-in-out infinite;
}
.loading .lt { font-size: 14px; color: var(--ink-soft); letter-spacing: 2px; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.08); opacity: 1; } }

/* ---------------- 操作提示 ---------------- */
.tips {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: .5px;
  opacity: .85;
}

/* =========================================================
 * Phase 3：弹窗 / 道具栏
 * ========================================================= */
/* ---------------- 身份徽章 + 连接状态（联机） ---------------- */
.role-bar {
  display: none;
  align-items: center; gap: 8px;
  margin-top: 8px;
  pointer-events: auto;
}
.role-bar.show { display: flex; }
.role-badge {
  font-size: 12px; letter-spacing: 1px;
  padding: 2px 9px; border-radius: 2px;
  color: #FBF3E2; background: var(--seal);
}
.role-badge.p1 { background: #C0392B; }
.role-badge.p2 { background: #4A5FA5; }
.conn { font-size: 12px; color: var(--ink-soft); letter-spacing: .5px; }
.conn.bad { color: var(--seal); }

/* ---------------- 对手回合等待条 ---------------- */
.waiting {
  position: fixed; z-index: 11;
  top: 16px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(46, 42, 36, .9);
  color: #F6EFDF;
  font-size: 14px; letter-spacing: 1px;
  padding: 7px 22px; border-radius: 3px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.waiting.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.waiting .dots::after {
  content: ''; animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ''; } 25% { content: '·'; } 50% { content: '··'; } 75% { content: '···'; } }

.modal-mask {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(40, 34, 26, .42);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }

.modal {
  width: min(440px, 90vw);
  max-height: 84vh;
  overflow: auto;
  background: var(--paper);
  border: 1px solid rgba(46, 42, 36, .32);
  border-radius: 4px;
  padding: 20px 22px 18px;
  box-shadow: 0 18px 50px rgba(40, 30, 16, .38);
  transform: translateY(10px) scale(.98);
  transition: transform .18s cubic-bezier(.2, .8, .3, 1);
}
.modal-mask.show .modal { transform: translateY(0) scale(1); }

.m-title {
  font-size: 22px; font-weight: 700; letter-spacing: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.m-desc {
  margin-top: 8px;
  font-size: 13px; line-height: 1.7;
  color: var(--ink-soft);
}
.m-body { margin-top: 12px; }

.m-lines { display: flex; flex-direction: column; }
.m-line {
  display: flex; justify-content: space-between;
  font-size: 14px; line-height: 2.05;
  color: var(--ink-soft);
}
.m-line b { color: var(--ink); font-weight: 700; }

.m-items { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.m-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 255, 255, .38);
}
.mi-main { flex: 1; min-width: 0; }
.mi-label { font-size: 15px; }
.mi-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.mi-btns { display: flex; gap: 6px; flex: none; }

.m-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 16px; flex-wrap: wrap;
}

button.mini { padding: 4px 11px; font-size: 13px; }
button.danger { background: #8E2B22; color: #F7EFDF; border-color: #8E2B22; }
button.danger:hover { background: #A33329; }
button:disabled { opacity: .40; cursor: not-allowed; }
button:disabled:hover { background: var(--paper-a); border-color: var(--line); }

/* 道具栏 */
#hud-items { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 8px; flex-wrap: wrap; }
.item-btn {
  font-size: 13px;
  padding: 5px 12px;
  background: #FFFDF4;
  border-color: rgba(176, 58, 46, .45);
  color: #8E2B22;
}
.item-btn:hover { background: #FFF; border-color: rgba(176, 58, 46, .8); }

/* 放置路障时：光标变十字，提示条高亮 */
body.placing #scene { cursor: crosshair; }
body.placing .tips { color: var(--seal); font-weight: 700; opacity: 1; }

/* =========================================================
 * Phase 3+：联机大厅
 * ========================================================= */
.lobby {
  position: fixed; inset: 0; z-index: 45;
  display: flex; align-items: center; justify-content: center;
  background: rgba(40, 34, 26, .5);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.lobby.show { opacity: 1; pointer-events: auto; }

.lb-card {
  width: min(400px, 92vw);
  background: var(--paper);
  border: 1px solid rgba(46, 42, 36, .32);
  border-radius: 4px;
  padding: 22px 24px 18px;
  box-shadow: 0 18px 50px rgba(40, 30, 16, .45);
  transform: translateY(12px) scale(.98);
  transition: transform .2s cubic-bezier(.2, .8, .3, 1);
}
.lobby.show .lb-card { transform: translateY(0) scale(1); }

.lb-title {
  font-size: 22px; font-weight: 700; letter-spacing: 4px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.lb-desc { margin-top: 8px; font-size: 13px; line-height: 1.7; color: var(--ink-soft); }

.lb-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.lb-label { font-size: 13px; color: var(--ink-soft); flex: none; min-width: 30px; }
.lb-input {
  flex: 1; min-width: 0;
  font-family: var(--font); font-size: 14px; letter-spacing: 1px;
  color: var(--ink);
  background: #FFFDF4;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 11px;
}
.lb-input:focus { outline: none; border-color: rgba(176, 58, 46, .6); }
#code-input { text-transform: uppercase; letter-spacing: 4px; }

.lb-box {
  display: none; align-items: center; gap: 10px;
  margin-top: 14px; padding: 10px 14px;
  border: 1px dashed rgba(176, 58, 46, .5);
  border-radius: 3px;
  background: rgba(255, 255, 255, .45);
}
.lb-box.show { display: flex; }
.lb-hint { font-size: 12px; color: var(--ink-soft); }
.lb-code {
  font-size: 26px; font-weight: 700; letter-spacing: 8px;
  color: var(--seal); margin-left: auto;
}

.lb-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.lb-split {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 2px;
  color: var(--ink-soft); font-size: 12px;
}
.lb-split::before, .lb-split::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

.lb-msg {
  min-height: 34px; margin-top: 10px;
  font-size: 13px; line-height: 1.6;
  color: var(--ink-soft);
}
.lb-msg.err { color: var(--seal); }
.lb-msg.ok { color: #4E7A52; }

.lb-foot {
  display: flex; gap: 8px; justify-content: space-between;
  margin-top: 6px; padding-top: 12px;
  border-top: 1px solid var(--line);
}

@media (max-width: 720px) {
  .title { font-size: 20px; }
  .card { display: none; }
  .tips { max-width: 190px; }
  .pcard { min-width: 168px; font-size: 13px; }
  .modal { padding: 16px 16px 14px; }
  .m-title { font-size: 19px; }
}
