:root {
  --ink: #17242d;
  --ink-soft: #52606a;
  --ink-faint: #8a959b;
  --paper: #f4f1eb;
  --paper-deep: #e9e4db;
  --panel: #fbfaf7;
  --line: #dedbd3;
  --line-strong: #c7c4bb;
  --red: #ae4b4a;
  --red-soft: #f4e5e0;
  --blue: #31677b;
  --blue-soft: #e3edf0;
  --gold: #b88b42;
  --gold-soft: #f3ead7;
  --green: #4c735b;
  --shadow: 0 18px 46px rgba(31, 39, 42, 0.08);
  --radius: 18px;
  --small-radius: 10px;
  --serif: Georgia, "Times New Roman", "Noto Serif SC", serif;
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(184, 139, 66, 0.035) 25%, transparent 25%) 0 0 / 13px 13px,
    var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.site-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
  z-index: 0;
}

.panel {
  position: relative;
  background: rgba(251, 250, 247, 0.93);
  border: 1px solid rgba(199, 196, 187, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(360px, 440px);
  align-items: center;
  gap: clamp(48px, 9vw, 150px);
  max-width: 1160px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 64px 28px;
}

.auth-intro {
  padding: 20px 0 20px 32px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  line-height: 1.3;
}

.auth-intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(48px, 7vw, 82px);
  font-weight: 400;
  letter-spacing: -0.06em;
  line-height: 1.08;
}

.auth-intro h1 em {
  color: var(--red);
  font-style: normal;
}

.intro-copy {
  max-width: 420px;
  margin: 28px 0 38px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.9;
}

.intro-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 26px;
  color: var(--ink-soft);
  font-size: 12px;
}

.intro-notes span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.intro-notes strong {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 400;
}

.auth-card {
  z-index: 1;
  padding: 36px 38px 32px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup strong {
  font-size: 14px;
  letter-spacing: 0.08em;
}

.brand-lockup div span {
  margin-top: 4px;
  color: var(--ink-faint);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.auth-tabs {
  display: flex;
  gap: 24px;
  margin: 44px 0 28px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  position: relative;
  padding: 0 0 12px;
  color: var(--ink-faint);
  background: transparent;
  font-size: 15px;
}

.auth-tab.active {
  color: var(--ink);
  font-weight: 700;
}

.auth-tab.active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--red);
  content: "";
}

.auth-form {
  display: grid;
  gap: 18px;
}

.auth-form label,
.mark-input-label {
  display: grid;
  gap: 8px;
}

.auth-form label > span,
.mark-input-label > span {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.auth-form input,
.mark-input-label textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: rgba(244, 241, 235, 0.6);
  color: var(--ink);
  padding: 12px 13px;
  transition: border 160ms, box-shadow 160ms, background 160ms;
}

.auth-form input:focus,
.mark-input-label textarea:focus {
  border-color: var(--gold);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(184, 139, 66, 0.12);
}

.auth-form input::placeholder,
.mark-input-label textarea::placeholder {
  color: #abb0af;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: transform 160ms, box-shadow 160ms, background 160ms;
}

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

.button-primary {
  color: #fffaf1;
  background: var(--ink);
  box-shadow: 0 7px 17px rgba(23, 36, 45, 0.13);
}

.button-primary:hover {
  background: #273944;
  box-shadow: 0 9px 22px rgba(23, 36, 45, 0.18);
}

.button-secondary {
  color: var(--ink);
  border-color: var(--line-strong);
  background: transparent;
}

.button-secondary:hover,
.quiet-button:hover {
  border-color: var(--ink-soft);
  background: #f0ede7;
}

.button-danger {
  color: #98504e;
  border-color: #e5c5c1;
  background: #fff8f5;
}

.button-danger:hover {
  background: var(--red-soft);
}

.button-small {
  min-height: 32px;
  padding: 0 11px;
  font-size: 11px;
}

.button-wide {
  width: 100%;
  min-height: 46px;
  margin-top: 5px;
}

.button-plus {
  font-size: 20px;
  font-weight: 300;
  line-height: 0;
}

.quiet-button,
.text-button {
  color: var(--ink-soft);
  background: transparent;
  font-size: 12px;
}

.quiet-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 7px;
}

.text-button:hover {
  color: var(--red);
}

.form-hint {
  margin: -1px 0 0;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.6;
}

.form-message {
  min-height: 18px;
  margin: 18px 0 0;
  color: var(--red);
  font-size: 12px;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.topbar {
  border-bottom: 1px solid rgba(199, 196, 187, 0.72);
  background: rgba(244, 241, 235, 0.87);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  min-height: 76px;
  margin: 0 auto;
  padding: 0 32px;
}

.topbar-brand {
  transform: scale(0.96);
  transform-origin: left center;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 22px;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  font-size: 20px;
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--panel);
}

.bell-icon {
  display: block;
  transform: rotate(-20deg);
  font-size: 24px;
  line-height: 1;
}

.notification-dot {
  position: absolute;
  top: 4px;
  right: 3px;
  width: 7px;
  height: 7px;
  border: 1px solid var(--paper);
  border-radius: 50%;
  background: var(--red);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip strong,
.user-chip small {
  display: block;
}

.user-chip strong {
  max-width: 110px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip small {
  margin-top: 4px;
  color: var(--gold);
  font-size: 10px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--gold-soft);
  font-family: var(--serif);
}

.page-shell {
  width: min(1380px, calc(100% - 64px));
  margin: 0 auto;
  padding: 58px 0 80px;
}

.page-heading,
.game-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 34px;
}

.page-heading h1,
.game-heading h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(31px, 4vw, 47px);
  font-weight: 400;
  letter-spacing: -0.05em;
  line-height: 1.1;
}

.heading-copy {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.heading-actions,
.game-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
}

.games-panel,
.rule-panel,
.score-panel,
.board-stage,
.selection-panel,
.replay-panel {
  padding: 25px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.panel-heading.compact {
  align-items: center;
  margin-bottom: 18px;
}

.panel-heading h2,
.score-panel h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.panel-heading p:not(.eyebrow) {
  margin: 6px 0 0;
  color: var(--ink-faint);
  font-size: 11px;
}

.games-list {
  display: grid;
  gap: 10px;
}

.game-card {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(175px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 105px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.42);
  cursor: pointer;
  transition: border 160ms, transform 160ms, background 160ms;
}

.game-card:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
  background: #fff;
}

.game-card-main,
.game-card-seats,
.game-card-side {
  min-width: 0;
}

.game-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.game-card-title strong {
  font-size: 14px;
}

.game-card-title small,
.game-card-meta {
  color: var(--ink-faint);
  font-size: 11px;
}

.game-card-meta {
  display: flex;
  gap: 10px;
}

.card-turn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.card-turn.waiting {
  color: var(--ink-faint);
}

.turn-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.card-turn.waiting .turn-dot {
  background: var(--line-strong);
}

.seat-dots {
  display: flex;
  gap: 7px;
}

.seat-dot {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-faint);
  background: var(--paper);
  font-size: 10px;
}

.seat-dot.filled {
  color: #fff;
  border-color: transparent;
}

.seat-dot.red {
  background: var(--red);
}

.seat-dot.blue {
  background: var(--blue);
}

.game-card-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.deadline-mini {
  color: var(--ink-soft);
  font-size: 11px;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 20px;
  color: var(--green);
  background: #e7efe7;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.status-badge.waiting {
  color: var(--ink-soft);
  background: var(--paper-deep);
}

.status-badge.finished {
  color: var(--red);
  background: var(--red-soft);
}

.status-badge.grace {
  color: #9b6b25;
  background: var(--gold-soft);
}

.empty-list {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--ink-faint);
  text-align: center;
}

.empty-list .empty-symbol {
  margin-bottom: 12px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 34px;
}

.empty-list p {
  margin: 0;
  line-height: 1.8;
}

.dashboard-side {
  display: grid;
  align-content: start;
  gap: 18px;
}

.rule-list {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rule-list li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
}

.rule-list li > span {
  color: var(--gold);
  font-family: var(--serif);
  font-size: 16px;
}

.rule-list strong,
.rule-list small {
  display: block;
}

.rule-list strong {
  margin-bottom: 5px;
  font-size: 12px;
}

.rule-list small {
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.6;
}

.score-panel {
  background: var(--ink);
  color: #f8f4eb;
}

.score-panel .eyebrow {
  color: #bf9e63;
}

.score-panel-title {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 23px;
}

.score-panel h2 {
  color: #f8f4eb;
}

.score-seal {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border: 1px solid rgba(250, 246, 236, 0.3);
  border-radius: 50%;
  color: #c9a763;
  font-family: var(--serif);
  font-size: 18px;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(250, 246, 236, 0.17);
  padding-top: 18px;
}

