:root {
  --ink: #243d38;
  --ink-deep: #1a2e2a;
  --mute: #5d736d;
  --foam: #f3f7f5;
  --jade-deep: #4d736b;
  --mist: #e8f1ee;
  --mist-deep: #d6e6e0;
  --jade-mist: #c5d9d3;
  --sand: #e8d4b8;
  --line: rgba(36, 61, 56, 0.12);
  --panel: rgba(255, 255, 255, 0.72);
  --shadow: 0 18px 50px rgba(36, 61, 56, 0.1);
  --font-display: "Noto Serif SC", "Songti SC", serif;
  --font-latin: "Instrument Serif", serif;
  --font-body: "Noto Sans SC", sans-serif;
  --header-h: 3rem;
  --info-h: 4.8rem;
  --page-gap: 0.4rem;
  --picker-top: calc(var(--header-h) + 1.65rem);
  --picker-h: 2.85rem;
  --lantern-top: calc(var(--picker-top) + var(--picker-h));
  --lantern-block: 5.6rem;
  --center-w: min(
    calc(100vw - 9rem),
    calc((100dvh - var(--header-h) - var(--info-h) - 0.9rem) * 16 / 9)
  );
  --side-w: max(72px, calc((100vw - var(--center-w)) / 2));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--mist);
  display: flex;
  flex-direction: column;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--mist);
}

.page-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 70% at 12% 40%, rgba(197, 217, 211, 0.55), transparent 68%),
    radial-gradient(ellipse 55% 70% at 88% 58%, rgba(197, 217, 211, 0.5), transparent 68%),
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(214, 230, 224, 0.65), transparent 72%),
    radial-gradient(ellipse 50% 40% at 50% 0%, rgba(232, 212, 184, 0.32), transparent 60%),
    radial-gradient(ellipse 45% 35% at 20% 85%, rgba(63, 101, 94, 0.08), transparent 70%),
    radial-gradient(ellipse 45% 35% at 80% 90%, rgba(45, 78, 72, 0.07), transparent 70%),
    linear-gradient(180deg, var(--mist) 0%, var(--mist-deep) 48%, #dceae5 100%);
}

.page-wash::before,
.page-wash::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: min(42vw, 480px);
  opacity: 0.55;
  background:
    radial-gradient(ellipse 70% 40% at 35% 28%, rgba(214, 230, 224, 0.55), transparent 72%),
    radial-gradient(ellipse 55% 36% at 62% 58%, rgba(197, 217, 211, 0.4), transparent 74%),
    radial-gradient(ellipse 48% 28% at 45% 78%, rgba(232, 212, 184, 0.2), transparent 70%);
  filter: blur(10px);
  mix-blend-mode: multiply;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 55%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 55%, transparent 100%);
}

.page-wash::before {
  left: 0;
}

.page-wash::after {
  right: 0;
  transform: scaleX(-1);
}

.bg-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      90deg,
      rgba(214, 230, 224, 0.45) 0%,
      rgba(232, 241, 238, 0.55) 22%,
      rgba(214, 230, 224, 0.5) 50%,
      rgba(232, 241, 238, 0.55) 78%,
      rgba(214, 230, 224, 0.45) 100%
    ),
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(197, 217, 211, 0.22), transparent 72%);
  mix-blend-mode: multiply;
}

.game-header,
.game-shell {
  position: relative;
  z-index: 1;
  /* 绝不可用 none：会吞掉底栏棋种/对战/开始等全部点击 */
  pointer-events: auto !important;
}

.game-header {
  flex: 0 0 var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  height: var(--header-h);
  padding: 0 clamp(0.7rem, 2vw, 1.2rem);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  padding: 0.22rem 0.7rem 0.22rem 0.28rem;
  border: 1px solid rgba(90, 70, 45, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(232, 241, 238, 0.35)),
    rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  color: var(--ink);
  text-decoration: none;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.back:hover {
  transform: translateY(-1px);
  border-color: rgba(77, 115, 107, 0.35);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(214, 230, 224, 0.45)),
    rgba(255, 255, 255, 0.4);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.45),
    0 8px 18px rgba(36, 61, 56, 0.08);
}

.back-seal {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.back-text {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  line-height: 1;
}

.back-text em {
  font-style: normal;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--mute);
}

.back-text strong {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink-deep);
}

.title-wrap {
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--jade-deep);
  letter-spacing: 0.22em;
  font-size: 0.62rem;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.2;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.header-actions .btn {
  min-height: 2rem;
  padding: 0.25rem 0.8rem;
  font-size: 0.88rem;
}

.brand-seal {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
}

.game-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.55rem 0.5rem 1rem;
  overflow: hidden;
}

.stage-center {
  --max-w: calc(100vw - 9rem);
  --stage-radius: 22px;
  position: relative;
  z-index: 5;
  pointer-events: auto;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--info-h);
  gap: 0;
  width: var(--center-w);
  height: min(
    calc(100dvh - var(--header-h) - 1rem),
    calc(var(--center-w) * 9 / 16 + var(--info-h))
  );
  max-width: 100%;
  max-height: calc(100dvh - var(--header-h) - 1rem);
  min-height: 0;
  border-radius: var(--stage-radius);
  overflow: visible;
  border: 1px solid rgba(90, 70, 45, 0.16);
  background:
    linear-gradient(180deg, rgba(232, 241, 238, 0.55), rgba(227, 236, 232, 0.42)),
    rgba(214, 230, 224, 0.35);
  box-shadow:
    0 22px 56px rgba(36, 61, 56, 0.16),
    0 2px 0 rgba(255, 255, 255, 0.28) inset;
  transform: none;
  animation: stage-float-in 0.55s ease both;
}

