/* ---------- Base / Reset ---------- */
:root {
  --base-width: 1920;
  --base-height: 1080;
  --panel-width: 420px;
  --right-panel-width: 420px;
}

/* ---------- Basic Page ---------- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  background: #241a14;
}

/* ---------- Scaling Wrapper ---------- */
#app-scale-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#app {
  width: 1920px;
  height: 1000px;
  transform-origin: center;
  position: relative;
  box-sizing: border-box;
}

/* ---------- Centered Game Mode Selection ---------- */
.center-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.title {
  font-size: 220px;
  color: #f3efe8;
  margin-bottom: 32px;
  letter-spacing: 1px;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  font-weight: 900;
}

.menu-buttons {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-btn {
  width: 400px;
  padding: 18px 22px;
  border-radius: 08px;
  border: none;
  cursor: pointer;
  font-size: 40px;
  font-weight: 400;
  color: #fff;
  background: #463026;
  box-shadow: 0 8px 18px rgba(0,0,0,0.45);
  transition: transform 220ms cubic-bezier(.2,.9,.2,1), box-shadow 220ms;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mode-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 12px 26px rgba(0,0,0,0.6);
}

.mode-btn:active {
  transform: scale(1.02);
}

/* ---------- Main Container ---------- */
.container-centered {
  width: 100%;
  height: 100%;
  padding: 40px;
  box-sizing: border-box;
}

/* ---------- Layout Grid ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--right-panel-width) 1fr var(--panel-width);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "controls board history"
    "right board history";
  gap: 20px 32px;
  align-items: start;
  justify-content: center;
  height: 935px;
}

/* ---------- Controls ---------- */
.controls {
  grid-area: controls;
  display: flex;
  flex-direction: row;
  gap: 20px;
}

.side-btn {
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  background: #463026;
  color: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  transition: transform 180ms, box-shadow 180ms;
  display: inline-flex; 
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.controls .side-btn {
  width: 200px;
  height: 100px;
  font-size: 30px;
}

.side-btn:hover {
  transform: scale(1.02);
}

.confirm-btn {
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  background: #463026;
  color: #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.45);
}

/* ---------- Left Panel (History) ---------- */
.left-panel {
  grid-area: history;
  background: #463026;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.move-history {
  flex: 2 2 auto;
  overflow-y: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace;
  color: #f7f3ee;
  font-size: 25px;
  line-height: 1.6;
  display: grid;
  grid-auto-rows: min-content;
  gap: 10px;
}

.move-row {
  display: flex;
  gap: 25px;
  align-items: baseline;
}

.move-number {
  color: #ffffff;
  min-width: 48px;
  text-align: right;
  font-weight: 700;
}

.move-pair {
  display: flex;
  gap: 30px;
}

.move-white,
.move-black {
  background: #463026;
  padding: 6px 10px;
  border-radius: 8px;
  color: #fff;
  min-width: 40px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.45);
}

/* ---------- Board ---------- */
.board-area {
  grid-area: board;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 940px;
  height: 940px;
  aspect-ratio: 1/1;
  border: 10px solid #463026;
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.08);
  overflow: hidden;
}

.square {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(25px, 4vw, 48px);
  cursor: pointer;
  position: relative;
  transition: background-color 120ms ease-in-out;
}

.square.light {
  background-color: #F0D9B5;
}

.square.dark {
  background-color: #9a7251;
}

.piece {
  pointer-events: none;
  user-select: none;
}

.piece.white {
  color: #ffffff;
  -webkit-text-stroke: 1px rgba(0,0,0,0.2);
  text-shadow: 0 3px 6px rgba(0,0,0,0.28);
}

.piece.black {
  color: #000000;
  text-shadow: 0 2px 4px rgba(0,0,0,0.12);
}

/* ---------- Animations ---------- */
@keyframes moved-pop {
  0% { transform: scale(0.72); filter: brightness(1.06); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.piece.moved {
  animation: moved-pop 300ms cubic-bezier(.2,.9,.2,1) both;
}

.selected {
  background-color: #FFD700 !important;
  filter: brightness(1.05);
}

.legal-move-dot {
  position: absolute;
  width: 20%;
  height: 20%;
  background-color: rgba(0,0,0,0.2);
  border-radius: 50%;
  pointer-events: none;
}

.legal-capture-ring {
  position: absolute;
  width: 90%;
  height: 90%;
  border: 6px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  box-sizing: border-box;
  pointer-events: none;
}

.check {
  background-color: #ff3835 !important;
  animation: pulse-check 1.5s infinite;
}

@keyframes pulse-check {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
  100% { filter: brightness(1); }
}

/* ---------- Coordinate Labels ---------- */
.coord-label {
  position: absolute;
  font-size: clamp(10px, 2.1vw, 12px);
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.coord-label.rank {
  top: 4px;
  left: 6px;
}

.coord-label.file {
  bottom: 4px;
  right: 6px;
}

.square.light .coord-label {
  color: #795548;
  opacity: 0.85;
}

.square.dark .coord-label {
  color: #EFEBE9;
  opacity: 0.85;
}

/* ---------- Right Panel ---------- */
.right-panel {
  grid-area: right;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
}

.captured-box {
  background: #463026;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  color: #f3efe8;
}

.captured-box h3, .left-panel h3 {
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 18px;
  font-weight: 700;
  color: #f3efe8;
}

.captured-pieces {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-content: flex-start;
  overflow-y: auto;
  font-size: 44px;
}

/* ---------- Modals ---------- */
#promotion-modal {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.6);
  z-index: 100;
}

#promotion-content {
  background: #fefefe;
  padding: 20px;
  border-radius: 10px;
  display: flex;
  gap: 12px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.4);
}

.custom-modal {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.custom-modal-inner {
  background: #fff;
  padding: 22px;
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
}

/* ---------- Accessibility ---------- */
.mode-btn:focus,
.side-btn:focus,
.confirm-btn:focus {
  outline: 3px solid rgba(255,255,255,0.06);
  outline-offset: 3px;
}

/* ---------- Align Game Container to Top ---------- */
#game-container {
  justify-content: flex-start;
  padding-top: 30px;
  padding-bottom: 30px;
}
