/* 楚河 — 漆木与宣纸风格，非官方皮卡鱼界面拷贝 */
:root {
  --ink: #1a120c;
  --ink-soft: #4a3b2f;
  --paper: #f3ead8;
  --paper-2: #efe4cc;
  --cinnabar: #c4452c;
  --cinnabar-d: #9a2f1c;
  --gold: #c9a24a;
  --gold-s: #e7d5a3;
  --lacquer: #241910;
  --panel: rgba(243, 234, 216, 0.96);
  --line: #d7c8a8;
  --blue: #1d6fd6;
  --pink: #d6457a;
  --good: #2a7d4f;
  --bad: #b13333;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
  --song: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--ui);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(196, 69, 44, 0.18), transparent 50%),
    radial-gradient(900px 600px at 110% 20%, rgba(201, 162, 74, 0.12), transparent 50%),
    linear-gradient(180deg, #2a1c14, #140e0a 40%, #0f0b08);
  min-height: 100vh;
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}

header.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 4px 14px;
  color: var(--gold-s);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 160px; }
.logo {
  font-family: var(--kai);
  font-size: 32px;
  letter-spacing: 0.12em;
  color: #f2d9a0;
  text-shadow: 0 1px 0 #000, 0 0 18px rgba(201, 162, 74, 0.35);
}
.tag { font-size: 12px; opacity: 0.7; letter-spacing: 0.16em; }
nav.modes { display: flex; background: rgba(0,0,0,0.28); border: 1px solid rgba(201,162,74,0.28); border-radius: 999px; padding: 3px; }
nav.modes button {
  appearance: none; border: 0; background: transparent;
  color: #e6d3ad; font: inherit; padding: 8px 18px; border-radius: 999px; cursor: pointer;
}
nav.modes button.active {
  background: linear-gradient(180deg, #d4573c, #a83220);
  color: #fff8e8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.header-actions button, .btn, .toolbar button, .nav-row button {
  font: inherit; cursor: pointer;
  border: 1px solid rgba(201,162,74,0.35);
  background: rgba(255,248,232,0.08);
  color: #f3e4c2;
  padding: 7px 12px;
  border-radius: 8px;
}
.btn.primary, .toolbar button.primary, .toolbar button.on {
  background: linear-gradient(180deg, #d4573c, #a83220);
  border-color: transparent;
  color: #fff8e8;
}
.btn.ghost, .toolbar button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ink, .panel .btn, .modal .btn, .editor-bar .btn, #panel-play .btn, #panel-review .btn, #panel-games .btn {
  border: 1px solid #c4b18a;
  background: #fffaf0;
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.btn-ink.primary, .panel .btn.primary {
  background: linear-gradient(180deg, #d4573c, #b33a24);
  border-color: #8c2716;
  color: #fff8e8;
}
.btn-ink:hover, .panel .btn:hover { filter: brightness(1.03); }
.btn-ink:disabled { opacity: 0.45; cursor: not-allowed; }

main.layout {
  display: grid;
  grid-template-columns: minmax(320px, 640px) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}

.board-col {
  background: linear-gradient(180deg, #3a2a1c, #2a1d13);
  border: 1px solid rgba(201,162,74,0.3);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.toolbar button { font-size: 13px; }
.toolbar-more {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}
.toolbar-more-toggle::after {
  content: " ▾";
  font-size: 0.85em;
}
.toolbar-more-toggle[aria-expanded="true"]::after {
  content: " ▴";
}
.toolbar-more-menu {
  position: absolute;
  z-index: 8;
  top: calc(100% + 4px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 100%;
  padding: 6px;
  background: #2a1d13;
  border: 1px solid rgba(201,162,74,0.35);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.toolbar-more-menu[hidden] { display: none; }
.toolbar-more-menu button {
  white-space: nowrap;
  width: 100%;
  text-align: center;
}

.auto-play-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
}
.auto-play-row[hidden] { display: none; }
.auto-play-label {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}
.auto-play-row button {
  font: inherit;
  cursor: pointer;
  border: 1px solid #c4b18a;
  background: #fffaf0;
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 8px;
}
.auto-play-row button.on {
  background: linear-gradient(180deg, #d4573c, #a83220);
  border-color: transparent;
  color: #fff8e8;
}
.auto-play-note {
  flex: 1 1 180px;
  font-size: 12px;
  color: var(--ink-soft);
}

.xq-board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 620 / 684;
  user-select: none;
  touch-action: manipulation;
}
.xq-board-svg { width: 100%; height: 100%; display: block; }
.xq-wood { fill: #c9a36a; stroke: #4a2c14; stroke-width: 5; }
.xq-wood-inner { fill: #e7c888; }
.xq-line { stroke: #5c3317; stroke-width: 1.7; fill: none; }
.xq-tick { stroke: #5c3317; stroke-width: 1.2; }
.xq-river { fill: #6b3d1f; font-size: 22px; font-family: var(--kai); letter-spacing: 0.4em; }
.xq-coord { fill: #5a3a22; font-size: 13px; font-family: var(--song); }
.xq-last-from {
  fill: rgba(255, 214, 80, 0.2);
  stroke: #e0a81a;
  stroke-width: 2.6;
}
.xq-last-to {
  fill: rgba(232, 80, 36, 0.42);
  stroke: #c41a1a;
  stroke-width: 2.8;
}
.xq-last-from.xq-engine {
  fill: rgba(255, 200, 60, 0.22);
  stroke: #f0c24a;
  stroke-width: 2.8;
}
.xq-last-to.xq-engine {
  fill: rgba(220, 48, 28, 0.52);
  stroke: #9a180e;
  stroke-width: 3.2;
}
.xq-flash.xq-last-from, .xq-flash.xq-last-to {
  animation: last-flash 0.85s ease 0s 2;
}
.xq-selected { fill: rgba(29, 111, 214, 0.28); stroke: #1d6fd6; stroke-width: 2; }
.xq-check { fill: rgba(196, 26, 26, 0.28); stroke: #c41a1a; stroke-width: 2.4; animation: pulse 1.2s ease infinite; }
.xq-dot { fill: rgba(42, 90, 40, 0.85); }
.xq-cap { fill: none; stroke: rgba(180, 40, 40, 0.9); stroke-width: 3; }
.xq-pieces { position: absolute; inset: 0; pointer-events: none; }
.xq-piece {
  position: absolute;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--kai);
  font-weight: 700;
  line-height: 1;
  box-shadow: 1px 3px 6px rgba(0,0,0,.38), inset 0 2px 3px rgba(255,255,255,.55);
  transition: left .2s ease, top .2s ease, transform .18s ease, box-shadow .18s ease;
  z-index: 2;
}
.xq-piece-lifted {
  z-index: 8;
  transform: translateY(-10px) scale(1.1);
  box-shadow: 2px 12px 18px rgba(0,0,0,.48), 0 4px 8px rgba(0,0,0,.3), inset 0 2px 3px rgba(255,255,255,.55);
}
.xq-pieces.xq-no-anim .xq-piece { transition: none; }
.xq-piece-moving {
  z-index: 6;
  transition: left .28s cubic-bezier(.2,.7,.2,1), top .28s cubic-bezier(.2,.7,.2,1);
}
.xq-piece-arrive { animation: piece-arrive .55s ease; }
.xq-piece.red {
  background: radial-gradient(circle at 35% 28%, #fff8e8, #f0d4a8 55%, #e2c08a);
  color: #c41a1a;
  border: 3px solid #b01414;
}
.xq-piece.black {
  background: radial-gradient(circle at 35% 28%, #fff8e8, #ecd9b8 55%, #d5c09a);
  color: #161616;
  border: 3px solid #1c1c1c;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@keyframes last-flash {
  0% { opacity: 0.2; }
  40% { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes piece-arrive {
  0% { transform: scale(1.14); box-shadow: 0 0 0 7px rgba(196, 69, 44, 0.55), 1px 3px 6px rgba(0,0,0,.38); }
  100% { transform: scale(1); }
}
@keyframes note-pop {
  0% { transform: scale(0.92); opacity: 0.4; }
  60% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); }
}
.last-move-note {
  font-family: var(--kai);
  font-size: 18px;
  font-weight: 700;
  color: #fff8e8;
  background: rgba(40, 28, 16, 0.72);
  border: 1px solid rgba(201, 162, 74, 0.55);
  padding: 5px 14px;
  border-radius: 8px;
  letter-spacing: 0.08em;
  min-height: 34px;
  display: flex;
  align-items: center;
}
.last-move-note[hidden] { display: none; }
.last-move-note.engine {
  background: rgba(164, 36, 22, 0.88);
  border-color: #f0c24a;
  box-shadow: 0 0 0 1px rgba(240, 194, 74, 0.35);
}
.last-move-note.flash { animation: note-pop 0.45s ease; }

.nav-row, .status-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 8px; justify-content: center;
}
.status-row {
  color: #f3e4c2;
  min-height: 28px;
  font-size: 15px;
  justify-content: space-between;
  padding: 4px 6px;
}
.status-row .check-flag { color: #ffb4a8; font-weight: 700; }
.status-row .over-flag { color: #ffe08a; font-weight: 700; }

.panel-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel {
  background: var(--panel);
  border: 1px solid #d7c8a8;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--cinnabar-d);
  font-weight: 700;
  display: flex; justify-content: space-between; align-items: baseline;
}
.panel h2 small { font-weight: 400; color: var(--ink-soft); letter-spacing: 0; }

.eval-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.eval-score { font-family: var(--song); font-size: 28px; font-weight: 700; }
.eval-score.red { color: #b01414; }
.eval-score.black { color: #222; }
.eval-meta { font-size: 12px; color: var(--ink-soft); display: flex; gap: 10px; flex-wrap: wrap; }
.pv-line { margin-top: 8px; line-height: 1.7; font-family: var(--song); font-size: 15px; min-height: 2.4em; }
.pv-line .red { color: #b01414; }
.pv-line .black { color: #1a1a1a; }
.engine-hint { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.plan-text { margin-top: 2px; line-height: 1.75; font-family: var(--song); font-size: 16px; min-height: 2.6em; }
.plan-warn {
  margin-top: 8px; padding: 8px 10px;
  background: #fde8e4; color: #8c2716;
  border: 1px solid #e8b0a4; border-radius: 8px;
  font-size: 15px; line-height: 1.6;
}
.plan-warn[hidden] { display: none; }

.graph { width: 100%; height: 88px; display: block; cursor: pointer; background: #faf6ea; border-radius: 8px; border: 1px solid var(--line); }
.graph-empty { height: 88px; display: flex; align-items: center; justify-content: center; color: #8a7a64; font-size: 13px; }

.move-list { max-height: 280px; overflow: auto; font-family: var(--song); font-size: 15px; }
.move-row { display: grid; grid-template-columns: 2.2em 1fr 1fr; gap: 4px; padding: 2px 0; align-items: center; }
.move-row .n { color: #8a7a64; text-align: right; padding-right: 6px; }
.move-row button {
  text-align: left; border: 0; background: transparent; font: inherit; cursor: pointer;
  padding: 3px 6px; border-radius: 6px; color: inherit;
}
.move-row button:hover { background: #efe0c0; }
.move-row button.current { background: #e8c98a; font-weight: 700; }
.move-row button.red { color: #b01414; }
.move-row button.black { color: #1a1a1a; }
.nag { font-family: var(--ui); font-size: 11px; margin-left: 4px; color: var(--cinnabar); }

.cloud-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cloud-table th, .cloud-table td { padding: 4px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.cloud-table tr { cursor: pointer; }
.cloud-table tr:hover { background: #efe0c0; }
.muted { color: var(--ink-soft); font-size: 13px; }

.play-setup label, .review-box label, .editor-side label {
  display: block; margin: 8px 0 4px; font-size: 13px; color: var(--ink-soft);
}
.play-setup select, .play-setup input, textarea, .editor-side select, input[type="text"] {
  font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid #c4b18a; width: 100%;
  background: #fffdf8;
}
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.stat-pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.pill { background: #efe0c0; border-radius: 999px; padding: 4px 10px; font-size: 12px; }

#import-text { min-height: 120px; resize: vertical; }
.review-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.review-card { background: #fffaf0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.review-card strong { display: block; font-size: 20px; }

.games-list { list-style: none; margin: 0; padding: 0; }
.games-list li {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.games-list .meta { font-size: 12px; color: var(--ink-soft); }

.overlay {
  position: fixed; inset: 0; background: rgba(10,6,4,0.62);
  display: none; align-items: center; justify-content: center; z-index: 20; padding: 16px;
}
.overlay.show { display: flex; }
.modal {
  background: var(--paper);
  max-width: 640px; width: 100%;
  max-height: 90vh; overflow: auto;
  border-radius: 16px; padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid #d7c8a8;
}
.modal h2 { margin: 0 0 10px; font-family: var(--kai); font-size: 24px; }
.modal p, .modal li { line-height: 1.7; }
.help-list { padding-left: 1.2em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
#confirm-overlay .confirm-modal { max-width: 420px; }
#confirm-overlay .confirm-modal h2 { font-size: 20px; line-height: 1.45; }
#confirm-overlay .confirm-modal p { margin: 0 0 4px; }


.editor-layout { display: grid; grid-template-columns: 1fr 180px; gap: 12px; }
.tray { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.tray button, .tray .blank {
  height: 42px; border-radius: 8px; border: 1px solid #c4b18a; background: #fffaf0;
  font-family: var(--kai); font-size: 20px; cursor: pointer;
}
.tray button.red { color: #c41a1a; }
.tray button.black { color: #111; }
.tray button.active { outline: 2px solid var(--blue); }
.warn { color: var(--cinnabar-d); font-size: 13px; min-height: 1.4em; }

footer.credit {
  margin-top: 18px; color: #cbb892; font-size: 12px; line-height: 1.6; opacity: 0.85;
}
footer.credit a { color: #e7d5a3; }

@media (max-width: 860px) {
  #app { padding: 8px 8px 24px; }
  main.layout { grid-template-columns: 1fr; }
  .logo { font-size: 26px; }
  nav.modes button { padding: 8px 12px; }
  .editor-layout { grid-template-columns: 1fr; }
  .move-list { max-height: 220px; }
}

.engine-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #efe0c0;
  color: #7a2b16;
  font-size: 12px;
  letter-spacing: 0.06em;
}
.engine-loading {
  background: #fffaf0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.engine-loading-title {
  margin: 0 0 4px;
  color: var(--cinnabar-d);
  font-weight: 700;
}
.engine-loading code { font-size: 12px; }
.progress {
  height: 8px;
  background: #e8d9b8;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 6px;
}
#engine-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c4452c, #c9a24a);
  transition: width 0.2s ease;
}
#engine-progress-text { font-size: 12px; }
#engine-fallback-warn { margin: 0 0 8px; }
