.weather-chess-game {
  --chess-ink: #edf5ff;
  --chess-muted: #aab8d0;
  --chess-panel: rgba(10, 18, 35, 0.9);
  --chess-line: rgba(157, 197, 232, 0.23);
  --chess-gold: #e6bd67;
  color: var(--chess-ink);
  width: min(1500px, calc(100% - 1rem));
  margin: 1rem auto 3rem;
  overflow: clip;
}

.weather-chess-game *,
.weather-chess-game *::before,
.weather-chess-game *::after {
  box-sizing: border-box;
}

.weather-chess-game button,
.weather-chess-game select,
.weather-chess-game input,
.weather-chess-game textarea {
  font: inherit;
}

.chess-hero,
.chess-setup,
.chess-sidebar section,
.chess-lower-grid > section,
.chess-diagnostics {
  border: 1px solid var(--chess-line);
  background:
    linear-gradient(145deg, rgba(27, 46, 76, 0.78), rgba(7, 13, 27, 0.94)),
    radial-gradient(circle at 20% 0%, rgba(97, 181, 225, 0.12), transparent 42%);
  border-radius: 1.25rem;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.26),
    inset 0 1px rgba(255, 255, 255, 0.05);
}

.chess-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.2rem, 3vw, 2.2rem);
  margin-bottom: 1rem;
}

.chess-hero h1 {
  margin: 0.15rem 0;
  font-family: Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  color: #fff4d2;
  text-shadow: 0 3px 18px rgba(230, 189, 103, 0.26);
}
.chess-hero p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--chess-muted);
}
.chess-eyebrow {
  margin: 0;
  color: var(--chess-gold) !important;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.chess-hero-actions,
.chess-inline-actions,
.chess-primary-actions,
.chess-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.chess-setup {
  padding: 1rem;
  margin-bottom: 1rem;
}
.chess-section-heading,
.chess-inline-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.chess-section-heading h2,
.chess-inline-heading h2,
.chess-sidebar h2,
.chess-lower-grid h2,
.chess-diagnostics h2 {
  margin: 0 0 0.5rem;
  font-family: Georgia, serif;
  font-size: 1.18rem;
}
.chess-section-heading > p {
  color: var(--chess-muted);
}
.chess-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 0.7rem;
  margin: 0.75rem 0;
}
.chess-option-grid label,
.chess-sidebar label {
  display: grid;
  gap: 0.35rem;
  color: #dce7f7;
  font-size: 0.84rem;
  font-weight: 700;
}
.chess-check {
  display: flex !important;
  align-items: center;
  align-self: end;
  min-height: 42px;
}
.chess-check input {
  accent-color: #e6bd67;
  width: 1rem;
  height: 1rem;
}

.weather-chess-game .select,
.weather-chess-game .input,
.weather-chess-game .textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(178, 205, 235, 0.3);
  border-radius: 0.65rem;
  background: #0b1427;
  color: #f4f8ff;
  padding: 0.58rem 0.7rem;
}

.weather-chess-game .textarea {
  resize: vertical;
  min-height: 70px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.76rem;
}
.weather-chess-game button:focus-visible,
.weather-chess-game select:focus-visible,
.weather-chess-game input:focus-visible,
.weather-chess-game textarea:focus-visible,
.chess-canvas-shell canvas:focus-visible {
  outline: 3px solid #72d8ff;
  outline-offset: 3px;
}

.chess-play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 370px);
  gap: 1rem;
  align-items: start;
}
.chess-board-column {
  min-width: 0;
}
.chess-canvas-shell {
  position: relative;
  width: min(100%, 900px);
  margin-inline: auto;
  border: clamp(5px, 1vw, 11px) solid #202c42;
  border-radius: 0.75rem;
  background: #10192a;
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(229, 194, 112, 0.32);
  touch-action: none;
  aspect-ratio: 1;
  overflow: hidden;
}
.chess-canvas-shell canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.chess-canvas-shell canvas:active {
  cursor: grabbing;
}
.chess-pause-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.35rem;
  background: rgba(4, 9, 20, 0.82);
  backdrop-filter: blur(8px);
  z-index: 6;
}
.chess-pause-cover[hidden] {
  display: none;
}
.chess-pause-cover strong {
  font:
    700 clamp(1.8rem, 6vw, 3.6rem) Georgia,
    serif;
  color: #fff1c5;
}

