/* style.css - CChess2 介面樣式（自製程式碼） */

* {
  box-sizing: border-box;
}

/* hidden 屬性優先於任何 display 設定（banner/thinking 都靠它隱藏） */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, #2c3542, #1a2028 60%, #141920);
  color: #efe7d6;
  min-height: 100vh;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

/* ── 頁首 ─────────────────────────────── */

.app-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.logo {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: linear-gradient(145deg, #c23a2c, #8f2418);
  color: #fdf0dd;
  font-family: "Kaiti TC", KaiTi, "DFKai-SB", KAIU, "Noto Serif TC", serif;
  font-size: 30px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4), inset 0 1px 2px rgba(255, 255, 255, .35);
}

.app-head h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 4px;
}

.app-head .sub {
  font-size: 12px;
  color: #b8ad97;
  margin-top: 2px;
}

/* ── 主版面 ───────────────────────────── */

.main {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
}

.board-side {
  flex: 0 1 560px;
  min-width: 0;
}

.panel {
  flex: 0 1 330px;
  min-width: 264px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── 棋盤 ─────────────────────────────── */

.tag {
  font-size: 14px;
  color: #cfc4ab;
  padding: 2px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag .dot, #statusDot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(0, 0, 0, .35);
  flex: none;
}

.dot.red { background: #cf4a3a; }
.dot.black { background: #2e2b27; }
.dot.pulse { animation: pulse 1s infinite; }

@keyframes pulse {
  50% { box-shadow: 0 0 0 6px rgba(207, 74, 58, .25); }
}

.tag-bottom {
  justify-content: center;
  margin-top: 6px;
}

.board-frame {
  position: relative;
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(160deg, #7a5a33, #59391b);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5), inset 0 1px 2px rgba(255, 255, 255, .25);
}

#board {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 10;
  border-radius: 8px;
  overflow: hidden;
  container-type: inline-size;
  cursor: pointer;
  touch-action: manipulation;
}

#board > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#pieceLayer, #markLayer {
  position: absolute;
  inset: 0;
}

#markLayer {
  pointer-events: none;
}

/* 棋子 */

.piece {
  position: absolute;
  width: 10.2%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Kaiti TC", "Kaiti SC", KaiTi, "DFKai-SB", KAIU, BiauKai, "TW-Kai", "Noto Serif TC", serif;
  font-weight: 700;
  font-size: 5.6cqw;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  transition: left .18s ease, top .18s ease, opacity .25s ease;
  box-shadow: 0 .4cqw 1cqw rgba(0, 0, 0, .45),
      inset 0 .3cqw .4cqw rgba(255, 255, 255, .55),
      inset 0 -.3cqw .5cqw rgba(120, 80, 30, .35);
}

.piece::after {
  /* 內圈刻線 */
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  border: .28cqw solid currentColor;
  opacity: .55;
  pointer-events: none;
}

.piece.red {
  color: #a92e22;
  background: radial-gradient(circle at 35% 30%, #fdf6e0, #eddbb2 55%, #d8bb85);
}

.piece.black {
  color: #2c2823;
  background: radial-gradient(circle at 35% 30%, #fdf6e0, #eddbb2 55%, #d8bb85);
}

.piece.selected {
  z-index: 5;
  box-shadow: 0 0 0 .55cqw rgba(255, 176, 66, .95),
      0 .4cqw 1.4cqw rgba(0, 0, 0, .5),
      inset 0 .3cqw .4cqw rgba(255, 255, 255, .55);
}

.piece.in-check {
  animation: checkPulse 0.9s infinite;
}

@keyframes checkPulse {
  50% {
    box-shadow: 0 0 0 .6cqw rgba(230, 57, 34, .95),
        0 .4cqw 1cqw rgba(0, 0, 0, .5);
  }
}

.piece.captured {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.6);
  transition: opacity .25s ease, transform .25s ease;
}

/* 標記層 */

.lm {
  position: absolute;
  width: 3.2%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(230, 150, 40, .85);
  box-shadow: 0 0 .6cqw rgba(230, 150, 40, .8);
}

.hint {
  position: absolute;
  width: 3.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(45, 28, 10, .55);
  box-shadow: 0 0 .4cqw rgba(0, 0, 0, .4);
}

.hint.cap {
  width: 10.8%;
  aspect-ratio: 1;
  background: transparent;
  border: .45cqw solid rgba(205, 60, 35, .8);
}

/* 結果橫幅 */

.banner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 12, 8, .45);
  backdrop-filter: blur(1.5px);
  z-index: 20;
}

