:root {
  color-scheme: dark;
  --bg: #171713;
  --panel: #25241d;
  --panel-2: #302d22;
  --line: #605944;
  --track: #8f8260;
  --camp: #3e6f5a;
  --hq: #7b5f2a;
  --text: #f4ecd6;
  --muted: #b6aa8d;
  --red: #bd3d32;
  --blue: #2f68a8;
  --gold: #d7b66a;
  --ok: #54ad7f;
  --bad: #d65b52;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.02) 1px, transparent 1px),
    radial-gradient(circle at 15% 10%, rgba(215, 182, 106, .14), transparent 30rem),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto, auto;
  color: var(--text);
  font-family: "Songti SC", "Noto Serif SC", Georgia, serif;
}

button, input {
  font: inherit;
}

button {
  border: 1px solid #7c7258;
  background: #363224;
  color: var(--text);
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: var(--gold);
}

button.primary {
  background: #8f342d;
  border-color: #d87b63;
}

button.toggle.on {
  background: #7c632c;
  border-color: #f0cf78;
  color: #fff3c5;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 0 14px rgba(215, 182, 106, .2);
}

button.toggle.off {
  background: #23221c;
  border-color: #4a4437;
  color: #817967;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.mode-switch button {
  min-height: 34px;
  padding: 0 10px;
  background: #242219;
  color: var(--muted);
}