.record-grid div {
  display: grid;
  gap: 5px;
  text-align: center;
}

.record-grid div + div {
  border-left: 1px solid rgba(250, 246, 236, 0.17);
}

.record-grid strong {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 400;
}

.record-grid span {
  color: #9ca9ac;
  font-size: 10px;
}

.admin-link {
  color: var(--ink-soft);
  font-size: 11px;
  text-align: right;
}

.admin-link:hover {
  color: var(--red);
}

.toast-region {
  position: fixed;
  z-index: 20;
  top: 88px;
  right: 24px;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 48px));
}

.toast {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 9px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-left-color: var(--red);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-heading {
  align-items: center;
  margin-bottom: 22px;
}

.game-heading-left {
  display: flex;
  align-items: center;
  gap: 25px;
}

.back-button {
  min-height: 35px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  background: rgba(251, 250, 247, 0.6);
  font-size: 11px;
}

.back-button:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.game-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.game-title-line .eyebrow {
  margin: 0;
}

.deadline-box {
  display: grid;
  justify-items: end;
  gap: 4px;
  min-width: 130px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
}

.deadline-box span {
  color: var(--ink-faint);
  font-size: 10px;
}

.deadline-box strong {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
}

.deadline-box.grace strong,
.deadline-box.grace span {
  color: #9b6b25;
}

.deadline-box.expired strong,
.deadline-box.expired span {
  color: var(--red);
}

.notice-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 15px;
  border: 1px solid #dfc990;
  border-radius: 10px;
  background: var(--gold-soft);
}

.notice-banner .notice-icon {
  color: var(--gold);
  font-size: 22px;
}

.notice-banner div {
  display: grid;
  gap: 3px;
  flex: 1;
}

.notice-banner strong {
  font-size: 12px;
}

.notice-banner small {
  color: var(--ink-soft);
  font-size: 11px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
  gap: 24px;
}

.board-stage {
  min-width: 0;
  padding: 22px;
}

.board-stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
}

.turn-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12px;
}

.turn-notice.my-turn {
  color: var(--green);
  font-weight: 800;
}

.turn-notice.my-turn .turn-dot {
  box-shadow: 0 0 0 4px rgba(76, 115, 91, 0.15);
}

.board-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--ink-faint);
  font-size: 10px;
}

.board-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-swatch.red {
  background: var(--red);
}

.legend-swatch.blue {
  background: var(--blue);
}

.legend-swatch.hidden-piece {
  border: 1px solid var(--line-strong);
  background: #d4d7d3;
}

.table-wrap {
  position: relative;
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 42px 42px 45px;
}

.table-wrap::before {
  position: absolute;
  inset: 15px;
  border: 1px solid rgba(187, 172, 140, 0.65);
  border-radius: 20px;
  background: #eee7d9;
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.25);
  content: "";
}

.board-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(15, minmax(14px, 1fr));
  grid-template-rows: repeat(15, minmax(14px, 1fr));
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid #a69e8a;
  border-radius: 5px;
  background: #dad5c8;
  box-shadow: 0 10px 20px rgba(81, 74, 57, 0.15);
}

.board-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 2px;
  border-right: 1px solid rgba(137, 131, 115, 0.42);
  border-bottom: 1px solid rgba(137, 131, 115, 0.42);
  background: rgba(241, 237, 226, 0.65);
  color: var(--ink);
}

.board-cell:nth-child(15n) {
  border-right: 0;
}

.board-cell:nth-last-child(-n + 15) {
  border-bottom: 0;
}

.board-cell.rail {
  background-color: rgba(230, 224, 210, 0.64);
}

.board-cell.rail::after {
  position: absolute;
  width: 48%;
  height: 48%;
  border: 1px solid rgba(184, 139, 66, 0.25);
  border-radius: 50%;
  content: "";
}

.board-cell.central {
  background: #e6ded1;
}

.board-cell.center-mark::before,
.board-cell.base-mark::before {
  color: rgba(140, 116, 74, 0.48);
  font-family: var(--serif);
  font-size: clamp(9px, 1.5vw, 17px);
  content: "营";
}

.board-cell.base-mark::before {
  content: "旗";
}

.board-cell.zone-red {
  background: rgba(174, 75, 74, 0.065);
}

.board-cell.zone-blue {
  background: rgba(49, 103, 123, 0.065);
}

.board-cell.selected {
  z-index: 3;
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 2px rgba(184, 139, 66, 0.25);
}

.board-cell.move-target {
  z-index: 2;
  background: rgba(76, 115, 91, 0.14);
  box-shadow: inset 0 0 0 2px rgba(76, 115, 91, 0.7);
}

.board-cell:focus-visible {
  z-index: 4;
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.piece-token {
  position: relative;
  display: grid;
  place-items: center;
  width: min(88%, 35px);
  aspect-ratio: 1;
  border: 2px solid #d6c5a1;
  border-radius: 50%;
  color: var(--ink);
  background: #fcf8ef;
  box-shadow: 0 2px 4px rgba(40, 42, 40, 0.22);
  font-family: var(--serif);
  font-size: clamp(8px, 1.25vw, 14px);
  line-height: 1;
  user-select: none;
}

.piece-token::after {
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(23, 36, 45, 0.18);
  border-radius: 50%;
  content: "";
}

.piece-token.red {
  color: #8f3f3d;
  border-color: #cb8a7d;
}

.piece-token.blue {
  color: #2f6275;
  border-color: #8db3bd;
}

.piece-token.hidden-piece {
  color: #5d6665;
  border-color: #aeb5b1;
  background:
    repeating-linear-gradient(45deg, #e4e7e2 0, #e4e7e2 3px, #d2d7d1 3px, #d2d7d1 6px);
  font-size: 13px;
}

.piece-token.marked::before {
  position: absolute;
  z-index: 2;
  top: -3px;
  right: -2px;
  width: 6px;
  height: 6px;
  border: 1px solid #fff;
  border-radius: 50%;
  background: var(--gold);
  content: "";
}

.piece-token.mini {
  width: 42px;
  font-size: 15px;
}

.player-seat {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 130px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(251, 250, 247, 0.91);
  box-shadow: 0 6px 15px rgba(31, 39, 42, 0.06);
}

.seat-top {
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
}

.seat-bottom {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.seat-left {
  top: 50%;
  left: -1px;
  transform: translateY(-50%);
}

.seat-right {
  top: 50%;
  right: -1px;
  transform: translateY(-50%);
}

.seat-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-family: var(--serif);
  font-size: 12px;
}

.seat-avatar.red {
  background: var(--red);
}

.seat-avatar.blue {
  background: var(--blue);
}

.seat-avatar.empty {
  color: var(--ink-faint);
  border: 1px dashed var(--line-strong);
  background: transparent;
}

.player-seat > div {
  min-width: 0;
}

.player-seat strong,
.player-seat small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-seat strong {
  max-width: 100px;
  font-size: 11px;
}

.player-seat small {
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 9px;
}

.player-seat.is-turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 139, 66, 0.12), 0 6px 15px rgba(31, 39, 42, 0.08);
}

.player-seat.is-me strong::after {
  margin-left: 4px;
  color: var(--gold);
  content: "· 我";
}

.player-seat.is-empty {
  border-style: dashed;
  box-shadow: none;
}

.board-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 16px auto 0;
  width: min(100%, 820px);
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.6;
}

.tip-mark {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--serif);
}

.game-sidebar {
  display: grid;
  align-content: start;
  gap: 18px;
}

.private-label {
  color: var(--gold);
  font-size: 10px;
}

.empty-selection {
  display: grid;
  place-items: center;
  min-height: 150px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--ink-faint);
  text-align: center;
}

.empty-symbol {
  display: block;
  margin-bottom: 9px;
  color: var(--line-strong);
  font-family: var(--serif);
  font-size: 32px;
}

.empty-selection p {
  margin: 0;
  font-size: 11px;
  line-height: 1.7;
}

.selected-piece-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 17px;
}

.selected-piece-head strong,
.selected-piece-head small {
  display: block;
}

.selected-piece-head strong {
  font-size: 13px;
}

.selected-piece-head small {
  margin-top: 5px;
  color: var(--ink-faint);
  font-size: 10px;
}

.mark-input-label textarea {
  resize: vertical;
  line-height: 1.5;
}

.selection-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
}

.panel-count {
  color: var(--ink-faint);
  font-size: 10px;
}

.replay-control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 6px;
}

.replay-play {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font-size: 10px;
}

.replay-play:hover {
  border-color: var(--gold);
  color: var(--gold);
}

