/*
=========== Contents ===========
1. General setup
2. Board controls
3. Checkered board
4. Board labels
5. Miscellaneous
*/

/*
=========== General setup ===========
*/
html {
  background-color: #a8a09a;
  overflow: hidden;
}
body {
  margin: 0;
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
}
#main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  position: relative;
}

/*
=========== Board controls ===========
*/
table {
  border-spacing: 0;
  user-select: none;
  -webkit-user-select: none;
  cursor: default !important;
}
td {
  text-align: center;
  width: var(--cell-size, 80px);
  height: var(--cell-size, 80px);
  border: none;
  position: relative;
}
/* Wrapper handles border, radius and shadow so Firefox clips corners */
#board-wrapper {
  border: var(--border-width, 20px) solid #5c3a1e;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(40, 25, 15, 0.45);
  overflow: hidden;
  line-height: 0;
}
/*Fix links to not look like links, and choose the proper font for pieces*/
#board a {
  text-decoration: none;
  font-family: 'Arial Unicode MS', sans-serif;
  font-variant-emoji: text;
}
/*Make the black pieces dark with subtle light shadow*/
#board a.black {
  color: #2c2420;
  text-shadow:
    0 1px 2px rgba(255, 245, 230, 0.25),
    0 0 1px rgba(255, 245, 230, 0.15);
}
/*Make the white pieces white with subtle dark shadow*/
#board a.white {
  color: #faf6f0;
  text-shadow:
    0 1px 3px rgba(50, 30, 15, 0.45),
    0 0 2px rgba(50, 30, 15, 0.25);
}

/*
=========== Checkered board ===========
Note that white cells are first, black are second
*/
.wc {
  background-color: #f0d9b5;
}
.bc {
  background-color: #b58863;
}
.lastMove.wc {
  background-color: #f5e6a3 !important;
}
.lastMove.bc {
  background-color: #d4a830 !important;
}
/* Valid move: green dot in center */
.valid::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 25%;
  height: 25%;
  border-radius: 50%;
  background: rgba(90, 145, 70, 0.55);
  pointer-events: none;
}
/* Capturable pieces: red ring */
.valid:has(a)::after {
  width: 85%;
  height: 85%;
  background: none;
  border: calc(var(--cell-size, 80px) * 0.08) solid rgba(180, 60, 45, 0.5);
}
.origin {
  background-color: rgba(196, 170, 120, 0.55) !important;
}

/*
=========== Board labels (A-H, 1-8) ============
*/
p {
  position: absolute;
  font-weight: 600;
  color: #faf6f0;
  text-shadow: 0 0 5px rgba(250, 246, 240, 0.8);
  margin: auto;
}
.invis {
  color: #a8a09a;
  text-shadow: none;
}

#whiteTurn2,
#blackTurn2,
#blackTurn2Landscape {
  position: static;
  text-align: center;
  flex-shrink: 0;
  width: calc(var(--cell-size, 80px) * 0.5);
  font-size: calc(var(--cell-size, 80px) * 0.35);
  line-height: calc(var(--cell-size, 80px) * 0.5);
}
#whiteTurn2 {
  text-shadow: 0 0 5px rgba(250, 246, 240, 0.8);
  color: #faf6f0;
}
#blackTurn2,
#blackTurn2Landscape {
  text-shadow: 0 0 5px rgba(44, 36, 32, 0.6);
  color: #2c2420;
}
.landscape-only {
  display: none !important;
}
#conversion {
  position: fixed;
  width: 320px;
  height: auto;
  padding: 24px 28px;
  top: 50%;
  left: 50%;
  margin-top: -90px;
  margin-left: -160px;
  border: none;
  background-color: #fdf9f5;
  text-align: center;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(40, 25, 15, 0.3);
  z-index: 20;
}
#conversion h1 {
  font-size: 18px;
  font-weight: 600;
  color: #3a2a1e;
  margin: 0 0 16px 0;
}
#conversion input[type='radio'] {
  margin: 8px 6px;
  accent-color: #5c3a1e;
}
#conversion a {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 28px;
  background: #5c3a1e;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease;
}
#conversion a:hover {
  background: #7a4f2e;
}
#startMenu {
  position: fixed;
  width: 320px;
  height: auto;
  padding: 28px 32px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  border: none;
  background-color: #fdf9f5;
  text-align: center;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(40, 25, 15, 0.3);
}
#background {
  align-items: center;
  justify-content: center;
  transition: 0.25s opacity;
  background: radial-gradient(
    rgba(120, 110, 100, 0.5),
    rgba(120, 110, 100, 0.5) 35%,
    rgba(30, 20, 15, 0.7)
  );
  bottom: 0;
  display: flex;
  left: 0;
  overflow: auto;
  padding: 20px;
  padding-bottom: 130px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 10;
}
h2 {
  font-size: 20px;
  font-weight: 700;
  color: #3a2a1e;
  margin: 0 0 20px 0;
}
h3 {
  font-size: 14px;
  font-weight: 600;
  color: #8a7568;
  margin: 12px 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#startMenu select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d4c4b0;
  border-radius: 8px;
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 14px;
  color: #3a2a1e;
  background: #fdfaf7;
  appearance: auto;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
#startMenu select:focus {
  outline: none;
  border-color: #5c3a1e;
}
#startMenu input[type='button'] {
  margin-top: 20px;
  padding: 10px 32px;
  background: #5c3a1e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
