:root {
  --light: #F0D9B5;
  --dark: #8b4513ca;

  --viewWH: min(76vmin, 512px);
  --viewMobile: min(70vmin, 512px);
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: #201f1f;
  color: #eee;
}

.container {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
}

shah {
  color: #786ed2;
  font-size: 1.15em;
}

#shah {
    color:#c8c7c7;
}

.game-area {
  display: flex;
  justify-content: center;
  position: relative;
  padding: 2vh;
}

.board {
  transform: translateZ(0);
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 5px solid #443;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  background: #695f5ff6;
  height: var(--viewWH);
  width: var(--viewWH);
}

.piece-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    transition: transform 0.18s ease-out;
    transform-origin: center center;
}

#piece-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}


.sq {
  position: relative;
  transform: translateZ(0);
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--viewWH) * 0.55);
  user-select: none;
  cursor: pointer;

  background-size: cover;
  background-repeat: repeat;
  background-blend-mode: multiply;
  background-image: url("https://www.transparenttextures.com/patterns/wood-pattern.png");
}

.sq.light {
  background-color: var(--light);
}

.sq.dark {
  background-color: var(--dark);
}

.sq.sel {
  border: 2px solid rgba(172, 229, 190, 0.9);
  border-radius: 50px;
}

.sq.move {
  position: relative;
}

.sq.move::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: rgba(0, 0, 0, 0.35); /* muda a cor se quiser */
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.sq.move-capture {
  position: relative;
}

.sq.move-capture::after {
  content: "";
  position: absolute;
  width: 56px;
  height: 56px;
  background: rgba(255, 0, 0, 0.130);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  pointer-events: none;

  animation: capturePulse 1s ease-in-out infinite;
}

.captured-anim {
  animation: pieceCaptureSpin 0.41s ease-out forwards;
  z-index: 5;
  position: relative;
}

#back-menu {
  display: none;
}


.info {
  display: flex;
  flex-direction: column;
  width: 20%;
  height: 100%;
  
  min-width: 25vw;
  min-height: 10vh;

  max-width: 50vw;
  max-height: 50vh;

  padding: 3vh;
}

.info h1 {
  margin: 0 0 8px 0;
  font-size: 20px;
}

#status {
  font-size: 13px;
  color: #ccc;
}

.controls {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

button {
    background: #5e54b8;
    border: none;
    color: #fafcfae3;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    width: 6vw;

    min-width: 120px;
    overflow-wrap: break-word;
    white-space: normal;

    border: 2px solid rgba(233, 232, 232, 0.3);

    /* leve sombra */
    box-shadow: 0 7px 4px rgba(0, 0, 0, 0.351);

    /* suavidade */
    transition: background-color 0.15s ease, 
                transform 0.1s ease, 
                box-shadow 0.15s ease;
}

button:hover {
    background-color: #5c53aea8;  /* ligeiramente mais escuro */
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.35);
}

button:active {
    transform: translateY(0px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
    background-color: #5c53ae48;
}

.fen-wrapper {
  margin-top: 12px;
}

.fen {
  font-family: monospace;
  background: #111;
  border: 1px solid #444;
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;

  min-width: 50px;
  min-height: 10px;
  max-width: 20vw;
  overflow-wrap: break-word;
  white-space: normal;
}

.note {
  margin-top: 10px;
  font-size: 12px;
  color: #ddd;

  width: 100%;
}

@keyframes capturePulse {
  0% {
    transform: translate(-50%, -50%) scale(0.95);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
  }
  100% {
    transform: translate(-50%, -50%) scale(0.95);
  }
}

@keyframes pieceCaptureSpin {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  70% {
    transform: scale(1.3) rotate(45deg);
    opacity: 0.7;
  }
  100% {
    transform: scale(0) rotate(80deg);
    opacity: 0;
  }
}

.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: var(--viewWH);
}

.clock {
  font-size: calc(var(--viewWH) * 0.06);
  font-weight: bold;
  padding: 4px 18px;
  width: fit-content;
  user-select: none;
  max-width: 100%;
  border-radius: 56px;

  margin-top: 1.2vh;
  margin-bottom: 1.2vh;
  margin-left: 0.5vw;
}

.clock-black {
  background: black;
  color: white;
}

.clock-white {
  background: white;
  color: black;
}

/* responsividade: em telas pequenas o menu volta a normal */
@media (max-width: 900px) {
  .board-wrapper {
    order: 1;
    margin-top: 3vh;
    transform: scale(1.1);
  }

  .clock {
    font-size: calc(var(--viewMobile) * 0.06);
  }

  .board-wrapper {
    align-items: center;
  }

  .board {
    height: var(--viewMobile);
    width: var(--viewMobile);
  }

  .info {
    order: 2;
    position: relative;
    width: 90%;
    padding: 0;
    max-height: none;
  }

  .fen {
    max-width: 35vw;
  }

  .note {
    max-width: 100%;
  }
}

/*responsividade para desktops ou superior*/
@media (min-width: 1920px) {
  .container {
    justify-content: center;
    gap: 5vw;
  }

  .controls {
    margin-left: 1vw;
  }
}