/* General Styling */
:root {
  --main-bg-color: brown;
}

body {
  margin: 0;
}

.game-grid {
  --max-height: calc(100vh - 2rem + 5px);
  --max-width: calc(100vw - 2rem + 5px);
  --number_of_squares: 6;
  display: flex;
  flex-wrap: wrap;
  position: relative;
  height: min(var(--max-height), var(--max-width));
  width: min(var(--max-height), var(--max-width));
  max-width: var(--max-width);
  max-height: var(--max-height);
  background-color: rgba(109, 127, 151, 0.5);
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5) inset, 0 1px 0 #fff;
  object-fit: cover;
  padding: 5px;
}
.grid-full {
  container-type: inline-size;
  container-name: fullgrid;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  flex-direction: row;
  gap: 1rem;
  width: 100vw;
  height: 100vh;
  margin: 0;
  background-image: url('bg-img/asbjorn.png'), url('bg-img/nuts.png');
  background-repeat: no-repeat;
  background-position: bottom right, top left;
  background-size: auto, cover;
  overflow-y: hidden;
}

.game-grid div {
  height: calc(
    min(var(--max-height), var(--max-width)) / (var(--number_of_squares))
  );
  width: calc(
    min(var(--max-height), var(--max-width)) / (var(--number_of_squares))
  );
  background-size: cover;
  background-position: center;
  border-radius: 5px;
  transition: transform 0.2s ease; /* Smooth animation for interactions */
}

/* Hover effect for interactivity */
.game-grid div:hover {
  transform: scale(1.05); /* Slightly enlarge on hover */
}

/* Scoreboard Styling */
.scoreBoard {
  position: absolute;
  box-sizing: border-box;
  background-color: hsl(48deg 100% 93.14% / 84%);
  border-radius: 20px;
  width: auto;
  padding: 20px;
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #85796b;
  max-width: 12rem;
  max-height: fit-content;
  bottom: 8%;
  right: 8%;
}

@container fullgrid (width < 600px) {
  .scoreBoard {
    height: fit-content;
    width: fit-content;
    flex-direction: column;
    left: 5%;
    right: auto;
    top: unset;
    bottom: 16px;
    background-position: initial;
  }
}

@media (width < 600px) {
  .grid-full {
    position: fixed;
    height: 100%;
    background-color: #ff6347;
    background-position: initial;
    background-image: url('bg-img/asbjorn.png'), url('bg-img/nuts.png');
    background-repeat: no-repeat;
    background-position: bottom right, center center;
    background-attachment: fixed;
    background-size: auto, cover;
    flex-direction: unset;
    align-content: flex-start;
    justify-self: start;
    padding-top: 16px;
  }
}

h3,
h1 {
  font-family: 'Montserrat', sans-serif;
  margin: 0;
}

.game-grid div:hover {
  transform: scale(1.05); /* Slightly enlarge on hover */
}

/* Mode Selection Styling */
#gameModeSelection {
  display: flex;
  position: absolute;
  top: 0;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: hsl(0deg 0% 94.12% / 42%);
  font-family: 'Montserrat', sans-serif;
  padding-block: 2rem;
}

#gameModeSelection h1 {
  padding-inline: 1rem;
  font-size: clamp(1.5rem, 2.5vw, 5rem);
  color: #333;
  text-align: center;
  margin-top: 16px;
}

#gameModeSelection p {
  padding-inline: 1rem;
}

#gameModeSelection button {
  margin: 10px;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background-color: #d76f2c;
  border: none;
  border-radius: 32px;
  padding: 16px 44px;
  color: white;
}
#gameModeSelection button.secondary {
  background-color: #fff;

  color: #d76f2c;

  position: relative;
  text-decoration: none;
  transform: perspective(1px) translateZ(0);
  white-space: nowrap;
  border: 2px solid #d76f2c;
}

#gameModeSelection button.button-info {
  background-color: unset;
  padding: unset;
  margin: 0px;
}

/* Timer and Change Mode Button */
#timer {
  font-size: 18px;
}

#gameChangeMode {
  margin-top: 10px;
  padding: 5px 10px;
  background-color: #ff6347;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#gameButtons {
  display: flex;
  flex-direction: column;
}

/* Initially Hide Game Elements */
.game-grid,
.scoreBoard {
  display: none;
}

[popover]:popover-open {
  display: block;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

[popover] {
  position: fixed;
  inset: 0;
  width: fit-content;
  max-width: min(754px, 98%);
  padding-block: 3rem;
  padding-inline: 1rem;
  border-radius: 0.5rem;
  height: fit-content;
  border: solid 1px #ccc;
  overflow: auto;
  color: CanvasText;
  background-color: Canvas;
}

[popover] button.popover-close svg {
  color: white;
}

[popover] button.popover-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  float: right;
  -webkit-box-align: center;
  align-items: center;
  -webkit-box-pack: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: background-color 0.3s ease-in-out;
  background-color: #d76f2c;
}
