/* Scoped game styles - consistent with your white container look */
body {
  font-family: Times New Roman, sans-serif;
  background: #f4f2ef;
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  background: #f3f4f6;
}

.main-wrapper {
  display: flex;
  flex-direction: column;      /* stack content vertically */
  justify-content: flex-start;  /* top-align content */
  align-items: center;          /* center horizontally */
  gap: 20px;
  padding: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  transition: margin-left 0.3s ease; /* smooth shift */
}

.game-page {
  width: 100%;
  display: flex;
  justify-content: center;
}

.game-box {
  width: 980px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  padding: 18px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.title {
  font-size: 1.5em;
  font-weight: bold;
  color: #0b3b66;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  /* background: #4caf50; */
  background-color: #2b6ea3;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
   text-decoration: none;
}

.btn:hover {
    opacity: 0.95;
    transform: translateY(-5px);
    background-color: #218838;

}

.btn-primary {
  background: #1e63ff;
}

.stat {
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #111;
}

/* floating Arabic word area (it moves via JS) */
.word-floating {
  height: 48px;
  width: 100%;
  margin-top: 12px;
  position: relative;
  overflow: visible;
  pointer-events: none;
  font-size: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b3b66;
  font-weight: 700;
}

/* canvas container */
.canvas-wrap {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

#gameCanvas {
  width: 100%;
  max-width: 940px;
  height: 500px;
  background: linear-gradient(180deg,#e6f2ff,#ffffff);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06) inset;
  outline: none;
  border: 2px solid rgba(0,0,0,0.03);
}

/* note */
.note {
  margin-top: 10px;
  color: #444;
  font-size: 0.95rem;
}

.back-btn {

  margin: 20px auto 0;
  text-align: center;
  padding: 10px 16px;
  /*background-color: #007bff; */
  background-color: #2b6ea3;
  color: white;
  border-radius: 8px;
  text-decoration: none;
  width: 150px;
}


.game-box {
  position: relative; /* needed for absolute overlay positioning */
}

body.overlay-active::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(2px);
  z-index: 999;
}

#gameRecapOverlay {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 20px 26px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  text-align: center;
  z-index: 1000;
  animation: fadeIn 0.4s ease;
}

#gameRecapOverlay #recapText {
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 12px;
}

body.overlay-active::before {
  content: "";
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(2px);
  z-index: 999;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.list-selector {
  margin: 10px 0 20px;
  text-align: center;
}

.list-selector label {
  font-weight: bold;
  margin-right: 10px;
}

.list-selector select {
  padding: 6px 10px;
  font-size: 1em;
  border-radius: 6px;
  border: 1px solid #ccc;
  background-color: #fff;
  cursor: pointer;
}

/* Mobile view

/* --- Responsive Design for Mobile --- */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .game-box {
    width: 100%;
    max-width: 95%;
    padding: 12px;
    box-sizing: border-box;
  }

  .game-header {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .title {
    font-size: 1.3em;
    text-align: center;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .btn {
    width: 45%;
    font-size: 1em;
    padding: 10px;
  }

  .stat {
    font-size: 0.9em;
    padding: 5px 8px;
  }

  .word-floating {
    font-size: 1.6rem;
    margin-top: 10px;
  }

  .canvas-wrap {
    margin-top: 10px;
  }

  #gameCanvas {
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9; /* keeps proportions without fixed 500px height */
    background: linear-gradient(180deg,#e6f2ff,#ffffff);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06) inset;
  outline: none;
  border: 2px solid rgba(0,0,0,0.03);
  display: block;
  }

  #gameRecapOverlay {
    width: 90%;
    padding: 16px;
  }
}

/* --- Tiny screens (phones under 400px) --- */
@media (max-width: 400px) {
  .btn {
    width: 100%;
    font-size: 0.95em;
  }

  .word-floating {
    font-size: 1.3rem;
  }

  .stat {
    width: 100%;
    text-align: center;
  }

  #gameCanvas {
    aspect-ratio: 4 / 3;
    max-height: 60vh; /* 60% of viewport height */
    height: auto;      /* allow height to scale */
  }
}