.mode-switch button.on {
  background: #705a2c;
  border-color: #e3c071;
  color: #fff0bd;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

input {
  width: 100%;
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid #6b624a;
  background: #15140f;
  color: var(--text);
  padding: 0 12px;
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 420px);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.table {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar, .panel {
  border: 1px solid rgba(215, 182, 106, .32);
  background: rgba(37, 36, 29, .92);
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 14px;
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.brand span, .subtle {
  color: var(--muted);
  font-size: 14px;
}

.board-wrap {
  position: relative;
  display: grid;
  place-items: start center;
  flex: 1;
  min-height: 0;
  padding: 8px 0 0;
}

.watch-panel {
  margin-top: 8px;
  padding: 12px;
}

.watch-head, .watch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.watch-head > div, .watch-row > div:last-child {
  display: flex;
  gap: 8px;
}

.watch-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.watch-row {
  border: 1px solid rgba(215, 182, 106, .22);
  background: rgba(21, 20, 15, .45);
  border-radius: 6px;
  padding: 8px;
}

.watch-row > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.watch-row span, .watch-row small {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.join-offer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 12px;
}

.join-offer > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.join-offer span {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.join-offer > div:last-child {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.quick-chat {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-chat-btn {
  flex: 1 1 96px;
  min-height: 30px;
  padding: 6px 8px;
  border-color: rgba(215, 182, 106, .28);
  background: rgba(36, 31, 20, .66);
  color: #f2dfac;
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

.quick-chat-btn:hover {
  border-color: rgba(248, 217, 135, .56);
  background: rgba(72, 51, 28, .82);
}

.victory-layer {
  position: absolute;
  inset: 8px 0 0;
  z-index: 30;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.victory-panel {
  position: relative;
  --victory-a: rgba(52, 32, 22, .96);
  --victory-b: rgba(102, 35, 28, .94);
  --victory-c: rgba(42, 50, 34, .95);
  --victory-border: rgba(255, 232, 160, .86);
  --victory-kicker: #f8d987;
  --victory-small: #f7cbb6;
  --victory-petal-a: #ffd9df;
  --victory-petal-b: #d55d77;
  --victory-robe-a: #e8b6ba;
  --victory-robe-b: #8f342d;
  --victory-robe-c: #482018;
  min-width: min(82vw, 440px);
  padding: 28px 54px 32px;
  overflow: hidden;
  border: 1px solid var(--victory-border);
  border-radius: 8px;
  background:
    linear-gradient(145deg, var(--victory-a), var(--victory-b) 52%, var(--victory-c));
  box-shadow: 0 28px 80px rgba(0,0,0,.58), inset 0 0 0 1px rgba(255,255,255,.14);
  text-align: center;
  pointer-events: auto;
}

.victory-red .victory-panel,
.victory-ns .victory-panel {
  --victory-a: rgba(76, 30, 24, .97);
  --victory-b: rgba(154, 48, 38, .95);
  --victory-c: rgba(100, 65, 26, .95);
  --victory-border: rgba(255, 210, 126, .9);
  --victory-kicker: #ffe08c;
  --victory-small: #ffd1bc;
  --victory-petal-a: #ffe0e0;
  --victory-petal-b: #dd5a49;
  --victory-robe-a: #f0c0ba;
  --victory-robe-b: #bd3d32;
  --victory-robe-c: #64201b;
}

.victory-blue .victory-panel {
  --victory-a: rgba(22, 40, 67, .97);
  --victory-b: rgba(38, 91, 143, .95);
  --victory-c: rgba(27, 55, 78, .95);
  --victory-border: rgba(169, 214, 255, .9);
  --victory-kicker: #cce9ff;
  --victory-small: #c0dcff;
  --victory-petal-a: #d8efff;
  --victory-petal-b: #4f94d8;
  --victory-robe-a: #b6d8f7;
  --victory-robe-b: #2f68a8;
  --victory-robe-c: #173758;
}

.victory-ew .victory-panel {
  --victory-a: rgba(25, 64, 48, .97);
  --victory-b: rgba(45, 120, 78, .95);
  --victory-c: rgba(28, 66, 98, .95);
  --victory-border: rgba(178, 239, 199, .88);
  --victory-kicker: #c9f4d6;
  --victory-small: #c6e7ff;
  --victory-petal-a: #d6ffe5;
  --victory-petal-b: #4fae78;
  --victory-robe-a: #c0eccf;
  --victory-robe-b: #2f8a5a;
  --victory-robe-c: #143b30;
}

.victory-kicker {
  display: block;
  color: var(--victory-kicker);
  font-size: 13px;
  letter-spacing: .18em;
  margin-bottom: 8px;
}

.victory-panel b {
  display: block;
  color: #fff7d6;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: .08em;
  text-shadow: 0 3px 12px rgba(0,0,0,.42);
}

.victory-panel small {
  display: block;
  margin-top: 10px;
  color: var(--victory-small);
  font-size: 15px;
  letter-spacing: .24em;
}

.victory-actions {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.victory-actions button {
  flex: 0 0 auto;
  min-width: 104px;
}

.beauty {
  position: absolute;
  bottom: -7px;
  width: 42px;
  height: 96px;
  opacity: .68;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.36));
}

.beauty::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f0d1aa;
}

.beauty::after {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 0;
  width: 38px;
  height: 74px;
  border-radius: 30px 30px 8px 8px;
  background: linear-gradient(160deg, var(--victory-robe-a), var(--victory-robe-b) 56%, var(--victory-robe-c));
  clip-path: polygon(50% 0, 88% 28%, 100% 100%, 0 100%, 12% 28%);
}

.beauty-left { left: 16px; transform: rotate(-8deg); }
.beauty-right { right: 16px; transform: scaleX(-1) rotate(-8deg); }

.petal {
  position: absolute;
  width: 9px;
  height: 14px;
  border-radius: 9px 9px 9px 1px;
  background: linear-gradient(145deg, var(--victory-petal-a), var(--victory-petal-b));
  opacity: .84;
  animation: petal-drift 4.8s linear infinite;
}

.p1 { left: 8%; animation-delay: 0s; }
.p2 { left: 17%; animation-delay: -.7s; }
.p3 { left: 25%; animation-delay: -1.4s; }
.p4 { left: 34%; animation-delay: -2.1s; }
.p5 { left: 45%; animation-delay: -2.8s; }
.p6 { left: 55%; animation-delay: -3.5s; }
.p7 { left: 64%; animation-delay: -4.2s; }
.p8 { left: 73%; animation-delay: -.3s; }
.p9 { left: 82%; animation-delay: -1.0s; }
.p10 { left: 91%; animation-delay: -1.7s; }
.p11 { left: 13%; animation-delay: -2.5s; }
.p12 { left: 29%; animation-delay: -3.2s; }
.p13 { left: 39%; animation-delay: -3.9s; }
.p14 { left: 49%; animation-delay: -.9s; }
.p15 { left: 59%; animation-delay: -1.6s; }
.p16 { left: 69%; animation-delay: -2.3s; }
.p17 { left: 79%; animation-delay: -3.0s; }
.p18 { left: 89%; animation-delay: -3.7s; }

@keyframes petal-drift {
  0% { top: -18px; transform: translateX(0) rotate(0deg); }
  100% { top: 112%; transform: translateX(34px) rotate(290deg); }
}

.board-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(100%, 1070px);
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(17, minmax(22px, 1fr));
  grid-template-rows: repeat(17, minmax(22px, 1fr));
  width: min(92vh, 100%);
  max-width: 980px;
  aspect-ratio: 1;
  border: 4px solid #6f5d39;
  background: #d6c79f;
  box-shadow: inset 0 0 0 2px #aa9467, 0 24px 70px rgba(0,0,0,.38);
}

.board-siguo {
  --siguo-cell-w: 5.2%;
  --siguo-cell-h: 4.6%;
  display: block;
  overflow: visible;
  background: #d8c59d;
}

.board-siguo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/map8.jpg") center / 100% 100% no-repeat;
  transform-origin: 50% 50%;
  pointer-events: none;
  z-index: 0;
}

.board-siguo-rel-0::before { transform: rotate(180deg); }
.board-siguo-rel-1::before { transform: rotate(90deg); }
.board-siguo-rel-2::before { transform: rotate(0deg); }
.board-siguo-rel-3::before { transform: rotate(-90deg); }

.board-stage-junqi {
  max-width: 900px;
  padding-right: clamp(170px, 25vw, 280px);
}

.board-surface-wrap-junqi {
  position: relative;
  width: auto;
  height: min(92vh, 100vw);
  max-height: 980px;
  aspect-ratio: 27 / 37;
}

.board-clip-junqi {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.38);
}

.board-junqi {
  --junqi-cell-w: 9.1%;
  --junqi-cell-h: 4.0%;
  display: block;
  overflow: hidden;
  width: auto;
  height: min(92vh, 100vw);
  max-height: 980px;
  aspect-ratio: 27 / 37;
  padding: 0;
  border: 0;
  background: #ded1a6;
  box-shadow: 0 24px 70px rgba(0,0,0,.38);
}

.board-junqi::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/map3.jpg") center / 100% 100% no-repeat;
  transform-origin: 50% 50%;
  pointer-events: none;
  z-index: 0;
}

.board-junqi-rel-0::before { transform: rotate(180deg); }
.board-junqi-rel-2::before { transform: rotate(0deg); }

.board-clip-junqi > .board-junqi {
  position: absolute;
  width: 100%;
  height: 100%;
  max-height: none;
  left: 0;
  top: 0;
  box-shadow: none;
}

.board-junqi .piece {
  left: 5%;
  right: 5%;
  top: 10%;
  bottom: 10%;
}

.dead-tray {
  width: min(92vh, 100%);
  max-width: 980px;
  min-height: 0;
  border: 1px solid rgba(215, 182, 106, .28);
  background: rgba(31, 29, 21, .78);
  border-radius: 8px;
  padding: 7px 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}

.dead-tray b {
  font-size: 13px;
  text-align: left;
  color: var(--muted);
}

.dead-list {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: auto;
}

.dead-piece {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  min-width: 30px;
  min-height: 24px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.25);
  font-weight: 800;
  font-size: clamp(10px, 1vw, 13px);
  line-height: 1;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24), inset 0 -6px 10px rgba(0,0,0,.16);
  opacity: .82;
  filter: saturate(.78);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  --cell-bg: #d8caa3;
  --grid-line: rgba(89, 76, 48, .44);
  --track-color: rgba(86, 80, 58, .72);
  background: var(--cell-bg);
  border: 1px solid var(--grid-line);
  min-width: 0;
  min-height: 0;
}

