:root {
  --bg1: #fff8f4;
  --bg2: #fef3f6;
  --card: rgba(255, 255, 255, 0.92);
  --text: #4a3b34;
  --muted: #8a776d;
  --primary: #c8886a;
  --primary-dark: #b47659;
  --ring: rgba(200, 136, 106, 0.18);
  --board-bg: #e8c896;
  --board-line: #8b6914;
  --black-stone: #1a1410;
  --white-stone: #faf8f5;
  --highlight: rgba(200, 136, 106, 0.45);
  --success: #5a9a6e;
  --danger: #c45c5c;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at -10% -20%, #ffe9dc 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 120%, #ffe5ef 0%, transparent 60%),
    linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 100%);
}

.shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.hero {
  text-align: center;
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: #9b6a52;
  background: #fff2ea;
  margin: 0 0 10px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: 0.04em;
}

.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow:
    0 16px 40px rgba(120, 82, 66, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.panel.hidden {
  display: none;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(200, 136, 106, 0.25);
  border-radius: 12px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 6px 16px var(--ring);
}

.btn-primary:hover {
  filter: brightness(1.03);
}

.btn-ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(200, 136, 106, 0.22);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #d07070 0%, #c45c5c 100%);
}

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

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(200, 136, 106, 0.2);
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff8f4;
  font-size: 0.9rem;
}

.user-bar strong {
  color: #9b6a52;
}

.room-code {
  text-align: center;
  margin: 16px 0;
}

.room-code-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.room-code-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #9b6a52;
}

.seats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 18px 0;
}

.seat {
  border-radius: 14px;
  padding: 18px 14px;
  text-align: center;
  border: 2px dashed rgba(200, 136, 106, 0.35);
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.seat:hover:not(.seat--taken):not(.seat--mine) {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.seat--black .seat-stone {
  background: radial-gradient(circle at 35% 30%, #444 0%, var(--black-stone) 55%);
}

.seat--white .seat-stone {
  background: radial-gradient(circle at 35% 30%, #fff 0%, #e8e4df 55%);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.seat-stone {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin: 0 auto 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
}

.seat-label {
  font-weight: 600;
  margin-bottom: 4px;
}

.seat-player {
  font-size: 0.88rem;
  color: var(--muted);
  min-height: 1.2em;
}

.seat--taken {
  cursor: default;
  border-style: solid;
  border-color: rgba(200, 136, 106, 0.45);
}

.seat--mine {
  border-color: var(--primary);
  background: #fff5ef;
  box-shadow: 0 0 0 3px var(--ring);
}

.seat--disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.spectators-card {
  margin: 4px 0 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(200, 136, 106, 0.18);
}

.spectators-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.spectators-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.spectators-count {
  font-size: 0.85rem;
  color: var(--muted);
}

.spectator-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spectator-list li {
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff8f4;
  border: 1px solid rgba(200, 136, 106, 0.2);
  font-size: 0.85rem;
}

.spectator-list li.is-me {
  border-color: var(--primary);
  background: #fff5ef;
  font-weight: 600;
}

.spectator-empty {
  color: var(--muted);
  background: transparent !important;
  border: none !important;
  padding-left: 0 !important;
}

.side-actions {
  flex-direction: column;
}

.status-banner {
  text-align: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff5ef;
  color: #9b6a52;
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.status-banner.is-playing {
  background: #f0faf3;
  color: var(--success);
}

.status-banner.is-ended {
  background: #fff0f0;
  color: var(--danger);
}

.game-layout {
  display: grid;
  gap: 16px;
}

@media (min-width: 720px) {
  .game-layout {
    grid-template-columns: 1fr 220px;
    align-items: start;
  }
}

.board-wrap {
  overflow: auto;
  padding: 4px;
  -webkit-overflow-scrolling: touch;
}

.board {
  position: relative;
  width: min(100%, 480px);
  margin: 0 auto;
  aspect-ratio: 1;
  background: var(--board-bg);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 2px #c4a060,
    0 8px 24px rgba(100, 70, 40, 0.2);
  touch-action: manipulation;
}

.board-grid {
  position: absolute;
  inset: 3.33%;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
}

.board-lines {
  position: absolute;
  inset: 3.33%;
  pointer-events: none;
}

.intersection {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.intersection::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72%;
  height: 72%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  opacity: 0;
  background: var(--highlight);
  transition: opacity 0.12s;
}

.intersection.can-play:hover::before {
  opacity: 1;
}

.stone {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 88%;
  height: 88%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

.stone--black {
  background: radial-gradient(circle at 35% 28%, #555 0%, var(--black-stone) 60%);
}

.stone--white {
  background: radial-gradient(circle at 35% 28%, #fff 0%, #e0dbd4 65%);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.stone--last {
  box-shadow:
    0 0 0 2px var(--primary),
    0 2px 5px rgba(0, 0, 0, 0.25);
}

.side-panel {
  display: grid;
  gap: 12px;
}

.info-card {
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(200, 136, 106, 0.15);
}

.info-card h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.player-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 0.92rem;
}

.player-line .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-line .dot--black {
  background: var(--black-stone);
}

.player-line .dot--white {
  background: var(--white-stone);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.player-line.is-turn {
  font-weight: 700;
  color: #9b6a52;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(74, 59, 52, 0.92);
  color: #fff;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.offline-hint {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff8e8;
  color: #8a6d3b;
  font-size: 0.85rem;
  line-height: 1.6;
}

.offline-hint code {
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

.back-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
}

.back-link:hover {
  color: var(--primary-dark);
}