@keyframes stage-float-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.stage-wrap {
  position: relative;
  z-index: 1;
  isolation: isolate;
  border: none;
  border-radius: var(--stage-radius) var(--stage-radius) 0 0;
  overflow: hidden;
  box-shadow: none;
  background: #d7e6e1;
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
}

.bg-side {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  min-height: 0;
  padding: 1.1rem 0.35rem 1.2rem;
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  isolation: isolate;
  pointer-events: none;
}

.bg-side--left {
  left: 0;
  overflow: hidden;
  mask-image: linear-gradient(90deg, #000 0%, #000 52%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 52%, transparent 100%);
}

.bg-side--right {
  right: 0;
  overflow: hidden;
  mask-image: linear-gradient(270deg, #000 0%, #000 52%, transparent 100%);
  -webkit-mask-image: linear-gradient(270deg, #000 0%, #000 52%, transparent 100%);
}

.bg-side::before,
.bg-side::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-side::before {
  background: linear-gradient(
    90deg,
    rgba(232, 241, 238, 0.28) 0%,
    rgba(232, 241, 238, 0.1) 40%,
    transparent 78%
  );
}

.bg-side--right::before {
  background: linear-gradient(
    270deg,
    rgba(232, 241, 238, 0.28) 0%,
    rgba(232, 241, 238, 0.1) 40%,
    transparent 78%
  );
}

.bg-side::after {
  background:
    radial-gradient(ellipse 80% 45% at 40% 22%, rgba(197, 217, 211, 0.18), transparent 70%),
    radial-gradient(ellipse 70% 40% at 55% 78%, rgba(214, 230, 224, 0.16), transparent 72%);
  mix-blend-mode: multiply;
}

.ink-clouds {
  position: absolute;
  top: 8%;
  width: 140%;
  height: 38%;
  pointer-events: none;
  opacity: 0.42;
  background:
    radial-gradient(ellipse 42% 30% at 30% 40%, rgba(197, 217, 211, 0.55), transparent 72%),
    radial-gradient(ellipse 38% 26% at 62% 55%, rgba(214, 230, 224, 0.48), transparent 72%),
    radial-gradient(ellipse 32% 22% at 48% 30%, rgba(232, 212, 184, 0.28), transparent 72%);
  filter: blur(8px);
  mix-blend-mode: multiply;
  animation: cloud-drift 18s ease-in-out infinite alternate;
}

.ink-clouds--b {
  top: auto;
  bottom: 10%;
  animation-delay: -6s;
  opacity: 0.34;
}

.ink-mount {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: 0;
  height: 48%;
  pointer-events: none;
  background:
    linear-gradient(180deg, transparent, rgba(77, 115, 107, 0.04) 30%, rgba(63, 101, 94, 0.1)),
    radial-gradient(ellipse 55% 70% at 30% 100%, rgba(63, 101, 94, 0.14), transparent 70%),
    radial-gradient(ellipse 50% 65% at 70% 110%, rgba(45, 78, 72, 0.1), transparent 70%);
  opacity: 0.85;
  mix-blend-mode: multiply;
}

.ink-mount--flip {
  transform: scaleX(-1);
}

.frame-ornament {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.frame-ornament span {
  display: block;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(120, 90, 55, 0.38);
  transform: rotate(45deg);
  background: rgba(214, 230, 224, 0.35);
}

.frame-ornament span:nth-child(2) {
  width: 11px;
  height: 11px;
  border-color: rgba(77, 115, 107, 0.45);
}

.frame-lantern-space {
  flex: 0 0 var(--lantern-block);
  width: 1px;
  height: var(--lantern-block);
  pointer-events: none;
  visibility: hidden;
}

.frame-lantern {
  position: fixed;
  left: calc(var(--side-w) / 2);
  top: var(--lantern-top);
  z-index: 2;
  display: grid;
  justify-items: center;
  margin: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

.bg-side--right .frame-lantern {
  left: calc(100% - var(--side-w) / 2);
}

.info-bar .btn,
.info-bar .bar-select-trigger,
.diff-picker .diff-trigger {
  pointer-events: auto !important;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.diff-picker {
  position: fixed;
  left: calc(var(--side-w) / 2);
  top: var(--picker-top);
  z-index: 10001;
  transform: translateX(-50%);
  margin: 0;
  pointer-events: auto !important;
}

.diff-picker--right {
  left: calc(100% - var(--side-w) / 2);
}

.diff-picker--right .diff-menu {
  left: auto;
  right: calc(100% + 0.45rem);
  transform: translateX(8px) scale(0.96);
  transform-origin: right center;
}

.diff-trigger {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
  padding: 0.28rem 0.4rem 0.22rem;
  border: 1px solid rgba(77, 115, 107, 0.35);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(244, 247, 245, 0.72), rgba(214, 230, 224, 0.65));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 4px 12px rgba(36, 61, 56, 0.08);
  color: var(--jade-deep);
  cursor: pointer;
  font: inherit;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.diff-trigger:hover,
.diff-picker.is-open .diff-trigger {
  border-color: rgba(77, 115, 107, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(214, 230, 224, 0.82));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 6px 16px rgba(36, 61, 56, 0.12);
}

.diff-icon {
  display: block;
}

.diff-trigger-label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--ink-deep);
  line-height: 1;
}

.diff-menu {
  position: absolute;
  top: 0;
  left: calc(100% + 0.45rem);
  z-index: 8;
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  min-width: 10.5rem;
  border: 1px solid rgba(90, 70, 45, 0.16);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(243, 247, 245, 0.96), rgba(232, 241, 238, 0.94));
  box-shadow: 0 14px 32px rgba(36, 61, 56, 0.14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-8px) scale(0.96);
  transform-origin: left center;
  transition:
    opacity 0.24s ease,
    transform 0.24s ease,
    visibility 0.24s ease;
}

.diff-picker.is-open .diff-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.diff-picker--right.is-open .diff-menu {
  transform: translateX(0) scale(1);
}

.diff-menu li {
  display: grid;
  gap: 0.12rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.15s ease;
}

.diff-menu li:hover,
.diff-menu li:focus-visible {
  outline: none;
  background: rgba(197, 217, 211, 0.45);
}

.diff-menu li[aria-selected="true"] {
  background: rgba(111, 149, 140, 0.22);
}

.diff-menu em {
  font-style: normal;
  font-family: var(--font-display);
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  color: var(--ink-deep);
}

.diff-menu span {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--mute);
  white-space: nowrap;
}

.lantern-cord {
  width: 2px;
  height: 14px;
  background: linear-gradient(#6b5340, #4d736b);
  opacity: 0.75;
}

.lantern-body {
  width: 36px;
  height: 46px;
  border-radius: 13px;
  border: 1.8px solid rgba(107, 83, 64, 0.55);
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(107, 83, 64, 0.18) 8% 10%, transparent 10% 90%, rgba(107, 83, 64, 0.18) 90% 92%, transparent 92%),
    linear-gradient(180deg, rgba(244, 233, 214, 0.72), rgba(232, 212, 184, 0.55) 55%, rgba(215, 184, 137, 0.48));
  box-shadow: 0 10px 22px rgba(201, 168, 106, 0.22);
  animation: lantern-sway 4.8s ease-in-out infinite;
  transform-origin: top center;
}

.bg-side--right .lantern-body {
  animation-delay: -1.6s;
}

.lantern-glow {
  width: 64px;
  height: 26px;
  margin-top: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 212, 184, 0.65), transparent 70%);
  filter: blur(1px);
}

