:root {
  color-scheme: dark;
  --page: #0e0c10;
  --panel: #1a1720;
  --line: rgba(255, 255, 255, 0.12);
  --ink: #f2eee6;
  --muted: #a89f95;
  --gold: #f0c36a;
  --seat0: #e05a4f;
  --seat1: #4aa3c4;
  /* 丙不能用金色：金色是落点/选中的强调色，会分不清棋子和落点。 */
  --seat2: #9b6bd6;
  --seat3: #9ad08a;
  --seat4: #d4737a;
  --seat5: #e8a33d;
  font-family: "Iowan Old Style", Palatino, "Songti SC", "PingFang SC", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 50% -10%, #262030, transparent 55%), var(--page);
}

main {
  width: min(1100px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 14px 28px;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 2px 2px 10px;
}
.brand { font-size: 26px; font-weight: 700; letter-spacing: 0.06em; line-height: 1; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.chip {
  font: 600 13px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.chip.gold { background: rgba(240, 195, 106, 0.16); border-color: rgba(240, 195, 106, 0.5); color: var(--gold); }

.status {
  position: sticky;
  top: 0;
  z-index: 3;
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 10px;
  min-height: 1.4em;
  padding: 4px 0;
  background: transparent;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.status b { color: var(--ink); }
.status .err { color: #ffb4ac; }
.status.mine { color: var(--gold); font-weight: 700; }
.hole.goal { fill: rgba(240, 195, 106, 0.14); stroke: rgba(240, 195, 106, 0.55); stroke-width: 0.05; }
.goal-text { fill: rgba(240, 195, 106, 0.85); font-size: 0.9px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }

svg.board {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  touch-action: manipulation;
  user-select: none;
}

/* 竖屏按高度收敛，整盘一屏放下；手机横屏撑满宽度、允许上下滚，
   横屏高屏（桌面/平板）再按高度收敛，避免棋盘被切底。 */
@media (orientation: portrait) {
  svg.board { max-width: calc((100dvh - 220px) * 0.88); }
}
@media (orientation: landscape) and (max-height: 500px) {
  svg.board { max-width: 100%; }
}
@media (orientation: landscape) and (min-height: 501px) {
  svg.board { max-width: min(100%, calc((100dvh - 220px) * 0.88)); }
}

.hole { fill: #2a2530; stroke: rgba(255, 255, 255, 0.08); }
.hole.seat0 { fill: rgba(224, 90, 79, 0.18); }
.hole.seat1 { fill: rgba(74, 163, 196, 0.18); }
.hole.seat2 { fill: rgba(155, 107, 214, 0.18); }
.hole.seat3 { fill: rgba(154, 208, 138, 0.18); }
.hole.seat4 { fill: rgba(212, 115, 122, 0.18); }
.hole.seat5 { fill: rgba(232, 163, 61, 0.18); }
.hole.f0 { fill: rgba(224, 90, 79, 0.18); }
.hole.f1 { fill: rgba(74, 163, 196, 0.18); }
.hole.f2 { fill: rgba(240, 195, 106, 0.18); }
.hole.f3 { fill: rgba(127, 196, 224, 0.18); }
.hole.f4 { fill: rgba(212, 115, 122, 0.18); }
.hole.f5 { fill: rgba(154, 208, 138, 0.18); }

.piece { stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.05; }
.piece.seat0 { fill: var(--seat0); }
.piece.seat1 { fill: var(--seat1); }
.piece.seat2 { fill: var(--seat2); }
.piece.seat3 { fill: var(--seat3); }
.piece.seat4 { fill: var(--seat4); }
.piece.seat5 { fill: var(--seat5); }
.piece.pickable { cursor: pointer; stroke: rgba(240, 195, 106, 0.55); stroke-width: 0.05; }
.piece.picked { stroke: var(--gold); stroke-width: 0.12; cursor: pointer; }
.halo { fill: none; stroke: var(--gold); stroke-width: 0.09; opacity: 0.9; animation: halo 1.2s ease-in-out infinite; }
@keyframes halo {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.95; }
}

.target { fill: rgba(240, 195, 106, 0.8); cursor: pointer; pointer-events: all; animation: target 1.4s ease-in-out infinite; }

.target.jump { fill: none; stroke: var(--gold); stroke-width: 0.17; }
.target-core { fill: var(--gold); pointer-events: none; }
.target.jump:hover { fill: rgba(240, 195, 106, 0.5); }
@keyframes target {
  0%, 100% { opacity: 0.78; }
  50% { opacity: 1; }
}

.players { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 2px 0; font-size: 13px; color: var(--muted); }
.players .p { display: inline-flex; align-items: center; gap: 6px; }
.players .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.players .p.turn { color: var(--ink); font-weight: 600; }
.players .p.off { opacity: 0.45; }
.offline-tag { font-size: 11px; color: #ffb4ac; border: 1px solid rgba(255, 180, 172, 0.4); border-radius: 4px; padding: 0 4px; }
.lobby .status { position: static; margin: 0; min-height: 0; padding: 0; background: none; text-shadow: none; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.actions button {
  flex: 1;
  padding: 14px 12px;
  border: 0;
  border-radius: 14px;
  font: 600 16px/1 inherit;
  cursor: pointer;
}
.actions .primary { background: var(--gold); color: #2b2113; }
.actions .secondary { background: rgba(255, 255, 255, 0.1); color: var(--ink); }
.actions button:disabled { background: rgba(255, 255, 255, 0.06); color: rgba(255, 255, 255, 0.3); cursor: not-allowed; }

.lobby { max-width: 560px; margin: clamp(8px, 5vh, 56px) auto 0; display: grid; gap: 12px; }
.lobby h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: 0.06em; }
.lobby .lede { margin: 0 0 6px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.entry { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.entry.primary { border-color: rgba(240, 195, 106, 0.45); }
.entry h2 { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.entry p { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.entry form { display: flex; gap: 8px; flex-wrap: wrap; }
.entry input, .entry select {
  flex: 1 1 120px;
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  border-radius: 11px;
  padding: 12px 14px;
  font: inherit;
}
.entry button {
  border: 0;
  border-radius: 11px;
  padding: 12px 20px;
  font: 600 15px/1 inherit;
  background: var(--gold);
  color: #2b2113;
  cursor: pointer;
}
.entry.secondary button { background: rgba(255, 255, 255, 0.12); color: var(--ink); }

@media (max-width: 640px) {
  main { padding: 12px 10px 24px; }
  .brand { font-size: 22px; }
  .entry button { flex: 1 1 100%; }
  .players { font-size: 14px; }
  .entry p, .lobby .lede { font-size: 14px; }
}