.chess-player-bar {
  width: min(100%, 900px);
  margin: 0.55rem auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--chess-line);
  border-radius: 0.85rem;
  background: rgba(8, 16, 31, 0.9);
  transition:
    box-shadow 180ms,
    border-color 180ms;
}
.chess-player-bar.active {
  border-color: #f3d484;
  box-shadow:
    0 0 0 2px rgba(243, 212, 132, 0.22),
    0 0 24px rgba(243, 212, 132, 0.16);
}
.chess-player-bar > div {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.55rem;
}
.chess-player-bar small {
  grid-column: 2;
  color: var(--chess-muted);
}
.chess-player-bar time {
  border-radius: 0.55rem;
  background: #050b17;
  padding: 0.42rem 0.7rem;
  font:
    800 1.3rem ui-monospace,
    monospace;
}
.chess-player-bar time.warning {
  color: #ff9c91;
  animation: chess-clock-pulse 1s infinite;
}
.chess-faction-dot {
  grid-row: 1 / 3;
  align-self: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 3px double #c89c43;
}
.chess-faction-dot.light {
  background: radial-gradient(circle at 35% 30%, #fff, #d8b65c);
}
.chess-faction-dot.dark {
  background: radial-gradient(circle at 35% 30%, #53617c, #171d2a);
}

.chess-status {
  width: min(100%, 900px);
  margin: 0.75rem auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 66px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--chess-line);
  border-radius: 0.9rem;
  background: rgba(9, 18, 35, 0.94);
}
.chess-status p {
  margin: 0.15rem 0 0;
  color: var(--chess-muted);
}
.chess-status-rune {
  color: var(--chess-gold);
  font-size: 1.5rem;
}
.chess-primary-actions {
  width: min(100%, 900px);
  margin: 0 auto;
  justify-content: center;
}
.chess-primary-actions button {
  flex: 1 1 105px;
}

.chess-sidebar {
  display: grid;
  gap: 1rem;
}
.chess-sidebar section,
.chess-lower-grid > section,
.chess-diagnostics {
  padding: 1rem;
}
.chess-sidebar section {
  min-width: 0;
}
.chess-inline-heading > span {
  color: var(--chess-gold);
  font-size: 0.8rem;
}
.chess-moves {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 285px;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}
.chess-moves li {
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.045);
  color: #dce8f8;
  font-family: ui-monospace, monospace;
}
.chess-moves li:not(:has(button)),
.chess-moves button {
  padding: 0.38rem 0.48rem;
}
.chess-moves button {
  width: 100%;
  border: 0;
  border-radius: inherit;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.chess-moves button:hover,
.chess-moves button:focus-visible {
  background: rgba(114, 216, 255, 0.12);
}
.chess-moves li:last-child {
  color: #ffe9a9;
  background: rgba(230, 189, 103, 0.1);
}
.chess-review-exit {
  width: 100%;
  margin-top: 0.6rem;
}
.chess-captured {
  margin-top: 0.65rem;
}
.chess-captured > span {
  display: block;
  color: var(--chess-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.chess-captured > div {
  min-height: 2.3rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  color: var(--chess-muted);
}
.chess-captured img {
  width: 30px;
  height: 30px;
  object-fit: cover;
  object-position: left top;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
}
.chess-captured-fallback {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--chess-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #fff0bd;
  font-weight: 800;
}
.chess-board-description {
  color: var(--chess-muted);
  line-height: 1.55;
  max-height: 155px;
  overflow: auto;
}
.chess-sidebar .chess-inline-actions {
  margin: 0.45rem 0 0.85rem;
}

.chess-lower-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}
.chess-stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  margin: 0;
}
.chess-stats div {
  display: contents;
}
.chess-stats dt {
  color: var(--chess-muted);
}
.chess-stats dd {
  margin: 0;
  font-weight: 800;
  color: #fff0bd;
}
.chess-achievements {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
}
.chess-achievements li {
  color: var(--chess-muted);
}
.chess-achievements li.unlocked {
  color: #fff0bd;
}
.chess-achievements li::before {
  content: "◇";
  margin-right: 0.45rem;
}
.chess-achievements li.unlocked::before {
  content: "◆";
  color: #e6bd67;
}

.chess-dialog {
  width: min(620px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  color: var(--chess-ink);
  border: 1px solid rgba(230, 189, 103, 0.5);
  border-radius: 1rem;
  padding: 1.25rem;
  background: #0c172b;
  box-shadow: 0 28px 100px #000;
}
.chess-dialog::backdrop {
  background: rgba(2, 7, 16, 0.8);
  backdrop-filter: blur(5px);
}
.chess-dialog h2 {
  margin-top: 0;
  color: #fff0bd;
  font-family: Georgia, serif;
}
.chess-dialog-actions {
  justify-content: flex-end;
  margin-top: 1rem;
}
.chess-promotion-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.chess-promotion-options button {
  min-height: 70px;
  font-weight: 800;
  text-transform: capitalize;
}

.chess-result-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(
    circle,
    transparent 0 18%,
    rgba(240, 197, 96, 0.16) 19%,
    transparent 20% 32%,
    rgba(105, 212, 255, 0.12) 33%,
    transparent 34%
  );
  animation: chess-result 1.5s ease-out infinite;
}
.chess-result-burst[hidden] {
  display: none;
}
.chess-diagnostics {
  margin-top: 1rem;
  border-color: rgba(117, 223, 255, 0.55);
}
.chess-diagnostics pre {
  white-space: pre-wrap;
  color: #bcecff;
  background: #050b15;
  padding: 0.75rem;
  border-radius: 0.65rem;
  overflow: auto;
}
.chess-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes chess-clock-pulse {
  50% {
    box-shadow: 0 0 18px rgba(255, 94, 77, 0.34);
  }
}
@keyframes chess-result {
  from {
    transform: scale(0.86) rotate(0);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  to {
    transform: scale(1.18) rotate(10deg);
    opacity: 0;
  }
}

@media (max-width: 1050px) {
  .chess-play-layout {
    grid-template-columns: 1fr;
  }
  .chess-sidebar {
    grid-template-columns: repeat(2, 1fr);
  }
  .chess-sidebar section:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .weather-chess-game {
    width: calc(100% - 0.5rem);
  }
  .chess-hero,
  .chess-section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .chess-hero-actions {
    width: 100%;
  }
  .chess-hero-actions button {
    flex: 1;
  }
  .chess-sidebar,
  .chess-lower-grid {
    grid-template-columns: 1fr;
  }
  .chess-sidebar section:last-child {
    grid-column: auto;
  }
  .chess-option-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .chess-player-bar time {
    font-size: 1.05rem;
  }
  .chess-canvas-shell {
    border-width: 4px;
    border-radius: 0.35rem;
  }
}

@media (max-width: 440px) {
  .chess-option-grid {
    grid-template-columns: 1fr;
  }
  .chess-promotion-options {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .weather-chess-game *,
  .weather-chess-game *::before,
  .weather-chess-game *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