.couplet {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 3.6em;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(0.82rem, 1.1vw, 1.05rem);
  letter-spacing: 0.16em;
  line-height: 1.7;
  writing-mode: vertical-rl;
  color: rgba(55, 42, 28, 0.48);
  text-shadow: none;
}

.seal-stamp {
  position: relative;
  z-index: 1;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 2px solid rgba(158, 56, 48, 0.5);
  border-radius: 4px;
  color: rgba(158, 56, 48, 0.62);
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  writing-mode: vertical-rl;
  background: transparent;
  transform: rotate(-8deg);
  box-shadow: none;
  opacity: 0.88;
}

.seal-stamp--alt {
  transform: rotate(7deg);
}

.frame-notes {
  position: relative;
  z-index: 1;
  list-style: none;
  margin: 0;
  padding: 0.2rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-display);
  letter-spacing: 0.14em;
  color: rgba(55, 42, 28, 0.48);
  font-size: clamp(0.88rem, 1.2vw, 1.05rem);
}

.frame-notes li {
  width: auto;
  height: auto;
  display: block;
  border: none;
  border-radius: 0;
  background: transparent;
  opacity: 0.8;
}

.bamboo {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.45rem;
  align-items: flex-end;
  height: 3.2rem;
}

.plum {
  position: relative;
  z-index: 1;
  width: 2.6rem;
  height: 2.6rem;
}

.bamboo i {
  display: block;
  width: 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(111, 149, 140, 0.12), rgba(63, 101, 94, 0.55));
  box-shadow: none;
}

.bamboo i:nth-child(1) {
  height: 68%;
}

.bamboo i:nth-child(2) {
  height: 100%;
}

.bamboo i:nth-child(3) {
  height: 78%;
}

.plum i {
  position: absolute;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50% 50% 50% 0;
  background: rgba(158, 76, 72, 0.45);
  transform: rotate(45deg);
}

.plum i:nth-child(1) {
  left: 1.35rem;
  top: 0.2rem;
}

.plum i:nth-child(2) {
  left: 0.25rem;
  top: 1.1rem;
}

.plum i:nth-child(3) {
  right: 0.25rem;
  top: 1.1rem;
}

.plum i:nth-child(4) {
  left: 0.55rem;
  bottom: 0.45rem;
}

.plum i:nth-child(5) {
  right: 0.55rem;
  bottom: 0.45rem;
  background: rgba(201, 133, 74, 0.4);
}

.stage-corner {
  position: absolute;
  z-index: 4;
  width: 34px;
  height: 34px;
  pointer-events: none;
  border: 2px solid rgba(120, 90, 55, 0.4);
}

