* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { overscroll-behavior: none; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: linear-gradient(160deg, #1d2431 0%, #2b3446 55%, #3a2f3f 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  color: #e8e4da;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right))
           calc(30px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
}

header { text-align: center; margin-bottom: 22px; }
header h1 {
  font-size: 30px;
  letter-spacing: 6px;
  background: linear-gradient(90deg, #f5d67b, #e8a54b, #f5d67b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
header .sub { margin-top: 8px; font-size: 13px; color: #9aa3b5; letter-spacing: 2px; }

.layout { display: flex; gap: 22px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }

.panel { width: 300px; display: flex; flex-direction: column; gap: 14px; }

.card {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.rank-card { text-align: center; }
.rank-label { font-size: 12px; color: #9aa3b5; letter-spacing: 3px; }
.rank-name {
  margin: 8px 0 12px;
  font-size: 26px;
  font-weight: bold;
  color: #f5d67b;
  letter-spacing: 3px;
}
.dots { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-bottom: 10px; }
.dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
}
.dot.done { background: #7bc47f; border-color: #7bc47f; }
.dot.cur { background: #f5d67b; border-color: #fff3c9; box-shadow: 0 0 8px #f5d67b; transform: scale(1.15); }
.stats { font-size: 13px; color: #c8cede; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.controls .btn.primary { grid-column: 1 / -1; }

.btn {
  padding: 11px 10px;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: #eee;
  font-size: 15px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.16); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #d8452e, #a92f1d);
  border-color: #e86a52;
  font-weight: bold;
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn.danger { border-color: rgba(230,90,70,.5); color: #ff9c8a; }
.btn.ghost { background: transparent; font-size: 12px; padding: 7px 10px; }

.log-card { display: flex; flex-direction: column; }
.log-title { font-size: 13px; color: #9aa3b5; letter-spacing: 3px; margin-bottom: 8px; }
.log {
  height: 170px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.85;
  color: #cfd4df;
}
.log div { border-bottom: 1px dashed rgba(255,255,255,.07); }
.log .red { color: #ff9c8a; }
.log .black { color: #bfc9dd; }
.log .event { color: #f5d67b; }

.small { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { font-size: 11px; color: #8891a3; }

.board-area { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.opponent-bar {
  width: 100%;
  display: flex; justify-content: space-between;
  font-size: 14px; color: #d8cfa8; letter-spacing: 1px;
}
#turnLabel { color: #9aa3b5; }

canvas#board {
  display: block;
  width: min(570px, 100%);
  height: auto;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.08);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.overlay {
  position: fixed; inset: 0;
  background: rgba(10,12,18,.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }
.modal {
  width: min(420px, 88vw);
  background: linear-gradient(170deg, #2e3648, #232a38);
  border: 1px solid rgba(245,214,123,.35);
  border-radius: 18px;
  padding: 34px 28px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.modal h2 { font-size: 26px; letter-spacing: 4px; margin-bottom: 14px; color: #f5d67b; }
.modal p { font-size: 14px; color: #c3c9d6; line-height: 1.9; margin-bottom: 22px; white-space: pre-line; }
.modal .btn { width: 60%; }

@media (max-width: 980px) {
  .layout { flex-direction: column; align-items: center; gap: 16px; }
  .board-area { order: 1; width: min(570px, 100%); }
  .panel { order: 2; width: min(570px, 100%); }
}

@media (max-width: 640px) {
  header { margin-bottom: 14px; }
  header h1 { font-size: 22px; letter-spacing: 4px; }
  header .sub { font-size: 11px; letter-spacing: 1px; }
  .opponent-bar { width: 100%; font-size: 12px; }
  .rank-name { font-size: 21px; }
  .dot { width: 11px; height: 11px; }
  .controls { grid-template-columns: repeat(3, 1fr); }
  .controls .btn.primary { grid-column: auto; }
  .btn { padding: 9px 4px; font-size: 13px; letter-spacing: 1px; }
  .log { height: 120px; font-size: 12px; }
  .small { flex-wrap: wrap; }
  .modal { padding: 26px 18px; }
  .modal h2 { font-size: 21px; }
}