.board-siguo .cell {
  position: absolute;
  width: var(--siguo-cell-w);
  height: var(--siguo-cell-h);
  border-color: transparent;
  background: transparent;
  z-index: 2;
}

.off {
  --cell-bg: #d1c091;
  border-color: rgba(116, 100, 63, .18);
}
.home-north {
  --cell-bg: #8da0b7;
  --grid-line: rgba(34, 50, 70, .48);
  --track-color: rgba(35, 49, 66, .72);
}
.home-east {
  --cell-bg: #8f9396;
  --grid-line: rgba(45, 50, 54, .50);
  --track-color: rgba(40, 44, 47, .74);
}
.home-south {
  --cell-bg: #b77466;
  --grid-line: rgba(96, 37, 32, .48);
  --track-color: rgba(86, 37, 31, .74);
}
.home-west {
  --cell-bg: #9a9b61;
  --grid-line: rgba(68, 75, 38, .50);
  --track-color: rgba(58, 66, 35, .74);
}
.home-center {
  --cell-bg: #d8c99f;
  --grid-line: rgba(113, 95, 56, .42);
  --track-color: rgba(86, 80, 58, .74);
}

.board-junqi .cell {
  position: absolute;
  width: var(--junqi-cell-w);
  height: var(--junqi-cell-h);
  border-color: transparent;
  background: transparent;
  z-index: 2;
}

