.chess-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: #eef6ef;
  --chess-gold: #d6aa55;
  --chess-ink: #111827;
  --chess-panel: rgba(8, 13, 12, 0.86);
  --chess-panel-soft: rgba(255, 255, 255, 0.055);
  --chess-border: rgba(255, 255, 255, 0.105);
  --chess-muted: rgba(238, 246, 239, 0.62);
  --chess-green: #0d3a24;
  --chess-green-deep: #061a12;
  padding: 0;
  border-radius: 14px;
  background: #07090c;
  overflow: hidden;
}

.chess-layout,
.chess-meta-row,
.chess-hero-actions {
  display: grid;
  gap: 12px;
}

.chess-hero {
  position: relative;
  padding: 18px 20px;
  border-radius: 0;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(214, 170, 85, 0.16), transparent 58%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  border: 0;
  border-bottom: 1px solid var(--chess-border);
  box-shadow: none;
  overflow: hidden;
  text-align: center;
}

.chess-hero::before {
  display: none;
}

.chess-hero-frame-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  pointer-events: none;
}

.chess-hero-frame-corner::before,
.chess-hero-frame-corner::after {
  content: "";
  position: absolute;
  background: rgba(212, 162, 76, 0.7);
  border-radius: 1px;
}

.chess-hero-frame-corner::before { width: 100%; height: 2px; top: 0; left: 0; }
.chess-hero-frame-corner::after  { width: 2px; height: 100%; top: 0; left: 0; }

.chess-hero-frame-corner.tl { top: 14px; left: 14px; }
.chess-hero-frame-corner.tr { top: 14px; right: 14px; transform: scaleX(-1); }
.chess-hero-frame-corner.bl { bottom: 14px; left: 14px; transform: scaleY(-1); }
.chess-hero-frame-corner.br { bottom: 14px; right: 14px; transform: scale(-1); }

.chess-hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.chess-hero-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(320px, 80%);
  margin: 2px 0;
}

.chess-hero-rule span:not(.chess-hero-rule-diamond) {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 162, 76, 0.45), transparent);
}

.chess-hero-rule-diamond {
  font-size: 0.55rem;
  color: rgba(212, 162, 76, 0.7);
  line-height: 1;
}

.chess-kicker,
.chess-panel-kicker,
.chess-promo-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(241, 231, 210, 0.64);
  color: var(--chess-muted);
}

.chess-kicker {
  font-family: "Oswald", sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.28em;
  color: var(--chess-gold);
}

.chess-title,
.chess-panel-title,
.chess-promo-title {
  font-family: "Oswald", sans-serif;
  letter-spacing: 0.04em;
}

.chess-title {
  font-family: "Cinzel", serif;
  font-size: clamp(1.9rem, 4vw, 3rem);
  letter-spacing: 0.06em;
  line-height: 1;
  background: linear-gradient(160deg, #f8fafc 20%, var(--chess-gold) 58%, #c7f9d4 88%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 2px 12px rgba(212, 162, 76, 0.35));
}

.chess-copy,
.chess-stage-copy,
.chess-detail-copy,
.chess-log-meta,
.chess-player-meta {
  color: var(--chess-muted);
}

.chess-meta-row {
  grid-template-columns: repeat(3, minmax(0, max-content));
  justify-content: center;
}

.chess-hero-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.chess-pill {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--chess-border);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.76rem;
  font-weight: 700;
}

.chess-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.78fr);
  align-items: start;
  padding: 12px;
}

.chess-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chess-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 12px;
  max-height: 90vh;
  min-height: 0;
}

.chess-log-list,
.chess-move-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chess-stage,
.chess-panel {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--chess-border);
  background: var(--chess-panel);
  backdrop-filter: blur(12px);
}

.chess-stage-head,
.chess-player-head,
.chess-board-toolbar,
.chess-log-item,
.chess-move-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.chess-board-toolbar {
  margin: 10px 0;
}

.chess-board-shell {
  padding: 12px;
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(26, 92, 53, 0.72), rgba(7, 31, 19, 0.92)),
    rgba(10, 13, 11, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 40px rgba(0, 0, 0, 0.38);
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 14px;
  container-type: inline-size;
}

.chess-square {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform 120ms ease, box-shadow 120ms ease;
  will-change: transform;
}

.chess-square:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.9);
  outline-offset: -3px;
  z-index: 2;
}

