/* ==========================================================================
   林徽因风格主题 · 中国象棋对战
   设计语言: 黛青 / 月白 / 胭脂 / 藤黄 / 青绿山水 + 回纹窗棂古典纹样
   ========================================================================== */
:root {
  --ink: #2b3a42;          /* 黛青 */
  --ink-soft: #465a64;
  --paper: #f4efe1;        /* 宣纸月白 */
  --paper-2: #ece3cf;
  --rouge: #a5322f;        /* 胭脂 */
  --rouge-soft: #c05a4d;
  --gamboge: #c9a24b;      /* 藤黄 */
  --jade: #4a7c6f;         /* 青绿山水 */
  --jade-soft: #6f9a8c;
  --sandal: #b07c5b;       /* 檀色 */
  --gold-line: rgba(201, 162, 75, 0.55);
  --shadow: rgba(43, 58, 66, 0.22);
  --serif: "Noto Serif SC", "Songti SC", "STKaiti", "KaiTi", "SimSun", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--serif);
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #f7f2e6 0%, #ece2cc 55%, #e2d5b8 100%);
}

/* 宣纸肌理 + 淡淡的回纹底纹 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(0deg, transparent 23px, var(--gold-line) 24px),
    linear-gradient(90deg, transparent 23px, var(--gold-line) 24px);
  background-size: 24px 24px;
  mask-image: radial-gradient(circle at 50% 40%, rgba(0,0,0,0.10), transparent 70%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, rgba(0,0,0,0.10), transparent 70%);
}

.wrap { position: relative; z-index: 1; }

/* -------------------- 通用组件 -------------------- */
.btn {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--paper);
  background: linear-gradient(160deg, var(--rouge) 0%, #8f2723 100%);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--shadow), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 8px 22px var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: linear-gradient(160deg, #f6f0e0, #e6dcc4);
  color: var(--ink);
  border: 1px solid var(--gold-line);
}
.btn.jade { background: linear-gradient(160deg, var(--jade), #35594f); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.input {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--gold-line);
  border-radius: 8px;
  padding: 10px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--jade); box-shadow: 0 0 0 3px rgba(74,124,111,0.18); }

/* 带边框纹样的卡片 */
.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.25)),
    var(--paper);
  border: 1px solid var(--gold-line);
  border-radius: 14px;
  box-shadow: 0 10px 30px var(--shadow), inset 0 0 0 6px rgba(255,255,255,0.25);
  padding: 22px;
}
.panel::after { /* 内嵌回纹边角 */
  content: "";
  position: absolute; inset: 8px;
  border: 1px solid rgba(176,124,91,0.35);
  border-radius: 9px;
  pointer-events: none;
}

