body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
}

/* ---------------- HEADER + CONTAINERS ---------------- */
.headcontainer {
  display: flex;
  justify-content: center;
  align-items: center;
}

.container1 {
  width: 100%;
  text-align: center;
  max-width: 800px;
  padding-top: 10vh;
}

/* ---------------- PUZZLE LAYOUT ---------------- */
.puzzle-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  width: 100%;
  max-width: 1400px;
}

.puzzle-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  text-align: left;
}

.puzzle-content {
  flex: 1;
  max-width: 400px;
}

.spacer {
  margin: 10vh;
}

.puzzle {
  flex-shrink: 0;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1/1;
  display: grid;
  gap: 2px;
  background: #333;
  padding: 4px;
  border-radius: 8px;
}

/* ---------------- TILE ---------------- */
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #000;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(0.8rem, 3vw, 2rem);
}

.empty {
  background: #fff !important;
  cursor: default;
}

/* ---------------- TEXT & BUTTONS ---------------- */
.label {
  margin-top: 6px;
  font-weight: bold;
  color: #444;
  font-size: 14px;
}

.puzzle-text {
  text-align: left;
  flex: 1;
}

.puzzle-text h3 {
  margin: 0 0 10px;
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: bold;
  color: #222;
}

.puzzle-text p {
  margin: 0;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  color: #555;
  line-height: 1.5;
}

.btn {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  font-weight: bold;
  background: #154d71;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.3s;
}

.btn:hover {
  background: #e65c00;
}

/* ---------------- MENU / GAME STATE ---------------- */
.parent,
.game {
  display: none;
}

.menu.active,
.game.active,
.parent.active {
  display: block;
}

.menu select,
.menu button {
  padding: 10px 20px;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  margin: 10px;
}

/* Puzzle Grid (game board) */
#puzzle {
  display: grid;
  gap: 2px;
  margin: 20px auto;
  background: #444;
  border: 5px solid #154d71;
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1/1;
}

.game {
  min-height: 100vh;
}

/* ---------------- CONTROLS ---------------- */
.controls {
  margin-top: 15px;
}

.controls button {
  padding: 8px 16px;
  margin: 5px;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  cursor: pointer;
}
#moves,#message{
  color: white;
}

/* ---------------- POPUP ---------------- */
.popup-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: none;
  justify-content: center;
  align-items: center;
}

.popup-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  width: min(90%, 320px);
  text-align: center;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.popup-content h2 {
  margin-top: 0;
  font-size: clamp(1rem, 4vw, 1.4rem);
}

#popup {
  display: none;
}

/* ---------------- TABLE ---------------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.7rem, 2.5vw, 0.9rem);
  color: black;
  overflow-x: auto;
  display: block;
}

th,
td {
  border: 1px solid #ddd;
  padding: 6px;
  text-align: center;
}

th {
  background: #eee;
}

/* ---------------- RESPONSIVE FIXES ---------------- */
@media (max-width: 992px) {
  .puzzle-wrapper {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .puzzle-text {
    text-align: center;
  }
}

@media (max-width: 600px) {
  .puzzle {
    max-width: 90vw;
  }
  .btn {
    padding: 10px;
  }
  .puzzle-text h3 {
    font-size: 16px;
  }
  .puzzle-text p {
    font-size: 13px;
  }
}
