/* === Global Styles === */
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'DM Serif Text', serif;
  background: #fffdf0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

button,
input,
select {
  font-family: 'DM Serif Text', serif;
  background-color: #fffdf0;
}

select {
  background-color: #444;
}

select#game-mode {
  color: #fffdf0;
  border-radius: 5px;
}

/* === Game Wrapper Scale === */
#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: scale(1.2);
  transform-origin: top center;
  width: 100%;
}


/* === Headings === */
h1 {
  font-size: 2rem;
  color: #3d3d3d;
  margin-bottom: 1rem;
  white-space: nowrap;
}

#main-title {
  font-size: 2rem;
  color: #3d3d3d;
  margin-top: 5rem;
  margin-bottom: 0.5rem;
  text-align: center;
  font-weight: bold;
}

#main-title strong {
  font-weight: bold !important /* Force bold style for strong tag */
}


/* === Title Container and Info Button === */
#title-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0 40px; /* equal padding left and right */
}

#title-container h1 {
  font-size: 2rem;
  color: #3d3d3d;
  margin: 0;
  text-align: center;
  white-space: nowrap;
}

#info-button {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 2px solid #444;
  border-radius: 50%;
  background-color: transparent;
  color: #444;
  font-family: 'DM Serif Text', serif;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.2s ease;
}

#info-button:hover {
  background-color: #f2e9dd;
}

/* === Turn Indicator === */
#turn {
  font-size: 1.2rem;
  margin: 1rem 0;
  color: #444;
  text-align: center;
}

/* === Say Buttons === */
#say-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, auto));
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
}

/* === Buttons === */
button {
  padding: 0.8rem 1.2rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 10px;
  background-color: #fffdf0;
  color: #444;
  cursor: pointer;
  transition: background-color 0.2s ease;
  box-sizing: border-box;
}

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

.cream-btn {
  background-color: #fffdf0;
  color: #444;
  border: 1px solid #ccc;
}

.cream-btn:hover {
  background-color: #f2e9dd;
}

/* === Number Area === */
.number-area {
  max-height: 300px;
  overflow-y: auto;
  margin: 1.5rem auto;
  display: grid;
  grid-template-columns: repeat(5, 50px);
  gap: 10px;
  justify-content: center;
}

.number-box {
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 8px;
  color: white;
}

.player1 {
  background-color: #958BBE;
}

.player2 {
  background-color: #004f74;
}

.loser {
  background-color: #e63946 !important;
}

.winner {
  background-color: #009e30 !important;
}

/* === Game Result Text === */

/* Default result text color (loss or draw) */
.result {
  font-size: 1.3rem;
  font-weight: bold;
  color: #e63946; /* red for loss by default */
  margin-top: 1rem;
}

/* When player wins */
.result.win {
  color: #009e30 !important; /* green for win */
}

/* When it's a draw */
.result.draw {
  color: #f1faee !important; /* light gray/white for draw */
}

/* When player loses */
.result.lose {
  color: #d62828 !important; /* dark red for loss */
}


/* === Hidden Utility === */
.hidden {
  display: none !important;
}

/* === Setup Screen === */
.setup-screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
  background-color: #ffd39d;
  border-radius: 1rem;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  max-width: 320px;
  width: 90%;
  margin: 2rem auto 0 auto; /* centered horizontally */
  margin-top: 0.5rem;
  text-align: center;
  font-size: 1.05rem;
  align-items: center;
}


.setup-screen h2 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  font-family: 'DM Serif Text', serif;
}

.setup-screen label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
}

.setup-screen input,
.setup-screen select {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  max-width: 100%; /* Allow it to expand fully within the container */
  width: 100%; /* Ensures the inputs take full width available */
  box-sizing: border-box;
  background-color: #fffdf0;
  color: #444;
}


.setup-screen button {
  max-width: 200px;
  margin: 0 auto;
}

/* === Game Container === */
#game-container {
  display: none;
  text-align: center;
  max-width: 600px;
  width: 90%;
}