/* -------------------- 大厅 -------------------- */
.hero {
  text-align: center;
  padding: 46px 20px 24px;
}
.hero .seal {
  display: inline-flex; align-items: center; justify-content: center;
  width: 74px; height: 74px; margin-bottom: 14px;
  background: linear-gradient(145deg, var(--rouge), #7f221f);
  color: #fff2e0; font-size: 30px; border-radius: 12px;
  box-shadow: 0 6px 18px var(--shadow);
  transform: rotate(-4deg);
  border: 2px solid rgba(255,255,255,0.35);
}
.hero h1 {
  font-size: 40px; letter-spacing: 10px; color: var(--ink);
  text-shadow: 0 2px 0 rgba(255,255,255,0.6);
}
.hero .sub {
  margin-top: 10px; color: var(--jade); letter-spacing: 4px; font-size: 15px;
}
.hero .poem {
  margin-top: 8px; color: var(--sandal); font-size: 13px; letter-spacing: 2px; opacity: .85;
}

.lobby {
  max-width: 1040px; margin: 0 auto; padding: 10px 20px 60px;
  display: grid; grid-template-columns: 340px 1fr; gap: 24px;
}
@media (max-width: 860px) { .lobby { grid-template-columns: 1fr; } }

.lobby h2 {
  font-size: 20px; letter-spacing: 4px; margin-bottom: 16px; color: var(--ink);
  border-left: 4px solid var(--rouge); padding-left: 10px;
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: 2px; }
.field .input { width: 100%; }

.room-list { display: flex; flex-direction: column; gap: 12px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.room-card {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--gold-line);
  border-radius: 10px; padding: 14px 16px;
  transition: transform .12s, box-shadow .12s;
}
.room-card:hover { transform: translateX(3px); box-shadow: 0 6px 18px var(--shadow); }
.room-card .meta .title { font-size: 16px; letter-spacing: 2px; }
.room-card .meta .info { font-size: 12px; color: var(--ink-soft); margin-top: 4px; letter-spacing: 1px; }
.room-card .acts { display: flex; gap: 8px; }
.room-card .acts .btn { padding: 7px 14px; font-size: 13px; letter-spacing: 1px; }
.tag {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px;
  letter-spacing: 1px; margin-right: 6px; border: 1px solid transparent;
}
.tag.waiting { background: rgba(201,162,75,0.18); color: #9a7a2a; border-color: var(--gold-line); }
.tag.playing { background: rgba(74,124,111,0.18); color: var(--jade); border-color: var(--jade-soft); }
.tag.over { background: rgba(165,50,47,0.14); color: var(--rouge); }
.empty-hint { color: var(--ink-soft); text-align: center; padding: 40px 0; letter-spacing: 2px; }

/* -------------------- 对局页 -------------------- */
.game-layout {
  display: grid;
  grid-template-columns: 300px minmax(360px, 1fr) 320px;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .game-layout { grid-template-columns: 1fr; }
}

.board-stage {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
#board {
  border-radius: 12px;
  box-shadow: 0 14px 40px var(--shadow);
  cursor: pointer;
  touch-action: none;
}

.turn-banner {
  display: flex; align-items: center; gap: 12px;
  font-size: 16px; letter-spacing: 3px;
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--gold-line);
  border-radius: 30px; padding: 8px 20px;
}
.turn-banner .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,0.6); }
.turn-banner .dot.r { background: var(--rouge); }
.turn-banner .dot.b { background: var(--ink); }
.turn-banner.check { animation: pulse 1s infinite; color: var(--rouge); font-weight: bold; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.player-tag {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 10px; margin-bottom: 8px;
  background: rgba(255,255,255,0.5); border: 1px solid var(--gold-line);
}
.player-tag .side { display: flex; align-items: center; gap: 10px; }
.player-tag .chip { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 16px; }
.player-tag .chip.r { background: var(--rouge); }
.player-tag .chip.b { background: var(--ink); }
.player-tag .name { letter-spacing: 2px; }
.player-tag .voice-ind { font-size: 12px; color: var(--jade); }
.player-tag.active { box-shadow: 0 0 0 2px var(--gamboge); }

.section-title { font-size: 15px; letter-spacing: 3px; color: var(--ink); margin-bottom: 12px; display:flex; align-items:center; gap:8px; }
.section-title::before { content:""; width: 6px; height: 16px; background: var(--rouge); border-radius: 2px; }

/* 棋谱 */
.moves { max-height: 200px; overflow-y: auto; font-size: 13px; line-height: 1.9; color: var(--ink-soft); }
.moves .mv { display: inline-block; min-width: 46%; }
.moves .mv b { color: var(--rouge); }
.moves .mv.b b { color: var(--ink); }

/* 聊天室 */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-log {
  flex: 1; min-height: 220px; max-height: 46vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; padding: 4px;
}
.msg { font-size: 13px; line-height: 1.5; }
.msg .who { color: var(--jade); letter-spacing: 1px; }
.msg.player .who { color: var(--rouge); }
.msg .txt { color: var(--ink); }
.msg.sys { text-align: center; color: var(--sandal); font-size: 12px; letter-spacing: 1px; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input .input { flex: 1; }

/* 语音控制 */
.voice-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.voice-bar .btn { padding: 8px 14px; font-size: 13px; }
.voice-status { font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; }
.voice-status .live { color: var(--jade); }
.voice-status .off { color: var(--rouge); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1400px; margin: 0 auto; padding: 16px 24px 0;
}
.topbar .brand { font-size: 20px; letter-spacing: 6px; }
.topbar .brand .seal-mini {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  background: var(--rouge); color: #fff2e0; border-radius: 7px; margin-right: 10px;
  transform: rotate(-4deg); vertical-align: middle;
}
.topbar .room-id { font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; }

/* 结算浮层 */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: rgba(43,58,66,0.5); backdrop-filter: blur(3px);
}
.overlay.show { display: flex; }
.result-card { text-align: center; min-width: 300px; }
.result-card .big { font-size: 34px; letter-spacing: 8px; margin: 8px 0 4px; }
.result-card .big.win { color: var(--rouge); }
.result-card .big.lose { color: var(--ink); }
.result-card .reason { color: var(--ink-soft); letter-spacing: 2px; margin-bottom: 18px; }
.result-card .acts { display: flex; gap: 12px; justify-content: center; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 10px 22px; border-radius: 24px;
  letter-spacing: 2px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: all .25s ease; z-index: 60; box-shadow: 0 8px 24px var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spec-badge {
  display:inline-block; background: rgba(74,124,111,0.16); color: var(--jade);
  border:1px solid var(--jade-soft); border-radius: 20px; padding: 2px 10px;
  font-size:12px; letter-spacing:1px;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(176,124,91,0.4); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