.board-siguo .normal,
.board-siguo .railroad,
.board-siguo .frontline,
.board-siguo .track-segment,
.board-siguo .camp,
.board-siguo .hq,
.board-siguo .mountain {
  background: transparent;
  border-color: transparent;
}

.board-siguo .rails,
.board-siguo .river-label,
.board-siguo .camp::before,
.board-siguo .hq::before {
  display: none;
}

.board-junqi .home-north {
  --cell-bg: #b9b39f;
  --grid-line: rgba(54, 62, 59, .42);
  --track-color: rgba(41, 44, 39, .82);
}

.board-junqi .home-south {
  --cell-bg: #cdbb8e;
  --grid-line: rgba(94, 65, 31, .42);
  --track-color: rgba(64, 47, 30, .82);
}

.board-junqi .camp {
  border-radius: 0;
  margin: 0;
  border: 0;
  background: transparent;
}

.board-junqi .hq {
  margin: 0;
  border: 0;
  background: transparent;
}

.board-junqi .frontline {
  background: transparent;
}

.board-junqi .mountain {
  --cell-bg: #c4b585;
  --grid-line: rgba(85, 62, 31, .24);
  background: transparent;
}

.board-junqi .home-gap {
  --cell-bg: #c4b585;
  --grid-line: rgba(85, 62, 31, .18);
  background: transparent;
}

