/* =====================================================
   matching.css — full, self-contained stylesheet
   Matches blast.html header, styles grid/cards and overlay
   ===================================================== */

/* Page layout */
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;
  font-size: 1.05rem;
  color: #0b3b66;
  box-sizing: border-box;
  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 */
}

/* Container that matches blast.html sizing */
.game-page {
  width: 100%;
  display: flex;
  justify-content: center;
}

.game-box {
  max-width: 980px;
  width: 100%;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  padding: 18px;
  box-sizing: border-box;
  position: relative; /* IMPORTANT: for absolute overlay positioning */
}

/* Header (title + controls) */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

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

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

/* Buttons (consistent with blast.css) */
.btn,
.back-btn {
  background: #2b6ea3;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Stat chips like Blaster (score/timer) */
.stat {
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #111;
}

/* Matching board wrapper */
.matching-container {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

/* Grid */
#matching-grid {
  width: 880px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  grid-auto-rows: 100px;
  gap: 12px;
  align-items: stretch;
  justify-items: stretch;
  padding: 12px;
  box-sizing: border-box;
  background: transparent;
}

/* Card styling */
.card {
  background: #eef9ff;
  border: 2px solid rgba(11,59,102,0.08);
  border-radius: 10px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  font-weight: 700;
  color: #0b3b66;
  cursor: pointer;
  text-align: center;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(11,59,102,0.04);
  user-select: none;
  transition: background 0.2s ease, transform 0.12s ease, opacity 0.2s ease;
}

.card.selected {
  background: #2b6ea3;
  color: #fff;
  transform: scale(1.03);
}

.card.matched {
  opacity: 0.6;
  transform: scale(0.98);
  pointer-events: none;
}

/* Recap overlay (centered) */
#matchRecapOverlay {
  display: none; /* JS toggles this (style.display or class) */
  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;
  opacity: 1;
}

/* Recap text */
#matchRecapText {
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 12px;
}

/* Optional fade helper if you decide to use class-based fades later */
#matchRecapOverlay.fade {
  transition: opacity 0.35s ease;
}

/* Subtle backdrop when overlay active */
body.overlay-active::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.18);
  backdrop-filter: blur(2px);
  z-index: 999;
}

/* Ensure overlay receives pointer events while backdrop blocks background */
body.overlay-active #matchRecapOverlay {
  pointer-events: auto;
}

/* === Responsive adjustments === */
@media (max-width: 980px) {
  .game-box {
    max-width: 95%;
    width: 100%;
    padding: 12px;
  }

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

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

  #matching-grid {
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
  }

  .card {
    height: 90px;
    font-size: 1.2rem;
  }

  #matchRecapOverlay {
    width: 90%;
    padding: 16px;
    font-size: 1rem;
  }
}

/* Even smaller devices (phones under 600px wide) */
@media (max-width: 600px) {
  .card {
    height: 80px;
    font-size: 1rem;
  }

  .btn {
    width: 45%;
    min-width: 120px;
  }

  .stat {
    font-size: 0.9rem;
  }
}