#replayRange {
  width: 100%;
  accent-color: var(--gold);
}

.replay-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 23px;
  color: var(--ink-faint);
  font-size: 10px;
}

.move-log {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
  margin-top: 7px;
  padding-right: 3px;
}

.move-log::-webkit-scrollbar {
  width: 4px;
}

.move-log::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: var(--line-strong);
}

.move-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid rgba(222, 219, 211, 0.72);
  cursor: pointer;
}

.move-item:hover,
.move-item.active {
  color: var(--gold);
}

.move-index {
  color: var(--ink-faint);
  font-family: var(--serif);
  font-size: 14px;
}

.move-item p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.5;
}

.move-item.active p {
  color: var(--gold);
}

.move-item small {
  display: block;
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 9px;
}

@media (max-width: 1000px) {
  .auth-layout {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
    gap: 35px;
  }

  .auth-intro {
    padding-left: 0;
  }

  .dashboard-grid,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-side {
    grid-template-columns: 1fr 1fr;
  }

  .admin-link {
    grid-column: 1 / -1;
  }

  .game-sidebar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .auth-layout {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 30px;
    padding: 38px 18px;
  }

  .auth-intro {
    padding-top: 10px;
  }

  .auth-intro h1 {
    font-size: 53px;
  }

  .intro-copy {
    margin: 20px 0;
    font-size: 14px;
  }

  .auth-card {
    padding: 28px 23px 24px;
  }

  .topbar-inner {
    min-height: 67px;
    padding: 0 16px;
  }

  .topbar-actions {
    gap: 11px;
  }

  .topbar-actions > .text-button {
    display: inline-flex;
    white-space: nowrap;
  }

  .page-shell {
    width: min(100% - 30px, 1380px);
    padding: 36px 0 55px;
  }

  .page-heading,
  .game-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
  }

  .heading-actions,
  .game-actions {
    justify-content: flex-start;
  }

  .game-heading {
    gap: 14px;
  }

  .game-heading-left {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .game-actions {
    width: 100%;
    justify-content: space-between;
  }

  .deadline-box {
    justify-items: start;
    margin-right: auto;
    padding-right: 0;
    border-right: 0;
  }

  .dashboard-side,
  .game-sidebar {
    grid-template-columns: 1fr;
  }

  .game-card {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .game-card-seats {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .game-card-side {
    grid-column: 2;
    grid-row: 1;
  }

  .table-wrap {
    padding: 37px 25px 40px;
  }

  .player-seat {
    min-width: 95px;
    padding: 7px;
  }

  .player-seat strong {
    max-width: 63px;
  }

  .player-seat small {
    font-size: 8px;
  }

  .board-stage {
    padding: 14px 10px 18px;
  }

  .board-stage-top {
    align-items: flex-start;
    flex-direction: column;
    margin: 0 5px 12px;
  }

  .board-tip {
    padding: 0 5px;
  }
}

@media (max-width: 440px) {
  .heading-actions,
  .heading-actions .button {
    width: 100%;
  }

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

  .game-actions {
    flex-wrap: wrap;
  }

  .game-actions .button-danger {
    width: 100%;
  }

  .table-wrap {
    padding-right: 17px;
    padding-left: 17px;
  }

  .seat-left,
  .seat-right {
    display: none;
  }
}

/* v4 正式棋盘：不再把 17×17 坐标盒误画成 225 个棋位。 */
.status-badge.paused, .status-badge.legacy {
  color: #8c622b;
  background: #f5ebd3;
}
.seat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px auto 10px;
  max-width: 900px;
}
.seat-strip .player-seat {
  position: static;
  transform: none;
  min-width: 0;
  padding: 7px;
}
.seat-strip .player-seat strong { max-width: 110px; }
.seat-strip .player-seat small { max-width: 125px; }
.board-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px auto 7px;
  max-width: 900px;
  color: var(--ink-faint);
  font-size: 11px;
}
.board-scroller {
  position: relative;
  isolation: isolate;
  max-width: 900px;
  margin: 0 auto;
  overflow: auto;
  border-radius: 10px;
  /* 只有滚动容器承载草地，透明棋盘与外围绝不各铺一张地面。 */
  background: url("/assets/board/table-surround.svg") center / cover no-repeat;
  box-shadow: 0 12px 28px rgba(31, 49, 37, .23);
  scrollbar-color: #839a68 #263b2c;
}
.board-grid {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.board-svg { display: block; width: 100%; height: auto; background: transparent; border: 0; box-shadow: none; }
.board-hit { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.board-hit:focus, .board-hit:focus-visible { outline: none; }
.board-hit rect { stroke: none; }
.board-piece .piece-body {
  transform-box: fill-box;
  transform-origin: center;
}
.board-piece.selected-piece .piece-body {
  transform: scale(1.08);
}
@media (prefers-reduced-motion: reduce) {
  .board-piece.selected-piece .piece-body { transform: scale(1.08); }
  .board-piece.selected-piece .piece-body > rect { stroke: #fff2be; stroke-width: 3; }
}
.board-scroller.zoomed .board-grid { width: max(100%, 1050px); }
.notice-banner > div { flex: 1; }
@media (max-width: 900px) {
  .seat-strip { grid-template-columns: 1fr 1fr; }
  .seat-strip .player-seat { display: flex; }
  .board-scroller {
    height: min(72dvh, 680px);
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
  }
  .board-scroller.overview { height: auto; }
  .board-scroller:not(.overview) .board-grid { width: max(100%, 980px); }
  .board-scroller.overview .board-grid { width: 100%; }
  .board-controls { align-items: flex-start; }
  .board-controls span { max-width: 65%; }
}
@media (max-width: 440px) {
  .seat-strip .seat-left, .seat-strip .seat-right { display: flex; }
  .seat-strip .player-seat strong { max-width: 84px; }
}

/* 正式首页：左侧棋桌预览，右侧游戏菜单。 */
.lobby-page {
  padding-top: 42px;
}

.lobby-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: stretch;
  gap: 24px;
}

.lobby-board-card {
  min-width: 0;
  overflow: hidden;
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid rgba(199, 196, 187, 0.8);
  border-radius: 22px;
  background:
    radial-gradient(circle at 10% 0%, rgba(184, 139, 66, 0.13), transparent 32%),
    linear-gradient(145deg, rgba(251, 250, 247, 0.98), rgba(238, 235, 226, 0.92));
  box-shadow: var(--shadow);
}

.lobby-board-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.lobby-board-heading h1,
.lobby-menu-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.04em;
}

.lobby-board-heading h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
}

.lobby-board-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid rgba(76, 115, 91, 0.25);
  border-radius: 20px;
  color: var(--green);
  background: rgba(231, 239, 231, 0.72);
  font-size: 10px;
  font-weight: 800;
}

.lobby-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(76, 115, 91, 0.13);
}

.lobby-board-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 246px;
  align-items: stretch;
  gap: 18px;
}

.home-board-frame {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  gap: 9px;
}

.home-board-frame-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.home-board-frame-label span:last-child {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 400;
}

.home-board-scroller {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  min-height: 520px;
  height: clamp(520px, 48vw, 700px);
  overflow: auto;
  border: 1px solid rgba(134, 157, 108, 0.6);
  border-radius: 16px;
  box-shadow:
    inset 0 0 0 7px rgba(255, 255, 255, 0.06),
    0 12px 28px rgba(31, 49, 37, 0.2);
  scrollbar-color: #839a68 #263b2c;
}

.home-board-grid {
  flex: 0 0 auto;
  width: min(100%, 760px);
  min-width: 620px;
  margin: auto;
  border-radius: 0;
}

.home-board-grid .board-svg {
  min-width: 620px;
}

.home-board-empty {
  display: grid;
  place-items: center;
  align-content: center;
  width: 100%;
  min-height: 460px;
  padding: 30px;
  color: rgba(255, 255, 255, 0.78);
  text-align: center;
}

.home-board-empty .empty-symbol {
  color: #e6c87f;
}

.home-board-empty p {
  margin: 0;
  font-size: 12px;
  line-height: 1.8;
}

.formation-tools {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 17px;
  border: 1px solid rgba(184, 139, 66, 0.28);
  border-radius: 16px;
  background: rgba(255, 252, 244, 0.76);
}

.tool-kicker {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.formation-tools h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
}

.formation-copy {
  margin: 10px 0 17px;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.65;
}

.formation-actions {
  display: grid;
  gap: 8px;
}

.formation-action {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 49px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(251, 250, 247, 0.72);
  text-align: left;
  transition: transform 160ms, border 160ms, background 160ms;
}

.formation-action:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
  background: #fff;
}