.stage-corner--tl {
  top: 12px;
  left: 12px;
  border-right: none;
  border-bottom: none;
  border-radius: var(--stage-radius) 0 0 0;
}

.stage-corner--tr {
  top: 12px;
  right: 12px;
  border-left: none;
  border-bottom: none;
  border-radius: 0 var(--stage-radius) 0 0;
}

.stage-corner--bl,
.stage-corner--br {
  display: none;
}

.stage-badge {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  letter-spacing: 0.28em;
  color: rgba(55, 42, 28, 0.45);
  font-size: 0.78rem;
  font-family: var(--font-display);
}

.stage-badge--top {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.stage-badge--bottom {
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
}

/* 按键提示 · 雾青主题 */
.key-hints {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.42rem;
  padding: 0;
  pointer-events: none;
  border: none;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  filter: none;
}

.key-hint-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  line-height: 1;
}

.key-caps {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.3rem;
  border: 1px solid rgba(77, 115, 107, 0.42);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(244, 247, 245, 0.72), rgba(214, 230, 224, 0.78));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 1px 2px rgba(36, 61, 56, 0.1);
  color: var(--ink-deep);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-shadow: none;
}

.kbd-wide {
  min-width: 2.5rem;
  padding: 0 0.42rem;
  letter-spacing: 0.08em;
}

.key-or {
  color: rgba(93, 115, 109, 0.55);
  font-size: 0.62rem;
  margin: 0 0.04rem;
}

.key-label {
  min-width: 5.2em;
  color: rgba(36, 61, 56, 0.72);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

@keyframes lantern-sway {
  0%,
  100% {
    transform: rotate(-4deg);
  }
  50% {
    transform: rotate(4deg);
  }
}

@keyframes cloud-drift {
  from {
    transform: translateX(-8px);
  }
  to {
    transform: translateX(10px);
  }
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(232, 241, 238, 0.55);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

/* 必须用 !important，否则 .overlay { display:grid } 会盖过 [hidden] */
.overlay[hidden],
.overlay.is-hidden {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none !important;
}

.overlay-card {
  position: relative;
  z-index: 6;
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  width: min(100%, 400px);
  padding: 1.5rem 1.5rem 1.35rem;
  border-radius: 24px;
  border: 1px solid rgba(36, 61, 56, 0.1);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 40px rgba(36, 61, 56, 0.12);
  text-align: center;
  pointer-events: auto;
  overflow: hidden;
}

.overlay-card .btn {
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 7;
}

.overlay-kicker {
  margin: 0;
  font-family: var(--font-latin);
  font-style: italic;
  color: var(--jade-deep);
  letter-spacing: 0.12em;
}

.overlay h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  font-size: 1.45rem;
}

.overlay p {
  margin: 0;
  color: var(--mute);
  line-height: 1.7;
  font-weight: 300;
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: break-word;
}

.overlay.pause-overlay {
  z-index: 8;
  background: rgba(26, 46, 42, 0.28);
}

.info-bar {
  position: relative;
  z-index: 10000;
  display: grid;
  grid-template-columns: minmax(9.5rem, 1fr) auto minmax(9.5rem, 1fr);
  align-items: center;
  gap: 0.55rem 0.9rem;
  width: 100%;
  height: var(--info-h);
  min-height: 0;
  box-sizing: border-box;
  padding: 0.45rem 0.85rem;
  border: none;
  border-top: 1px solid rgba(90, 70, 45, 0.1);
  border-radius: 0 0 var(--stage-radius) var(--stage-radius);
  background:
    linear-gradient(180deg, rgba(232, 241, 238, 0.62), rgba(227, 236, 232, 0.48)),
    rgba(214, 230, 224, 0.28);
  backdrop-filter: blur(12px);
  box-shadow: none;
  overflow: visible;
  pointer-events: auto !important;
}

.info-left {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-self: start;
  gap: 0.4rem 0.55rem;
  min-width: 0;
  overflow: visible;
}

.info-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 0.4rem;
  flex-shrink: 0;
}

.info-bar .btn {
  min-height: 2.35rem;
  min-width: 4.6rem;
  padding: 0.32rem 0.85rem;
  font-size: 0.9rem;
}

.info-bar .btn-primary {
  position: relative;
  z-index: 3;
}

.name-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.name-field span,
.info-item span {
  color: var(--mute);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.name-field input {
  width: 6.2rem;
  border: 1px solid rgba(90, 70, 45, 0.16);
  border-radius: 999px;
  background: rgba(214, 230, 224, 0.45);
  color: var(--ink);
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.92rem;
  outline: none;
}

.name-field input:focus {
  border-color: rgba(77, 115, 107, 0.45);
  box-shadow: 0 0 0 3px rgba(111, 149, 140, 0.15);
}

.bar-select {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  flex-shrink: 0;
  z-index: 6;
}

.bar-select.is-open {
  z-index: 60;
}

.bar-select span {
  color: var(--mute);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.bar-select-trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  min-width: 4.8rem;
  min-height: 2.05rem;
  border: 1px solid rgba(90, 70, 45, 0.16);
  border-radius: 999px;
  color: var(--ink);
  padding: 0.28rem 1.55rem 0.28rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  outline: none;
  cursor: pointer;
  background-color: rgba(214, 230, 224, 0.55);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--jade-deep) 50%),
    linear-gradient(135deg, var(--jade-deep) 50%, transparent 50%);
  background-position:
    calc(100% - 12px) calc(50% - 2px),
    calc(100% - 7px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.bar-select-trigger em {
  font-style: normal;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-deep);
}