.board-junqi .off.home-gap {
  border-color: transparent;
}
.normal { background: var(--cell-bg); }
.railroad, .frontline {
  background: var(--cell-bg);
}
.frontline {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.track-segment {
  background: var(--cell-bg);
  border-color: rgba(113, 95, 56, .14);
}
.board-junqi .track-segment {
  background: transparent;
  border-color: transparent;
}
.cell.occupied {
  z-index: 5;
}
.board-junqi .river-label,
.board-junqi .rails,
.board-junqi .camp::before,
.board-junqi .hq::before {
  display: none;
}
.river-label {
  position: absolute;
  inset: 8%;
  display: grid;
  place-items: center;
  color: rgba(88, 56, 22, .92);
  font-family: "STLiti", "LiSu", "BiauKai", "KaiTi", serif;
  font-size: clamp(10px, 1.24vw, 19px);
  font-weight: 600;
  line-height: .95;
  letter-spacing: .06em;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255,255,255,.28);
  pointer-events: none;
  z-index: 2;
  opacity: .9;
}
.river-label-left {
  transform: translate(-12%, 0);
}
.river-label-right {
  transform: translate(12%, 0);
}
.river-label-top {
  margin-top: -6%;
}
.river-label-bottom {
  margin-top: 6%;
}
.rails {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}
.rails line,
.rails path {
  fill: none;
  vector-effect: non-scaling-stroke;
  stroke-linecap: butt;
  stroke-linejoin: round;
}
.rail-shadow line,
.rail-shadow path {
  stroke: rgba(72, 16, 14, .72);
  stroke-width: 3.5px;
}
.rail-main line,
.rail-main path {
  stroke: rgba(210, 28, 28, .96);
  stroke-width: 2.5px;
}
.rail-sleeper line {
  stroke: rgba(92, 18, 16, .72);
  stroke-width: 1px;
}
.camp::before {
  content: "";
  width: 62%;
  height: 34%;
  border: 2px solid rgba(44, 91, 69, .9);
  background: rgba(218, 226, 184, .34);
  box-shadow: 0 0 0 1px rgba(255,255,255,.24);
  z-index: 3;
}
.home-east.camp::before,
.home-west.camp::before {
  width: 34%;
  height: 62%;
}
.hq::before {
  content: "★";
  color: #f2d36f;
  opacity: .92;
  text-shadow: 0 1px 1px rgba(0,0,0,.45);
}
.turn-front {
  box-shadow:
    inset 0 0 0 3px rgba(40, 224, 123, .98),
    inset 0 0 20px rgba(40, 224, 123, .42);
  z-index: 1;
}
.turn-front::after {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 3px;
  border: 1px solid rgba(126, 255, 184, .88);
  pointer-events: none;
}

.combat-hit {
  animation: combat-cell 760ms ease-out;
}

.combat-hit .piece {
  animation: combat-piece 760ms cubic-bezier(.22, 1, .36, 1);
}

@keyframes combat-cell {
  0% { box-shadow: inset 0 0 0 2px rgba(255, 246, 184, .95), 0 0 0 rgba(255, 80, 55, 0); }
  20% { box-shadow: inset 0 0 0 4px rgba(255, 238, 142, 1), 0 0 28px rgba(255, 86, 54, .72); transform: translateX(-1px); }
  35% { transform: translateX(1px); }
  50% { transform: translateX(-1px); }
  100% { box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 0 0 rgba(255, 80, 55, 0); transform: translateX(0); }
}

@keyframes combat-piece {
  0% { transform: scale(1); filter: brightness(1); }
  18% { transform: scale(1.18) rotate(-3deg); filter: brightness(1.35); }
  42% { transform: scale(.94) rotate(2deg); }
  100% { transform: scale(1) rotate(0); filter: brightness(1); }
}

.piece {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 18%;
  bottom: 18%;
  display: grid;
  place-items: center;
  min-width: 0;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.34);
  color: #fff6e4;
  font-weight: 800;
  font-size: clamp(8px, 1vw, 14px);
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  padding-bottom: 0.12em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), inset 0 -8px 12px rgba(0,0,0,.18), 0 8px 14px rgba(0,0,0,.22);
  user-select: none;
  z-index: 4;
}
.cell.occupied .piece {
  z-index: 6;
}

