.xq-app {
  --xq-ink: #eef7ff;
  --xq-muted: #a7bdd3;
  --xq-subtle: #7896b4;
  --xq-sea-950: #020817;
  --xq-sea-900: #061426;
  --xq-sea-850: #0a1c35;
  --xq-sea-800: #0c2544;
  --xq-indigo: #4f46e5;
  --xq-blue: #2563eb;
  --xq-cyan: #22d3ee;
  --xq-cyan-soft: rgba(34, 211, 238, 0.2);
  --xq-border: rgba(143, 194, 232, 0.2);
  --xq-border-strong: rgba(103, 232, 249, 0.42);
  --xq-panel: rgba(7, 25, 48, 0.82);
  --xq-panel-solid: #091b32;
  --xq-red: #ff6b6b;
  --xq-red-dark: #8f1d2c;
  --xq-black-piece: #16263b;
  --xq-gold: #f7cf72;
  --xq-success: #34d399;
  --xq-danger: #fb7185;
  --xq-wood-frame-dark: #3b1d0d;
  --xq-wood-frame: #6d3818;
  --xq-wood-frame-light: #a9692f;
  --xq-wood-board: #d7a354;
  --xq-wood-board-light: #edc477;
  --xq-wood-line: #5b2d17;
  --xq-piece-ivory: #f6e7c0;
  --xq-radius: 22px;
  --xq-radius-sm: 14px;
  --xq-shadow: 0 24px 70px rgba(0, 6, 20, 0.38);
  width: 100%;
  max-width: 1180px;
  min-width: 0;
  margin-inline: auto;
  color: var(--xq-ink);
  color-scheme: dark;
  font-family: inherit;
  line-height: 1.5;
  isolation: isolate;
}

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

.xq-app :where(button, select, input, textarea) {
  font: inherit;
}

.xq-app :where(button, select, a):focus-visible {
  outline: 3px solid rgba(103, 232, 249, 0.92);
  outline-offset: 3px;
}

.xq-app :where(button, select)[disabled],
.xq-app :where(button, select)[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.48;
  filter: saturate(0.65);
}

.xq-hero {
  position: relative;
  display: block;
  height: 150px;
  min-height: 150px;
  margin-bottom: clamp(16px, 2.2vw, 24px);
  overflow: hidden;
  border: 1px solid rgba(125, 211, 252, 0.25);
  border-radius: clamp(18px, 2.2vw, 24px);
  background:
    radial-gradient(circle at 78% 18%, rgba(34, 211, 238, 0.25), transparent 34%),
    linear-gradient(135deg, #061326 0%, #0b2450 52%, #292165 100%);
  box-shadow: var(--xq-shadow);
}

.xq-hero::before,
.xq-hero::after {
  position: absolute;
  z-index: 1;
  content: "";
  pointer-events: none;
}

.xq-hero::before {
  inset: 0;
  background:
    linear-gradient(90deg, rgba(2, 8, 23, 0.93) 0%, rgba(4, 16, 38, 0.76) 44%, rgba(9, 22, 57, 0.2) 78%, rgba(9, 22, 57, 0.08) 100%),
    linear-gradient(0deg, rgba(2, 8, 23, 0.64), transparent 58%);
}

.xq-hero::after {
  width: 190px;
  height: 190px;
  right: -62px;
  bottom: -122px;
  border: 1px solid rgba(103, 232, 249, 0.22);
  border-radius: 50%;
  box-shadow:
    0 0 0 34px rgba(79, 70, 229, 0.08),
    0 0 0 68px rgba(34, 211, 238, 0.045);
}

.xq-hero__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.62;
  filter: saturate(0.92) contrast(1.07);
}

.xq-hero__image :where(img, picture) {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.xq-hero__content {
  position: relative;
  z-index: 2;
  align-self: center;
  width: 100%;
  min-width: 0;
  padding: 16px clamp(320px, 34vw, 400px) 16px clamp(20px, 3.4vw, 40px);
}

.xq-identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 5px;
  padding: 4px 10px;
  border: 1px solid rgba(103, 232, 249, 0.35);
  border-radius: 999px;
  background: rgba(4, 20, 42, 0.66);
  color: #c8f6ff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
}

.xq-identity::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--xq-cyan);
  box-shadow: 0 0 14px var(--xq-cyan);
  content: "";
}

