/* Englishbuds Chess Game */

:root {
  --chess-light: #f3e7c9;
  --chess-dark: #79a86b;
  --chess-border: #456e3d;
  --selection: #ffd83d;
  --last-move: rgba(255, 216, 61, 0.42);
  --panel-border: #d5e6cb;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 10% 5%, rgba(142, 216, 248, 0.2), transparent 28rem), var(--eb-background);
}

button:focus-visible,
.square:focus-visible {
  outline: 4px solid var(--eb-yellow);
  outline-offset: 2px;
}

.chess-app {
  width: min(100% - 24px, 1180px);
  padding-block: 18px 28px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--eb-space-md);
  margin-bottom: 14px;
  padding: 10px 16px;
  border: 1px solid #cfe4f1;
  border-radius: var(--eb-radius-medium);
  background: rgba(255, 255, 255, 0.94);
}

.brand-title { display: flex; align-items: center; min-width: 0; gap: 16px; }
.game-logo { width: min(185px, 31vw); }
.title-divider { width: 1px; height: 34px; background: var(--eb-border); }
.brand-title h1 { margin: 0; color: var(--eb-green-dark); font-size: clamp(1.25rem, 2.6vw, 2rem); line-height: 1.1; white-space: nowrap; }
.restart-button { min-height: 44px; padding: 9px 18px; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 290px);
  gap: 18px;
  align-items: start;
}

.board-section,
.game-panel {
  border: 1px solid var(--eb-border);
  border-radius: var(--eb-radius-large);
  background: var(--eb-white);
  box-shadow: var(--eb-shadow);
}

.board-section { display: grid; justify-items: center; padding: clamp(14px, 2.5vw, 26px); }

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: min(100%, 720px);
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: clamp(5px, 1vw, 10px) solid var(--chess-border);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(33, 78, 45, 0.2);
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.square.light { background: var(--chess-light); }
.square.dark { background: var(--chess-dark); }
.square:hover { filter: brightness(1.04); }
.square:disabled { cursor: default; }
.square.last-move { box-shadow: inset 0 0 0 999px var(--last-move); }
.square.selected { box-shadow: inset 0 0 0 4px var(--selection); }
.square.last-move.selected { box-shadow: inset 0 0 0 999px var(--last-move), inset 0 0 0 4px var(--selection); }

.square.legal-move::after {
  content: "";
  position: absolute;
  width: 18%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: rgba(44, 82, 43, 0.48);
  pointer-events: none;
}

.square.legal-capture::after {
  content: "";
  position: absolute;
  inset: 7%;
  border: 4px solid rgba(255, 216, 61, 0.78);
  border-radius: 50%;
  pointer-events: none;
}

.chess-piece {
  position: absolute;
  display: grid;
  place-items: center;
  width: 86%;
  height: 86%;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
  font-size: clamp(2rem, 6.2vw, 4.7rem);
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.chess-piece.white {
  color: #fffdf7;
  text-shadow: -1px -1px 0 #333, 1px -1px 0 #333, -1px 1px 0 #333, 1px 1px 0 #333, 0 2px 3px rgba(0,0,0,.3);
}

.chess-piece.black { color: #202522; text-shadow: 0 2px 2px rgba(255,255,255,.28); }

.game-message { min-height: 1.5em; margin: 12px 0 0; color: var(--eb-green-dark); font-weight: 700; text-align: center; }

.game-panel { display: grid; gap: 16px; padding: 16px; }
.status-card { padding: 14px; border: 1px solid var(--panel-border); border-radius: var(--eb-radius-medium); }
.player-row { padding: 7px 4px; font-size: 1.08rem; font-weight: 700; }
.player-label { display: inline-flex; align-items: center; gap: 9px; }
.player-piece { display: inline-grid; place-items: center; width: 28px; height: 28px; font-family: "Segoe UI Symbol", sans-serif; font-size: 1.7rem; line-height: 1; }
.player-piece.white, .turn-piece.white { color: white; text-shadow: -1px -1px 0 #333, 1px -1px 0 #333, -1px 1px 0 #333, 1px 1px 0 #333; }
.player-piece.black, .turn-piece.black { color: #202522; }

.turn-display { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--eb-green-light); color: #355517; font-weight: 800; }
.turn-piece { font-family: "Segoe UI Symbol", sans-serif; font-size: 1.55rem; line-height: 1; }
.check-display { margin: 10px 0 0; padding: 8px; border-radius: 10px; background: #fff1c7; color: #8a5710; font-weight: 800; text-align: center; }

.mascot-area { display: grid; place-items: end center; min-height: 0; }
.game-mascot { display: block; width: min(150px, 76%); height: auto; }

.dialog-overlay,
.result-dialog { position: fixed; z-index: 11; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(45, 61, 48, 0.28); }
.dialog-card { width: min(100%, 380px); padding: 24px; border: 1px solid var(--eb-border); border-radius: var(--eb-radius-medium); background: white; box-shadow: var(--eb-shadow); text-align: center; }
.dialog-card h2 { margin: 0 0 20px; color: var(--eb-text); font-size: 1.35rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions .eb-button { min-height: 48px; padding: 10px 16px; }

.promotion-card { width: min(100%, 470px); }
.promotion-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.promotion-choices button { display: grid; place-items: center; gap: 4px; min-height: 92px; padding: 8px; border: 2px solid var(--eb-green); border-radius: 14px; background: white; color: #202522; cursor: pointer; }
.promotion-choices button:hover { background: var(--eb-green-light); }
.promotion-choices span { font-family: "Segoe UI Symbol", sans-serif; font-size: 2.5rem; line-height: 1; }
.promotion-choices small { font-weight: 700; }

.result-dialog { z-index: 12; background: rgba(32, 48, 36, 0.54); }
.result-card { width: min(100%, 430px); padding: 30px; border: 5px solid var(--eb-green-light); border-radius: var(--eb-radius-large); background: white; box-shadow: 0 16px 45px rgba(0,0,0,.25); text-align: center; }
.result-eyebrow { margin: 0; color: #327ab8; font-size: .8rem; font-weight: 800; letter-spacing: .14em; }
.result-card h2 { margin: 8px 0; color: var(--eb-green-dark); font-size: clamp(1.5rem, 5vw, 2.2rem); }
.result-message { margin: 0 0 22px; color: var(--eb-text); font-size: 1.25rem; font-weight: 700; }

@media (max-width: 780px) {
  .game-layout { grid-template-columns: 1fr; }
  .game-panel { grid-template-columns: 1fr 1fr; align-items: center; }
  .game-mascot { width: min(120px, 80%); }
}

@media (max-width: 560px) {
  .chess-app { width: 100%; padding: 10px; }
  .game-header { align-items: flex-start; padding: 10px; }
  .brand-title { align-items: flex-start; flex-direction: column; gap: 4px; }
  .game-logo { width: 142px; }
  .title-divider { display: none; }
  .restart-button { width: auto; min-height: 42px; padding-inline: 12px; }
  .board-section { padding: 10px; border-radius: var(--eb-radius-medium); }
  .chess-piece { font-size: clamp(1.75rem, 11vw, 3.1rem); }
  .square.selected { box-shadow: inset 0 0 0 3px var(--selection); }
  .game-panel { grid-template-columns: 1fr; }
  .status-card { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .turn-display, .check-display { grid-column: 1 / -1; }
  .game-mascot { width: 105px; }
  .promotion-choices { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
