:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --danger: #dc2626;
  --board: #dfa46d;
  --board-dark: #9b6a3d;
  --line: rgba(39, 25, 15, 0.72);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at top, #ffffff 0, var(--bg) 60%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  color: #ffffff;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

button.secondary {
  color: var(--text);
  background: #e5e7eb;
}

.app-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 2rem);
}

.hidden {
  display: none !important;
}

.login-card {
  width: min(100%, 420px);
  margin: 12vh auto 0;
  padding: 2rem;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}

.login-card h1 {
  margin: 0 0 0.5rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.login-brand img {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-card form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.login-card label {
  display: grid;
  gap: 0.4rem;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
}

.message,
.toast {
  color: var(--danger);
}

.game-layout {
  display: grid;
  gap: 1rem;
  min-height: calc(100vh - 2rem);
  align-content: center;
}

.top-bar,
.status-card,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 16px;
  padding: 1rem;
  background: var(--card);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.top-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-identity img {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
}

.pill {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  color: #ffffff;
  background: #111827;
  font-size: 0.85rem;
}

.board-stage {
  display: grid;
  place-items: center;
}

#boardCanvas {
  width: min(88vw, 72vh, 620px);
  height: min(88vw, 72vh, 620px);
  border-radius: 6px;
  background: var(--board);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.28);
  touch-action: manipulation;
}

.player-card,
.clock-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.player-card.right {
  text-align: right;
}

.player-card span,
.clock-card span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 999px;
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.black-stone {
  background: #111827;
}

.white-stone {
  border: 1px solid #d1d5db;
  background: #ffffff;
}

.clock-card {
  flex-direction: column;
  gap: 0.2rem;
  text-align: center;
}

#timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(1.4rem, 4vw, 2.1rem);
}

.actions {
  justify-content: center;
}

.toast {
  margin: 0;
  text-align: center;
}

dialog {
  width: min(92vw, 380px);
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-body {
  padding: 1.5rem;
}

.dialog-body h2 {
  margin: 0 0 0.75rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.active-turn {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0.75rem;
  }

  .top-bar,
  .status-card,
  .actions {
    padding: 0.8rem;
  }

  .status-card {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .login-brand {
    align-items: flex-start;
  }

  .login-brand img {
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }

  #boardCanvas {
    width: min(94vw, 58vh);
    height: min(94vw, 58vh);
  }
}