.bar-select-trigger:hover,
.bar-select.is-open .bar-select-trigger {
  border-color: rgba(77, 115, 107, 0.45);
  background-color: rgba(243, 247, 245, 0.9);
  box-shadow: 0 0 0 3px rgba(111, 149, 140, 0.12);
}

.bar-select-menu {
  position: absolute;
  left: 2.2rem;
  bottom: calc(100% + 0.4rem);
  z-index: 70;
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  min-width: 6.4rem;
  border: 1px solid rgba(90, 70, 45, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(232, 241, 238, 0.94));
  box-shadow: 0 14px 28px rgba(36, 61, 56, 0.14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px) scale(0.98);
  transform-origin: bottom left;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0.18s ease;
}

.bar-select.is-open .bar-select-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.bar-select-menu[hidden] {
  display: none !important;
}

.bar-select.is-open .bar-select-menu[hidden] {
  display: block !important;
}

.bar-select-menu li {
  padding: 0.48rem 0.75rem;
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.bar-select-menu li:hover,
.bar-select-menu li:focus-visible {
  background: rgba(197, 217, 211, 0.55);
  outline: none;
}

.bar-select-menu li[aria-selected="true"] {
  background: linear-gradient(135deg, rgba(77, 115, 107, 0.92), rgba(61, 94, 88, 0.95));
  color: #f3f7f5;
}

.diff-picker[hidden] {
  display: none !important;
}

.info-stats {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 0;
  overflow: hidden;
}

.info-item {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.3rem;
  flex: 0 1 auto;
  padding: 0.1rem 0.7rem;
  border-left: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

.info-item[hidden] {
  display: none !important;
}

.info-item:first-child {
  border-left: none;
}

.info-item strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
}

.info-tip {
  margin: 0;
  color: var(--mute);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn {
  min-height: 2.35rem;
  padding: 0.4rem 1.15rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0.06em;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease,
    background 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  flex-shrink: 0;
  background: linear-gradient(135deg, #5f857c, #3f655e);
  color: #f7fbf9;
  box-shadow: 0 8px 20px rgba(63, 101, 94, 0.22);
  font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 26px rgba(63, 101, 94, 0.3);
}

.overlay-card .btn-primary {
  margin-top: 0.35rem;
  min-width: 9.5rem;
}

.btn-ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem;
}

.board-backdrop {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(36, 61, 56, 0.18);
  pointer-events: auto;
}

.board-backdrop[hidden] {
  display: none !important;
}

.board-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 140;
  width: min(420px, calc(100vw - 2rem));
  max-height: min(70dvh, 520px);
  overflow: auto;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.board-panel[hidden] {
  display: none !important;
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.board-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.06em;
}

.board-note {
  margin: 0 0 0.85rem;
  color: var(--mute);
  font-size: 0.86rem;
}

.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.board-list li {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: rgba(238, 244, 241, 0.85);
}

.board-list .rank {
  font-family: var(--font-display);
  color: var(--jade-deep);
}

.board-list .name {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}

.board-list .board-diff {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
  border: 1px solid rgba(77, 115, 107, 0.28);
  background: rgba(255, 255, 255, 0.6);
  color: var(--jade-deep);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  line-height: 1.35;
  white-space: nowrap;
}

.board-list .board-meta {
  color: var(--mute);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.board-list .empty {
  display: block;
  color: var(--mute);
  text-align: center;
  padding: 1rem;
}

@media (max-width: 1100px) {
  :root {
    --center-w: min(calc(100vw - 1.2rem), calc((100dvh - var(--header-h) - var(--info-h) - 1rem) * 16 / 9));
    --side-w: max(0px, calc((100vw - var(--center-w)) / 2));
  }

  .stage-center {
    width: var(--center-w);
  }

  /* 窄屏侧栏宽度可能为 0，避免路数/联机按钮被 translate 移出视口 */
  .diff-picker {
    left: 10px;
    transform: none;
  }

  .diff-picker--right {
    left: auto;
    right: 10px;
    transform: none;
  }
}

@media (max-width: 860px) {
  :root {
    --header-h: 2.7rem;
    --info-h: 5.2rem;
  }

  .info-tip {
    display: none;
  }

  .info-bar {
    grid-template-columns: 1fr auto;
    align-items: start;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  .info-stats {
    display: none;
  }

  .info-left {
    gap: 0.35rem;
  }

  .name-field input {
    width: 5.2rem;
  }

  .bar-select-trigger {
    min-width: 4.2rem;
    padding-left: 0.55rem;
  }

  .bar-select-menu {
    left: 0;
  }

  .stage-badge {
    display: none;
  }

  .key-hints {
    right: 8px;
    bottom: 8px;
    gap: 0.32rem;
  }

  .key-label {
    min-width: 0;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
  }

  .couplet,
  .frame-notes {
    display: none;
  }
}

@media (max-height: 760px) {
  :root {
    --header-h: 2.6rem;
    --info-h: 4.4rem;
    --page-gap: 0.3rem;
  }

  .frame-notes,
  .bamboo,
  .plum,
  .frame-ornament {
    display: none;
  }
}

@media (max-width: 720px) {
  .game-header {
    grid-template-columns: auto 1fr auto;
  }

  .title-wrap {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lantern-body,
  .ink-clouds {
    animation: none;
  }
}

/* —— 潮纹对弈 —— */
.stage-wrap--duel {
  display: grid;
  place-items: center;
  container-type: size;
  background:
    radial-gradient(ellipse 70% 60% at 50% 40%, rgba(255, 255, 255, 0.5), transparent 70%),
    linear-gradient(165deg, rgba(232, 222, 198, 0.55), rgba(197, 217, 211, 0.88));
}

.stage-wrap--duel > .overlay {
  z-index: 20;
  background: rgba(26, 46, 42, 0.42);
  backdrop-filter: blur(2px);
  /* 遮罩不拦截底部信息栏与侧栏；仅卡片可点 */
  pointer-events: none;
}

.stage-wrap--duel > .overlay .overlay-card {
  animation: duel-overlay-in 0.28s ease both;
  pointer-events: auto;
}

@keyframes duel-overlay-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.duel-stage {
  width: min(84cqh, calc(96cqw - 10.5rem), 96%);
  max-width: 96%;
  max-height: 96%;
  aspect-ratio: 1;
  padding: clamp(0.28rem, 0.9vw, 0.5rem);
  touch-action: none;
  justify-self: center;
}

.duel-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  cursor: crosshair;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 12px 28px rgba(36, 61, 56, 0.14);
}

.duel-rival {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: min(14.5rem, 42%);
  padding: 0.4rem 0.7rem 0.4rem 0.4rem;
  border: 1px solid rgba(55, 42, 28, 0.14);
  border-radius: 999px 1rem 1rem 999px;
  background:
    linear-gradient(135deg, rgba(255, 252, 246, 0.92), rgba(232, 239, 236, 0.88));
  box-shadow: 0 8px 22px rgba(40, 52, 48, 0.1);
  pointer-events: none;
}

.duel-rival[hidden] {
  display: none !important;
}

.duel-chat {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: min(15.5rem, 42%);
  max-height: min(11.5rem, 34%);
  padding: 0.55rem 0.6rem 0.55rem;
  border: 1px solid rgba(55, 42, 28, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(165deg, rgba(255, 252, 246, 0.94), rgba(232, 239, 236, 0.9));
  box-shadow: 0 8px 22px rgba(40, 52, 48, 0.1);
  pointer-events: auto;
}

.duel-chat[hidden] {
  display: none !important;
}

.duel-chat-log {
  flex: 1 1 auto;
  min-height: 3.6rem;
  max-height: 7.2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding-right: 0.15rem;
  scrollbar-width: thin;
}

.duel-chat-line {
  margin: 0;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.45;
  letter-spacing: 0.02em;
  word-break: break-word;
}

.duel-chat-line.is-self {
  color: #2f4f4a;
}

.duel-chat-line.is-rival {
  color: #4a3a2a;
}

.duel-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  align-items: center;
}

.duel-chat-form input {
  width: 100%;
  min-width: 0;
  height: 1.9rem;
  padding: 0 0.55rem;
  border: 1px solid rgba(55, 42, 28, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 0.78rem;
  outline: none;
}

.duel-chat-form input:focus {
  border-color: rgba(77, 115, 107, 0.45);
  box-shadow: 0 0 0 2px rgba(77, 115, 107, 0.12);
}

.duel-chat-form .btn {
  min-height: 1.9rem;
  min-width: 3.1rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
}

.duel-rival-avatar {
  width: 2.35rem;
  height: 2.35rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgba(55, 42, 28, 0.16);
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9), transparent 55%),
    linear-gradient(145deg, #d7e8e3, #b7cfc8);
  color: #2f4f4a;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: var(--font-display, "Noto Serif SC", serif);
  font-size: 0.95rem;
  font-weight: 600;
}

.duel-rival-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.duel-rival-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  line-height: 1.2;
}

.duel-rival-meta strong {
  font-family: var(--font-display, "Noto Serif SC", serif);
  font-size: 0.92rem;
  font-weight: 600;
  color: #2a3834;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duel-rival-meta span {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: rgba(42, 56, 52, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duel-sheet {
  position: absolute;
  top: 50%;
  right: clamp(0.7rem, 2vw, 1.35rem);
  z-index: 8;
  transform: translateY(-54%);
  width: min(9.8rem, 26%);
  padding: 0.85rem 0.9rem 0.95rem;
  border: 1px solid rgba(90, 70, 45, 0.14);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(232, 241, 238, 0.78));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 14px 32px rgba(36, 61, 56, 0.12);
  backdrop-filter: blur(10px);
  pointer-events: none;
  animation: duel-sheet-in 0.4s ease both;
}

@keyframes duel-sheet-in {
  from {
    opacity: 0;
    transform: translateY(calc(-54% + 10px)) translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateY(-54%);
  }
}

.duel-sheet-kicker {
  margin: 0 0 0.65rem;
  color: var(--jade-deep);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
}

.duel-sheet-item {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.45rem 0;
  border-top: 1px solid rgba(36, 61, 56, 0.1);
}

.duel-sheet-item:first-of-type {
  border-top: none;
  padding-top: 0;
}

.duel-sheet-item span {
  color: var(--mute);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.duel-sheet-item strong {
  color: var(--ink-deep);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.duel-sheet-move-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-width: 0;
}

.duel-sheet-move-row strong {
  flex: 1 1 auto;
  min-width: 0;
}

.duel-sheet-my-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.32rem;
  margin-top: 0.35rem;
}

.duel-sheet-my-row[hidden] {
  display: none !important;
}

.duel-sheet-my-color {
  color: var(--ink-deep);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.duel-sheet-tag {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.14rem 0.42rem;
  border-radius: 999px;
  border: 1px solid rgba(77, 115, 107, 0.28);
  background: rgba(214, 230, 224, 0.75);
  color: var(--jade-deep);
  font-family: var(--font-body);
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.2;
  white-space: nowrap;
}

.duel-sheet-tag[data-side="self"] {
  border-color: rgba(77, 115, 107, 0.4);
  background: linear-gradient(135deg, rgba(77, 115, 107, 0.92), rgba(61, 94, 88, 0.95));
  color: #f3f7f5;
}

.duel-sheet-tag[data-side="rival"] {
  border-color: rgba(90, 70, 45, 0.22);
  background: rgba(255, 252, 246, 0.92);
  color: #6a5538;
}

.duel-sheet-tag[hidden] {
  display: none !important;
}

.duel-pass-toast {
  position: absolute;
  left: 50%;
  top: 1.1rem;
  z-index: 25;
  transform: translateX(-50%);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(90, 70, 45, 0.16);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(36, 61, 56, 0.14);
  color: var(--ink-deep);
  font-family: var(--font-display);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  pointer-events: none;
  animation: duel-pass-toast-in 0.28s ease both;
}

.duel-pass-toast[hidden] {
  display: none !important;
}

@keyframes duel-pass-toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}

.duel-sheet-item[hidden] {
  display: none !important;
}

.duel-online {
  /* 只占卡片区域；容器本身不接点击，避免误挡底栏/侧栏 */
  position: absolute;
  top: 50%;
  left: clamp(0.85rem, 2.8vw, 1.6rem);
  right: auto;
  bottom: auto;
  z-index: 21;
  display: block;
  width: min(320px, calc(100% - 1.7rem));
  max-width: 320px;
  padding: 0;
  margin: 0;
  background: transparent;
  transform: translateY(-50%);
  pointer-events: none;
  animation: duel-online-in 0.28s ease both;
}

.duel-online[hidden] {
  display: none !important;
}

.duel-online-card {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: stretch;
  gap: 0.55rem;
  width: 100%;
  padding: 1.5rem 1.5rem 1.35rem;
  border-radius: 24px;
  border: 1px solid rgba(36, 61, 56, 0.1);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 40px rgba(36, 61, 56, 0.12);
  text-align: center;
  pointer-events: auto;
  overflow: visible;
}

.duel-online-card .overlay-kicker {
  margin: 0;
}

.duel-online-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3.2vw, 1.85rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-deep);
}

