.chess-wrap {
  width: min(1240px, calc(100% - 40px));
  margin: auto;
}
.chess-hero {
  padding: 72px 0 48px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
}
.chess-hero h1 {
  font-size: clamp(3rem, 6vw, 5.6rem);
  background: linear-gradient(100deg, #fff 25%, var(--sky), var(--pink));
  -webkit-background-clip: text;
  color: transparent;
}
.chess-hero > div > p:not(.eyebrow) {
  color: var(--muted);
  max-width: 470px;
  line-height: 1.8;
}
.hero-badge {
  background: linear-gradient(140deg, #172554, #312e81);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 26px;
  min-width: 230px;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 0 12px;
}
.hero-badge span {
  grid-row: 1/3;
  font-size: 3rem;
  color: var(--lime);
}
.hero-badge strong {
  align-self: end;
}
.hero-badge small {
  color: var(--muted);
  font-size: 0.7rem;
  align-self: start;
}
.game-layout {
  display: grid;
  grid-template-columns: 230px minmax(330px, 610px) 230px;
  justify-content: center;
  align-items: start;
  gap: 24px;
  padding-bottom: 80px;
}
.game-side {
  display: grid;
  gap: 16px;
}
.mini-card {
  background: rgba(22, 34, 56, 0.82);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}
.mini-card h3 {
  font-size: 1.1rem;
  margin: 0 0 7px;
}
.mini-card p:not(.eyebrow) {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.7;
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--sky), var(--lilac));
  color: #0f172a;
  font-weight: 800;
  margin-bottom: 10px;
}
.online-dot {
  color: #86efac !important;
  font-size: 0.68rem !important;
}
.online-dot:before {
  content: "●";
  margin-right: 5px;
}
.small-button,
.mode,
.connect-button {
  width: 100%;
  border: 1px solid var(--line);
  background: #1c2c46;
  color: var(--ink);
  border-radius: 9px;
  padding: 10px;
  font:
    700 0.73rem Manrope,
    sans-serif;
  cursor: pointer;
  transition: 0.2s;
}
.small-button:hover,
.mode:hover,
.connect-button:hover {
  border-color: var(--sky);
  background: #263d60;
}
.mode {
  text-align: left;
  margin-bottom: 8px;
}
.active-mode {
  border-color: var(--sky);
  color: var(--sky);
}
.mode-note {
  font-size: 0.67rem !important;
  margin: 8px 0 0;
}
.board-panel {
  min-width: 0;
}
.player-bar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 5px;
}
.player-bar div {
  display: grid;
  gap: 0;
}
.player-bar strong {
  font-size: 0.78rem;
}
.player-bar small {
  color: var(--muted);
  font-size: 0.62rem;
}
.piece-label {
  font-size: 1.65rem;
  color: #94a3b8;
  line-height: 1;
}
.piece-label.light {
  color: #f8fafc;
}
.turn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: auto;
  background: transparent;
}
.turn-dot.current {
  background: #4ade80;
  box-shadow: 0 0 10px #4ade80;
}
.chess-board {
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border-radius: 10px;
  overflow: hidden;
  border: 8px solid #223654;
  box-shadow: 0 17px 35px rgba(0, 0, 0, 0.3);
}
.square {
  border: 0;
  position: relative;
  display: grid;
  place-items: center;
  font-family: serif;
  font-size: clamp(1.65rem, 4.7vw, 3.55rem);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.square.light {
  background: #d9e6ee;
}
.square.dark {
  background: #6e9cba;
}
.square.selected {
  box-shadow: inset 0 0 0 5px #facc15;
}
.square[draggable="true"] {
  cursor: grab;
}
.square.dragging {
  opacity: 0.48;
  cursor: grabbing;
}
.square.last-move {
  background: #b8d98b;
}
.square.in-check {
  background: #f87171;
  animation: kingAlarm 0.9s ease-in-out infinite alternate;
}
@keyframes kingAlarm {
  from { box-shadow: inset 0 0 0 2px rgba(127, 29, 29, 0.35); }
  to { box-shadow: inset 0 0 0 7px rgba(127, 29, 29, 0.6); }
}
.square.move:after {
  content: "";
  width: 20%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(8, 42, 72, 0.47);
  position: absolute;
}
.square.capture:after {
  content: "";
  position: absolute;
  inset: 7%;
  border: 4px solid rgba(220, 38, 38, 0.65);
  border-radius: 50%;
}
.square .coord {
  position: absolute;
  bottom: 2px;
  left: 3px;
  font: 700 8px "DM Mono";
  color: rgba(15, 23, 42, 0.65);
}
.square.dark .coord {
  color: rgba(255, 255, 255, 0.65);
}
.white-piece {
  color: #fff;
  text-shadow: 0 2px 1px #1e293b;
}
.black-piece {
  color: #142235;
  text-shadow: 0 1px 0 #94a3b8;
}
.game-actions {
  padding: 15px 2px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.move-history { margin-top: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(22,34,56,.6); }.move-history ol { display:flex; flex-wrap:wrap; gap:6px 14px; margin:8px 0 0; padding-left:20px; color:var(--muted); font: .7rem "DM Mono",monospace; }.move-history li { min-width:70px; }
.text-button {
  color: var(--sky);
  font:
    700 0.72rem Manrope,
    sans-serif;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 7px;
}
.game-actions #gameMessage {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.68rem;
}
.game-actions #gameMessage.error {
  color: #fca5a5;
}
.room-label {
  display: block;
  color: var(--muted);
  font: 700 0.68rem "DM Mono", monospace;
  margin-top: 14px;
}
.room-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.room-row input {
  min-width: 0;
  width: 100%;
  background: #101b2d;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 9px;
  font: 0.72rem "DM Mono", monospace;
}
#onlineRoom .small-button {
  width: auto;
  padding-inline: 13px;
}
#roomStatus {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.5;
  margin-top: 8px;
}
.stats-card > h3 {
  font-size: 2.3rem;
  color: var(--sky);
  letter-spacing: -0.08em;
  margin: 0;
}
.rating-label {
  color: var(--muted);
  font-size: 0.65rem;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.stat-grid div {
  display: grid;
  gap: 3px;
}
.stat-grid b {
  font-size: 1rem;
}
.stat-grid small {
  color: var(--muted);
  font-size: 0.58rem;
}
.connect-button {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}
.connect-button span {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #2563eb;
  font-weight: 800;
}
.connect-button:nth-of-type(2) span {
  background: #81b64c;
  color: #fff;
}
.chess-features {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  padding: 48px 0 75px;
}
.chess-features span {
  font-family: "DM Mono";
  font-size: 0.7rem;
  color: var(--pink);
}
.chess-features h2 {
  font-size: 1.3rem;
  margin: 10px 0;
}
.chess-features p {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.7;
}
dialog {
  width: min(430px, calc(100% - 32px));
  background: #162238;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 30px 100px #000;
}
dialog::backdrop {
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(4px);
}
dialog h2 {
  font-size: 2.4rem;
}
dialog h2 span {
  color: var(--pink);
}
.close-dialog {
  position: absolute;
  right: 16px;
  top: 12px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}
.dialog-copy {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
}
.dialog-copy + form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}
#authForm label {
  font-size: 0.72rem;
  font-weight: 800;
}
#authForm label small {
  color: var(--muted);
  font-weight: 400;
}
#authForm input {
  width: 100%;
  margin-top: 7px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--sky);
  padding: 9px 0;
  font: inherit;
  color: var(--ink);
  outline: 0;
}
@media (max-width: 950px) {
  .game-layout {
    grid-template-columns: 220px minmax(330px, 1fr);
  }
  .game-layout > .game-side:last-child {
    grid-column: 1/3;
    grid-template-columns: 1fr 1fr;
  }
  .chess-hero {
    padding-top: 55px;
  }
}
@media (max-width: 640px) {
  .chess-wrap {
    width: calc(100% - 28px);
  }
  .chess-hero {
    display: block;
    padding: 48px 0 34px;
  }
  .hero-badge {
    margin-top: 25px;
  }
  .game-layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
  }
  .game-side {
    width: 100%;
  }
  .game-layout > .game-side:last-child {
    display: grid;
    grid-template-columns: 1fr;
  }
  .board-panel {
    width: 100%;
  }
  .chess-board {
    border-width: 5px;
  }
  .chess-features {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  .game-actions {
    flex-wrap: wrap;
  }
  .game-actions #gameMessage {
    margin-left: 0;
  }
  .square {
    font-size: clamp(1.55rem, 9.2vw, 2.5rem);
  }
}
