* {
  box-sizing: border-box;
}

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', sans-serif;
  background-color: rgb(254, 251, 227);
  color: #FEF494;
  overflow-x: hidden;
}

.background {
  min-height: 100vh;
  padding: 30px 20px 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
}

/* === Fancy Heading === */
.fancy-heading {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 20px;
}

.fancy-heading span {
  display: inline-block;
  padding: 15px 20px;
  font-size: 2.8rem;
  font-weight: bold;
  color: #222;
  background-color: #ffeb3b;
  border-radius: 10px;
  transform: rotate(var(--angle));
  box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
  transition: transform 0.3s ease;
}

.fancy-heading span:nth-child(odd) {
  background-color: #ffb300;
}

.fancy-heading span:hover {
  transform: scale(1.1);
}

.fancy-heading span:nth-child(odd) {
  background-color: #ffb300;
}

.fancy-heading span:hover {
  transform: scale(1.1) rotate(0deg);
}

/* === Setup and Controls === */
.setup, .controls {
  background: #FEF494;
  padding: 30px 20px;
  border-radius: 20px;
  margin: 30px auto 0;
  width: 100%;
  max-width: 850px;
  box-shadow: 0 6px 18px rgb(0,0,0 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
}

label {
  display: block;
  margin: 15px 0 5px;
  font-size: 1.2em;
  color: #fff;
  width: 100%;
  max-width: 300px;
  text-align: left;
}

select, input[type="number"] {
  padding: 10px;
  border-radius: 8px;
  font-size: 1em;
  width: 100%;
  max-width: 300px;
  margin-bottom: 10px;
  border: none;
}

button {
  padding: 12px 25px;
  margin-top: 20px;
  font-size: 18px;
  background-color:rgb(26, 72, 127, 0.92);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #0077cc;
}

/* === Game Board === */
#gameBoard {
  display: grid;
  gap: 4px;
  margin: 20px auto;
  justify-content: center;
  background-color: #F4A52d;
  padding: 10px;
  border-radius: 12px;

  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.cell {
  width: 70px;
  height: 70px;
  background: #fefbe3;
  border: 1px solid #de9517;
  transition: transform 0.2s, background-color 0.3s;
  border-radius: 8px;
}

.cell:hover {
  transform: scale(1.05);
}

.hover-preview {
  background-color: rgba(0, 255, 255, 0.4) !important;
}
.turn-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.turn-box {
  width: 50px;
  height: 50px;
  border-radius: 8px;
}

.turn-box.blue {
  background-color: #25b7d9;
}

.turn-box.red {
  background-color: #f4832c;
}

.horizontal {
  flex-direction: row;
}

.vertical {
  flex-direction: column;
}

.blue {
  background-color: #25b7d9;
}

.red {
  background-color: #f4832c;
}

.placed {
  animation: zoomIn 0.3s ease;
  box-shadow: inset 0 0 5px rgba(0,0,0,0.3);
}

#winner, .winner-text {
  font-size: 2.2rem;
  font-weight: bold;
  color: #ffe600;
  text-shadow: 2px 2px 6px #000;
  animation: flash 1s ease infinite alternate;
  margin-top: 10px;
  text-align: center;
}

.hidden {
  display: none;
}

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

@keyframes flash {
  0% { opacity: 1; }
  100% { opacity: 0.6; }
}

/* ==== Rules Box ==== */
.rules-box {
  position: fixed;
  top: 20px;
  right: 25px;
  cursor: pointer;
  z-index: 99;
  background-color: rgba(26, 72, 127, 0.92);
  padding: 18px 28px;
  border-radius: 16px;
  transition: transform 0.3s ease, background-color 0.3s ease;
  font-size: 1.8rem;
  color: #fff;
  font-weight: 600;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(234, 231, 231, 0.4);
}

.rules-box:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.rules-popup {
  position: absolute;
  top: 120%;
  right: 0;
  background-color: #ffffff;
  color: #222;
  padding: 25px 30px;
  width: 360px;
  border-radius: 16px;
  text-align: left;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  display: none;
  animation: fadeInUp 0.4s ease forwards;
  font-size: 1.15rem;
  line-height: 1.8;
  z-index: 100;
}

.rules-box:hover .rules-popup {
  display: block;
}

.rules-popup h3 {
  margin-top: 0;
  font-size: 1.5rem;
  margin-bottom: 15px;
}

.rules-popup ul {
  padding-left: 18px;
  margin: 0;
}

.rules-popup li {
  margin-bottom: 10px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Responsive Adjustments === */
@media (max-width: 768px) {
  .cell {
    width: 50px;
    height: 50px;
  }

  .setup, .controls {
    padding: 20px;
  }

  label, button, select, input[type="number"] {
    font-size: 1em;
  }

  .rules-popup {
    width: 90vw;
    right: 5%;
    font-size: 1rem;
  }

  .rules-box {
    font-size: 1.5rem;
    padding: 16px 22px;
  }
}
/* Make Rules Box Bigger */
.rules-box {
  font-size: 1.6rem;
  padding: 18px 28px;
  border-radius: 16px;
}

.rules-popup {
  width: 360px;
  padding: 22px 24px;
  font-size: 1.15rem;
  line-height: 1.8;
}

.rules-popup h3 {
  font-size: 1.6rem;
}

.rules-popup li {
  margin-bottom: 12px;
}