.duel-online-lead {
  margin: 0 0 0.25rem;
  color: var(--mute);
  font-size: 0.88rem;
  line-height: 1.55;
  letter-spacing: 0.02em;
}

@keyframes duel-online-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes duel-online-card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.duel-online-card {
  animation: duel-online-card-in 0.28s ease both;
}

.duel-online-id,
.duel-online-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.28rem;
  margin: 0;
  text-align: left;
}

.duel-online-id span,
.duel-online-field span {
  color: var(--mute);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.duel-online-id strong {
  flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  padding: 0 1.85rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: var(--ink-deep);
  word-break: break-all;
  text-align: center;
  cursor: pointer;
}

.duel-online-id-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(90, 70, 45, 0.12);
  border-radius: 999px;
  background: rgba(214, 230, 224, 0.4);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.duel-online-id-row:hover,
.duel-online-id-row:focus-within {
  border-color: rgba(77, 115, 107, 0.4);
  background: rgba(243, 247, 245, 0.88);
  box-shadow: 0 0 0 3px rgba(111, 149, 140, 0.12);
}

.duel-online-id-row.is-copied {
  border-color: rgba(77, 115, 107, 0.45);
  background: rgba(214, 230, 224, 0.72);
}

.duel-online-copy-btn {
  appearance: none;
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--jade-deep);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.duel-online-copy-btn:hover,
.duel-online-copy-btn:focus-visible {
  background: rgba(77, 115, 107, 0.12);
  color: var(--ink-deep);
  outline: none;
}

.duel-online-copy-btn:active {
  transform: translateY(-50%) scale(0.94);
}

.duel-online-field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(90, 70, 45, 0.16);
  border-radius: 999px;
  background: rgba(214, 230, 224, 0.45);
  color: var(--ink);
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  outline: none;
  text-align: center;
}