.formation-action-primary {
  border-color: rgba(184, 139, 66, 0.62);
  background: var(--gold-soft);
}

.formation-action-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid rgba(184, 139, 66, 0.36);
  border-radius: 8px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 14px;
}

.formation-action span:last-child {
  min-width: 0;
}

.formation-action strong,
.formation-action small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formation-action strong {
  font-size: 11px;
}

.formation-action small {
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 9px;
}

.formation-status {
  margin: auto 0 0;
  padding-top: 16px;
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.6;
}

.lobby-board-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin-top: 14px;
  color: var(--ink-faint);
  font-size: 10px;
}

.lobby-board-footer > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.footer-key {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.footer-key.muted {
  background: #aeb5b1;
}

.lobby-board-note {
  margin-left: auto;
  color: var(--green);
}

.lobby-menu {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 25px 18px 18px;
  border: 1px solid #2a4837;
  border-radius: 20px;
  color: #f3f0e5;
  background:
    radial-gradient(circle at 100% 0%, rgba(213, 177, 91, 0.16), transparent 34%),
    linear-gradient(160deg, #1b3529, #13251f);
  box-shadow: 0 18px 46px rgba(21, 44, 32, 0.18);
}

.lobby-menu .eyebrow {
  color: #c6a56a;
}

.lobby-menu-heading {
  padding: 0 8px 18px;
}

.lobby-menu-heading h2 {
  font-size: 28px;
}

.lobby-menu-heading p:last-child {
  max-width: 240px;
  margin: 9px 0 0;
  color: #a7b5ad;
  font-size: 11px;
  line-height: 1.65;
}

.home-menu-list {
  display: grid;
  gap: 5px;
}

.home-menu-item {
  display: grid;
  grid-template-columns: 33px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 56px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #e8e9dd;
  background: transparent;
  text-align: left;
  transition: transform 160ms, background 160ms, border 160ms;
}

.home-menu-item:hover {
  transform: translateX(2px);
  border-color: rgba(221, 194, 132, 0.24);
  background: rgba(255, 255, 255, 0.07);
}

.home-menu-item.featured {
  border-color: rgba(223, 194, 121, 0.4);
  color: #fff8e9;
  background: linear-gradient(100deg, rgba(184, 139, 66, 0.35), rgba(184, 139, 66, 0.12));
}

.home-menu-icon {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid rgba(196, 211, 194, 0.2);
  border-radius: 9px;
  color: #d7c28d;
  font-family: var(--serif);
  font-size: 13px;
}

.home-menu-item.featured .home-menu-icon {
  border-color: rgba(239, 213, 152, 0.4);
  color: #fff1c8;
}

.home-menu-item strong,
.home-menu-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-menu-item strong {
  font-size: 12px;
}

.home-menu-item small {
  margin-top: 3px;
  color: #8fa398;
  font-size: 9px;
}

.home-menu-item b {
  color: #789185;
  font-size: 16px;
  font-weight: 400;
  text-align: right;
}

.lobby-menu-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding: 17px 8px 2px;
  border-top: 1px solid rgba(215, 229, 215, 0.13);
}

.menu-footer-label {
  display: block;
  margin-bottom: 5px;
  color: #81978a;
  font-size: 9px;
}

.lobby-menu-footer strong {
  color: #e8d29a;
  font-size: 11px;
}

.menu-footer-link {
  padding: 4px 0;
  color: #b3c3b8;
  background: transparent;
  font-size: 10px;
}

.menu-footer-link:hover {
  color: #f2d796;
}

.home-content-panel {
  margin-top: 24px;
  padding: 25px;
  border: 1px solid rgba(199, 196, 187, 0.8);
  border-radius: 18px;
  background: rgba(251, 250, 247, 0.94);
  box-shadow: var(--shadow);
  scroll-margin-top: 24px;
}

.home-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.home-panel-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
}

.home-panel-section {
  min-width: 0;
}

.home-panel-section > .panel-heading {
  margin-bottom: 18px;
}

.home-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.home-feature-card {
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(244, 241, 235, 0.5);
}

.feature-card-icon {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  margin-bottom: 13px;
  border-radius: 10px;
  color: var(--gold);
  background: var(--gold-soft);
  font-family: var(--serif);
}

.home-feature-card strong {
  display: block;
  font-size: 13px;
}

.home-feature-card p {
  margin: 8px 0 0;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.7;
}

.home-empty-panel {
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--ink-faint);
  text-align: center;
}

.home-empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 11px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 20px;
}

.home-empty-panel h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.home-empty-panel p {
  max-width: 530px;
  margin: 9px 0 17px;
  font-size: 11px;
  line-height: 1.7;
}

.home-ranking-list,
.home-settings-list {
  display: grid;
  gap: 8px;
}

.home-ranking-row,
.home-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(244, 241, 235, 0.45);
}

.home-ranking-row > span {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.home-ranking-row strong {
  margin-left: auto;
  color: var(--gold);
  font-size: 12px;
}

.home-ranking-row small,
.home-setting-row small {
  color: var(--ink-faint);
  font-size: 10px;
}

.home-setting-row > div {
  min-width: 0;
}

.home-setting-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.setting-state {
  flex: 0 0 auto;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.home-rule-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-record-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
}

.home-record-strip .score-seal {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.home-record-strip strong {
  margin-left: 9px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
}

.home-record-strip small {
  color: var(--ink-faint);
  font-size: 10px;
}

.home-record-score {
  margin-left: auto;
  color: var(--ink-faint);
}

.home-record-score b {
  margin-left: 5px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
}

@media (max-width: 1120px) {
  .lobby-layout {
    grid-template-columns: minmax(0, 1fr) 285px;
  }

  .lobby-board-workspace {
    grid-template-columns: minmax(0, 1fr) 220px;
  }

  .home-board-grid,
  .home-board-grid .board-svg {
    min-width: 560px;
  }
}

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

  .lobby-menu {
    order: 2;
  }

  .lobby-board-card {
    order: 1;
  }

  .lobby-board-workspace {
    grid-template-columns: minmax(0, 1fr) 230px;
  }

  .home-board-scroller {
    height: min(70vw, 620px);
    min-height: 430px;
  }
}

@media (max-width: 640px) {
  .lobby-page {
    padding-top: 25px;
  }

  .lobby-board-card {
    padding: 18px 13px 15px;
    border-radius: 16px;
  }

  .lobby-board-heading {
    margin-bottom: 18px;
  }

  .lobby-board-heading h1 {
    font-size: 31px;
  }

  .lobby-board-badge {
    padding: 7px 9px;
    font-size: 9px;
  }

  .lobby-board-workspace {
    grid-template-columns: 1fr;
  }

  .home-board-scroller {
    justify-content: flex-start;
    height: min(86vw, 520px);
    min-height: 340px;
  }

  .home-board-grid,
  .home-board-grid .board-svg {
    min-width: 520px;
  }

  .formation-tools {
    padding: 17px 14px;
  }

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

  .formation-status {
    margin-top: 12px;
  }

  .lobby-board-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .lobby-board-note {
    margin-left: 0;
  }

  .lobby-menu {
    padding: 20px 12px 14px;
    border-radius: 16px;
  }

  .home-content-panel {
    padding: 18px 14px;
  }

  .home-feature-grid,
  .home-rule-list {
    grid-template-columns: 1fr;
  }

  .home-ranking-row,
  .home-setting-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .home-ranking-row strong {
    margin-left: 0;
  }

  .home-record-score {
    width: 100%;
    margin-left: 0;
  }
}

/* 首页棋桌版式：让棋盘直接落在连续草地上，避免后台卡片感。 */
body.dashboard-open {
  background:
    radial-gradient(circle at 12% 16%, rgba(208, 185, 112, 0.14), transparent 24%),
    radial-gradient(circle at 82% 72%, rgba(20, 53, 34, 0.2), transparent 36%),
    #4b684a;
}

body.dashboard-open .site-noise {
  opacity: 0.12;
}

body.dashboard-open .topbar {
  border-bottom-color: rgba(226, 220, 183, 0.18);
  background: rgba(19, 45, 30, 0.74);
  box-shadow: 0 8px 24px rgba(17, 39, 26, 0.12);
}

body.dashboard-open .topbar .brand-lockup strong {
  color: #f3f0df;
}

body.dashboard-open .topbar .brand-lockup div span,
body.dashboard-open .topbar .icon-button,
body.dashboard-open .topbar .text-button {
  color: #bdcbb9;
}

body.dashboard-open .topbar .brand-mark {
  color: #23402e;
  background: #dfc379;
}

body.dashboard-open .topbar .icon-button:hover {
  border-color: rgba(224, 196, 122, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

body.dashboard-open .topbar .user-chip strong {
  color: #f3f0df;
}

body.dashboard-open .topbar .user-chip small {
  color: #e0c47d;
}

body.dashboard-open .topbar .avatar {
  color: #23402e;
  border-color: rgba(239, 220, 157, 0.6);
  background: #dfc379;
}

#dashboardView.lobby-page {
  position: relative;
  z-index: 1;
  width: min(1880px, calc(100% - 44px));
  min-height: calc(100vh - 76px);
  padding: 24px 0 58px;
}

#dashboardView.lobby-page::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(25, 56, 35, 0.16), transparent 30%, rgba(17, 43, 28, 0.18)),
    linear-gradient(180deg, rgba(15, 42, 26, 0.08), transparent 28%, rgba(19, 45, 30, 0.12));
  pointer-events: none;
  content: "";
}

#dashboardView .lobby-layout {
  grid-template-columns: minmax(0, 1fr) clamp(258px, 16vw, 300px);
  gap: clamp(18px, 2vw, 34px);
  align-items: stretch;
}

