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

:root {
  --bg: #171310;
  --panel: #211a14;
  --panel2: #281f17;
  --line: #3a2e22;
  --text: #e9decb;
  --muted: #9a8a74;
  --gold: #d9a441;
  --red: #c05345;
  --black-chip: #8b93a1;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Heiti TC", sans-serif;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 頂部 ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
  flex: none;
}

h1 { font-size: 19px; letter-spacing: 6px; font-weight: 700; }
.brand .sub {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--muted);
}

#hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

#turn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 108px;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 14px;
}
#turnDot { width: 11px; height: 11px; border-radius: 50%; background: var(--red); box-shadow: 0 0 9px var(--red); }

button {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
button:hover { background: #33281d; border-color: #4d3c2a; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }

#repoLink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--muted);
  text-decoration: none;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  letter-spacing: 1px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#repoLink:hover { background: #33281d; border-color: #4d3c2a; color: var(--text); }
#repoLink svg { flex: none; }

/* ---------- 主区域 ---------- */
main { flex: 1; display: flex; min-height: 0; }

#stage { flex: 1; min-width: 0; position: relative; }
#stage canvas { display: block; }

aside {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 14px;
  background: var(--panel);
  overflow-y: auto;
}
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); }

aside h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 8px;
}

.tray { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.chips { min-height: 26px; display: flex; flex-wrap: wrap; gap: 4px; }
.chips em { color: var(--muted); font-size: 13px; font-style: normal; }
.chip {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 700;
  background: radial-gradient(circle at 35% 30%, #eed6a8, #c08f52);
}
.chip.red { color: #b32c20; }
.chip.black { color: #26221d; }

.help { color: var(--muted); font-size: 12px; line-height: 1.75; }
.help p { margin-bottom: 4px; }

/* 左下角版權：字體與 .help 說明文字一致 */
.copyright {
  margin-top: auto;
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}
.copyright a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 2px;
}
.copyright a:hover { color: var(--text); text-decoration-color: var(--text); }

#log {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
#log li {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
}
#log li:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
.side {
  width: 20px; height: 20px;
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}
.side.red { background: rgba(192, 83, 69, 0.2); color: #e08577; border: 1px solid rgba(192, 83, 69, 0.5); }
.side.black { background: rgba(139, 147, 161, 0.16); color: #aeb6c2; border: 1px solid rgba(139, 147, 161, 0.45); }
#logEmpty { color: var(--muted); font-size: 12.5px; line-height: 1.7; padding: 4px 2px; }

/* ---------- 將軍提示 ---------- */
#checkBanner {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  font-size: 92px;
  font-weight: 900;
  letter-spacing: 18px;
  padding-left: 18px;
  color: #ffb454;
  text-shadow: 0 0 24px rgba(255, 120, 40, 0.75), 0 4px 22px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  animation: checkpop 0.55s cubic-bezier(0.2, 1.6, 0.4, 1) both;
  z-index: 20;
}

@keyframes checkpop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- 勝負覆蓋層 ---------- */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 5, 0.62);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  animation: fadein 0.25s ease both;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 64px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: cardin 0.32s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes cardin { from { opacity: 0; transform: translateY(18px) scale(0.94); } to { opacity: 1; transform: none; } }
.card h2 { font-size: 40px; letter-spacing: 10px; padding-left: 10px; margin-bottom: 10px; color: var(--gold); }
.card p { color: var(--muted); font-size: 14px; margin-bottom: 24px; letter-spacing: 2px; }
.card button { font-size: 15px; padding: 10px 28px; }

.hidden { display: none !important; }

/* ---------- 小螢幕 ---------- */
@media (max-width: 900px) {
  main { flex-direction: column; }
  aside { width: 100%; max-height: 190px; }
  #left { border-right: none; border-bottom: 1px solid var(--line); }
  #right { display: none; }
  #stage { flex: 1; }
  h1 { font-size: 16px; }
  #repoLink span { display: none; }
}