.duel-online-field input:focus {
  border-color: rgba(77, 115, 107, 0.45);
  box-shadow: 0 0 0 3px rgba(111, 149, 140, 0.15);
}

.duel-online-card .btn {
  width: 100%;
  min-height: 2.85rem;
  margin-top: 0.15rem;
  font-size: 0.95rem;
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 7;
}

.duel-online-card .btn + .btn {
  margin-top: 0.2rem;
}

.duel-online-status {
  margin: 0.15rem 0 0;
  color: var(--mute);
  font-size: 0.8rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.stage-wrap--duel.is-online .duel-stage {
  width: min(84cqh, calc(96cqw - 10.5rem), 96%);
}

.invite-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(26, 46, 42, 0.35);
  backdrop-filter: blur(2px);
}

.invite-backdrop[hidden],
.invite-modal[hidden] {
  display: none !important;
}

#undo-modal[hidden],
#setting-confirm-modal[hidden] {
  display: none !important;
}

.invite-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 81;
  transform: translate(-50%, -50%);
  width: min(22rem, calc(100vw - 2rem));
  padding: 1.25rem 1.3rem 1.2rem;
  border: 1px solid rgba(90, 70, 45, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(232, 241, 238, 0.94));
  box-shadow: 0 22px 48px rgba(36, 61, 56, 0.18);
}