#dashboardView .lobby-board-card {
  min-width: 0;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#dashboardView .lobby-board-heading {
  align-items: center;
  gap: 18px;
  margin: 0 0 9px;
  padding: 0 2px;
}

#dashboardView .lobby-board-heading h1 {
  color: #f5f1df;
  font-size: clamp(22px, 2.3vw, 32px);
  text-shadow: 0 2px 16px rgba(22, 48, 30, 0.24);
}

#dashboardView .lobby-board-heading .eyebrow {
  margin-bottom: 4px;
  color: #e0c47d;
}

#dashboardView .lobby-board-heading .heading-copy {
  margin-top: 4px;
  color: rgba(239, 241, 222, 0.68);
  font-size: 11px;
}

#dashboardView .lobby-board-badge {
  padding: 7px 10px;
  border-color: rgba(216, 207, 160, 0.25);
  color: #dfe4cb;
  background: rgba(17, 48, 30, 0.42);
  box-shadow: 0 4px 14px rgba(19, 44, 28, 0.12);
}

#dashboardView .lobby-live-dot {
  background: #b9d276;
  box-shadow: 0 0 0 4px rgba(185, 210, 118, 0.13);
}

#dashboardView .lobby-board-workspace {
  display: flex;
  align-items: flex-end;
  gap: clamp(14px, 1.4vw, 22px);
  min-width: 0;
}

#dashboardView .home-board-frame {
  flex: 1 1 min(100%, calc(100vh - 155px));
  width: min(100%, calc(100vh - 155px));
  min-width: 0;
  gap: 5px;
}

#dashboardView .home-board-frame-label {
  min-height: 18px;
  padding: 0 3px;
  color: rgba(237, 240, 220, 0.82);
  font-size: 10px;
  text-shadow: 0 1px 8px rgba(16, 39, 25, 0.35);
}

#dashboardView .home-board-frame-label span:last-child {
  color: rgba(224, 232, 206, 0.58);
}

#dashboardView .home-board-scroller {
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(223, 221, 169, 0.24);
  border-radius: 6px;
  background-color: rgba(26, 57, 36, 0.08);
  box-shadow:
    0 18px 34px rgba(19, 44, 28, 0.27),
    inset 0 0 0 1px rgba(242, 235, 183, 0.08);
  scrollbar-color: #91a76c #294633;
}

#dashboardView .home-board-grid,
#dashboardView .home-board-grid .board-svg {
  width: 100%;
  min-width: 0;
  margin: 0;
}

#dashboardView .home-board-empty {
  min-height: 0;
  height: 100%;
  color: rgba(245, 243, 222, 0.76);
}

#dashboardView .home-board-empty .empty-symbol {
  color: #e0c47d;
}

#dashboardView .formation-tools {
  flex: 0 0 clamp(224px, 16vw, 270px);
  align-self: flex-end;
  min-height: 332px;
  padding: 17px 14px 15px;
  border: 1px solid rgba(222, 204, 140, 0.26);
  border-radius: 7px;
  color: #f2f1df;
  background:
    linear-gradient(180deg, rgba(30, 67, 42, 0.73), rgba(15, 42, 27, 0.83)),
    rgba(16, 44, 28, 0.68);
  box-shadow:
    0 18px 34px rgba(17, 40, 25, 0.22),
    inset 0 0 0 1px rgba(245, 233, 180, 0.05);
  backdrop-filter: blur(4px);
}

#dashboardView .tool-kicker {
  margin-bottom: 6px;
  color: #e0c47d;
}

#dashboardView .formation-tools h2 {
  color: #f3f0df;
  font-size: 21px;
}

#dashboardView .formation-copy {
  margin: 8px 0 14px;
  color: rgba(219, 229, 205, 0.66);
  font-size: 10px;
}

#dashboardView .formation-actions {
  gap: 6px;
}

#dashboardView .formation-action {
  min-height: 48px;
  padding: 6px 7px;
  border-color: rgba(217, 220, 183, 0.16);
  border-radius: 5px;
  color: #eef0dc;
  background: rgba(241, 241, 210, 0.06);
}

#dashboardView .formation-action:hover {
  border-color: rgba(233, 205, 125, 0.62);
  background: rgba(230, 198, 113, 0.14);
}

#dashboardView .formation-action-primary {
  border-color: rgba(230, 198, 113, 0.5);
  background: rgba(213, 174, 83, 0.18);
}

#dashboardView .formation-action-icon {
  border-color: rgba(232, 203, 125, 0.32);
  color: #e4c67d;
}

#dashboardView .formation-action strong {
  color: #f3f0df;
}

#dashboardView .formation-action small {
  color: rgba(214, 226, 202, 0.6);
}

#dashboardView .formation-status {
  padding-top: 12px;
  color: rgba(214, 226, 202, 0.64);
}

#dashboardView .lobby-board-footer {
  margin-top: 8px;
  padding: 0 3px;
  color: rgba(225, 232, 207, 0.62);
}

#dashboardView .footer-key {
  width: 7px;
  height: 7px;
  background: #cf6c5f;
}

#dashboardView .footer-key.muted {
  background: #a8b3a0;
}

#dashboardView .lobby-board-note {
  color: rgba(221, 226, 194, 0.72);
}

#dashboardView .lobby-menu {
  min-height: 100%;
  padding: 20px 13px 13px;
  border: 1px solid rgba(228, 213, 156, 0.18);
  border-radius: 7px;
  background:
    linear-gradient(160deg, rgba(24, 57, 36, 0.96), rgba(10, 31, 20, 0.95)),
    #132c1e;
  box-shadow:
    0 20px 40px rgba(13, 35, 22, 0.25),
    inset 0 0 0 1px rgba(233, 218, 163, 0.04);
}

#dashboardView .lobby-menu-heading {
  padding: 0 7px 13px;
}

#dashboardView .lobby-menu-heading h2 {
  color: #f3f0df;
  font-size: 25px;
}

#dashboardView .lobby-menu-heading p:last-child {
  margin-top: 7px;
  color: rgba(210, 224, 201, 0.63);
  font-size: 10px;
}

#dashboardView .home-menu-list {
  gap: 3px;
}

#dashboardView .home-menu-item {
  grid-template-columns: 30px minmax(0, 1fr) 12px;
  min-height: 51px;
  padding: 6px 7px;
  gap: 8px;
  border-radius: 5px;
}

#dashboardView .home-menu-item:hover {
  border-color: rgba(227, 201, 128, 0.3);
  background: rgba(244, 233, 177, 0.08);
}

#dashboardView .home-menu-item.featured {
  border-color: rgba(226, 194, 112, 0.42);
  background: linear-gradient(100deg, rgba(197, 151, 65, 0.31), rgba(197, 151, 65, 0.1));
}

#dashboardView .home-menu-icon {
  width: 27px;
  height: 27px;
  border-color: rgba(210, 225, 200, 0.18);
  border-radius: 6px;
  color: #dfc17a;
  font-size: 12px;
}

#dashboardView .home-menu-item strong {
  color: #edf0dd;
  font-size: 11px;
}

#dashboardView .home-menu-item small {
  margin-top: 2px;
  color: rgba(194, 214, 193, 0.58);
  font-size: 8px;
}

#dashboardView .home-menu-item b {
  color: rgba(211, 199, 141, 0.65);
  font-size: 14px;
}

#dashboardView .lobby-menu-footer {
  padding: 13px 7px 1px;
  border-top-color: rgba(211, 226, 202, 0.13);
}

#dashboardView .menu-footer-label {
  color: rgba(194, 214, 193, 0.55);
}