.xq-hero h1,
.xq-hero h2 {
  max-width: 18ch;
  margin: 0;
  color: #fff;
  font-size: clamp(1.65rem, 2.5vw, 1.875rem);
  font-weight: 850;
  line-height: 1.04;
  letter-spacing: -0.04em;
  text-wrap: balance;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.38);
}

.xq-hero p {
  max-width: 58ch;
  margin: 7px 0 0;
  color: rgba(230, 245, 255, 0.86);
  font-size: clamp(0.78rem, 1.15vw, 0.92rem);
  line-height: 1.45;
}

.xq-hero .xq-hero-eyebrow {
  display: none;
}

.xq-hero .xq-hero-subtitle {
  max-width: 58ch;
  margin-top: 6px;
  overflow: hidden;
  font-size: 0.8125rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xq-profile-strip {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: clamp(20px, 3.4vw, 40px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-self: center;
  width: clamp(270px, 29vw, 340px);
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 15px;
  background:
    linear-gradient(135deg, rgba(15, 51, 88, 0.72), rgba(7, 20, 45, 0.76));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.08),
    0 12px 30px rgba(0, 7, 24, 0.2);
  backdrop-filter: blur(14px);
  transform: translateY(-50%);
}

.xq-profile-strip > span {
  display: grid;
  min-width: 0;
  gap: 1px;
  padding: 0 10px;
  color: var(--xq-muted);
  font-size: 0.66rem;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}

.xq-profile-strip > span + span {
  border-left: 1px solid rgba(143, 194, 232, 0.19);
}

.xq-profile-strip strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-overflow: ellipsis;
}

.xq-profile-strip small {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--xq-subtle);
  font-size: 0.61rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xq-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(286px, 340px);
  align-items: start;
  gap: clamp(16px, 2.2vw, 26px);
  min-width: 0;
}

.xq-main,
.xq-sidebar {
  min-width: 0;
}

.xq-main,
.xq-sidebar {
  display: grid;
  gap: clamp(14px, 2vw, 20px);
}

.xq-sidebar {
  position: sticky;
  top: 20px;
}

.xq-panel {
  min-width: 0;
  padding: clamp(16px, 2.4vw, 24px);
  overflow: hidden;
  border: 1px solid var(--xq-border);
  border-radius: var(--xq-radius);
  background:
    linear-gradient(145deg, rgba(15, 42, 73, 0.8), rgba(5, 19, 38, 0.9)),
    var(--xq-panel);
  box-shadow: 0 16px 44px rgba(0, 8, 27, 0.2);
  backdrop-filter: blur(18px);
}

.xq-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  color: #f7fbff;
  font-size: 0.94rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.xq-panel-title::after {
  width: 34px;
  height: 2px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--xq-cyan), transparent);
  content: "";
}

.xq-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  margin: 0 0 15px;
}

.xq-panel-heading h2 {
  min-width: 0;
  margin: 0;
  color: #f7fbff;
  font-size: 1rem;
  font-weight: 780;
  line-height: 1.3;
}

.xq-panel-heading small {
  flex: 0 0 auto;
  padding-top: 2px;
  color: var(--xq-subtle);
  font-size: 0.7rem;
  line-height: 1.35;
  text-align: right;
}

.xq-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.xq-field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.xq-field > :where(label, span, strong):first-child {
  color: var(--xq-muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.xq-select,
.xq-field select {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 38px 0 12px;
  border: 1px solid rgba(148, 193, 225, 0.25);
  border-radius: 12px;
  background-color: rgba(2, 14, 31, 0.68);
  color: var(--xq-ink);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.xq-select:hover,
.xq-field select:hover {
  border-color: rgba(103, 232, 249, 0.45);
}

.xq-select:focus,
.xq-field select:focus {
  border-color: var(--xq-cyan);
  background-color: rgba(4, 24, 49, 0.92);
  box-shadow: 0 0 0 4px var(--xq-cyan-soft);
}

.xq-select option,
.xq-field select option {
  background: var(--xq-sea-900);
  color: var(--xq-ink);
}

.xq-segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  min-width: 0;
  padding: 4px;
  border: 1px solid rgba(148, 193, 225, 0.2);
  border-radius: 13px;
  background: rgba(2, 12, 27, 0.62);
}

.xq-segment,
.xq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  min-width: 0;
  padding: 9px 14px;
  border: 1px solid rgba(145, 192, 225, 0.25);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(23, 54, 89, 0.9), rgba(9, 29, 55, 0.9));
  color: #eaf7ff;
  font-size: 0.86rem;
  font-weight: 720;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition:
    transform 140ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
  touch-action: manipulation;
}

