:root {
  color-scheme: light;
  --paper: #f6f3eb;
  --ink: #252b27;
  --soft: #625f55;
  --line: #d6d0c2;
  --red: #963e31;
  --blue: #294854;
  --gold: #a27b48;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #eeeae0;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 12% 12%, #faf8f1, transparent 68%), var(--paper);
}
button,
input {
  font: inherit;
}
button,
a,
summary {
  touch-action: manipulation;
}
button,
summary {
  cursor: pointer;
}
button {
  color: inherit;
  background: #faf8f2;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 13px;
}
button:hover:not(:disabled) {
  border-color: #9c7951;
  background: #f2ebdf;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid #b68533;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
header {
  height: 58px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(5vw, 18px);
  position: relative;
}
header a,
.rule {
  font-size: 13px;
  color: var(--soft);
  text-decoration: none;
}
.brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 12px;
  font:
    600 12px Georgia,
    serif;
  letter-spacing: 2px;
}
.brand i {
  height: 12px;
  border-left: 1px solid #a69d87;
}
main {
  max-width: 1030px;
  margin: auto;
  display: grid;
  grid-template-columns: minmax(300px, 1.18fr) minmax(300px, 0.9fr);
  align-items: start;
  gap: clamp(32px, 5vw, 85px);
  padding: 26px 30px 32px;
}
.desk {
  max-width: 480px;
  width: 100%;
  margin: auto;
}
.player {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 39px;
  font-size: 13px;
}
.player small {
  margin-left: auto;
  color: var(--soft);
}
.seal {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff3d9;
}
.seal.red {
  background: var(--red);
}
.frame {
  padding: clamp(9px, 1.2vw, 16px);
  border-radius: 10px;
  background: repeating-linear-gradient(
    3deg,
    #49382e 0,
    #533e30 3px,
    #594332 6px,
    #47352a 9px
  );
  box-shadow:
    inset 0 0 0 2px #553e31,
    inset 0 0 0 4px #725b44,
    0 7px 0 -3px #392d25,
    0 16px 28px -13px #48392866;
}
#board {
  position: relative;
  aspect-ratio: 5/6.9;
  background: linear-gradient(115deg, #f0e5ca, #e5d3ae 65%, #e9d9bb);
  box-shadow:
    0 0 0 1px #30281b,
    inset 0 0 18px #8a693b40;
  isolation: isolate;
  border-radius: 2px;
}
.tracks {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.cell {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 17%;
  height: 6.9%;
  background: transparent;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
}
.cell:hover:not(:disabled) {
  background: #fffa;
  border-radius: 5px;
}
.piece {
  display: grid;
  place-items: center;
  width: 86%;
  height: 85%;
  border-radius: 4px;
  font:
    700 clamp(13px, 1.7vw, 21px) / 1 "Songti SC",
    STSong,
    "Noto Serif CJK SC",
    serif;
  letter-spacing: 0.08em;
  color: #8d3024;
  background: linear-gradient(150deg, #fff4d6, #e8d2a7);
  box-shadow:
    0 2px 0 #9c7953,
    0 3px 4px #523d3350,
    inset 0 0 0 1px #a48a63,
    inset 0 0 0 3px #f1dfbb,
    inset 0 0 0 4px #be9780;
}
.piece.blue {
  color: #244951;
  box-shadow:
    0 2px 0 #92714d,
    0 3px 4px #523d3350,
    inset 0 0 0 1px #958568,
    inset 0 0 0 4px #eedfbc,
    inset 0 0 0 5px #8f9a8c;
}
.piece.back {
  font:
    normal clamp(14px, 2vw, 23px) Georgia,
    serif;
  color: #eddbb4;
  background: repeating-linear-gradient(45deg, #79382e 0 3px, #824036 3px 5px);
  box-shadow:
    0 2px 0 #57372b,
    inset 0 0 0 1px #743b30,
    inset 0 0 0 3px #8a4938,
    inset 0 0 0 4px #c19668;
}
.piece.back.blue,
.piece.back.neutral {
  background: repeating-linear-gradient(45deg, #364e53 0 3px, #3e5659 3px 5px);
  box-shadow:
    0 2px 0 #373e38,
    inset 0 0 0 1px #425857,
    inset 0 0 0 4px #415355,
    inset 0 0 0 5px #b1a783;
}
.piece.back.neutral {
  filter: sepia(0.6);
}
.site {
  font:
    11px "Songti SC",
    serif;
  color: #786c54;
  background: #eadbbb;
  padding: 1px 3px;
  border: 1px solid #9e9276;
}
.site.camp {
  border-radius: 50%;
  padding: 3px 6px;
}
.site.base {
  border: 3px double #998563;
}
.cell.selected .piece {
  outline: 3px solid #b5862e;
  transform: translateY(-3px);
}
.cell.legal:after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px solid #497565;
  background: #e4e8c9bb;
  border-radius: 50%;
}
.cell.attack:after {
  width: 94%;
  height: 98%;
  border: 2px dashed #a54432;
  border-radius: 6px;
  background: none;
}
.cell.last:before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 42%;
  height: 2px;
  background: #a04e35;
}
.cell.recent .piece {
  animation: settle 0.28s ease-out;
}
@keyframes settle {
  from {
    transform: translateY(-5px);
    opacity: 0.65;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
aside {
  padding-top: 22px;
}
.heading {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
}
.emblem {
  border: 3px double #9a4639;
  border-radius: 3px;
  color: #9a4639;
  font:
    700 18px/1.05 "Songti SC",
    serif;
  padding: 5px 3px;
  transform: rotate(-3deg);
}
h1 {
  font:
    700 53px/1.15 "Songti SC",
    STSong,
    serif;
  letter-spacing: 0.1em;
  margin: 0;
}
.subtitle {
  font-size: 12px;
  letter-spacing: 0.24em;
  color: var(--soft);
}
.rule {
  margin-left: auto;
  background: transparent;
  border: 0;
  padding: 8px 0;
}
.panel {
  border-top: 1px solid var(--line);
  padding: 17px 0;
}
h2,
summary {
  font-size: 16px;
  font-weight: 650;
  margin: 0 0 12px;
}
.panel p,
dialog p {
  font-size: 14px;
  color: var(--soft);
  line-height: 1.75;
  margin: 8px 0 14px;
}
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.modes button {
  text-align: left;
  padding: 13px;
  font-weight: 650;
}
.modes small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--soft);
  margin-top: 5px;
}
.modes .active {
  border-color: #8f5342;
  background: #f5e9db;
  box-shadow: inset 0 -2px #96513a;
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}
.row button {
  font-size: 13px;
}
.major {
  background: #293e39 !important;
  border-color: #293e39;
  color: #fff7e5;
}
.launch {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
  margin-top: 17px;
}
.launch button {
  padding: 12px 6px;
}
.link {
  font-size: 13px;
  border: 0;
  background: transparent;
  padding: 9px 0;
  color: var(--red);
}
.muted,
summary span {
  font: 12px sans-serif;
  color: var(--soft);
}
summary span {
  float: right;
}
summary {
  margin: 0;
}
#logs {
  max-height: 210px;
  overflow: auto;
  padding-left: 33px;
  font-size: 13px;
  line-height: 1.85;
  color: var(--soft);
}
#logs:empty:after {
  content: "开局后记录每一步。";
}
#logs li::marker {
  color: #988a71;
}
#notice {
  margin-bottom: 0;
}
.bubble {
  background: #e7eade;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
}
.flagline {
  background: #ebe4d4;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}
.request {
  padding: 10px;
  border-left: 3px solid var(--gold);
  background: #eee8da;
  margin: 10px 0;
}
.roomcode {
  font:
    600 18px ui-monospace,
    monospace;
  letter-spacing: 0.13em;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  padding: 24px;
  width: min(400px, 92vw);
  max-height: 85vh;
}
dialog::backdrop {
  background: #24282170;
}
input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  margin: 5px 0 10px;
}
@media (min-width: 1100px) and (max-height: 850px) {
  .desk {
    max-width: 415px;
  }
  main {
    max-width: 960px;
    padding-top: 14px;
  }
}
@media (max-width: 720px) {
  header {
    height: 46px;
  }
  .brand {
    font-size: 10px;
    gap: 6px;
  }
  main {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 8px 12px 24px;
  }
  .desk {
    order: 1;
    max-width: 410px;
  }
  aside {
    display: contents;
  }
  .heading,
  #controls,
  #feedback,
  #ledger {
    width: 100%;
    max-width: 410px;
    margin: auto;
  }
  .heading {
    order: 0;
    padding: 5px 0 8px;
    gap: 9px;
  }
  h1 {
    font-size: 25px;
  }
  .heading > div:nth-child(2) {
    display: flex;
    align-items: baseline;
    gap: 8px;
  }
  .emblem {
    font-size: 10px;
    padding: 2px;
  }
  .subtitle {
    font-size: 10px;
  }
  .player {
    height: 30px;
  }
  .piece {
    font-size: clamp(13px, 4vw, 18px);
  }
  #board {
    aspect-ratio: 5/6.1;
  }
  #controls {
    order: 3;
  }
  #feedback {
    order: 2;
    padding: 9px 0;
  }
  #feedback h2 {
    display: none;
  }
  #notice {
    margin: 0;
  }
  #ledger {
    order: 4;
  }
  .panel {
    padding: 12px 0;
  }
  .rule {
    font-size: 12px;
  }
  .frame {
    padding: 9px;
  }
  .desk .player:last-child {
    margin: 4px 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}