.invite-kicker {
  margin: 0 0 0.35rem;
  color: var(--jade-deep);
  font-family: var(--font-latin);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.invite-modal h2 {
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-deep);
}

.invite-modal p {
  margin: 0;
  color: var(--mute);
  font-size: 0.92rem;
  line-height: 1.55;
}

.invite-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
  margin-top: 1.1rem;
}

.invite-actions .btn {
  min-width: 5.2rem;
}

.stage-wrap--duel .key-hints {
  right: clamp(0.7rem, 2vw, 1.35rem);
  bottom: 0.7rem;
}

@media (max-width: 900px) {
  .duel-sheet {
    width: min(8.4rem, 24%);
    padding: 0.7rem 0.75rem;
  }

  .duel-sheet-item strong {
    font-size: 0.95rem;
  }

  .duel-online {
    left: 0.75rem;
    width: min(300px, calc(100% - 1.5rem));
  }

  .duel-online-card {
    padding: 1.25rem 1.2rem 1.15rem;
  }
}

@media (max-width: 760px) {
  .duel-stage {
    width: min(98cqw, 98cqh);
    max-width: 98%;
    max-height: 98%;
    padding: 0.22rem;
  }

  .duel-sheet {
    display: none;
  }

  .duel-rival {
    top: 0.65rem;
    left: 0.55rem;
    max-width: min(11.5rem, 58%);
    padding: 0.28rem 0.5rem 0.28rem 0.28rem;
    gap: 0.45rem;
  }

  .duel-chat {
    left: 0.55rem;
    bottom: 0.55rem;
    width: min(13.5rem, 62%);
    max-height: min(10rem, 30%);
    padding: 0.45rem 0.5rem;
  }

  .duel-chat-log {
    min-height: 2.8rem;
    max-height: 5.6rem;
  }

  .duel-chat-line {
    font-size: 0.72rem;
  }

  .duel-rival-avatar {
    width: 1.9rem;
    height: 1.9rem;
    font-size: 0.8rem;
  }

  .duel-rival-meta strong {
    font-size: 0.8rem;
  }

  .duel-rival-meta span {
    font-size: 0.66rem;
  }

  .duel-online {
    left: 50%;
    right: auto;
    width: min(300px, calc(100% - 1.5rem));
    transform: translate(-50%, -50%);
  }

  .stage-wrap--duel.is-online .duel-stage {
    width: min(98cqw, 98cqh);
  }

  .info-bar .btn {
    min-width: 3.8rem;
    padding: 0.28rem 0.55rem;
    font-size: 0.84rem;
  }
}

.overlay-card .btn + .btn {
  margin-top: 0.45rem;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  margin-top: 0.15rem;
}

.overlay-actions .btn {
  margin-top: 0;
  width: 100%;
}

.overlay-card .btn[hidden] {
  display: none !important;
}

.nigiri-panel {
  margin: 0.35rem 0 0.55rem;
  text-align: center;
}

.nigiri-panel[hidden] {
  display: none !important;
}

.nigiri-rule {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--ink, #1c2430) 72%, transparent);
}

.nigiri-hold {
  display: grid;
  gap: 0.65rem;
}

.nigiri-hold[hidden] {
  display: none !important;
}

.nigiri-hold-actions {
  display: grid;
}

.nigiri-grip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.nigiri-grip-btn {
  appearance: none;
  min-height: 2.15rem;
  border: 1px solid rgba(90, 70, 45, 0.16);
  border-radius: 10px;
  background: rgba(214, 230, 224, 0.45);
  color: var(--ink-deep);
  font: inherit;
  font-family: var(--font-display);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.nigiri-grip-btn:hover,
.nigiri-grip-btn:focus-visible {
  border-color: rgba(77, 115, 107, 0.45);
  background: rgba(243, 247, 245, 0.92);
  outline: none;
}

.nigiri-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.nigiri-btn {
  min-height: 2.7rem;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
}

.nigiri-reveal[hidden] {
  display: none !important;
}

.nigiri-stones {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.28rem;
  max-width: 14rem;
  margin: 0.2rem auto 0.7rem;
  min-height: 2.2rem;
}

.nigiri-stone {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #f7f4ee, #d8d2c6 45%, #9a958c);
  box-shadow: 0 1px 2px rgba(28, 36, 48, 0.28);
  animation: nigiri-pop 0.35s ease both;
}

.nigiri-result {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: color-mix(in srgb, var(--ink, #1c2430) 88%, transparent);
}

@keyframes nigiri-pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
