/* Fonts fallback: 使用系统自带中文字体，无需联网 */

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

body {
  font-family: 'Noto Sans SC', sans-serif;
  background: #1a1a2e;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #e0e0e0;
  overflow-x: hidden;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(99,102,241,0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(236,72,153,0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.app-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Header */
.header {
  text-align: center;
}
.header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, #a78bfa, #ec4899, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}
.header p {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 4px;
  letter-spacing: 0.1em;
}

/* Control Panel */
.control-panel {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 760px;
  backdrop-filter: blur(10px);
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ctrl-label {
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 500;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.seg-btn {
  position: relative;
  display: flex;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
}
.seg-btn button {
  padding: 6px 14px;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 500;
  color: #9ca3af;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.seg-btn button.active {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border-radius: 8px;
}
.seg-btn button:hover:not(.active) {
  color: #e0e0e0;
  background: rgba(255,255,255,0.06);
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-restart {
  background: rgba(99,102,241,0.15);
  color: #a78bfa;
  border-color: rgba(99,102,241,0.3);
}
.btn-restart:hover {
  background: rgba(99,102,241,0.3);
  border-color: rgba(99,102,241,0.5);
}
.btn-undo {
  background: rgba(245,158,11,0.1);
  color: #fbbf24;
  border-color: rgba(245,158,11,0.25);
}
.btn-undo:hover {
  background: rgba(245,158,11,0.2);
  border-color: rgba(245,158,11,0.4);
}
.btn-undo:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 760px;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px 18px;
  flex: 1;
  backdrop-filter: blur(10px);
}
.stone-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
}
.stone-dot.black {
  background: radial-gradient(circle at 35% 32%, #888, #111);
  box-shadow: 0 2px 8px rgba(0,0,0,0.6), inset 0 1px 2px rgba(255,255,255,0.15);
}
.stone-dot.white {
  background: radial-gradient(circle at 35% 32%, #fff, #ccc);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.8);
}
.turn-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: #d1d5db;
}
.turn-sub {
  font-size: 0.72rem;
  color: #6b7280;
}

.score-panel {
  display: flex;
  gap: 10px;
}
.score-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px 16px;
  text-align: center;
  min-width: 70px;
  backdrop-filter: blur(10px);
}
.score-card .sc-label {
  font-size: 0.68rem;
  color: #6b7280;
  letter-spacing: 0.05em;
}
.score-card .sc-val {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
}
.sc-black { color: #c4b5fd; }
.sc-white { color: #f9a8d4; }

/* Main game area */
.game-area {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  flex-wrap: wrap;
}

/* Board Container */
.board-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06),
    0 20px 60px rgba(0,0,0,0.6),
    0 0 80px rgba(99,102,241,0.05);
}

#boardCanvas {
  display: block;
  cursor: crosshair;
  max-width: 100%;
  height: auto;
}

/* Side panel */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 180px;
  max-width: 220px;
}

.panel-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px 16px;
  backdrop-filter: blur(10px);
}
.panel-card h3 {
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.move-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.move-list::-webkit-scrollbar { width: 3px; }
.move-list::-webkit-scrollbar-track { background: transparent; }
.move-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.move-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 0.75rem;
  transition: background 0.15s;
}
.move-item:last-child {
  background: rgba(99,102,241,0.15);
}
.move-item .mi-num {
  font-size: 0.65rem;
  color: #6b7280;
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}
.mi-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mi-dot.black { background: radial-gradient(circle at 35% 30%, #888, #111); }
.mi-dot.white { background: radial-gradient(circle at 35% 30%, #fff, #ccc); border: 1px solid #aaa; }
.move-item .mi-coord {
  color: #d1d5db;
  font-weight: 500;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.legend-row:last-child { border-bottom: none; }
.legend-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #d1d5db;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-backdrop.show {
  opacity: 1;
  pointer-events: all;
}
.modal-box {
  background: linear-gradient(145deg, #1e1b4b, #1a1a2e);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 36px 40px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(99,102,241,0.2);
  transform: scale(0.9) translateY(10px);
  transition: transform 0.3s;
}
.modal-backdrop.show .modal-box {
  transform: scale(1) translateY(0);
}
.modal-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  line-height: 1;
}
.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.modal-desc {
  font-size: 0.9rem;
  color: #9ca3af;
  line-height: 1.6;
  margin-bottom: 24px;
}
.modal-desc strong {
  color: #d1d5db;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.modal-btn {
  padding: 10px 28px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}
.modal-btn-primary {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  box-shadow: 0 4px 15px rgba(109,40,217,0.4);
}
.modal-btn-primary:hover {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  box-shadow: 0 6px 20px rgba(109,40,217,0.5);
  transform: translateY(-1px);
}
.modal-btn-secondary {
  background: rgba(255,255,255,0.06);
  color: #9ca3af;
  border: 1px solid rgba(255,255,255,0.1);
}
.modal-btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  color: #d1d5db;
}

.modal-btn-undo {
  background: rgba(245,158,11,0.2);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,0.3);
}
.modal-btn-undo:hover {
  background: rgba(245,158,11,0.35);
  border-color: rgba(245,158,11,0.5);
  transform: translateY(-1px);
}

/* AI difficulty indicator */
.diff-dots {
  display: flex;
  gap: 4px;
}
.diff-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
}
.diff-dot.on { background: #a78bfa; }

/* Responsive */
@media (max-width: 680px) {
  .header h1 { font-size: 1.6rem; }
  .side-panel { display: none; }
  .control-panel { gap: 8px; }
}