/* GLOBAL RESET */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 10px;
  background: #FEFBE3;
  font-family: Arial, sans-serif;
  text-align: center;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* --- RULES BUTTON --- */
.rules-btn {
  position: fixed;
  top: 15px;
  right: 15px;
  width: 45px;
  height: 45px;
  background: #C95A2E;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  z-index: 300;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  transition: transform 0.2s;
  touch-action: manipulation;
}

.rules-btn:hover {
  transform: scale(1.1);
  background: #1A8ACB;
}

/* --- RULES MODAL --- */
.rules-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  background: #FFF7E2;
  border: 4px solid #1A8ACB;
  border-radius: 20px;
  padding: 0;
  z-index: 299;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  text-align: left;
}

.rules-header {
  background: #FFEB8A;
  padding: 15px 20px;
  border-bottom: 2px solid #FBC498;
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.rules-header h3 {
  margin: 0;
  color: #C95A2E;
  font-size: 1.5rem;
}

.close-rules {
  font-size: 2rem;
  font-weight: bold;
  color: #C95A2E;
  cursor: pointer;
  line-height: 1;
}

.rules-body {
  padding: 20px;
}

/* RULE ITEMS */
.rule-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 25px;
  border-bottom: 1px solid #ddd;
  text-align: center;
}

.rule-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.rule-text {
  margin-bottom: 15px;
  width: 100%;
}

.rule-text strong {
  display: block;
  color: #1A8ACB;
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.rule-text p {
  margin: 0;
  font-size: 1rem;
  color: #333;
  line-height: 1.5;
}

/* IMAGE STYLING */
.rule-img {
  width: 100%; 
  max-width: 280px; 
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  border: 3px solid #C95A2E; 
  display: block;
  margin-bottom: 15px;
}

.rule-img:last-child {
  margin-bottom: 0;
}

/* --- LOGO --- */
.game-logo {
  max-width: 400px;
  width: 85%;
  height: auto;
  margin: 10px auto;
  display: block;
}

/* --- RESULT MODAL --- */
.result-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-content {
  background: #FEFBE3;
  border: 4px solid #C95A2E;
  border-radius: 20px;
  padding: 20px;
  width: 340px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  animation: popIn 0.3s ease-out;
}

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

.result-content h2 {
  color: #C95A2E;
  font-size: 1.8rem;
  margin: 10px 0;
}

.final-score {
  display: flex;
  justify-content: space-around;
  margin: 15px 0;
  background: #FFF7E2;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #333;
}

.p-score {
  display: flex;
  flex-direction: column;
  font-weight: bold;
}

.p-score span:first-child { font-size: 0.9rem; color: #555; }
.p-score span:last-child { font-size: 1.6rem; color: #111; }

.result-content button {
  background: #FFEB8A;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #FBC498;
}

/* --- MENU & CONTROLS --- */
.menu-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.menu-card button {
  background: #FFEB8A;
  border: none;
  padding: 12px 20px;
  border-radius: 18px;
  font-size: 1rem;
  cursor: pointer;
}

.menu-card button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(100%);
}

.info-text {
  color: #C95A2E;
  font-size: 1.1rem;
  margin-top: 15px;
}

.controls {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.controls button {
  background: #FFEB8A;
  border: none;
  padding: 10px 18px;
  border-radius: 18px;
  font-size: 1rem;
  cursor: pointer;
}

/* --- PASS BUTTON LOCATION --- */
.pass-wrapper {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 5px;
  min-height: 40px; /* Reserves a little space */
  display: flex;
  justify-content: center;
}

/* Pass Button Styling */
#passBtn {
  background: #FFEB8A;
  color: #C95A2E;
  border: 3px solid #C95A2E;
  padding: 15px 40px;
  font-size: 1.4rem;
  border-radius: 4px; /* Rectangular */
  cursor: pointer;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  
  /* Boxy 3D effect */
  box-shadow: 0 8px 0 #C95A2E, 0 15px 20px rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
  margin-bottom: 15px; /* Adjust for the shadow */
}

#passBtn:active {
  transform: translateY(8px);
  box-shadow: 0 0 0 #C95A2E, inset 0 2px 5px rgba(0,0,0,0.3);
}


/* --- BOARDS CONTAINER --- */
.boards {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 20px;
  width: 100%;
}

/* --- BOARD WRAPPER --- */
.board-wrapper {
  position: relative;
  width: 420px; 
  height: 420px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
}

.dark-board { background-image: url("assets/board-dark.png"); }
.light-board { background-image: url("assets/board-light.png"); }

.path-svg {
  position: absolute;
  top: 13.81%;
  left: 13.81%;
  width: 72.38%;
  height: 72.38%;
  pointer-events: none;
  z-index: 5;
}

.path-svg line {
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.7;
}

/* --- GRID OVERLAY --- */
.grid-overlay {
  position: absolute;
  top: 13.81%;
  left: 13.81%;
  width: 72.38%;
  height: 72.38%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  border-top: 1px solid rgba(255,255,255,0.55);
  border-left: 1px solid rgba(255,255,255,0.55);
  pointer-events: auto;
  z-index: 10;
  touch-action: none;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: bold;
  color: #111;
  cursor: pointer;
  user-select: none;
  border-right: 1px solid rgba(255,255,255,0.55);
  border-bottom: 1px solid rgba(255,255,255,0.55);
}

.valid { background: rgba(255,255,255,0.15); }
.visited { color: #000; }
.covered { color: transparent; cursor: not-allowed; }

/* --- SCORES & TABLE --- */
.scores {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-weight: bold;
  margin-top: 12px;
  flex-wrap: wrap;
}

.round-text { margin-top: 10px; font-weight: bold; }

#roundTable {
  margin: 20px auto;
  border-collapse: collapse;
  background: #FFF7E2;
  width: 95%;
  max-width: 500px;
}

#roundTable th, #roundTable td {
  border: 1px solid #333;
  padding: 6px 4px;
  text-align: center;
}
#roundTable th { background: #FBC498; }

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 900px) {
  .boards {
    flex-direction: column;
    align-items: center;
    gap: 30px;
  }

  .board-wrapper {
    width: 85vmin;
    height: 85vmin;
    max-width: 420px;
    max-height: 420px;
    margin: 20px auto;
  }
  
  .cell { font-size: 5vmin; }

  @media (min-width: 500px) {
    .cell { font-size: 1.4rem; }
  }

  .scores { font-size: 0.9rem; }
  .game-logo { margin-top: 50px; }
}