/* A focused, full-viewport arena using the lobby's obsidian, lime and gold. */
body:has(.chess-dialog[open]) {
  overflow: hidden;
}
.chess-dialog {
  inset: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(ellipse at 18% 34%, #8ebd2520, transparent 54%),
    radial-gradient(ellipse at 100% 0%, #b58b2920, transparent 48%), #080e0c;
  color: #f1f5e8;
  overflow: auto;
  overscroll-behavior: contain;
}
.chess-dialog::backdrop {
  background: #080e0c;
  backdrop-filter: blur(20px);
}
.chess-shell {
  position: relative;
  isolation: isolate;
  min-height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 42px 30px;
}
.chess-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(100deg, #080e0c 16%, #080e0c99),
    url('assets/chess-hero.webp') right top / auto 100vh no-repeat;
  opacity: 0.19;
}
.arena-atmosphere {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}
.arena-atmosphere::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(#d4ec9804 1px, transparent 1px),
    linear-gradient(90deg, #d4ec9804 1px, transparent 1px);
  background-size: 65px 65px;
  mask-image: linear-gradient(transparent, #000, transparent);
}
.arena-atmosphere i {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #d9f69a;
  border-radius: 50%;
  opacity: 0;
  box-shadow: 0 0 16px #c3fa4c;
  animation: arena-particle 12s linear infinite;
}
.arena-atmosphere i:nth-child(1) {
  left: 8%;
  top: 90%;
  animation-delay: -2s;
}
.arena-atmosphere i:nth-child(2) {
  left: 23%;
  top: 83%;
  animation-delay: -8s;
}
.arena-atmosphere i:nth-child(3) {
  left: 39%;
  top: 96%;
  animation-delay: -5s;
}
.arena-atmosphere i:nth-child(4) {
  left: 51%;
  top: 80%;
  animation-delay: -10s;
}
.arena-atmosphere i:nth-child(5) {
  left: 69%;
  top: 91%;
  animation-delay: -1s;
  background: #ffe7a7;
}
.arena-atmosphere i:nth-child(6) {
  left: 79%;
  top: 94%;
  animation-delay: -7s;
}
.arena-atmosphere i:nth-child(7) {
  left: 88%;
  top: 85%;
  animation-delay: -4s;
  background: #ffe7a7;
}
.arena-atmosphere i:nth-child(8) {
  left: 95%;
  top: 78%;
  animation-delay: -9s;
}
.chess-dialog .dialog-header {
  position: relative;
  z-index: 20;
  margin-bottom: 20px;
  padding-bottom: 17px;
  border-color: #ccdc9e1c;
}
.chess-brand-emblem {
  width: 56px;
  height: 56px;
  border-radius: 17px;
  background: radial-gradient(circle at 25% 0%, #d6f47230, #111a12 70%);
  border-color: #c2df5b55;
  box-shadow: 0 0 26px #c3fa4c10;
}
.chess-brand-emblem img {
  height: 53px;
  width: 53px;
}
.dialog-header .eyebrow {
  color: #c3fa4c;
  letter-spacing: 3px;
  font-size: 8px;
}
.dialog-header h2 {
  font-size: 30px;
  letter-spacing: -1.1px;
}
.dialog-header h2 span {
  color: #e3c477;
  font-weight: 450;
}
.match-edition {
  color: #98aa91;
  font-size: 8px;
}
.match-header-actions {
  gap: 14px;
}
.dialog-header .close-dialog {
  width: auto;
  min-height: 44px;
  padding: 0 14px;
  gap: 9px;
  display: flex;
  border-radius: 12px;
  border: 1px solid #b4c29d33;
  background: #ffffff06;
}
.dialog-header .close-dialog span {
  font-size: 11px;
}
#chess-fullscreen {
  border: 1px solid #b4c29d33;
  border-radius: 12px;
  font-size: 24px;
  min-width: 44px;
  min-height: 44px;
  background: #ffffff06;
}
.chess-layout {
  grid-template-columns: minmax(0, 1fr) minmax(265px, 310px);
  gap: clamp(26px, 4vw, 72px);
  max-width: 1190px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.board-column {
  max-width: min(100%, calc(100dvh - 330px));
  margin: 0 auto;
}
.player-row {
  border: 1px solid #a6bd8c19;
  background: linear-gradient(110deg, #18221aee, #111a14bb);
  padding: 9px 14px;
  border-radius: 13px;
  min-height: 61px;
  margin-bottom: 0;
}
.player-row:last-child {
  margin-top: 16px;
}
.player-row.is-turn {
  background: linear-gradient(110deg, #c3fa4c14, #141e14bb);
  border-color: #c3fa4c55;
  box-shadow: 0 0 24px #c3fa4c08;
}
.player-avatar,
.player-avatar.opponent {
  position: relative;
  overflow: visible;
  width: 43px;
  height: 43px;
  background: radial-gradient(ellipse at 50% 100%, #bc97493a, #151c19);
  border: 1px solid #d2bd7555;
}
.player-row strong {
  font-size: 12px;
}
.player-row small {
  font-size: 7px;
  letter-spacing: 1.5px;
}
.turn-pill.active {
  background: #c3fa4c18;
  box-shadow: 0 0 15px #c3fa4c13;
}
.is-thinking .computer-player {
  border-color: #e3c47e77;
  background: linear-gradient(110deg, #cda14a14, #141e14bb);
}
.is-thinking .computer-player .player-avatar::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 1px solid transparent;
  border-top-color: #ffe9ac;
  border-right-color: #c3fa4c;
  border-radius: 14px;
  animation: arena-orbit 1.7s linear infinite;
}
.arena-turnline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 37px;
  padding: 4px 3px;
  color: #a8b9a1;
  font-size: 9px;
}
.arena-turnline strong {
  margin-left: auto;
  color: #ffe2a0;
  letter-spacing: 1px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.thinking-orbit {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.thinking-orbit i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #c3fa4c;
}
.is-thinking .thinking-orbit i {
  background: #ffe0a0;
  animation: arena-think 1s ease-in-out infinite;
}
.is-thinking .thinking-orbit i:nth-child(2) {
  animation-delay: 0.15s;
}
.is-thinking .thinking-orbit i:nth-child(3) {
  animation-delay: 0.3s;
}
.is-thinking .arena-turnline {
  color: #e8d1a4;
}
.board-stage {
  isolation: isolate;
  padding: 12px;
  border-radius: 17px;
  border: 1px solid #d1e38255;
  background: linear-gradient(135deg, #95a95b30, #111e16 30%, #0c1710 65%, #a18f4930);
  box-shadow:
    0 24px 64px #0009,
    0 0 42px #c3fa4c16,
    inset 0 1px 0 #e7f0b866;
}
.board-stage::before {
  inset: 5px;
  border-radius: 12px;
  border-color: #d5e59b38;
}
.board-stage::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 18px;
  pointer-events: none;
  z-index: -1;
  box-shadow:
    -10px -6px 30px #c3fa4c0c,
    10px 8px 30px #ffd46d10;
  animation: arena-frame 5s ease-in-out infinite;
}
.board-corner {
  width: 34px;
  height: 34px;
  color: #d8ed96;
  filter: drop-shadow(0 0 6px #c3fa4c88);
}
.corner-tl {
  border-top-left-radius: 17px;
}
.corner-br {
  border-bottom-right-radius: 17px;
  color: #e7c477;
}
.board-surface {
  position: relative;
}
.chess-board {
  border: 1px solid #060f08;
  border-radius: 7px;
  box-shadow:
    0 0 0 1px #ced99e55,
    0 6px 20px #0007;
}
.chess-board .square {
  background: linear-gradient(145deg, #d4dbc2, #a6b29a);
  box-shadow:
    inset 0 1px 0 #ffffff33,
    inset 1px 0 0 #ffffff10;
}
.chess-board .square.dark {
  background: linear-gradient(145deg, #536459, #334b40);
  box-shadow: inset 0 1px 0 #ffffff08;
}
.chess-board .square.last-move {
  box-shadow: inset 0 0 0 100px #e4d27820;
}
.chess-board .square.selected {
  background: linear-gradient(135deg, #c3e979, #739e3a);
}
.chess-board .square.legal::after {
  width: 14%;
  height: 14%;
  left: 43%;
  top: 43%;
  background: #d9ff9f;
  box-shadow: 0 0 12px #c3fa4ca0;
}
.chess-board .square.legal.has-piece::after {
  inset: 5%;
  width: 90%;
  height: 90%;
  background: transparent;
}
.chess-dialog .piece {
  width: 94%;
  height: 94%;
  filter: drop-shadow(0 4px 2px #0b1b19aa);
}
.chess-dialog .piece.black {
  filter: drop-shadow(0 4px 2px #010804aa);
}
.chess-board .square.selected .piece {
  filter: drop-shadow(0 0 6px #ebffa288) drop-shadow(0 7px 2px #061b1688);
  transform: translateY(-4px) scale(1.04);
}
.chess-board .square.checked {
  background: linear-gradient(135deg, #aa7153, #69332b);
}
.chess-board .square.arrival-burst::after {
  content: '';
  position: absolute;
  inset: 7%;
  width: 86%;
  height: 86%;
  border: 2px solid #eeffba;
  border-radius: 50%;
  pointer-events: none;
  animation: arena-arrival 0.85s ease-out forwards;
}
.square.moving .piece {
  transition: none;
}
.opponent-arrow {
  position: absolute;
  inset: 1px;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  overflow: visible;
  z-index: 10;
  pointer-events: none;
}
.opponent-arrow[hidden] {
  display: none;
}
.move-beam-halo {
  fill: none;
  stroke: #e6ffad;
  stroke-width: 19;
  opacity: 0.5;
  filter: url(#move-beam-glow);
}
.move-beam {
  fill: none;
  stroke: url(#move-beam-gradient);
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0.9;
}
.move-beam-flow {
  fill: none;
  stroke: #fffce3;
  stroke-width: 2.5;
  stroke-dasharray: 3 22;
  stroke-linecap: round;
  animation: arena-arrow-flow 1.4s linear infinite;
}
.move-arrowhead {
  fill: #ffe2a0;
  stroke: #8b6c26;
  stroke-width: 1;
  filter: drop-shadow(0 0 4px #ffe099);
}
.move-origin {
  fill: #c3fa4c33;
  stroke: #e3ff9f;
  stroke-width: 3;
}
.move-arrival {
  fill: none;
  stroke: #ffe3a5;
  stroke-width: 2.5;
  stroke-dasharray: 7 8;
  animation: arena-arrow-flow 4s linear infinite;
}
.game-panel {
  border-color: #b9c98b30;
  border-radius: 18px;
  padding: 22px;
  background: linear-gradient(150deg, #22301bd9, #0d1711ed 55%, #1a2116e6);
  box-shadow: 0 18px 40px #0004;
}
.game-status {
  background: linear-gradient(110deg, #c3fa4c16, #8b9d3608);
  border-color: #c3fa4c38;
  border-radius: 12px;
  min-height: 79px;
}
.game-status strong {
  font-size: 12px;
}
.status-caption {
  font-size: 7px;
  letter-spacing: 1.8px;
}
.is-thinking .game-status {
  border-color: #ecd28b55;
  background: #efbf4810;
}
.is-thinking .game-status .status-dot {
  background: #ffe09a;
  animation: arena-think 1.2s infinite;
}
.game-panel select {
  border-color: #81936555;
  min-height: 46px;
  font-size: 11px;
  border-radius: 9px;
}
.game-help {
  color: #a0af95;
  font-size: 11px;
}
.color-settings {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.color-settings label {
  margin: 0;
  font-size: 10px;
}
.board-controls #flip-board {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  border-radius: 9px;
  min-height: 44px;
  font-size: 11px;
}
.history-heading {
  color: #cbd7bf;
}
.history-columns {
  background: #d5e39809;
  color: #9eac90;
}
.move-history {
  background: #070f0b7a;
  max-height: 210px;
}
.history-empty {
  border-color: #b7cd7f25;
  background: #080f0b66;
  color: #96a68b;
}
.game-panel > .primary-button {
  border-radius: 10px;
  min-height: 47px;
  background: linear-gradient(115deg, #d5ff78, #adf03a);
  box-shadow: 0 4px 20px #b3ed2914;
}
.promotion-panel {
  z-index: 40;
}
@keyframes arena-particle {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 0;
  }
  20%,
  70% {
    opacity: 0.6;
  }
  100% {
    transform: translate3d(35px, -75vh, 0);
    opacity: 0;
  }
}
@keyframes arena-orbit {
  to {
    transform: rotate(360deg);
  }
}
@keyframes arena-think {
  50% {
    opacity: 0.3;
    transform: translateY(-2px);
  }
}
@keyframes arena-frame {
  50% {
    box-shadow:
      -10px -6px 40px #c3fa4c2b,
      10px 8px 40px #ffd46d1a;
  }
}
@keyframes arena-arrow-flow {
  to {
    stroke-dashoffset: -100;
  }
}
@keyframes arena-arrival {
  0% {
    transform: scale(0.35);
    opacity: 0;
  }
  35% {
    opacity: 0.9;
  }
  100% {
    transform: scale(1.38);
    opacity: 0;
  }
}
@media (max-width: 1000px) {
  .chess-shell {
    padding: 20px 24px;
  }
  .chess-layout {
    gap: 26px;
    grid-template-columns: minmax(0, 1fr) 260px;
  }
  .game-panel {
    padding: 17px;
  }
  .board-column {
    max-width: 100%;
  }
  .match-edition {
    display: none;
  }
}
@media (max-width: 700px) {
  .chess-shell {
    padding: 14px 12px calc(25px + env(safe-area-inset-bottom));
  }
  .chess-dialog .dialog-header {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }
  .chess-brand {
    gap: 9px;
  }
  .chess-brand-emblem {
    width: 42px;
    height: 44px;
    border-radius: 12px;
  }
  .chess-brand-emblem img {
    width: 41px;
    height: 41px;
  }
  .dialog-header h2 {
    font-size: 24px;
  }
  .dialog-header .eyebrow {
    font-size: 6px;
    letter-spacing: 2px;
  }
  .match-header-actions {
    gap: 7px;
  }
  .dialog-header .close-dialog {
    padding: 0 9px;
    min-height: 40px;
    gap: 5px;
    border-radius: 9px;
  }
  .dialog-header .close-dialog span {
    font-size: 9px;
  }
  .dialog-header .close-dialog svg {
    width: 16px;
    height: 16px;
  }
  #chess-fullscreen {
    min-width: 38px;
    min-height: 40px;
    font-size: 22px;
    border-radius: 9px;
  }
  .chess-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .board-column {
    max-width: 500px;
    width: 100%;
  }
  .board-stage {
    padding: 8px;
    border-radius: 13px;
  }
  .board-stage::before {
    inset: 4px;
    border-radius: 9px;
  }
  .board-stage::after {
    border-radius: 14px;
  }
  .board-corner {
    width: 25px;
    height: 25px;
  }
  .corner-tl {
    border-top-left-radius: 13px;
  }
  .corner-br {
    border-bottom-right-radius: 13px;
  }
  .player-row {
    min-height: 55px;
    padding: 7px 10px;
    border-radius: 10px;
  }
  .player-row:last-child {
    margin-top: 12px;
  }
  .player-avatar,
  .player-avatar.opponent {
    width: 37px;
    height: 37px;
  }
  .player-row strong {
    font-size: 11px;
  }
  .player-row small {
    font-size: 6px;
    letter-spacing: 1px;
  }
  .arena-turnline {
    font-size: 8px;
    gap: 6px;
    min-height: 34px;
  }
  .arena-turnline strong {
    font-size: 10px;
  }
  .chess-dialog .piece {
    width: 97%;
    height: 97%;
  }
  .game-panel {
    width: 100%;
    max-width: 500px;
    justify-self: center;
    padding: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 11px 10px;
  }
  .game-status {
    grid-column: 1/-1;
    grid-row: 1;
    min-height: 66px;
    margin: 0;
  }
  .game-panel label {
    grid-column: 1/-1;
    grid-row: 2;
    margin: 3px 0 -3px;
  }
  .game-panel select {
    grid-column: 1/-1;
    grid-row: 3;
    font-size: 12px;
  }
  .game-help {
    grid-column: 1/-1;
    grid-row: 4;
    margin: 0;
    font-size: 10px;
  }
  .board-controls {
    grid-column: 1;
    grid-row: 5;
  }
  .game-panel > .primary-button {
    grid-column: 2;
    grid-row: 5;
    margin: 0;
    font-size: 11px;
    min-height: 44px;
  }
  .history-heading {
    grid-column: 1/-1;
    grid-row: 6;
    margin: 10px 0 0;
  }
  .history-columns {
    grid-column: 1/-1;
    grid-row: 7;
    margin-bottom: -11px;
  }
  .history-empty,
  .move-history {
    grid-column: 1/-1;
    grid-row: 8;
    margin: 0;
  }
  .history-empty {
    min-height: 90px;
  }
  .chess-note {
    grid-column: 1/-1;
    grid-row: 9;
    margin: 4px 0 0;
    font-size: 8px;
  }
  .promotion-panel {
    position: fixed;
  }
}
@media (max-width: 360px) {
  .chess-shell {
    padding-left: 8px;
    padding-right: 8px;
  }
  .chess-brand-emblem {
    display: none;
  }
  .dialog-header h2 {
    font-size: 23px;
  }
  .board-stage {
    padding: 6px;
  }
  .arena-turnline {
    font-size: 7.5px;
  }
}
@media (max-width: 700px) {
  .game-panel .color-settings {
    grid-column: 1/-1;
    grid-row: 4;
    grid-template-columns: 90px minmax(0, 1fr);
    align-items: center;
    margin-top: 2px;
  }
  .game-panel .color-settings label {
    margin: 0;
    grid-column: auto;
    grid-row: auto;
  }
  .game-panel .color-settings select {
    grid-column: auto;
    grid-row: auto;
    font-size: 11px;
  }
  .game-panel .game-help {
    grid-row: 5;
  }
  .game-panel .board-controls,
  .game-panel > .primary-button {
    grid-row: 6;
  }
  .game-panel .history-heading {
    grid-row: 7;
  }
  .game-panel .history-columns {
    grid-row: 8;
  }
  .game-panel .move-history,
  .game-panel .history-empty {
    grid-row: 9;
  }
  .game-panel .chess-note {
    grid-row: 10;
  }
}
@media (prefers-reduced-motion: reduce) {
  .arena-atmosphere {
    display: none;
  }
  .chess-dialog *,
  .chess-dialog *::before,
  .chess-dialog *::after {
    animation: none !important;
    transition: none !important;
  }
}