.piece-red { background: linear-gradient(145deg, #dd5a49, #84241e); }
.piece-green { background: linear-gradient(145deg, #4fae78, #1f6841); }
.piece-yellow {
  background: linear-gradient(145deg, #f1d05a, #a87518);
  color: #2d2010;
  text-shadow: 0 1px 0 rgba(255,255,255,.36);
}
.piece-blue {
  background: linear-gradient(145deg, #4f94d8, #1f568f);
  color: #f5fbff;
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.piece-hidden {
  color: transparent;
}
.piece-hidden::after {
  content: "";
  width: 34%;
  height: 46%;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.58);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.16);
}
.piece-rel-0 {
  transform: rotate(0deg);
}
.piece-rel-1 {
  transform: rotate(-90deg);
}
.piece-rel-2 {
  transform: rotate(180deg);
}
.piece-rel-3 {
  transform: rotate(90deg);
}
.flag-exposed {
  transform: rotate(-13deg) translateY(1px);
  outline: 2px dashed rgba(255, 237, 150, .95);
  outline-offset: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.32),
    inset 0 -8px 12px rgba(0,0,0,.18),
    0 0 0 2px rgba(96, 43, 31, .42),
    0 10px 18px rgba(0,0,0,.26);
}
.piece-rel-0.flag-exposed {
  transform: rotate(-13deg) translateY(1px);
}
.piece-rel-1.flag-exposed {
  transform: rotate(-103deg) translateY(1px);
}
.piece-rel-2.flag-exposed {
  transform: rotate(167deg) translateY(1px);
}
.piece-rel-3.flag-exposed {
  transform: rotate(77deg) translateY(1px);
}
.selected .piece {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.side {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
}

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

.stack {
  display: grid;
  gap: 10px;
}

.culture-panel {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  background:
    linear-gradient(145deg, rgba(47, 39, 27, .96), rgba(27, 31, 24, .94)),
    radial-gradient(circle at 85% 10%, rgba(215, 182, 106, .18), transparent 12rem);
}

.culture-panel::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(215, 182, 106, .28);
  pointer-events: none;
}

.culture-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.culture-head b {
  display: block;
  color: #f7dfaa;
  font-size: 20px;
  letter-spacing: .12em;
}

.culture-head span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .22em;
}

.music-chip {
  flex: 0 0 auto;
  min-width: 68px;
  min-height: 32px;
  padding: 0 10px;
  border-color: rgba(240, 207, 120, .6);
  background: rgba(112, 90, 44, .72);
  color: #fff0bd;
}

.poem-window {
  position: relative;
  z-index: 2;
  height: 190px;
  overflow: hidden;
  border: 1px solid rgba(86, 49, 22, .55);
  background:
    linear-gradient(90deg, rgba(236, 199, 131, .2), rgba(255,255,255,0), rgba(78, 41, 19, .18)),
    url("/picture02.png") center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 238, 180, .24), 0 14px 32px rgba(0,0,0,.28);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}

.poem-window::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 224, 156, .12), rgba(255, 244, 210, .03) 45%, rgba(53, 24, 10, .12));
  pointer-events: none;
  z-index: 1;
}

.poem-scroll {
  position: absolute;
  top: 0;
  left: 74%;
  z-index: 2;
  display: flex;
  align-items: stretch;
  gap: 30px;
  width: max-content;
  height: 100%;
  padding: 14px 28px;
  animation: poem-cross 42s linear infinite;
}

.poem-scroll span {
  display: block;
  margin: 0;
  max-height: 100%;
  color: rgba(19, 14, 10, .92);
  font-family: "STXingkai", "AR PL UKai CN", "AR PL UKai SC", "FandolKai", "HanziPen SC", "Xingkai SC", "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif CJK SC", "Noto Serif SC", serif;
  font-size: clamp(18px, 2.05vh, 26px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: .08em;
  writing-mode: vertical-rl;
  text-orientation: upright;
  white-space: normal;
  text-shadow: 0 1px 0 rgba(255, 238, 202, .45), 0 3px 8px rgba(255, 225, 160, .28);
}

.poem-scroll .poem-title {
  font-size: clamp(22px, 2.45vh, 31px);
  font-weight: 700;
  letter-spacing: .16em;
}

.poem-scroll .poem-author {
  font-size: clamp(15px, 1.7vh, 22px);
  letter-spacing: .12em;
  opacity: .84;
}

@keyframes poem-cross {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(-100% - 100vw)); }
}

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

.row > * {
  flex: 1;
}

