/* === Base Styles === */
body {
  font-family: 'Montserrat', sans-serif;
  margin: 0;
  padding: 0;
  background: #fffbe3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow-x: hidden;
}

h1 {
  font-family: 'Michroma', sans-serif;
  margin-bottom: 0.5rem;
}

/* === Game Board === */
#board {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 0;
  transform: scale(1);
  transform-origin: top center;
}

.sub-board {
  display: grid;
  grid-template-columns: repeat(3, auto);
  border: 4px solid #8ed6ea;
  position: relative;
}

/* Clean outer borders */
.sub-board:nth-child(-n+3) { border-top: none; }
.sub-board:nth-child(3n+1) { border-left: none; }
.sub-board:nth-child(3n) { border-right: none; }
.sub-board:nth-child(n+7) { border-bottom: none; }

/* === Cells === */
.cell {
  font-family: 'Michroma', sans-serif;
  width: 60px;
  height: 60px;
  font-size: 32px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border: 1px solid #fdec51;
  transition: opacity 0.3s ease;
}

.sub-board .cell:nth-child(3n) {
  border-right: none;
}
.sub-board .cell:nth-child(n+7) {
  border-bottom: none;
}

/* === Sub-board Winner Overlay === */
.sub-board-winner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  font-size: 200px;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  pointer-events: none;
  z-index: 2;
}

/* === Game Status === */
#game-message {
  font-family: 'Michroma', sans-serif;
  font-size: 1.5rem;
  color: #333;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  text-align: center;
  display: none;
  transition: opacity 0.3s ease;
}

#game-message.game-message-box {
  padding: 1rem 2rem;
  border: 3px solid #fdec51;
  background-color: #fff9c4;
  font-size: 1.6rem;
  font-weight: bold;
  border-radius: 10px;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1);
}

/* === Buttons & Dropdowns === */
button {
  font-family: 'Michroma', sans-serif;
  background-color: #fdec51;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  padding: 0.4rem 0.8rem;
  font-size: 1rem;
}

button:hover {
  background-color: #fbe521;
}

select {
  font-family: 'Montserrat', sans-serif;
  background-color: #fdec51;
  font-size: 1rem;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  border: 1px solid #aaa;
  min-width: 80px; /* Prevent dropdowns from shrinking too much */
}

/* === Mode Row === */
.mode-container {
  margin: 1rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* FORCE horizontal layout on small screens */
@media (max-width: 480px) {
  .mode-container {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }

  #ai-choice-container,
  #game-mode,
  #info-icon {
    flex-shrink: 0;
    white-space: nowrap;
    margin-bottom: 0.5rem;
  }
}


/* === AI Choice === */
#ai-choice-container {
  display: none; /* Controlled by JS */
  align-items: center;
  gap: 0.3rem;
}

/* === Info Icon & Rules Modal === */
#info-icon {
  cursor: pointer;
  font-size: 1.2rem;
  color: #fdec51;
  user-select: none;
  flex-shrink: 0;
  white-space: nowrap;
}

#rules-modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

#rules-content {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  width: 80%;
  max-width: 400px;
  position: relative;
  font-size: 1rem;
  color: black;
  max-height: 80vh;
  overflow-y: auto;
}

#close-rules {
  position: absolute;
  top: 0.4rem;
  right: 0.8rem;
  font-size: 1.5rem;
  cursor: pointer;
}

/* === Responsive Layout for Mobile === */
@media (max-width: 768px) {
  #board {
    transform: scale(0.95);
  }
}

@media (max-width: 480px) {
  #board {
    transform: scale(0.9);
  }

  .cell {
    width: 12vw;
    height: 12vw;
    font-size: 6vw;
  }

  .sub-board-winner {
    font-size: 100px;
  }

  h1 {
    font-size: 7vw;
    text-align: center;
    margin-bottom: 0.2rem;
  }

  body > div:first-of-type {
    margin-top: 0.2rem;
    margin-bottom: 0.5rem;
  }

  #game-message {
    font-size: 6vw;
  }
}

/* === Utility Classes === */
.underline-italic {
  text-decoration: underline;
  font-style: italic;
  color: inherit;
}

.side-by-side {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
}

.side-by-side img {
  max-height: 60px;
  width: auto;
}


