/* ============ 楚汉争锋 · 样式 ============ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&family=Cinzel:wght@500;700&display=swap');

:root {
  --gold: #d9b45f;
  --gold-bright: #f2d896;
  --gold-dim: rgba(217, 180, 95, .35);
  --ink: #0a0e14;
  --surface: rgba(255, 255, 255, .035);
  --surface-hover: rgba(255, 255, 255, .06);
  --border: rgba(217, 180, 95, .16);
  --border-strong: rgba(217, 180, 95, .4);
  --text: #ece6d9;
  --text-muted: #8e929c;
  --red: #d9534f;
  --jade: #4fb3a5;
  --serif: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  --display: 'Cinzel', 'Noto Serif SC', serif;
}

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

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

body {
  font-family: var(--serif);
  background: var(--ink);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 背景氛围 */
.ambient {
  position: fixed; inset: 0; z-index: -3;
  background:
    radial-gradient(ellipse 90% 70% at 50% -10%, rgba(45, 68, 74, .45), transparent 65%),
    radial-gradient(ellipse 60% 60% at 10% 100%, rgba(88, 48, 32, .22), transparent 70%),
    radial-gradient(ellipse 50% 50% at 95% 80%, rgba(30, 60, 58, .18), transparent 70%),
    linear-gradient(180deg, #0d131a 0%, #090c11 100%);
}
.ambient-grid {
  position: fixed; inset: 0; z-index: -2; pointer-events: none; opacity: .28;
  background-image:
    linear-gradient(rgba(217,180,95,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217,180,95,.035) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000, transparent 90%);
}

/* 顶栏 */
.topbar {
  max-width: 1360px; margin: 0 auto; padding: 26px 36px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand-seal {
  width: 52px; height: 52px; flex: 0 0 52px;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 900; color: #fff2d8;
  background: linear-gradient(145deg, #a4342c, #7a1f1a);
  border: 1px solid rgba(255, 220, 160, .45);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(150, 40, 30, .35), inset 0 1px 0 rgba(255,255,255,.2);
  transform: rotate(-3deg);
}
.brand-text h1 {
  font-size: 27px; font-weight: 900; letter-spacing: 5px; line-height: 1.15;
  background: linear-gradient(100deg, #f7e3b0, #d9b45f 45%, #fff0c8 75%, #c99a45);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 24px rgba(217, 180, 95, .12);
}
.brand-text p { font-family: var(--display); font-size: 10px; letter-spacing: 2.6px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 0 4px rgba(79,179,165,.12), 0 0 12px var(--jade); animation: pulse 2s infinite; }
.live-dot.thinking { background: var(--gold); box-shadow: 0 0 0 4px rgba(217,180,95,.12), 0 0 12px var(--gold); }
.sep { width: 1px; height: 14px; background: var(--border); }
.turn-badge { padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: 30px; color: var(--gold-bright); font-size: 12px; background: rgba(217,180,95,.06); letter-spacing: 1px; }
.turn-badge.black { color: #b9c6d0; border-color: rgba(185,198,208,.28); background: rgba(185,198,208,.05); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* 布局 */
.layout {
  max-width: 1360px; margin: 0 auto; padding: 8px 36px 50px;
  display: grid; grid-template-columns: minmax(0, 1fr) 338px; gap: 32px; align-items: start;
}

/* 棋盘区 */
.board-section { display: flex; flex-direction: column; align-items: center; }
.board-frame {
  position: relative; width: 100%; max-width: 716px; padding: 14px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(217,180,95,.16), rgba(217,180,95,.03) 40%, rgba(0,0,0,.25));
  border: 1px solid var(--border-strong);
  box-shadow: 0 26px 70px rgba(0,0,0,.55), 0 0 60px rgba(217,180,95,.05), inset 0 1px 0 rgba(255,240,200,.12);
}
.board-frame::before {
  content: ''; position: absolute; inset: 5px; border: 1px solid rgba(217,180,95,.12); border-radius: 8px; pointer-events: none;
}
#board { display: block; width: 100%; height: auto; border-radius: 4px; cursor: pointer; touch-action: manipulation; }
#fxCanvas { position: absolute; inset: 14px; z-index: 20; width: calc(100% - 28px); height: calc(100% - 28px); pointer-events: none; }
.board-vignette { position: absolute; inset: 14px; pointer-events: none; border-radius: 4px; box-shadow: inset 0 0 42px rgba(40,22,8,.28); }
.board-caption {
  margin-top: 18px; display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 12px;
  font-size: 12px; color: var(--text-muted); letter-spacing: .5px;
}
.cap-item { display: inline-flex; align-items: center; gap: 6px; }
.cap-dot { width: 7px; height: 7px; border-radius: 50%; }
.cap-dot.red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.cap-divider { width: 1px; height: 11px; background: var(--border); }

/* 面板 */
.panel { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px;
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 15px; }
.card-icon { color: var(--gold); font-size: 15px; }
.card-head h3 { font-size: 14px; font-weight: 600; letter-spacing: 2px; color: #e8dcc0; }
.card-badge { margin-left: auto; font-size: 11px; color: var(--text-muted); border: 1px solid var(--border); padding: 3px 9px; border-radius: 20px; }

/* 执子选择 */
.side-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.side-btn {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer;
  background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.07); border-radius: 7px;
  color: var(--text); transition: .25s ease; font-family: var(--serif); text-align: left;
}
.side-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.side-btn.active { background: linear-gradient(135deg, rgba(217,180,95,.18), rgba(217,180,95,.05)); border-color: var(--gold); box-shadow: 0 0 16px rgba(217,180,95,.1); }
.side-piece { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-size: 19px; font-weight: 900; }
.side-piece.red { background: radial-gradient(circle at 35% 30%, #f2d9b4, #a9794b); color: #8f2018; border: 2px solid rgba(126,42,24,.6); }
.side-piece.black { background: radial-gradient(circle at 35% 30%, #58636d, #161e25); color: #efe2c4; border: 2px solid rgba(214,196,158,.45); }
.side-label { font-size: 11px; letter-spacing: .5px; color: var(--text-muted); }
.side-btn.active .side-label { color: var(--gold-bright); }

/* 将军横幅 */
.check-banner {
  position: absolute; top: 22px; left: 50%; transform: translate(-50%, -22px); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 10px 26px; border-radius: 6px;
  font-size: 20px; font-weight: 900; letter-spacing: 6px; white-space: nowrap; pointer-events: none;
  color: #fff2cf; background: linear-gradient(100deg, rgba(150,40,25,.95), rgba(200,65,35,.92), rgba(150,40,25,.95));
  border: 1px solid rgba(255,180,100,.5);
  box-shadow: 0 0 34px rgba(220,70,35,.6), inset 0 1px 0 rgba(255,255,255,.2);
  opacity: 0; visibility: hidden; transition: transform .22s ease;
}
.check-banner.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); animation: checkShake .5s ease; }
.check-banner.danger { background: linear-gradient(100deg, rgba(170,25,20,.97), rgba(230,50,30,.95), rgba(170,25,20,.97)); box-shadow: 0 0 40px rgba(255,50,30,.7); }
.check-icon { font-size: 17px; animation: pulse .7s ease infinite; }
@keyframes checkShake { 0%,100%{transform:translate(-50%,0)} 25%{transform:translate(calc(-50% - 6px),0)} 75%{transform:translate(calc(-50% + 6px),0)} }

/* 棋谱学习 */
.learn-card .card-badge { font-size: 9px; padding: 3px 6px; }
.book-text {
  width: 100%; height: 92px; resize: vertical; padding: 9px 10px; font-family: var(--serif); font-size: 11px;
  line-height: 1.6; color: var(--text); background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px; outline: none;
}
.book-text:focus { border-color: var(--border-strong); }
.book-text::placeholder { color: #636973; }
.book-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.book-actions .btn { padding: 9px 6px; font-size: 12px; }
.use-book-label { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 11px; color: var(--text-muted); cursor: pointer; }
.use-book-label input { accent-color: var(--gold); cursor: pointer; }

/* 难度选择 */
.level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.level-btn {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 12px 14px; cursor: pointer; text-align: left;
  background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.07); border-radius: 7px;
  color: var(--text); transition: .25s ease; font-family: var(--serif);
}
.level-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.level-btn.active {
  background: linear-gradient(135deg, rgba(217,180,95,.18), rgba(217,180,95,.05));
  border-color: var(--gold); box-shadow: 0 0 18px rgba(217,180,95,.1), inset 0 1px 0 rgba(255,240,200,.12);
}
.level-btn.active::after { content: '✦'; position: absolute; top: 8px; right: 10px; color: var(--gold-bright); font-size: 11px; }
.lv-name { font-size: 15px; font-weight: 600; letter-spacing: 2px; }
.level-btn.active .lv-name { color: var(--gold-bright); }
.lv-desc { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; }
.level-hint { margin-top: 12px; font-size: 11px; color: var(--gold-dim); line-height: 1.6; min-height: 18px; }

/* 对局信息 */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 5px; align-items: center; padding: 10px 4px; background: rgba(0,0,0,.18); border-radius: 6px; border: 1px solid rgba(255,255,255,.04); }
.stat-label { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; }
.stat-value { font-family: var(--display); font-size: 19px; font-weight: 700; color: #e6dcc4; }
.red-val { color: #e87b72; } .dark-val { color: #9fb0bc; }
.captured-box { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.cap-line { display: flex; align-items: flex-start; gap: 10px; font-size: 11px; color: var(--text-muted); }
.cap-line > span { flex: 0 0 58px; padding-top: 3px; }
.cap-pieces { display: flex; flex-wrap: wrap; gap: 3px; color: var(--gold); }
.cap-chip { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 3px; font-size: 11px; border-radius: 4px; border: 1px solid rgba(217,180,95,.3); background: rgba(217,180,95,.06); }

/* 棋谱 */
.history-card { flex: 1; min-height: 190px; display: flex; flex-direction: column; }
.history-list { flex: 1; max-height: 214px; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 4px; }
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(217,180,95,.25); border-radius: 4px; }
.history-empty { margin: auto; font-size: 12px; color: #5c626c; letter-spacing: 1px; }
.hist-row { display: grid; grid-template-columns: 32px 1fr 1fr; gap: 6px; align-items: center; font-size: 12px; padding: 5px 7px; border-radius: 5px; background: rgba(0,0,0,.14); }
.hist-row:nth-child(even) { background: rgba(255,255,255,.02); }
.hist-no { color: #6a707a; font-family: var(--display); font-size: 11px; }
.hist-red { color: #e88b82; } .hist-black { color: #a7b7c2; }
.hist-latest { outline: 1px solid rgba(217,180,95,.5); background: rgba(217,180,95,.08) !important; }

/* 操作按钮 */
.action-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 8px; cursor: pointer; font-family: var(--serif); font-size: 13px; letter-spacing: 1px;
  color: var(--text); background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); border-radius: 7px;
  transition: .22s ease;
}
.btn span { font-size: 15px; line-height: 1; }
.btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-gold { color: var(--gold-bright); border-color: var(--border-strong); background: rgba(217,180,95,.08); }
.btn-danger { color: #d98b86; border-color: rgba(217,110,100,.22); }
.btn-danger:hover:not(:disabled) { background: rgba(217,90,80,.1); border-color: rgba(217,110,100,.45); }

.tip-card { display: flex; align-items: flex-start; gap: 9px; font-size: 11px; line-height: 1.7; color: #777d87; padding: 2px 6px; }
.tip-icon { color: var(--gold); font-size: 14px; }

/* 绝杀遮罩 */
.mate-overlay {
  position: absolute; inset: 14px; z-index: 10; display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(10,12,16,.72), rgba(6,8,11,.94));
  backdrop-filter: blur(3px); border-radius: 4px; overflow: hidden;
  animation: fadeIn .45s ease both;
}
.mate-overlay.hidden, .thinking-overlay.hidden, .toast.hidden { display: none; }
.mate-rays {
  position: absolute; width: 200%; height: 200%;
  background: repeating-conic-gradient(from 0deg, rgba(217,180,95,.07) 0deg 7deg, transparent 7deg 20deg);
  animation: spin 28s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.mate-content { position: relative; text-align: center; animation: matePop .65s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes matePop { from { transform: scale(.5) rotate(-8deg); opacity: 0 } to { transform: scale(1) rotate(0); opacity: 1 } }
.mate-title {
  font-size: clamp(54px, 9vw, 96px); font-weight: 900; letter-spacing: 18px; padding-left: 18px;
  background: linear-gradient(180deg, #fff4d6, #e2b95f 50%, #a87628);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 26px rgba(217,180,95,.5));
}
.mate-sub { margin-top: 12px; font-size: 14px; letter-spacing: 5px; color: #c9bda4; }
.mate-btn {
  margin-top: 30px; padding: 11px 30px; cursor: pointer; font-family: var(--serif); font-size: 14px; letter-spacing: 4px;
  color: #1a1408; background: linear-gradient(135deg, #f2d896, #c99a45); border: none; border-radius: 4px;
  box-shadow: 0 6px 24px rgba(217,180,95,.25); transition: .2s ease;
}
.mate-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(217,180,95,.4); }
.board-frame.shake { animation: shake .5s ease; }
@keyframes shake {
  0%,100% { transform: translate(0,0) }
  15% { transform: translate(-7px,3px) } 30% { transform: translate(6px,-4px) }
  45% { transform: translate(-5px,-2px) } 60% { transform: translate(4px,3px) } 80% { transform: translate(-2px,1px) }
}

/* AI 思考遮罩 */
.thinking-overlay {
  position: absolute; inset: 14px; z-index: 8; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; pointer-events: none;
  background: rgba(8,11,15,.42); backdrop-filter: blur(1.5px); border-radius: 4px;
  animation: fadeIn .2s ease both;
}
.think-ring { width: 54px; height: 54px; border-radius: 50%; border: 2px solid rgba(217,180,95,.15); border-top-color: var(--gold-bright); animation: spin 1s linear infinite; box-shadow: 0 0 22px rgba(217,180,95,.15); }
.think-text { font-size: 14px; letter-spacing: 3px; color: var(--gold-bright); text-shadow: 0 0 16px rgba(217,180,95,.3); }
.dots { animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0%{opacity:.2} 50%{opacity:1} 100%{opacity:.2} }

/* 全屏模式按钮 */
.fs-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px; cursor: pointer; font-family: var(--serif); font-size: 12px; letter-spacing: 1px;
  color: var(--gold-bright); background: rgba(217,180,95,.07); border: 1px solid var(--border-strong); border-radius: 6px;
  transition: .22s ease;
}
.fs-btn:hover { background: rgba(217,180,95,.16); border-color: var(--gold); transform: translateY(-1px); }

/* ============ 全屏对弈模式 ============ */
body.fs-mode { overflow: hidden; }
body.fs-mode .ambient-grid { opacity: .12; }
body.fs-mode .topbar { padding: 10px 22px; }
body.fs-mode .layout {
  max-width: none; height: calc(100vh - 68px); padding: 4px 20px 16px;
  grid-template-columns: minmax(0, 1fr) 300px; gap: 18px;
}
body.fs-mode .board-section { justify-content: center; }
body.fs-mode .board-frame {
  max-width: none; width: min(100%, calc(100vh - 96px)); aspect-ratio: 1 / 1;
  position: relative; margin: 0 auto; padding: 0;
}
body.fs-mode #board {
  position: absolute; inset: 12px; width: calc(100% - 24px) !important;
  height: calc(100% - 24px) !important; aspect-ratio: auto !important;
}
body.fs-mode .board-vignette, body.fs-mode #fxCanvas { inset: 12px; }
body.fs-mode .board-caption { margin-top: 10px; }
body.fs-mode .panel { overflow-y: auto; max-height: calc(100vh - 80px); padding-right: 4px; gap: 10px; }
body.fs-mode .panel::-webkit-scrollbar { width: 5px; }
body.fs-mode .panel::-webkit-scrollbar-thumb { background: rgba(217,180,95,.25); border-radius: 4px; }
body.fs-mode .card { padding: 13px 15px; }
body.fs-mode .history-card { min-height: 130px; }
body.fs-mode .history-list { max-height: 120px; }
/* 全屏时原生全屏API下用 :fullscreen 兜底 */
:fullscreen .layout { height: calc(100vh - 68px); }

@media (max-width: 900px) {
  body.fs-mode .layout { grid-template-columns: 1fr; overflow-y: auto; height: calc(100vh - 60px); }
  body.fs-mode .board-frame { width: min(96vw, calc(100vh - 120px)); }
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(16px); z-index: 50;
  padding: 11px 22px; border-radius: 6px; font-size: 13px; letter-spacing: 1px;
  background: rgba(20,26,32,.96); border: 1px solid var(--border-strong); color: var(--gold-bright);
  box-shadow: 0 10px 36px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: .3s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 响应式 */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; gap: 24px; }
  .panel { display: grid; grid-template-columns: 1fr 1fr; }
  .history-card { grid-column: 1 / -1; }
  .action-bar, .tip-card { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .topbar { padding: 18px 16px 12px; flex-wrap: wrap; }
  .brand-text h1 { font-size: 22px; }
  .layout { padding: 6px 12px 36px; }
  .board-frame { padding: 9px; }
  .panel { grid-template-columns: 1fr; }
  .history-card, .action-bar, .tip-card { grid-column: auto; }
  .board-caption { font-size: 11px; gap: 8px; }
}
