:root {
  color-scheme: dark;
  --page: #0a100d;
  --panel: rgba(24, 32, 27, 0.92);
  --line: rgba(255, 235, 205, 0.12);
  --ink: #f4ead9;
  --muted: #b3a894;
  --gold: #e8b95f;
  --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(ellipse at 50% -12%, rgba(72, 96, 78, 0.5), transparent 58%),
    radial-gradient(ellipse at 50% 118%, rgba(0, 0, 0, 0.6), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 5px),
    var(--page);
}

main {
  width: min(1100px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 14px 28px;
  display: flex;
  flex-direction: column;
  /* 棋盘、玩家条、操作按钮同宽，视觉上一根轴线。 */
  --board-w: min(100%, calc((100dvh - 240px) * 0.95), 800px);
}

.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.08em;
  line-height: 1;
  background: linear-gradient(180deg, #f6dfae, #d6a852);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(232, 185, 95, 0.22));
}
.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: 8px;
  z-index: 3;
  align-self: flex-start;
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 12px;
  min-height: 1.4em;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(10, 16, 13, 0.82);
  border: 1px solid rgba(255, 235, 205, 0.10);
  backdrop-filter: blur(4px);
  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; border-color: rgba(232, 185, 95, 0.45); }
.hole-goal { fill: none; stroke: rgba(232, 185, 95, 0.55); stroke-width: 0.05; }
.goal-arrow { fill: rgba(232, 185, 95, 0.8); }

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

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

.board-edge {
  fill: none;
  stroke: #20150f;
  stroke-width: 1.5;
  stroke-linejoin: round;
  filter: url(#boardShadow);
}
.board-top {
  fill: url(#wood);
  stroke: rgba(255, 216, 160, 0.20);
  stroke-width: 0.08;
  stroke-linejoin: round;
  filter: url(#grain);
}
.board-sheen { fill: url(#sheen); pointer-events: none; }

.hole { fill: url(#hole); stroke: rgba(0, 0, 0, 0.45); stroke-width: 0.035; }
.hole-tint { pointer-events: none; }

.stone { pointer-events: none; }
.stone[data-piece] { pointer-events: all; cursor: pointer; }
.stone-shadow { fill: rgba(0, 0, 0, 0.46); }
.stone-body { stroke: rgba(0, 0, 0, 0.28); stroke-width: 0.02; }
.stone-rim { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 0.016; }
.stone-gloss { fill: rgba(255, 255, 255, 0.58); pointer-events: none; }
.stone.pickable .stone-body { stroke: rgba(232, 185, 95, 0.7); stroke-width: 0.03; }
.pick-ring { fill: none; stroke: rgba(232, 185, 95, 0.8); stroke-width: 0.06; }
.stone.picked .stone-body { stroke: var(--gold); stroke-width: 0.05; }
.halo { fill: none; stroke: var(--gold); stroke-width: 0.075; opacity: 0.9; animation: halo 1.2s ease-in-out infinite; pointer-events: none; }
@keyframes halo {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.95; }
}

.target {
  fill: rgba(232, 185, 95, 0.14);
  stroke: rgba(232, 185, 95, 0.85);
  stroke-width: 0.05;
  cursor: pointer;
  pointer-events: all;
  animation: target 1.4s ease-in-out infinite;
}

.target.jump { fill: none; stroke: var(--gold); stroke-width: 0.16; }
.target-core { fill: var(--gold); pointer-events: none; }
.target.jump:hover { fill: rgba(232, 185, 95, 0.3); }
@keyframes target {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

.players { display: flex; flex-wrap: wrap; gap: 8px; width: var(--board-w); max-width: 100%; margin: 16px auto 0; }
.players .p {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(18, 26, 21, 0.72);
  border: 1px solid rgba(255, 235, 205, 0.08);
}
.players .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset -1px -1px 2px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.3);
}
.players .p.turn {
  color: var(--ink);
  font-weight: 650;
  border-color: rgba(232, 185, 95, 0.45);
  background: rgba(232, 185, 95, 0.10);
  box-shadow: 0 0 12px rgba(232, 185, 95, 0.10);
}
.players .p.off { opacity: 0.5; }
.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; width: var(--board-w); max-width: 100%; margin: 16px auto 0; }
.actions button {
  flex: 1;
  padding: 15px 12px;
  border: 0;
  border-radius: 14px;
  font: 600 16px/1 inherit;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.actions button:hover { transform: translateY(-1px); }
.actions button:active { transform: translateY(1px); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35); }
.actions .primary { background: linear-gradient(180deg, #f4cc7c, #d9a648); color: #2b2113; }
.actions .secondary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.actions button:disabled { background: rgba(255, 255, 255, 0.06); color: rgba(255, 255, 255, 0.3); cursor: not-allowed; box-shadow: none; transform: none; }

.lobby { max-width: 560px; margin: clamp(8px, 5vh, 56px) auto 0; display: grid; gap: 12px; }
.lobby h1 {
  font-size: 32px;
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  background: linear-gradient(180deg, #f6dfae, #d6a852);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lobby .lede { margin: 0 0 6px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.entry {
  background: linear-gradient(180deg, rgba(30, 40, 33, 0.94), rgba(19, 27, 22, 0.94));
  border: 1px solid rgba(255, 235, 205, 0.10);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.entry.primary { border-color: rgba(232, 185, 95, 0.40); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(232, 185, 95, 0.12); }
.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 rgba(255, 235, 205, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}
.entry input:focus, .entry select:focus {
  outline: none;
  border-color: rgba(232, 185, 95, 0.55);
  box-shadow: 0 0 0 3px rgba(232, 185, 95, 0.12);
}
.entry button {
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  font: 600 15px/1 inherit;
  background: linear-gradient(180deg, #f4cc7c, #d9a648);
  color: #2b2113;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}
.entry.secondary button {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07));
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

@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; }
}