.xq-segment {
  min-height: 34px;
  padding: 7px 9px;
  border-color: transparent;
  background: transparent;
  color: var(--xq-muted);
  font-size: 0.78rem;
}

.xq-segment[aria-pressed="true"],
.xq-segment.is-active,
.xq-btn[aria-pressed="true"],
.xq-btn.is-active {
  border-color: rgba(103, 232, 249, 0.5);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.75), rgba(79, 70, 229, 0.82));
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.22), inset 0 1px rgba(255, 255, 255, 0.16);
}

.xq-btn--primary,
.xq-btn.is-primary,
.xq-btn[data-variant="primary"] {
  border-color: rgba(103, 232, 249, 0.5);
  background: linear-gradient(135deg, #1773df, #5146df);
  color: #fff;
  box-shadow: 0 11px 26px rgba(37, 99, 235, 0.26);
}

.xq-btn--danger,
.xq-btn.is-danger,
.xq-btn[data-variant="danger"] {
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(125, 29, 53, 0.38);
  color: #ffd6dd;
}

.xq-btn--ghost,
.xq-btn.is-ghost,
.xq-btn[data-variant="ghost"] {
  background: rgba(6, 22, 43, 0.45);
  color: var(--xq-muted);
}

.xq-btn:active:not(:disabled),
.xq-segment:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.xq-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.xq-actions > .xq-btn:first-child:last-child {
  grid-column: 1 / -1;
}

.xq-competition-notice {
  display: grid;
  gap: 11px;
  margin: 12px 0 0;
  padding: 14px 15px;
  border: 1px solid rgba(247, 207, 114, 0.36);
  border-radius: 15px;
  background:
    radial-gradient(circle at 96% 0%, rgba(247, 207, 114, 0.12), transparent 44%),
    linear-gradient(135deg, rgba(86, 57, 19, 0.3), rgba(5, 20, 40, 0.72));
  color: #fff6d9;
  box-shadow: inset 0 1px rgba(255, 246, 217, 0.07);
}

.xq-competition-notice :where(h2, h3, strong) {
  margin: 0;
  color: #ffe59b;
  font-size: 0.9rem;
  line-height: 1.35;
}

.xq-competition-notice :where(p, small) {
  margin: 0;
  color: #ccbfa0;
  font-size: 0.76rem;
  line-height: 1.6;
}

.xq-competition-notice :where(.xq-actions, .xq-resign-confirm, [data-resign-confirm]) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

.xq-competition-notice :where(.xq-actions, .xq-resign-confirm, [data-resign-confirm]) .xq-btn {
  flex: 1 1 112px;
}

.xq-board-shell {
  position: relative;
  min-width: 0;
  padding: clamp(9px, 2vw, 18px);
  overflow: hidden;
  border: 1px solid rgba(209, 150, 79, 0.72);
  border-radius: clamp(18px, 2.6vw, 28px);
  background:
    linear-gradient(115deg, rgba(255, 222, 158, 0.12), transparent 28%, rgba(42, 17, 6, 0.2) 72%),
    repeating-linear-gradient(4deg, rgba(255, 224, 167, 0.035) 0 1px, transparent 1px 7px),
    linear-gradient(145deg, var(--xq-wood-frame-light), var(--xq-wood-frame) 42%, var(--xq-wood-frame-dark));
  box-shadow:
    0 24px 70px rgba(0, 4, 18, 0.42),
    0 0 0 1px rgba(34, 211, 238, 0.12),
    inset 0 1px rgba(255, 235, 194, 0.22),
    inset 0 -8px 22px rgba(34, 13, 4, 0.24);
}

.xq-board-shell::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(255, 235, 196, 0.1), transparent 32%),
    radial-gradient(ellipse at 18% 54%, rgba(61, 27, 9, 0.17), transparent 17%),
    radial-gradient(ellipse at 84% 24%, rgba(255, 212, 139, 0.08), transparent 19%);
  content: "";
  pointer-events: none;
}

.xq-side {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  color: rgba(255, 233, 190, 0.9);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-shadow: 0 1px 2px rgba(40, 14, 3, 0.72);
}