#startMenu input[type='button']:hover {
  background: #7a4f2e;
}
#startMenu br {
  display: none;
}

/*
=========== Miscellaneous ============
*/

#restartBtn,
#undoBtn {
  background: none;
  border: none;
  border-radius: 8px;
  font-family: 'Arial Unicode MS', sans-serif;
  font-size: calc(var(--cell-size, 80px) * 0.3);
  line-height: calc(var(--cell-size, 80px) * 0.5);
  width: calc(var(--cell-size, 80px) * 0.5);
  height: calc(var(--cell-size, 80px) * 0.5);
  cursor: pointer;
  color: #3a2a1e;
  opacity: 0.5;
  padding: 0;
  flex-shrink: 0;
  transition:
    opacity 0.15s ease,
    background 0.15s ease;
}
#restartBtn:hover,
#undoBtn:hover {
  opacity: 1;
}

.button-group {
  display: flex;
  flex-shrink: 0;
}
.hidden {
  display: none !important;
}
.invisible {
  visibility: hidden;
}
.notYourTurn {
  pointer-events: none;
}
/*
Fix-it-all for mouseposition shizz. This ensures that while mouse is being dragged, no events will be fired from the <a>
*/
a.dragging {
  pointer-events: none;
}
.tray-row {
  display: flex;
  align-items: center;
  width: calc(var(--cell-size, 80px) * 8 + var(--border-width, 20px) * 2 + 2px);
  padding: 0 var(--border-width, 20px);
  gap: 4px;
  box-sizing: border-box;
}
.captured-tray {
  flex: 1;
  text-align: center;
  font-family: 'Arial Unicode MS', sans-serif;
  font-size: calc(var(--cell-size, 80px) * 0.3);
  min-height: calc(var(--cell-size, 80px) * 0.5);
  line-height: calc(var(--cell-size, 80px) * 0.5);
  letter-spacing: 4px;
  user-select: none;
  -webkit-user-select: none;
  font-variant-emoji: text;
}
#captured-black {
  color: #2c2420;
  text-shadow: 0 0 4px rgba(255, 245, 230, 0.35);
}
#captured-white {
  color: #e8e0d8;
  text-shadow: 0 0 4px rgba(50, 30, 15, 0.35);
}

@media (orientation: landscape) {
  #main {
    flex-direction: row;
  }
  .tray-row {
    flex-direction: column;
    align-items: center;
    max-width: calc(var(--cell-size, 80px) * 0.5);
    height: calc(
      var(--cell-size, 80px) * 8 + var(--border-width, 20px) * 2 + 2px
    );
    padding: 0;
    gap: 0;
    overflow: hidden;
  }
  .button-group {
    flex-direction: column;
  }
  #blackTurn2 {
    visibility: hidden;
  }
  #blackTurn2Landscape {
    display: block !important;
    height: calc(var(--cell-size, 80px));
    line-height: calc(var(--cell-size, 80px));
  }
  .captured-tray {
    flex: 1;
    max-width: calc(var(--cell-size, 80px));
    word-break: break-all;
    line-height: calc(var(--cell-size, 80px) * 0.4);
  }
}