.chess-square.is-light { background: #e6dcc8; }
.chess-square.is-dark { background: #3d6b4f; }
.chess-square.is-selected {
  box-shadow: inset 0 0 0 4px rgba(56, 189, 248, 0.9);
}
.chess-square.is-last-move {
  box-shadow: inset 0 0 0 999px rgba(250, 204, 21, 0.14);
}
.chess-square.is-check {
  box-shadow: inset 0 0 0 999px rgba(239, 68, 68, 0.26);
}
.chess-square:hover {
  transform: scale(0.985);
}

.chess-piece {
  position: absolute;
  z-index: 2;
  font-size: clamp(1.8rem, 9.5cqw, 4.4rem);
  line-height: 1;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.chess-piece.is-white {
  color: #fff8ee;
  text-shadow:
    0 1px 0 rgba(0,0,0,0.55),
    0 3px 8px rgba(0,0,0,0.45),
    0 0 20px rgba(255,240,200,0.22);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.chess-piece.is-black {
  color: #111827;
  text-shadow:
    0 1px 0 rgba(255,210,130,0.28),
    0 3px 10px rgba(0,0,0,0.5),
    0 0 18px rgba(120,60,10,0.22);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.45));
}

.chess-target-marker {
  position: absolute;
  width: 22%;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.3);
}

.chess-target-marker.is-capture {
  width: 78%;
  height: 78%;
  background: transparent;
  border: 4px solid rgba(185, 28, 28, 0.65);
}

.chess-rank-label,
.chess-file-label {
  position: absolute;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.8;
}

.chess-rank-label {
  top: 6px;
  left: 8px;
}

.chess-file-label {
  right: 8px;
  bottom: 6px;
}

.chess-players-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chess-players-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.chess-players-head .chess-panel-title {
  font-size: 1rem;
  color: rgba(245, 239, 227, 0.5);
}

.chess-players-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.chess-panel-tabbed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chess-panel-tabbed .chess-move-list,
.chess-panel-tabbed .chess-log-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 162, 76, 0.28) transparent;
}

.chess-panel-tabbed .chess-move-list::-webkit-scrollbar,
.chess-panel-tabbed .chess-log-list::-webkit-scrollbar {
  width: 4px;
}

.chess-panel-tabbed .chess-move-list::-webkit-scrollbar-thumb,
.chess-panel-tabbed .chess-log-list::-webkit-scrollbar-thumb {
  background: rgba(212, 162, 76, 0.32);
  border-radius: 99px;
}

.chess-tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
}

.chess-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: rgba(245, 239, 227, 0.56);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.chess-tab-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(245, 239, 227, 0.84);
}

.chess-tab-btn.is-active {
  background: rgba(212, 162, 76, 0.18);
  color: #f7f4ea;
}

.chess-tab-btn:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.7);
  outline-offset: 1px;
}

.chess-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
}

.chess-player-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  background: var(--chess-panel-soft);
  border: 1px solid var(--chess-border);
}

.chess-player-card.is-active {
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.42);
}

.chess-player-card.is-winner {
  box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.48);
}

.chess-player-name {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-weight: 800;
}

.chess-you-tag,
.chess-ai-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chess-you-tag {
  background: rgba(96, 165, 250, 0.18);
  color: #93c5fd;
}

.chess-ai-tag {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
}

.chess-player-stat,
.chess-move-no {
  color: rgba(212, 162, 76, 0.92);
  font-weight: 800;
}

.chess-captured-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  align-items: center;
}

.chess-captured-piece {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.15rem;
}

.chess-captured-piece.is-white { color: #fffaf0; }
.chess-captured-piece.is-black { color: #16100a; background: rgba(255, 255, 255, 0.18); }

.chess-captured-empty,
.chess-empty-copy {
  color: rgba(245, 239, 227, 0.56);
}

.chess-move-row,
.chess-log-item {
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.chess-move-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
}

.chess-move-btn {
  border: 0;
  background: transparent;
  color: #f7f4ea;
  text-align: left;
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease;
}

.chess-move-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chess-move-btn.is-latest {
  background: rgba(56, 189, 248, 0.14);
}

.chess-move-btn:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.7);
  outline-offset: 1px;
}

.chess-promo-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 4, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 80;
}

.chess-promo-modal {
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(24, 17, 11, 0.98), rgba(63, 45, 29, 0.96));
  border: 1px solid rgba(212, 162, 76, 0.22);
}

.chess-promo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.chess-promo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(212, 162, 76, 0.22);
  background: rgba(23, 16, 11, 0.78);
  color: #f7f4ea;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.chess-promo-btn:hover {
  background: rgba(212, 162, 76, 0.18);
  border-color: rgba(212, 162, 76, 0.52);
  transform: translateY(-1px);
}

.chess-promo-btn:focus-visible {
  outline: 2px solid rgba(212, 162, 76, 0.8);
  outline-offset: 2px;
}

.chess-promo-piece {
  font-size: 1.8rem;
}

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

@media (max-width: 760px) {
  .chess-hero {
    padding: 28px 24px 24px;
  }

  .chess-meta-row {
    grid-template-columns: 1fr;
  }

  .chess-players-row {
    grid-template-columns: 1fr;
  }

  .chess-board-toolbar {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chess-square { transition: none; }
  .chess-promo-btn { transition: none; }
}