.xq-side--top {
  padding-bottom: 9px;
}

.xq-side--bottom {
  padding-top: 9px;
}

.xq-board-stage {
  position: relative;
  width: min(100%, 720px);
  aspect-ratio: 9 / 10;
  margin-inline: auto;
  overflow: hidden;
  border: clamp(4px, 0.8vw, 8px) solid var(--xq-wood-frame-dark);
  border-radius: clamp(12px, 2vw, 20px);
  background:
    radial-gradient(ellipse at 12% 30%, rgba(100, 52, 20, 0.13) 0 2%, transparent 2.6%),
    radial-gradient(ellipse at 76% 73%, rgba(96, 48, 18, 0.12) 0 1.7%, transparent 2.4%),
    repeating-linear-gradient(3deg, rgba(84, 44, 18, 0.07) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(88deg, rgba(255, 237, 184, 0.045) 0 1px, transparent 1px 18px),
    linear-gradient(135deg, var(--xq-wood-board-light) 0%, var(--xq-wood-board) 46%, #c58b3e 100%);
  background-size: auto, auto, auto, auto, auto;
  box-shadow:
    0 0 0 2px var(--xq-wood-frame-light),
    0 8px 20px rgba(38, 15, 4, 0.4),
    inset 0 0 0 2px rgba(255, 231, 178, 0.34),
    inset 0 0 42px rgba(92, 45, 13, 0.18);
  container-type: inline-size;
}

.xq-board-stage::after {
  position: absolute;
  z-index: 0;
  inset: 3px;
  border: 1px solid rgba(78, 37, 16, 0.28);
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.xq-board-lines {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: rgba(79, 39, 19, 0.82);
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(255, 227, 165, 0.24));
}

.xq-board-lines :where(line, path, polyline, polygon, circle) {
  stroke: currentColor;
  vector-effect: non-scaling-stroke;
}

.xq-board-lines text {
  fill: rgba(76, 35, 15, 0.86);
  font-family: "STKaiti", "KaiTi", "Noto Serif SC", serif;
  letter-spacing: 0.22em;
}

.xq-board-grid {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(0, 1fr));
}

.xq-square {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.xq-square::before {
  position: absolute;
  z-index: 0;
  width: min(38%, 22px);
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  content: "";
  transform: scale(0.6);
  opacity: 0;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.xq-square.legal-target::before,
.xq-square.is-target::before,
.xq-square:has(.xq-piece.legal-target)::before,
.xq-square:has(.xq-piece.is-target)::before {
  border-color: rgba(230, 252, 255, 0.96);
  background: rgba(5, 76, 113, 0.86);
  box-shadow:
    0 0 0 2px rgba(4, 42, 68, 0.5),
    0 0 13px rgba(11, 74, 109, 0.5);
  transform: scale(1);
  opacity: 1;
}

.xq-square:focus-visible {
  z-index: 5;
  outline-offset: -3px;
}

.xq-piece {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(78%, 4rem);
  max-width: 4rem;
  aspect-ratio: 1;
  place-items: center;
  border: clamp(1px, 0.45cqw, 3px) solid currentColor;
  border-radius: 50%;
  font-family: "STKaiti", "KaiTi", "Noto Serif SC", serif;
  font-size: clamp(0.72rem, 4.1cqw, 1.58rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px rgba(255, 250, 230, 0.38);
  box-shadow:
    0 5px 11px rgba(57, 25, 7, 0.42),
    inset 0 0 0 2px rgba(255, 250, 224, 0.38),
    inset 0 -5px 10px rgba(86, 45, 17, 0.16);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    filter 150ms ease;
  transform: translateZ(0);
  user-select: none;
}

.xq-piece.red,
.xq-piece.is-red {
  border-color: #9b2727;
  background:
    radial-gradient(circle at 34% 28%, #fff8df 0%, var(--xq-piece-ivory) 48%, #c99755 100%);
  color: #8e181f;
}

.xq-piece.black,
.xq-piece.is-black {
  border-color: #32271e;
  background:
    radial-gradient(circle at 34% 28%, #fff6dc 0%, #ead7ac 48%, #b88042 100%);
  color: #17130f;
}

.xq-piece.selected,
.xq-piece.is-selected {
  transform: translateY(-4%) scale(1.1);
  filter: brightness(1.12);
  box-shadow:
    0 0 0 3px #e9fdff,
    0 0 0 7px rgba(4, 77, 117, 0.88),
    0 10px 18px rgba(53, 24, 8, 0.5);
}

.xq-piece.last-move,
.xq-piece.is-last {
  box-shadow:
    0 0 0 3px rgba(16, 83, 123, 0.92),
    0 0 0 6px rgba(224, 250, 255, 0.5),
    0 7px 15px rgba(51, 22, 6, 0.46);
}

.xq-piece.in-check,
.xq-piece.is-check {
  border-color: #fff;
  box-shadow:
    0 0 0 3px rgba(251, 113, 133, 0.98),
    0 0 24px rgba(251, 113, 133, 0.72),
    0 7px 15px rgba(51, 22, 6, 0.48);
  animation: xq-check-pulse 1.15s ease-in-out infinite alternate;
}

.xq-piece.legal-target,
.xq-piece.is-target {
  filter: brightness(1.12);
}

.xq-square:active:not(:disabled) .xq-piece {
  transform: scale(0.94);
}

@keyframes xq-check-pulse {
  to {
    box-shadow:
      0 0 0 4px rgba(251, 113, 133, 0.82),
      0 0 32px rgba(251, 113, 133, 0.88),
      0 7px 15px rgba(0, 4, 16, 0.5);
  }
}

.xq-river-label {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  display: flex;
  justify-content: space-around;
  width: 72%;
  color: rgba(72, 31, 13, 0.86);
  font-family: "STKaiti", "KaiTi", "Noto Serif SC", serif;
  font-size: clamp(0.82rem, 4.4cqw, 1.7rem);
  letter-spacing: 0.3em;
  font-weight: 800;
  text-shadow: 0 1px rgba(255, 226, 161, 0.45);
  pointer-events: none;
  transform: translate(-50%, -50%);
  user-select: none;
}

.xq-status {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 14px 15px 14px 42px;
  border: 1px solid rgba(103, 232, 249, 0.22);
  border-radius: 15px;
  background: rgba(3, 18, 38, 0.62);
  color: var(--xq-ink);
}

.xq-status::before {
  position: absolute;
  top: 19px;
  left: 17px;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  background: var(--xq-cyan);
  box-shadow: 0 0 13px rgba(34, 211, 238, 0.72);
  content: "";
}

.xq-status strong {
  font-size: 0.94rem;
}

.xq-status small,
.xq-status p {
  margin: 0;
  color: var(--xq-muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.xq-status.is-thinking::before,
.xq-status[data-state="thinking"]::before {
  background: var(--xq-gold);
  box-shadow: 0 0 13px rgba(247, 207, 114, 0.7);
  animation: xq-thinking 900ms ease-in-out infinite alternate;
}

.xq-status.is-win::before,
.xq-status[data-state="win"]::before {
  background: var(--xq-success);
  box-shadow: 0 0 13px rgba(52, 211, 153, 0.72);
}

.xq-status.is-loss::before,
.xq-status.is-check::before,
.xq-status[data-state="loss"]::before,
.xq-status[data-state="check"]::before {
  background: var(--xq-danger);
  box-shadow: 0 0 13px rgba(251, 113, 133, 0.75);
}

@keyframes xq-thinking {
  to { opacity: 0.4; }
}

.xq-rules {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.xq-rules-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px 9px 12px;
  border: 1px solid rgba(143, 194, 232, 0.22);
  border-radius: 12px;
  background: rgba(3, 18, 38, 0.58);
  color: #eaf7ff;
  font-size: 0.8rem;
  font-weight: 720;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.xq-rules-toggle[aria-expanded="true"] {
  border-color: rgba(103, 232, 249, 0.38);
  background: rgba(11, 42, 72, 0.72);
  color: #fff;
}

.xq-rules-toggle > span:first-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.xq-rules-toggle > span:first-child strong {
  color: #f3faff;
  font-size: 0.82rem;
  line-height: 1.3;
}

.xq-rules-toggle > span:first-child small {
  overflow: hidden;
  color: var(--xq-subtle);
  font-size: 0.66rem;
  font-weight: 560;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xq-rules-toggle > span:last-child {
  display: grid;
  width: 28px;
  flex: 0 0 28px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(103, 232, 249, 0.24);
  border-radius: 50%;
  background: rgba(3, 15, 32, 0.44);
  color: #baf5ff;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
}

.xq-rules-body {
  padding: 12px 13px;
  border: 1px solid rgba(143, 194, 232, 0.15);
  border-radius: 12px;
  background: rgba(2, 14, 30, 0.38);
  color: var(--xq-muted);
  font-size: 0.76rem;
  line-height: 1.65;
}

.xq-rules-body[hidden] {
  display: none;
}

.xq-rules-body ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.45rem;
}

.xq-rules-body li::marker {
  color: var(--xq-cyan);
  font-weight: 800;
}

.xq-rule-note {
  margin: 10px 0 0;
  padding: 9px 10px;
  border-left: 3px solid rgba(247, 207, 114, 0.78);
  border-radius: 0 9px 9px 0;
  background: rgba(86, 57, 19, 0.22);
  color: #d8caa9;
}

.xq-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.xq-stat {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid rgba(149, 200, 232, 0.19);
  border-radius: 14px;
  background: rgba(3, 17, 35, 0.5);
}

.xq-stat :where(span, small) {
  display: block;
  color: var(--xq-subtle);
  font-size: 0.7rem;
  line-height: 1.3;
}

.xq-stat :where(strong, b) {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: #fff;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xq-moves,
.xq-history,
.xq-results-list {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.xq-moves {
  max-height: 290px;
  padding-right: 4px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(103, 232, 249, 0.35) transparent;
  scrollbar-width: thin;
}

.xq-move-row,
.xq-history-item,
.xq-result-item {
  display: grid;
  grid-template-columns: minmax(30px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(143, 194, 232, 0.14);
  border-radius: 12px;
  background: rgba(2, 14, 30, 0.46);
  color: var(--xq-muted);
  font-size: 0.77rem;
}

.xq-move-row > :nth-child(2),
.xq-history-item > :nth-child(2),
.xq-result-item > :nth-child(2) {
  min-width: 0;
  overflow: hidden;
  color: #e9f7ff;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xq-move-row.is-current,
.xq-move-row[aria-current="true"] {
  border-color: rgba(103, 232, 249, 0.42);
  background: rgba(37, 99, 235, 0.16);
  color: #c9f7ff;
}

.xq-result-item[data-result="win"] > :last-child,
.xq-history-item[data-result="win"] > :last-child {
  color: var(--xq-success);
}

.xq-result-item[data-result="loss"] > :last-child,
.xq-history-item[data-result="loss"] > :last-child {
  color: var(--xq-danger);
}

.xq-result-item[data-result="draw"] > :last-child,
.xq-history-item[data-result="draw"] > :last-child {
  color: var(--xq-gold);
}

.xq-result-item[data-result="local"] > :last-child,
.xq-history-item[data-result="local"] > :last-child {
  color: var(--xq-cyan);
}

.xq-community-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 1fr);
  align-items: start;
  gap: clamp(14px, 2vw, 20px);
  min-width: 0;
  margin-top: clamp(14px, 2vw, 20px);
}

.xq-community-grid > * {
  min-width: 0;
}

.xq-tabs {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px;
  max-width: 100%;
  margin: 0 0 13px;
  padding: 3px;
  border: 1px solid rgba(143, 194, 232, 0.18);
  border-radius: 12px;
  background: rgba(2, 12, 27, 0.56);
}

.xq-tab {
  min-width: 64px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--xq-muted);
  font-size: 0.75rem;
  font-weight: 720;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.xq-tab[aria-selected="true"],
.xq-tab.is-active {
  border-color: rgba(103, 232, 249, 0.4);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.72), rgba(79, 70, 229, 0.78));
  color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.2);
}

.xq-leaderboard {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.xq-rank-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(143, 194, 232, 0.14);
  border-radius: 12px;
  background: rgba(2, 14, 30, 0.46);
}

.xq-rank-number {
  display: grid;
  width: 30px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(143, 194, 232, 0.22);
  border-radius: 50%;
  background: rgba(12, 43, 75, 0.6);
  color: #d9efff;
  font-size: 0.73rem;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
}

.xq-rank-row:nth-child(1) .xq-rank-number {
  border-color: rgba(247, 207, 114, 0.72);
  background: rgba(130, 88, 24, 0.56);
  color: #fff0b7;
}

.xq-rank-row:nth-child(2) .xq-rank-number {
  border-color: rgba(198, 220, 235, 0.56);
  color: #eef8ff;
}

.xq-rank-row:nth-child(3) .xq-rank-number {
  border-color: rgba(196, 126, 69, 0.66);
  background: rgba(105, 54, 25, 0.46);
  color: #ffd4ad;
}

.xq-rank-player,
.xq-rank-rating {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.xq-rank-player strong,
.xq-rank-rating strong {
  min-width: 0;
  overflow: hidden;
  color: #eef8ff;
  font-size: 0.8rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xq-rank-player small,
.xq-rank-rating small {
  overflow: hidden;
  color: var(--xq-subtle);
  font-size: 0.66rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xq-rank-rating {
  justify-items: end;
  text-align: right;
}

.xq-rank-rating strong {
  color: #baf5ff;
  font-variant-numeric: tabular-nums;
}

.xq-sync-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(251, 113, 133, 0.42);
  border-radius: 11px;
  background: rgba(117, 27, 50, 0.27);
  color: #ffd8df;
  font-size: 0.74rem;
  line-height: 1.55;
}

.xq-sync-error p {
  flex: 1 1 180px;
  margin: 0;
}

.xq-sync-error .xq-btn {
  flex: 0 0 auto;
}

.xq-sync-error:empty,
.xq-sync-error[hidden] {
  display: none;
}

.xq-note,
.xq-empty {
  margin: 0;
  color: var(--xq-subtle);
  font-size: 0.76rem;
  line-height: 1.7;
}

.xq-note {
  padding: 11px 13px;
  border: 1px dashed rgba(143, 194, 232, 0.24);
  border-radius: 12px;
  background: rgba(2, 14, 30, 0.3);
}

.xq-empty {
  padding: 22px 14px;
  border: 1px dashed rgba(143, 194, 232, 0.18);
  border-radius: 13px;
  text-align: center;
}

.xq-toast {
  position: fixed;
  z-index: 1000;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(360px, calc(100vw - 32px));
  padding: 13px 16px;
  border: 1px solid rgba(103, 232, 249, 0.38);
  border-radius: 14px;
  background: rgba(4, 19, 39, 0.94);
  color: #effbff;
  font-size: 0.82rem;
  line-height: 1.5;
  box-shadow: 0 18px 55px rgba(0, 4, 18, 0.48);
  backdrop-filter: blur(18px);
}

.xq-toast[hidden] {
  display: none;
}

.xq-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (hover: hover) and (pointer: fine) {
  .xq-btn:hover:not(:disabled),
  .xq-segment:hover:not(:disabled),
  .xq-tab:hover:not(:disabled),
  .xq-rules-toggle:hover:not(:disabled) {
    border-color: rgba(103, 232, 249, 0.5);
    background-color: rgba(28, 73, 112, 0.86);
    color: #fff;
    transform: translateY(-1px);
  }

  .xq-square:hover:not(:disabled) .xq-piece {
    transform: translateY(-3%) scale(1.055);
    filter: brightness(1.08);
  }

  .xq-square:hover:not(:disabled) .xq-piece.selected,
  .xq-square:hover:not(:disabled) .xq-piece.is-selected {
    transform: translateY(-5%) scale(1.12);
  }

  .xq-move-row:hover,
  .xq-history-item:hover,
  .xq-result-item:hover,
  .xq-rank-row:hover {
    border-color: rgba(103, 232, 249, 0.3);
    background: rgba(12, 43, 75, 0.56);
  }
}

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

  .xq-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .xq-sidebar > .xq-panel:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .xq-moves {
    max-height: 230px;
  }
}

@media (max-width: 720px) {
  .xq-hero {
    height: 132px;
    min-height: 132px;
  }

  .xq-hero::before {
    background:
      linear-gradient(0deg, rgba(2, 8, 23, 0.94) 0%, rgba(4, 16, 38, 0.7) 72%, rgba(9, 22, 57, 0.2) 100%);
  }

  .xq-hero__image {
    object-position: 64% center;
    opacity: 0.54;
  }

  .xq-hero__content {
    position: absolute;
    top: 15px;
    right: 0;
    left: 0;
    padding: 0 18px;
  }

  .xq-identity,
  .xq-hero .xq-hero-eyebrow,
  .xq-hero .xq-hero-subtitle {
    display: none;
  }

  .xq-hero h1,
  .xq-hero h2 {
    max-width: 100%;
    font-size: clamp(1.45rem, 6.2vw, 1.875rem);
    line-height: 1;
  }

  .xq-profile-strip {
    top: auto;
    right: auto;
    bottom: 10px;
    left: 18px;
    width: min(390px, 100%);
    max-width: calc(100% - 36px);
    padding: 6px 7px;
    border-radius: 12px;
    transform: none;
  }

  .xq-profile-strip > span {
    padding-inline: 7px;
    font-size: 0.61rem;
  }

  .xq-profile-strip strong {
    font-size: 0.86rem;
  }

  .xq-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .xq-controls > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .xq-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }

  .xq-sidebar > .xq-panel:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .xq-community-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 480px) {
  .xq-hero {
    height: 130px;
    min-height: 130px;
    border-radius: 17px;
  }

  .xq-hero__content {
    top: 14px;
    padding: 0 14px;
  }

  .xq-profile-strip {
    left: 14px;
    max-width: calc(100% - 28px);
  }

  .xq-hero h1,
  .xq-hero h2 {
    font-size: clamp(1.34rem, 6.8vw, 1.75rem);
  }

  .xq-identity {
    margin-bottom: 3px;
    padding: 3px 8px;
    font-size: 0.61rem;
  }

  .xq-hero .xq-hero-eyebrow {
    margin-bottom: 2px;
    font-size: 0.6rem;
    letter-spacing: 0.12em;
  }

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

  .xq-panel-heading {
    gap: 9px;
    margin-bottom: 12px;
  }

  .xq-panel-heading h2 {
    font-size: 0.92rem;
  }

  .xq-panel-heading small {
    max-width: 45%;
    font-size: 0.65rem;
  }

  .xq-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 11px;
  }

  .xq-controls > :last-child:nth-child(odd) {
    grid-column: auto;
  }

  .xq-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .xq-stat:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .xq-board-shell {
    padding: 7px;
    border-radius: 16px;
  }

  .xq-board-stage {
    border-radius: 11px;
  }

  .xq-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .xq-actions > .xq-btn:first-child:last-child {
    grid-column: auto;
  }

  .xq-competition-notice :where(.xq-actions, .xq-resign-confirm, [data-resign-confirm]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .xq-btn {
    min-height: 44px;
  }

  .xq-move-row,
  .xq-history-item,
  .xq-result-item {
    gap: 7px;
    padding: 9px;
    font-size: 0.72rem;
  }

  .xq-tabs {
    display: grid;
    width: 100%;
  }

  .xq-tab {
    min-width: 0;
    padding-inline: 7px;
  }

  .xq-rank-row {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 9px;
  }

  .xq-rank-number {
    width: 28px;
  }
}

@media (max-width: 350px) {
  .xq-hero {
    height: 128px;
    min-height: 128px;
  }

  .xq-hero__content {
    top: 13px;
    padding: 0 12px;
  }

  .xq-hero h1,
  .xq-hero h2 {
    font-size: 1.28rem;
  }

  .xq-profile-strip {
    left: 12px;
    max-width: calc(100% - 24px);
    padding-inline: 4px;
  }

  .xq-profile-strip > span {
    padding-inline: 4px;
    font-size: 0.57rem;
  }

  .xq-profile-strip strong {
    font-size: 0.78rem;
  }

  .xq-layout,
  .xq-main,
  .xq-sidebar {
    gap: 12px;
  }

  .xq-panel {
    padding: 12px;
  }

  .xq-board-shell {
    padding: 5px;
  }

  .xq-piece {
    width: 82%;
    font-size: clamp(0.68rem, 4.3cqw, 0.9rem);
  }

  .xq-segment {
    padding-inline: 5px;
    font-size: 0.7rem;
  }

  .xq-stat {
    padding: 10px;
  }

  .xq-rank-row {
    grid-template-columns: 26px minmax(0, 1fr) auto;
    gap: 6px;
    padding-inline: 7px;
  }

  .xq-rank-number {
    width: 25px;
    font-size: 0.66rem;
  }

  .xq-rank-player strong,
  .xq-rank-rating strong {
    font-size: 0.74rem;
  }

  .xq-rank-player small,
  .xq-rank-rating small {
    font-size: 0.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .xq-app *,
  .xq-app *::before,
  .xq-app *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .xq-app {
    color: #111827;
  }

  .xq-hero,
  .xq-panel,
  .xq-board-shell {
    box-shadow: none;
  }

  .xq-controls,
  .xq-actions,
  .xq-toast {
    display: none !important;
  }
}