#dashboardView .lobby-menu-footer strong {
  color: #e2c47b;
}

#dashboardView .menu-footer-link {
  color: rgba(210, 224, 201, 0.72);
}

#dashboardView .home-content-panel {
  margin-top: 18px;
  padding: 22px;
  border-color: rgba(226, 216, 174, 0.24);
  border-radius: 7px;
  background: rgba(241, 239, 220, 0.94);
  box-shadow: 0 18px 36px rgba(16, 39, 25, 0.18);
}

@media (max-width: 1280px) {
  #dashboardView.lobby-page {
    width: min(100% - 32px, 1400px);
  }

  #dashboardView .lobby-layout {
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 20px;
  }

  #dashboardView .formation-tools {
    flex-basis: 224px;
  }
}

@media (max-width: 900px) {
  #dashboardView.lobby-page {
    min-height: 0;
    padding-top: 20px;
  }

  #dashboardView .lobby-layout {
    grid-template-columns: 1fr;
  }

  #dashboardView .lobby-menu {
    min-height: 0;
  }

  #dashboardView .lobby-board-workspace {
    gap: 12px;
  }

  #dashboardView .home-board-frame {
    flex-basis: min(100%, calc(100vw - 360px));
    width: min(100%, calc(100vw - 360px));
  }
}

@media (max-width: 720px) {
  body.dashboard-open .topbar-inner {
    padding-right: 16px;
    padding-left: 16px;
  }

  #dashboardView.lobby-page {
    width: min(100% - 22px, 680px);
    padding-top: 15px;
  }

  #dashboardView .lobby-board-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  #dashboardView .lobby-board-badge {
    align-self: flex-start;
  }

  #dashboardView .lobby-board-workspace {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
  }

  #dashboardView .home-board-frame {
    width: min(100%, 680px);
    flex-basis: auto;
  }

  #dashboardView .home-board-scroller {
    overflow: hidden;
  }

  #dashboardView .formation-tools {
    width: 100%;
    min-height: 0;
  }

  #dashboardView .formation-actions {
    grid-template-columns: 1fr 1fr;
  }

  #dashboardView .lobby-board-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  #dashboardView .lobby-board-note {
    margin-left: 0;
  }

  #dashboardView .home-content-panel {
    padding: 17px 13px;
  }
}

/* 首页按桌面单屏排布；正式对局不受这些规则影响。 */
body.dashboard-open .topbar { display: none; }
body.dashboard-open { overflow-x: hidden; }
#dashboardView.lobby-page {
  width: min(1880px, calc(100% - 40px));
  height: 100vh;
  min-height: 0;
  padding: 16px 0;
}
#dashboardView .lobby-layout {
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 20vw, 300px);
  gap: clamp(16px, 2vw, 28px);
}
#dashboardView .lobby-board-card,
#dashboardView .lobby-board-workspace {
  height: 100%;
  min-height: 0;
}
#dashboardView .lobby-board-workspace {
  display: flex;
  align-items: center;
  justify-content: center;
}
#dashboardView .home-board-frame {
  display: block;
  /*
   * 这是 flex 容器里的棋盘。旧的 flex-grow 会让棋盘按左栏宽度
   * 横向撑大，再由正方形比例把高度撑出视口，造成首页出现滚动条。
   * 桌面端棋盘必须以视口高度为上限，不能继续占满左栏宽度。
   */
  flex: 0 0 min(100%, calc(100vh - 32px));
  width: min(100%, calc(100vh - 32px));
  aspect-ratio: 1;
  min-width: 0;
}
#dashboardView .home-board-scroller {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: 1;
  overflow: hidden;
}
#dashboardView .home-board-grid,
#dashboardView .home-board-grid .board-svg {
  width: 100%;
  min-width: 0;
  margin: 0;
}
#dashboardView .formation-tools {
  position: absolute;
  z-index: 2;
  right: 3%;
  bottom: 4%;
  width: clamp(132px, 27%, 210px);
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
#dashboardView .formation-actions { display: grid; gap: 6px; }
#dashboardView .formation-action {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 7px 6px;
  border: 1px solid rgba(232, 218, 165, .42);
  border-radius: 4px;
  color: #f3f0df;
  background: rgba(18, 43, 28, .9);
  font-size: 12px;
  text-align: center;
}
#dashboardView .formation-action:hover { background: rgba(44, 76, 48, .96); }
#dashboardView .formation-action-primary { background: rgba(91, 76, 36, .94); }
#dashboardView .formation-status { display: none !important; }
#dashboardView .lobby-menu {
  height: 100%;
  min-height: 0;
  padding: 24px 18px 16px;
}
#dashboardView .lobby-menu-heading { padding: 0 4px; }
#dashboardView .lobby-menu-heading h2 { color: #f3f0df; font-size: 25px; }
#dashboardView .home-match-actions { display: grid; gap: 14px; margin-top: 20px; }
#dashboardView .home-match-button {
  min-height: clamp(108px, 17vh, 145px);
  border: 1px solid rgba(228, 213, 156, .35);
  border-radius: 6px;
  color: #f3f0df;
  background: rgba(236, 236, 208, .08);
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 700;
}
#dashboardView .home-match-button:hover { background: rgba(236, 236, 208, .15); }
#dashboardView .home-match-button.featured {
  border-color: rgba(226, 194, 112, .7);
  color: #fff1c8;
  background: linear-gradient(120deg, rgba(197, 151, 65, .35), rgba(197, 151, 65, .12));
}
#dashboardView .home-utility-list {
  display: grid;
  gap: 0;
  margin-top: auto;
  border-top: 1px solid rgba(211, 226, 202, .18);
}
#dashboardView .home-utility-item {
  min-height: 54px;
  padding: 0 8px;
  border-bottom: 1px solid rgba(211, 226, 202, .13);
  color: #edf0dd;
  background: transparent;
  text-align: left;
}
#dashboardView .home-utility-item:hover { color: #e2c47b; background: rgba(244, 233, 177, .06); }
#dashboardView .home-content-panel { margin-top: 18px; }

@media (max-width: 900px) {
  #dashboardView.lobby-page {
    width: min(100% - 24px, 680px);
    height: auto;
    min-height: 100vh;
    padding: 12px 0 20px;
  }
  #dashboardView .lobby-layout { height: auto; grid-template-columns: 1fr; }
  #dashboardView .lobby-board-card,
  #dashboardView .lobby-board-workspace { height: auto; }
  #dashboardView .home-board-frame {
    flex: 0 0 auto;
    width: min(100%, calc(100vw - 24px));
    height: auto;
    aspect-ratio: 1;
  }
  #dashboardView .home-board-scroller { height: 100%; }
  #dashboardView .lobby-menu { height: auto; min-height: 430px; }
  #dashboardView .home-match-button { min-height: 104px; }
}

/* 右侧三个固定功能分区：首页对阵列表继续由现有 renderGames 填充。 */
#dashboardView .home-utility-list {
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  min-height: 0;
}
#dashboardView .home-utility-section {
  min-width: 0;
}
#dashboardView .home-utility-item {
  display: block;
  width: 100%;
  min-height: 36px;
  border: 0;
  border-bottom: 1px solid rgba(211, 226, 202, .13);
  font-weight: 700;
}
#dashboardView .home-utility-slot {
  box-sizing: border-box;
  height: 48px;
  overflow: hidden;
  border-bottom: 1px solid rgba(211, 226, 202, .13);
  background: rgba(8, 27, 17, .16);
}
#dashboardView .home-current-games-slot {
  height: 104px;
  overflow: auto;
}
#dashboardView .home-sidebar-games {
  gap: 5px;
  padding: 5px;
}
#dashboardView .home-sidebar-games .game-card {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 6px;
  min-height: 0;
  padding: 6px 7px;
  border-color: rgba(211, 226, 202, .16);
  border-radius: 4px;
  background: rgba(241, 241, 210, .06);
}
#dashboardView .home-sidebar-games .game-card-main {
  min-width: 0;
}
#dashboardView .home-sidebar-games .game-card-seats {
  display: none;
}
#dashboardView .home-sidebar-games .game-card-title {
  gap: 5px;
  margin-bottom: 3px;
}
#dashboardView .home-sidebar-games .game-card-title strong {
  color: #edf0dd;
  font-size: 10px;
}
#dashboardView .home-sidebar-games .status-badge {
  min-height: 16px;
  padding: 0 5px;
  font-size: 8px;
}
#dashboardView .home-sidebar-games .game-card-meta {
  display: block;
  overflow: hidden;
  color: rgba(194, 214, 193, .68);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#dashboardView .home-sidebar-games .game-card-meta span + span {
  display: none;
}
#dashboardView .home-sidebar-games .card-turn {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#dashboardView .home-sidebar-games .game-card-side {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  gap: 3px;
}
#dashboardView .home-sidebar-games .deadline-mini {
  max-width: 72px;
  color: rgba(194, 214, 193, .65);
  font-size: 8px;
  text-align: right;
  white-space: normal;
}
#dashboardView .home-sidebar-games .game-card-side .quiet-button {
  padding: 2px 4px;
  color: #e2c47b;
  font-size: 8px;
}
#dashboardView .home-sidebar-games .empty-list {
  min-height: 0;
  height: 100%;
  padding: 5px;
  border: 0;
  color: rgba(194, 214, 193, .66);
  font-size: 9px;
}
#dashboardView .home-sidebar-games .empty-list .empty-symbol {
  display: none;
}
#dashboardView .home-sidebar-games .empty-list p {
  line-height: 1.45;
}