.banner-card {
  background: linear-gradient(170deg, #2b2419, #1d1811);
  border: 1px solid #6b5638;
  border-radius: 16px;
  padding: 26px 40px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  animation: rise .35s ease;
}

@keyframes rise {
  from { transform: translateY(14px); opacity: 0; }
}

#bannerTitle {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #f5d9a0;
  font-family: "Kaiti TC", KaiTi, "DFKai-SB", "Noto Serif TC", serif;
}

#bannerSub {
  margin-top: 8px;
  color: #c9bb9d;
  font-size: 15px;
}

.banner-btns {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── 控制面板 ─────────────────────────── */

.status-card, .controls, .moves {
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 12px 14px;
}

.turn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  min-height: 24px;
}

.thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e8b25c;
  font-size: 13px;
  margin-top: 6px;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(232, 178, 92, .3);
  border-top-color: #e8b25c;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ai-stats {
  margin-top: 6px;
  font-size: 12px;
  color: #9d927d;
  min-height: 15px;
}

.ctl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.ctl-row > label {
  flex: none;
  width: 74px;
  font-size: 13px;
  color: #cfc4ab;
}

.seg {
  display: flex;
  background: rgba(0, 0, 0, .3);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #bfb49c;
  font-size: 13px;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}

.seg button:hover {
  color: #efe7d6;
}

.seg button.on {
  background: linear-gradient(160deg, #b3502f, #8f3517);
  color: #fdf0dd;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}

select {
  flex: 1;
  background: rgba(0, 0, 0, .3);
  color: #efe7d6;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 13px;
  font-family: inherit;
}

select option {
  background: #241d15;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn {
  flex: 1;
  min-width: 70px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .07);
  color: #efe7d6;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, .14);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: .4;
  cursor: default;
}

.btn.primary {
  background: linear-gradient(160deg, #b3502f, #8f3517);
  border-color: rgba(255, 255, 255, .18);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(160deg, #c65e39, #a03f1e);
}

.hint-text {
  font-size: 11.5px;
  color: #8f8570;
  margin-top: 8px;
}

/* 棋譜 */

.moves-head {
  font-size: 13px;
  color: #cfc4ab;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.move-list {
  max-height: 300px;
  overflow-y: auto;
  font-size: 14.5px;
  scrollbar-width: thin;
}

.mv-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  padding: 4px 4px;
  border-bottom: 1px dashed rgba(255, 255, 255, .06);
  font-family: "Kaiti TC", KaiTi, "DFKai-SB", "Noto Serif TC", serif;
}

.mv-no {
  color: #8f8570;
  font-size: 12.5px;
  font-family: inherit;
  align-self: center;
}

.mv-row .zh {
  letter-spacing: 1px;
}

.mv-row .zh.cur {
  color: #f0b95e;
  font-weight: 700;
}

.mv-empty {
  color: #8f8570;
  font-size: 13px;
  padding: 10px 4px;
  text-align: center;
}

.panel-foot {
  font-size: 11.5px;
  color: #7d745f;
  text-align: center;
}

a {
  color: #d8a35c;
}

/* ── 響應式 ───────────────────────────── */

@media (max-width: 900px) {
  .main {
    flex-direction: column;
    align-items: center;
  }

  .board-side {
    width: 100%;
    max-width: 560px;
    flex: auto;
  }

  .panel {
    width: 100%;
    max-width: 560px;
    flex: auto;
  }

  .move-list {
    max-height: 200px;
  }
}