.seats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.seat {
  padding: 9px;
  border: 1px solid #5d543f;
  background: #1c1a13;
  border-radius: 6px;
}

.seat b {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 24px;
  margin-bottom: 5px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24), inset 0 -6px 10px rgba(0,0,0,.16);
  color: #fff6e4;
  line-height: 1;
}

.seat[data-seat="0"] b {
  background: linear-gradient(145deg, #dd5a49, #84241e);
}

.seat[data-seat="1"] b {
  background: linear-gradient(145deg, #4fae78, #1f6841);
}

.seat[data-seat="2"] b {
  background: linear-gradient(145deg, #f1d05a, #a87518);
  color: #2d2010;
  text-shadow: 0 1px 0 rgba(255,255,255,.36);
}

.seats-junqi .seat[data-seat="2"] b {
  background: linear-gradient(145deg, #4f94d8, #1f568f);
  color: #f5fbff;
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
}

.seat[data-seat="3"] b {
  background: linear-gradient(145deg, #4f94d8, #1f568f);
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
}

.seat.current {
  border-color: var(--gold);
}

.log, .chat-log {
  overflow: auto;
  min-height: 140px;
  max-height: 34vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.line {
  padding: 8px 9px;
  background: rgba(0,0,0,.18);
  border-radius: 5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.error {
  color: #ffd0c9;
  border-color: rgba(214,91,82,.45);
}

.player-ticker {
  position: absolute;
  box-sizing: border-box;
  width: 31.7647058824%;
  height: 11.7647058824%;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(28, 26, 19, 0.94);
  border: 1px solid rgba(215, 182, 106, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 2px;
  z-index: 4;
  pointer-events: none;
  font-size: clamp(9px, 0.95vw, 12px);
  color: var(--text);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.player-ticker::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  bottom: 5px;
  width: 4px;
  border-radius: 3px;
  background: transparent;
}

.player-ticker.ticker-rel-0 { left: 68.2352941176%; bottom: 0; }
.player-ticker.ticker-rel-2 { left: 0; top: 0; }
.player-ticker.ticker-rel-3 {
  left: 89.4117647059%;
  top: 11.7647058824%;
  height: 8.2352941176%;
  transform: rotate(-90deg);
}
.player-ticker.ticker-rel-1 {
  left: -21.1764705882%;
  top: 80%;
  height: 8.2352941176%;
  transform: rotate(90deg);
}

.player-ticker[data-seat="0"] {
  background: linear-gradient(145deg, #dd5a49, #84241e);
  border-color: rgba(255, 190, 174, 0.72);
  color: #fff6e4;
}
.player-ticker[data-seat="1"] {
  background: linear-gradient(145deg, #4fae78, #1f6841);
  border-color: rgba(177, 239, 199, 0.72);
  color: #fff6e4;
}
.player-ticker[data-seat="2"] {
  background: linear-gradient(145deg, #f1d05a, #a87518);
  border-color: rgba(255, 237, 166, 0.76);
  color: #2d2010;
  text-shadow: 0 1px 0 rgba(255,255,255,.36);
}
.player-ticker[data-seat="3"] {
  background: linear-gradient(145deg, #4f94d8, #1f568f);
  border-color: rgba(178, 219, 255, 0.72);
  color: #f5fbff;
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
}

.board-surface-wrap-junqi .player-ticker {
  width: 48%;
  min-width: 190px;
  max-width: 260px;
  height: auto;
  min-height: 92px;
}

.board-surface-wrap-junqi .player-ticker.ticker-rel-0 {
  left: calc(100% + 10px);
  bottom: 9%;
}

.board-surface-wrap-junqi .player-ticker.ticker-rel-2 {
  left: calc(100% + 10px);
  top: 9%;
}

.board-surface-wrap-junqi .player-ticker[data-seat="0"] {
  background: linear-gradient(145deg, rgba(221, 90, 73, 0.96), rgba(132, 36, 30, 0.96));
  border-color: rgba(255, 190, 174, 0.72);
  color: #fff6e4;
}

.board-surface-wrap-junqi .player-ticker[data-seat="2"] {
  background: linear-gradient(145deg, rgba(79, 148, 216, 0.96), rgba(31, 86, 143, 0.96));
  border-color: rgba(178, 219, 255, 0.72);
  color: #f5fbff;
}

.player-ticker .ticker-name,
.player-ticker .ticker-stats,
.player-ticker .ticker-time {
  color: inherit;
}

.player-ticker .ticker-bar {
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(0, 0, 0, 0.35);
}

.player-ticker.elim {
  opacity: 0.55;
  filter: saturate(0.55);
}

.player-ticker.active {
  border-color: rgba(40, 224, 123, 0.98);
  box-shadow: 0 0 0 2px rgba(40, 224, 123, 0.52), 0 6px 18px rgba(0, 0, 0, 0.55);
}

.player-ticker.active::before {
  background: #28e07b;
  box-shadow: 0 0 10px rgba(40, 224, 123, 0.86);
}

.ticker-head {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.1;
}

.ticker-seat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: clamp(9px, 0.85vw, 11px);
  font-weight: 800;
  background: rgba(0, 0, 0, 0.22);
  color: inherit;
  border: 1px solid rgba(0, 0, 0, 0.32);
}

.ticker-turn-logo {
  position: relative;
  flex: 0 0 27px;
  width: 27px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.player-ticker.active .ticker-turn-logo {
  opacity: 1;
}

.ticker-turn-logo::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 5px;
  bottom: 2px;
  height: 8px;
  border-radius: 6px 6px 3px 3px;
  background: #28e07b;
  box-shadow: 0 0 8px rgba(40, 224, 123, 0.78);
}

.ticker-turn-logo::after {
  content: "";
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 16px;
  height: 5px;
  border-radius: 4px;
  background: #28e07b;
  box-shadow: 7px 1px 0 -1px #28e07b;
}

.ticker-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 600;
}

.ticker-bar {
  position: relative;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.ticker-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #54ad7f, #d7b66a);
  transition: width 200ms linear;
}

.ticker-bar-fill.urgent {
  background: linear-gradient(90deg, #d65b52, #f0a54a);
  animation: ticker-pulse 0.7s ease-in-out infinite;
}

@keyframes ticker-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ticker-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--muted);
  font-size: clamp(9px, 0.85vw, 11px);
}

.ticker-time {
  min-width: 28px;
  font-weight: 800;
  color: var(--text);
}

.player-ticker.active .ticker-time {
  color: #28e07b;
}

.ticker-skips {
  letter-spacing: 0.02em;
}

.ticker-tag {
  color: var(--bad);
  font-weight: 700;
}

.ticker-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 5px;
  min-height: 0;
}

.ticker-actions button {
  min-height: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: clamp(8px, 0.78vw, 11px);
  line-height: 1;
  pointer-events: auto;
}

.request-banner {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(215, 182, 106, 0.55);
  background: rgba(50, 40, 24, 0.88);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: var(--text);
}

.request-banner.request-mine {
  border-color: #ffe57e;
  background: linear-gradient(90deg, rgba(125, 60, 24, 0.85), rgba(50, 40, 24, 0.92));
  animation: request-glow 1.6s ease-in-out infinite;
}

@keyframes request-glow {
  0%, 100% { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 0 2px rgba(255, 229, 126, 0.5), 0 8px 26px rgba(0, 0, 0, 0.55); }
}

.request-text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.4;
}

.request-text b {
  color: #ffe57e;
  margin-right: 4px;
}

.request-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.request-actions button {
  min-width: 76px;
  min-height: 34px;
  padding: 0 12px;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .board {
    width: min(96vw, 82vh);
  }
  .board-surface-wrap-junqi {
    width: auto;
    height: min(92vh, 100vw);
  }
  .board-junqi {
    width: auto;
    height: min(92vh, 100vw);
  }
}