@media (max-width: 900px) {
  #dashboardView .home-utility-list {
    margin-top: 20px;
    overflow: visible;
  }
  #dashboardView .home-current-games-slot {
    height: 104px;
  }
}

/* 首页最终视觉收口：草地棋盘成为页面底图，桌面端保持一屏。 */
body.dashboard-open {
  --dashboard-table-surface: url("/assets/board/table-surround%2Esvg");
  overflow: hidden;
  background:
    var(--dashboard-table-surface) center / cover fixed no-repeat;
  background-color: #4b684a;
}

body.dashboard-open .site-noise {
  opacity: 0.06;
}

#dashboardView.lobby-page {
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
}

#dashboardView.lobby-page::before {
  display: none;
}

#dashboardView .lobby-board-card {
  background: transparent;
}

#dashboardView .home-board-frame {
  max-height: 100%;
}

#dashboardView .home-board-scroller {
  background: var(--dashboard-table-surface) center / cover no-repeat;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#dashboardView .home-file-input {
  display: none !important;
}

#dashboardView .lobby-menu {
  background:
    linear-gradient(160deg, rgba(24, 57, 36, 0.86), rgba(10, 31, 20, 0.9)),
    rgba(19, 44, 30, 0.84);
  box-shadow: 0 16px 34px rgba(13, 35, 22, 0.2);
  backdrop-filter: blur(7px);
}

#dashboardView .home-match-actions {
  gap: 10px;
  margin-top: 0;
}

#dashboardView .home-match-button {
  min-height: clamp(56px, 8vh, 78px);
  padding: 10px 12px;
  font-size: clamp(20px, 1.75vw, 28px);
  line-height: 1.1;
}

#dashboardView .home-utility-list {
  flex: 1 1 auto;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  margin-top: 16px;
  border-top: 0;
}

#dashboardView .home-utility-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#dashboardView .home-utility-item {
  flex: 0 0 36px;
  min-height: 36px;
  border-top: 1px solid rgba(211, 226, 202, 0.13);
  border-bottom: 0;
}

#dashboardView .home-utility-slot {
  flex: 1 1 auto;
  height: auto;
  min-height: 48px;
}

#dashboardView .home-current-games-slot {
  height: auto;
  overflow: auto;
}

@media (max-width: 900px) {
  body.dashboard-open {
    overflow-x: hidden;
    overflow-y: auto;
    background-attachment: scroll;
  }

  #dashboardView.lobby-page {
    height: auto;
    max-height: none;
    min-height: 100vh;
    overflow: visible;
  }

  #dashboardView .home-utility-list {
    flex: initial;
    grid-template-rows: none;
  }

  #dashboardView .home-utility-section {
    display: block;
  }

  #dashboardView .home-utility-item {
    display: block;
  }

  #dashboardView .home-utility-slot,
  #dashboardView .home-current-games-slot {
    height: 104px;
  }
}

/*
 * 窄桌面 / 浏览器内嵌窗口仍然保留“左棋盘、右菜单”。
 * 900px 以下的旧规则会把首页整体改成上下堆叠；在 721—900px
 * 的可用宽度里，缩小棋盘和侧栏更符合正式首页的一屏布局。
 * 720px 以下才切换为真正的手机纵向布局。
 */
@media (min-width: 721px) and (max-width: 900px) {
  body.dashboard-open {
    overflow: hidden;
    background-attachment: scroll;
  }

  #dashboardView.lobby-page {
    width: calc(100% - 24px);
    height: 100vh;
    max-height: 100vh;
    min-height: 0;
    padding: 12px 0;
    overflow: hidden;
  }

  #dashboardView .lobby-layout {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) clamp(220px, 30vw, 250px);
    gap: 12px;
  }

  #dashboardView .lobby-board-card,
  #dashboardView .lobby-board-workspace {
    height: 100%;
    min-height: 0;
  }

  #dashboardView .lobby-board-workspace {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  #dashboardView .home-board-frame {
    flex: 0 0 min(100%, calc(100vh - 24px));
    width: min(100%, calc(100vh - 24px));
    height: auto;
    aspect-ratio: 1;
  }

  #dashboardView .home-board-scroller {
    height: 100%;
    min-height: 0;
  }

  #dashboardView .lobby-menu {
    height: 100%;
    min-height: 0;
    padding: 12px 10px;
  }

  #dashboardView .home-match-actions {
    gap: 8px;
  }

  #dashboardView .home-match-button {
    min-height: 52px;
    padding: 8px;
    font-size: clamp(16px, 2.2vw, 22px);
  }

  #dashboardView .home-utility-list {
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 10px;
  }

  #dashboardView .home-utility-item {
    flex-basis: 30px;
    min-height: 30px;
    font-size: 13px;
  }

  #dashboardView .home-utility-slot,
  #dashboardView .home-current-games-slot {
    min-height: 34px;
  }
}

/* 棋盘线稿是透明叠层，页面底图统一由 body 承载，避免出现一块不同裁切的背景矩形。 */
#dashboardView .home-board-scroller {
  background: transparent;
}

/*
 * 首页最后一轮比例调整：
 * 桌面端利用掉上下留白，再裁掉棋盘线稿自身的透明外圈，让实际棋盘
 * 更接近可用画面的边缘；右侧菜单同时留出更宽的文字和列表区域。
 * 只放大绘图层，不改变棋位坐标或点击区域的逻辑。
 */
@media (min-width: 901px) {
  #dashboardView.lobby-page {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  #dashboardView .lobby-layout {
    grid-template-columns: minmax(0, 1fr) clamp(300px, 22vw, 380px);
    gap: clamp(18px, 2vw, 32px);
  }

  #dashboardView .home-board-frame {
    flex-basis: min(100%, calc(100vh - 16px));
    width: min(100%, calc(100vh - 16px));
  }

  #dashboardView .home-board-grid {
    transform: scale(1.08);
    transform-origin: center;
  }

  #dashboardView .formation-tools {
    width: clamp(150px, 29%, 240px);
    right: 2.5%;
    bottom: 3%;
  }
}

@media (min-width: 721px) and (max-width: 900px) {
  #dashboardView .lobby-layout {
    grid-template-columns: minmax(0, 1fr) clamp(240px, 31vw, 290px);
  }

  #dashboardView .home-board-grid {
    transform: scale(1.05);
    transform-origin: center;
  }

  #dashboardView .formation-tools {
    width: clamp(145px, 29%, 220px);
  }
}

/* 正式棋局：棋盘独占主区，所有信息和操作收在右侧栏。 */
body.game-open {
  overflow: hidden;
  background: #4b684a url("/assets/board/table-surround.svg") center / cover fixed no-repeat;
}

body.game-open .topbar {
  display: none;
}

body.game-open .site-noise {
  opacity: 0.06;
}

#gameView {
  --sidebar-width: 312px;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#gameView .game-layout {
  grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
  align-items: stretch;
  gap: 0;
  height: 100%;
}

#gameView.sidebar-collapsed .game-layout {
  grid-template-columns: minmax(0, 1fr) 0;
}

#gameView .board-stage {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 8px;
  overflow: hidden;
}

#gameView .board-scroller {
  position: relative;
  width: min(100%, calc(100dvh - 16px));
  height: auto;
  max-height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#gameView .game-seat-statuses {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

#gameView .game-seat-status {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(38%, 230px);
  padding: 7px 11px;
  overflow: hidden;
  color: #f4f1dd;
  border: 1px solid rgba(245, 239, 199, .38);
  border-radius: 999px;
  background: rgba(24, 46, 32, .86);
  box-shadow: 0 3px 12px rgba(20, 35, 20, .22);
  font-size: clamp(10px, 1.05vw, 14px);
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#gameView .game-seat-status::before {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #e3d8a6;
  content: "";
}

