:root {
  --bg: #0f141b;
  --panel: #171e28;
  --panel-2: #1e2733;
  --line: #2b3746;
  --text: #e7edf5;
  --muted: #92a1b5;
  --accent: #53b3ff;
  --accent-2: #7ee0b8;
  --danger: #ff7a7a;
  --wood: #d9ab5c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(83, 179, 255, 0.18), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(126, 224, 184, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
}

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

header h1 {
  margin: 0 0 6px;
  font-size: clamp(22px, 3.4vw, 32px);
  letter-spacing: 0.5px;
}

header p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}

.board-card {
  background: linear-gradient(160deg, #202a36, #141b24);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

canvas.locked { cursor: progress; }

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 15px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

label.field {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

label.field:last-child { margin-bottom: 0; }

select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
}

button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid rgba(83, 179, 255, 0.4);
  background: linear-gradient(180deg, #2c6f9f, #23557c);
  color: #eaf6ff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.status {
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
}

.status .sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.status.error { color: var(--danger); }
.status.win { color: var(--accent-2); }

.status.your-turn {
  color: #b9ffe4;
  animation: turn-breathe 2.2s ease-in-out infinite;
}

.status.your-turn::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(126, 224, 184, 0.85);
  animation: turn-dot 2.2s ease-in-out infinite;
}

@keyframes turn-breathe {
  0%, 100% { text-shadow: 0 0 0 rgba(126, 224, 184, 0); }
  50% { text-shadow: 0 0 12px rgba(126, 224, 184, 0.8), 0 0 28px rgba(83, 179, 255, 0.3); }
}

@keyframes turn-dot {
  0%, 100% { opacity: 0.55; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .status.your-turn,
  .status.your-turn::before {
    animation: none;
  }
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 8, 14, 0.72);
  backdrop-filter: blur(4px);
}

.modal-mask[hidden] {
  display: none !important;
}

.modal-card {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, #202a36, #141b24);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  animation: modal-in 0.16s ease-out;
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 19px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

.modal-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button {
  flex: 1;
  width: auto;
}

button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

button.danger {
  border-color: rgba(255, 122, 122, 0.45);
  background: linear-gradient(180deg, #9f3e48, #792a33);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.load-progress {
  margin: 10px 0 2px;
}

.load-progress[hidden] {
  display: none !important;
}

.load-progress-track {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0c1219;
}

.load-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.18s ease;
}

.load-progress.indeterminate .load-progress-bar {
  width: 35%;
  animation: load-progress-slide 1.25s ease-in-out infinite;
}

@keyframes load-progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.meta span:last-child { color: var(--text); text-align: right; }

.rules {
  font-size: 12px;
  color: var(--muted);
}

.rules ul { margin: 6px 0 0; padding-left: 18px; }
.rules li { margin-bottom: 3px; }

footer {
  margin-top: 22px;
  font-size: 12px;
  color: var(--muted);
}

footer a { color: var(--accent); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .shell { padding: 18px 12px 36px; }
}
