:root {
  --bg: #f3ecdf;
  --ink: #2d241d;
  --accent: #a3320b;
  --accent-soft: #d2691e;
  --panel: rgba(255, 249, 238, 0.88);
  --line: #7a5637;
  --board: #d7b98a;
  --shadow: 0 18px 60px rgba(76, 46, 22, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(163, 50, 11, 0.15), transparent 32%),
    radial-gradient(circle at bottom left, rgba(122, 86, 55, 0.18), transparent 30%),
    var(--bg);
  font-family: "Noto Serif SC", "Source Han Serif SC", serif;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.site-header,
.page-shell,
.room-layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0 12px;
}

.brand {
  font-size: 28px;
  font-weight: 700;
  text-decoration: none;
}

.tagline {
  margin: 6px 0 0;
  opacity: 0.75;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.page-shell {
  padding-bottom: 40px;
}

.panel,
.auth-card {
  background: var(--panel);
  border: 1px solid rgba(122, 86, 55, 0.18);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel {
  padding: 22px;
  margin-bottom: 20px;
  min-width: 0;
}

.auth-card {
  max-width: 420px;
  margin: 64px auto;
  padding: 28px;
}

.stack-form,
.room-config {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

input,
select,
button,
.text-btn {
  border-radius: 12px;
  border: 1px solid rgba(122, 86, 55, 0.22);
  padding: 11px 14px;
}

button,
.text-btn {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  color: #fff9f0;
  cursor: pointer;
  text-decoration: none;
}

.ghost-btn {
  background: transparent;
  color: var(--ink);
}

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

.room-list {
  display: grid;
  gap: 12px;
}

.room-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.8);
  border: 1px solid rgba(122, 86, 55, 0.12);
}

.room-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 14px;
  opacity: 0.85;
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 720px) 340px;
  gap: 20px;
}

.board-panel {
  min-width: 0;
  overflow: hidden;
}

.xiangqi-board {
  position: relative;
  width: 100%;
  max-width: 760px;
  aspect-ratio: 9 / 10;
  margin: 0 auto;
  padding: 30px 28px;
  border-radius: 26px;
  background:
    radial-gradient(circle at top left, rgba(255, 245, 221, 0.7), transparent 32%),
    linear-gradient(180deg, #efd4a3, #d9b47a 55%, #cea269);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 234, 0.65),
    inset 0 0 0 14px rgba(120, 78, 39, 0.08),
    0 22px 54px rgba(70, 40, 16, 0.16);
}

.xiangqi-board::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 18px;
  border: 2px solid rgba(103, 65, 33, 0.28);
  pointer-events: none;
}

.board-svg,
.board-grid {
  position: absolute;
  inset: 30px 28px;
}

.board-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.board-outline,
.board-line {
  fill: none;
  stroke: #724621;
  stroke-linecap: square;
}

.board-outline {
  stroke-width: 0.08;
}

.board-line {
  stroke-width: 0.045;
}

.palace-line {
  stroke-width: 0.04;
}

.river-text {
  fill: rgba(104, 60, 28, 0.82);
  font-size: 0.42px;
  letter-spacing: 0.18px;
  text-anchor: middle;
  dominant-baseline: middle;
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
}

.board-hit {
  fill: transparent;
  cursor: pointer;
}

.board-hit.selected {
  fill: rgba(163, 50, 11, 0.08);
}

.piece-group {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
}

.piece-disc {
  fill: #ead0a2;
  stroke: rgba(109, 68, 35, 0.82);
  stroke-width: 0.04;
}

.piece-inner {
  fill: rgba(255, 246, 224, 0.78);
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 0.02;
}

.piece-label {
  font-size: 0.38px;
  font-weight: 700;
  line-height: 1;
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  paint-order: stroke fill;
  stroke: rgba(255, 248, 232, 0.72);
  stroke-width: 0.012;
}

.piece-group.red .piece-label {
  fill: var(--accent);
}

.piece-group.black .piece-label {
  fill: #2b2a30;
}

.piece-group.selected .piece-disc {
  stroke: rgba(163, 50, 11, 0.92);
  stroke-width: 0.055;
}

.piece-group.selected .piece-inner {
  fill: rgba(255, 248, 230, 0.92);
}

.sidebar {
  align-self: start;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.notice {
  padding: 12px;
  border-radius: 14px;
  background: rgba(163, 50, 11, 0.1);
  margin-bottom: 16px;
}

.hidden {
  display: none;
}

.history-list {
  padding-left: 18px;
  max-height: 280px;
  overflow: auto;
}

.flash-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.flash {
  background: rgba(163, 50, 11, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
}

.turn-indicator {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(163, 50, 11, 0.12);
}

@media (max-width: 920px) {
  .room-layout {
    grid-template-columns: 1fr;
  }

  .xiangqi-board {
    max-width: none;
    padding: 18px 16px;
  }

  .board-svg,
  .board-grid {
    inset: 18px 16px;
  }
}

@media (max-width: 560px) {
  .site-header,
  .page-shell,
  .room-layout {
    width: min(100%, calc(100% - 16px));
  }

  .panel {
    padding: 14px;
    border-radius: 18px;
  }

  .panel-head {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
  }

  .turn-indicator {
    padding: 6px 10px;
    font-size: 13px;
  }

  .xiangqi-board {
    padding: 12px 10px;
    border-radius: 18px;
  }

  .xiangqi-board::before {
    inset: 8px;
    border-radius: 12px;
  }

  .board-svg,
  .board-grid {
    inset: 12px 10px;
  }
}