#gameView .game-seat-status[data-state="preparing"]::before {
  background: #efbb5c;
}

#gameView .game-seat-status[data-state="ready"]::before {
  background: #82d3a0;
}

#gameView .game-seat-status.seat-top {
  top: 1.5%;
  left: 50%;
  transform: translateX(-50%);
}

#gameView .game-seat-status.seat-right {
  top: 50%;
  right: 1.2%;
  transform: translateY(-50%);
}

#gameView .game-seat-status.seat-bottom {
  bottom: 1.5%;
  left: 1.2%;
}

#gameView .game-seat-status.seat-left {
  top: 50%;
  left: 1.2%;
  transform: translateY(-50%);
}

#gameView .game-formation-tools {
  position: absolute;
  z-index: 4;
  right: 3%;
  bottom: 3%;
  display: grid;
  width: min(190px, 31%);
  gap: 7px;
  padding: 9px;
  border: 1px solid rgba(232, 229, 189, .38);
  border-radius: 10px;
  background: rgba(26, 48, 33, .84);
  box-shadow: 0 5px 20px rgba(20, 35, 20, .24);
}

#gameView .game-formation-button {
  min-height: 34px;
  padding: 6px 9px;
  color: #f2f0dc;
  border: 1px solid rgba(221, 228, 196, .28);
  border-radius: 6px;
  background: rgba(228, 235, 205, .1);
  font-size: clamp(10px, 1vw, 13px);
  line-height: 1.25;
  white-space: nowrap;
}

#gameView .game-formation-button:hover:not(:disabled) {
  background: rgba(228, 235, 205, .2);
}

#gameView .game-ready-button {
  color: #fff3ce;
  border-color: rgba(235, 202, 116, .58);
  background: rgba(112, 83, 35, .78);
}

#gameView .game-ready-button:hover:not(:disabled) {
  background: rgba(139, 103, 42, .9);
}

#gameView .game-formation-button:disabled {
  cursor: default;
  opacity: .58;
}

#gameView .board-grid {
  width: 100%;
  max-width: none;
  margin: 0;
  transform: scale(1.08);
  transform-origin: center;
}

#gameView .board-scroller.zoomed {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  overflow: auto;
  overscroll-behavior: contain;
}

#gameView .board-scroller.zoomed .board-grid {
  width: max(100%, 1050px);
  transform: none;
}

#gameView .game-sidebar {
  --ink: #f0f2e9;
  --ink-soft: #d4dfd2;
  --ink-faint: #aabbac;
  --line: rgba(219, 232, 211, 0.16);
  --line-strong: rgba(219, 232, 211, 0.3);
  --gold: #dfc47d;
  --green: #b6d890;
  --red: #e18a82;
  display: block;
  position: relative;
  z-index: 5;
  min-width: 0;
  width: var(--sidebar-width);
  height: 100%;
  padding: 20px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #67826b transparent;
  color: var(--ink);
  border-left: 1px solid var(--line);
  background: rgba(19, 42, 29, 0.96);
}

#gameView.sidebar-collapsed .game-sidebar {
  visibility: hidden;
  pointer-events: none;
}

#gameView .game-sidebar-toggle {
  position: absolute;
  z-index: 6;
  top: 18px;
  right: var(--sidebar-width);
  display: grid;
  place-items: center;
  width: 28px;
  height: 46px;
  padding: 0;
  color: #edf1e6;
  border: 1px solid rgba(219, 232, 211, 0.24);
  border-right: 0;
  border-radius: 6px 0 0 6px;
  background: #213e2b;
  font-size: 28px;
  line-height: 1;
}

#gameView .game-sidebar-toggle:hover {
  background: #34563b;
}

#gameView :focus-visible {
  outline: 2px solid #f1d389;
  outline-offset: 3px;
}

#gameView.sidebar-collapsed .game-sidebar-toggle {
  right: 0;
}

#gameView.sidebar-collapsed .game-sidebar-toggle span {
  transform: rotate(180deg);
}

#gameView .game-heading {
  display: block;
  margin: 0;
}

#gameView .game-sidebar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}

#gameView .game-title-line {
  justify-content: space-between;
}

#gameView .eyebrow {
  color: var(--gold);
  letter-spacing: 0;
}

#gameView .game-heading h1 {
  margin-top: 10px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

#gameView .heading-copy {
  margin-top: 6px;
  font-size: 11px;
}

#gameView .status-badge {
  flex-shrink: 0;
  color: #e0e9d5;
  background: #3b5740;
  letter-spacing: 0;
}

#gameView .status-badge.finished {
  color: #ffb9aa;
  background: #583c35;
}

#gameView .status-badge.grace {
  color: #f3d58b;
  background: #51472c;
}

#gameView .game-sidebar-section {
  margin-top: 16px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
}

#gameView .panel-heading.compact {
  gap: 8px;
  margin-bottom: 10px;
}

#gameView h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

#gameView .turn-notice {
  align-items: baseline;
  font-size: 12px;
  line-height: 1.6;
}

#gameView .turn-dot {
  flex: 0 0 7px;
}

#gameView .deadline-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  margin-top: 12px;
  padding: 0;
  border: 0;
}

#gameView .deadline-box strong {
  font-size: 18px;
}

#gameView .game-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

#gameView .button,
#gameView .back-button {
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: rgba(216, 231, 205, 0.06);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0;
}

#gameView .button:hover,
#gameView .back-button:hover {
  background: rgba(216, 231, 205, 0.14);
}

#gameView .button-danger {
  color: #ffb5a8;
  border-color: rgba(238, 153, 141, 0.36);
}

#gameView .button-primary {
  color: #f1dfa6;
  border-color: rgba(223, 196, 125, 0.4);
}

#gameView .quiet-button,
#gameView .text-button {
  min-height: 30px;
  color: var(--ink-soft);
}

#gameView .seat-strip {
  grid-template-columns: 1fr;
  gap: 4px;
  width: 100%;
  margin: 0 0 10px;
}

#gameView .player-seat {
  min-width: 0;
  min-height: 44px;
  padding: 7px 8px;
  border-color: transparent;
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
}

#gameView .player-seat.is-turn {
  border-color: rgba(223, 196, 125, 0.5);
  background: rgba(223, 196, 125, 0.07);
}

#gameView .player-seat.is-me:not(.is-turn) {
  background: rgba(216, 231, 205, 0.06);
}

#gameView .player-seat strong,
#gameView .player-seat small {
  max-width: 220px;
}

#gameView .board-legend {
  gap: 16px;
}

#gameView .empty-selection {
  min-height: 0;
  border: 0;
  text-align: left;
}

#gameView .empty-selection .empty-symbol {
  display: none;
}

#gameView .mark-input-label textarea {
  min-height: 64px;
  border-color: var(--line-strong);
  color: var(--ink);
  background: rgba(0, 0, 0, 0.12);
}

#gameView .mark-input-label textarea::placeholder {
  color: var(--ink-faint);
}

#gameView .selected-piece-head {
  margin-bottom: 10px;
}

#gameView .move-log {
  max-height: 180px;
}

#gameView .move-log .empty-selection {
  padding: 10px 0 0;
}

#gameView .board-controls {
  width: 100%;
  margin: 0;
}

#gameView .game-board-help {
  margin-top: 6px;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.7;
}

#gameView .game-board-help summary {
  cursor: pointer;
}

#gameView .game-board-help p {
  margin: 8px 0 0;
}

#gameView .notice-banner {
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 5px;
  border-color: rgba(223, 196, 125, 0.45);
  background: rgba(223, 196, 125, 0.1);
}

#gameView .notice-banner > div {
  flex-basis: 100%;
}

body.game-open .toast-region {
  top: auto;
  bottom: 16px;
  right: 16px;
  width: min(280px, calc(100vw - 32px));
}

@media (min-width: 1600px) {
  #gameView {
    --sidebar-width: 340px;
  }
}

@media (max-width: 1000px) {
  #gameView {
    --sidebar-width: 280px;
  }

  #gameView .game-sidebar {
    padding: 16px;
  }
}

@media (max-width: 720px) {
  #gameView {
    --sidebar-width: min(312px, calc(100vw - 48px));
  }

  #gameView .game-layout,
  #gameView.sidebar-collapsed .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  #gameView .game-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
  }

  #gameView .game-formation-tools {
    right: 2%;
    bottom: 2%;
    width: min(160px, 38%);
    gap: 5px;
    padding: 6px;
  }

  #gameView .game-formation-button {
    min-height: 30px;
    padding: 5px 6px;
  }

  #gameView .game-seat-status {
    max-width: 34%;
    padding: 5px 7px;
  }
}