/* === Button Row === */
.button-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.dark-grey-btn {
  background-color: #444444;
  color: white;
  border: none;
}

.dark-grey-btn:hover {
  background-color: #222222;
}

/* === Dropdown Option Colors === */
option {
  background-color: #fffdf0;
  color: #444;
}

#game-mode {
  text-align: center;
  text-align-last: center;
}

#game-mode-label {
  margin-right: 1rem;
}

#first-player {
  color: #fffdf0;
  border-radius: 5px;
  background-color: #444;
  text-align: center;
  text-align-last: center;
}

/* === First Move Section === */
#first-move-label {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

#first-move-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

/* === Dropdown Containers === */
.mode-select {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.dropdown-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* === Intro Group === */
.intro-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: auto;
  margin-bottom: auto;
}

/* === Rules Modal === */
#rules-modal.hidden {
  display: none !important;
}

#rules-modal {
  position: fixed;
  inset: 0; /* shorthand for top: 0; right: 0; bottom: 0; left: 0 */
  background: rgba(0, 0, 0, 0.5); /* full-screen overlay */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#rules-content {
  background: #fffdf0;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 90%;
  font-family: 'DM Serif Text', serif;
  color: #444;
  animation: fadeIn 0.25s ease-out;
  position: relative;
  text-align: left;

  /* Allow scrolling if content exceeds max height */
  max-height: 600px;  /* Adjust based on the height you want */
  overflow-y: auto;  /* This enables scrolling */
}

#rules-content h2 {
  margin-top: 0;
  font-size: 1.8rem;
  text-align: center;
}

#rules-content p {
  font-size: 1.1rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

#close-rules-btn {
  display: block;
  margin: 0 auto;
  padding: 0.6rem 1.2rem;
  background-color: #444444;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'DM Serif Text', serif;
  font-size: 1rem;
  transition: background-color 0.2s ease;
}

#close-rules-btn:hover {
  background-color: #222222;
}


@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* === Hide Game Title === */
#game-title-container {
  display: none;
}

/* === Responsive (Mobile) === */
@media (max-width: 600px) {
  body {
    padding: 1rem;
  }

  #main-title {
    font-size: 1.5rem;
    white-space: normal;
  }

  .setup-screen {
    margin-top: 2rem;
    padding: 1.5rem;
    width: calc(100% - 5rem);
    max-width: 100%;
    padding-left: 2rem;
    padding-right: 2rem;
    margin-left: 5rem;
    margin-right: 5rem;
  }


  .setup-screen input,
  .setup-screen select {
    width: auto;
    max-width: 140px;
    margin: 0 auto;
    text-align: center;
    box-sizing: border-box;
  }

  button,
  .setup-screen button {
    width: auto;
    max-width: 140px;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
    border-radius: 10px;
  }

  #say-buttons button {
    min-width: 60px;
    max-width: 140px;
    font-size: 0.95rem;
  }

  .number-area {
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: 6px;
  }

  .number-box {
    width: 100%;
    height: 40px;
    font-size: 1rem;
  }

  .button-row {
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }

  .mode-select,
  .dropdown-row {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  select,
  #game-mode,
  #first-player {
    width: auto;
    max-width: 140px;
    padding: 0.6rem;
    box-sizing: border-box;
    text-align: center;
    text-align-last: center;
    background-color: #444;
    color: #fffdf0;
    border-radius: 5px;
    display: block;
    margin-left: auto;
    margin-right: auto;
  }

  #title-container {
    padding: 0 40px;
    justify-content: center;
  }

  #title-container h1 {
    font-size: 1.5rem;
    white-space: normal;
    text-align: center;
    margin: 0;
  }

  #info-button {
    width: 26px;
    height: 26px;
    font-size: 1rem;
  }
}

/* === Result Color Classes === */
.win {
  color: green; /* Green for win */
}

.lose {
  color: red; /* Red for lose */
}

.draw {
  color: gray; /* Gray for draw */
}