/* ============================================================
   Word Grid — game-specific styles
   ============================================================ */

/* ── Layout ────────────────────────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows:    repeat(9, 1fr);
  gap: 3px;
  width:  min(500px, 95vw);
  height: min(500px, 95vw);
  margin-top: 1.6rem;
  position: relative;
}

#pills-left,
#pills-right {
  position: absolute;
  top: 0;
  width: 33.33%;
  height: 33.33%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
  padding: 6px 25px;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 1;
}

#pills-left  { left: 0; }
#pills-right { right: 0; }

#pills-left .word-result,
#pills-right .word-result {
  font-size: 1rem;
  padding: 2px 4px;
  text-align: center;
}

/* ── Cell base ─────────────────────────────────────────────── */
.cell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Salsa', cursive;
  font-size: 1.2rem;
  font-weight: 400;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.1s ease;
  user-select: none;
  text-transform: uppercase;
}

/* ── Cell variants ─────────────────────────────────────────── */
.cell-corner {
  background: transparent;
  pointer-events: none;
}

.cell-center {
  background-color: blanchedalmond;
  border: 2px solid saddlebrown;
  color: #3a1a04;
}

.cell-extension {
  background-color: rgba(241, 156, 75, 0.315);
  border: 1px solid saddlebrown;
  color: #3a1a04;
}

.cell-prefilled {
    background-color: #b6f7b0 !important;
    border: 2px solid #4a8c42 !important;
    color: #1e5a18 !important;
  cursor: default;
  pointer-events: none;
}

/* ── Interaction states ────────────────────────────────────── */
.cell-highlight {
  background-color: rgba(255, 243, 233, 0.925);
}

.cell-extension.cell-highlight {
  background-color: rgba(255, 243, 233, 0.925);
}

.cell.cell-active {
  background-color: rgba(212, 148, 83, 0.8) !important;
  border-color: saddlebrown !important;
  z-index: 2;
}

.cell-prefilled.cell-valid {
  background-color: #a8e6a0 !important;
  border-color: #4a8c42 !important;
  color: #1e5a18 !important;
}

.cell-prefilled.cell-invalid {
  background-color: #f5a9a0 !important;
  border-color: #8b3a2a !important;
  color: #5c1810 !important;
}

.cell-prefilled.cell-revealed {
    background-color: #b6f7b0 !important;
    border: 2px solid #4a8c42 !important;
    color: #1e5a18 !important;
}

/* ── Validation states ─────────────────────────────────────── */
.cell-valid {
  background-color: #a8e6a0 !important;
  border-color: #4a8c42 !important;
  color: #1e5a18 !important;
}

.cell-invalid {
  background-color: #f5a9a0 !important;
  border-color: #8b3a2a !important;
  color: #5c1810 !important;
}

.cell-revealed {
  background-color: #f5deba !important;
  border-color: saddlebrown !important;
  color: #3a1a04 !important;
}


/* ── Feedback line ─────────────────────────────────────────── */
#feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.5rem;
  max-width: min(500px, 94vw);
  font-family: 'Afacad Flux', sans-serif;
  font-size: 1.2rem;
  font-weight: 500;
  color: saddlebrown;
  text-align: center;
}

.word-result {
  font-family: 'Afacad Flux', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.2rem 0.65rem;
  border-radius: 8px;
  border: 1.5px solid saddlebrown;
  background: moccasin;
  color: saddlebrown;
  letter-spacing: 0.03em;
}

.word-result.valid {
  background: #c8f0c0;
  border-color: #4a8c42;
  color: #1e5a18;
}

.word-result.invalid {
  background: #f5c0bb;
  border-color: #8b3a2a;
  color: #5c1810;
}

.word-result.revealed {
  background: rgba(255, 238, 208, 0.7);
  border-color: saddlebrown;
  color: #3a1a04;
}

#keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(550px, 98vw);
  box-sizing: border-box;
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
}


.key-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.row-1{
  width: 100%;
}

.row-2{
  width: 90%;
}

.row-3{
  width: 84%;
}

.key {
  font-family: 'Salsa', cursive;
  font-size: 1.4rem;
  flex: 1;
  aspect-ratio: 4/5;
  border: 2px solid saddlebrown;
  border-radius: 8px;
  background-color: wheat;
  color: black;
  cursor: pointer;
  text-transform: lowercase;
  box-shadow: 0 3px 0 peru;
  transition: background-color 0.2s ease, box-shadow 0.1s ease,
              transform 0.1s ease, color 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
  text-transform: uppercase;
}

.key-wide { flex: 1.5; font-size: 1.4rem; text-transform: none; aspect-ratio: 6/5; }

.key:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 peru;
}

.key.key-pressing {
  transform: translateY(2px);
  box-shadow: 0 1px 0 peru;
}

.key.key-letter-used {
  background-color: #c97b6a;
  border-color: #8b3a2a;
  box-shadow: 0 3px 0 #6b2a1a;
  color: white;
  cursor: not-allowed;
}

/* ── Lifetime stats ────────────────────────────────────────── */
#lifetimeStats {
  display: flex;
  gap: 1.25rem;
  font-family: 'Afacad Flux', sans-serif;
  font-weight: 500;
  font-size: 1.2rem;
  justify-content: center;
  text-align: center;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  color: black;
}

/* ── Buttons ───────────────────────────────────────────────── */
#buttons {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 40px;
  width: min(420px, 92vw);
  flex-wrap: wrap;
}

.button {
  font-family: 'Afacad Flux', sans-serif;
  font-weight: 500;
  font-size: 1.2rem;
  padding: 0.35em 0.6em;
  background-color: moccasin;
  border: 2px solid saddlebrown;
  color: saddlebrown;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  margin-top: 0.75rem;
  flex: 1;
  min-width: 0;
  touch-action: manipulation;
}

.button:active {
  transform: scale(0.96);
}

#scoreBoardDiv {
  display: flex;
  gap: 2rem;
  font-family: 'Afacad Flux', sans-serif;
  font-weight: 400;
  font-size: 1.4rem;
  justify-content: center;
  text-align: center;
  padding: 0 1rem;
}

@media (hover: hover) and (pointer: fine) {
  .button:hover {
    background-color: peru;
    border-color: peru;
    color: wheat;
  }

  #keyboard{
    display: none;
  }


}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ── Popup pages ─────────────────────────────────────────────── */
.popup-page {
  display: none;
}
.popup-page.active {
  display: block;
}

.popup.active {
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}

.popup-page.active {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.popup-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(139, 69, 19, 0.25);
}

.popup-nav-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: saddlebrown;
  line-height: 1;
  transition: opacity 0.2s;
}
.popup-nav-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

.popup-dots {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.popup-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(139, 69, 19, 0.25);
  cursor: pointer;
  transition: background 0.2s;
}
.popup-dot.active {
  background: saddlebrown;
}

.popup-examples {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
}
.popup-example {
  flex: 1;
  text-align: center;
}
.popup-example img {
  width: 100%;
  border-radius: 6px;
  border: 2px solid rgba(139, 69, 19, 0.3);
  margin-top: 0.5rem;
}
.example-caption {
  margin-top: 0.4rem;
  font-family: 'Afacad Flux', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
}
.example-invalid { color: #8b3a2a; }
.example-valid   { color: #2a7a24; }
.example-normal   { color: black; }

/* ── Win pulse on status ───────────────────────────────────── */
@keyframes winPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}

.status-win {
  color: #2a7a24 !important;
  animation: winPulse 0.6s ease 2;
}

.status-lose {
  color: red !important;
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #grid {
    width:  96vw;
    height: 96vw;
    gap: 3px;
  }

  #pills-left,
  #pills-right {
    padding: 6px 12px;
  }

  .cell {
    font-size: 1.2rem;
  }

  .cell-prefilled {
    border: 1px solid #4a8c42 !important;
  }

  .cell-prefilled.cell-revealed {
      border: 1px solid #4a8c42 !important;
  }

  .cell-center {
    border: 1px solid saddlebrown;
  }

  .key-row {
    gap: 3px;
    margin-bottom: 0.2rem;
  }

  .key{
    font-size: 1.2rem;
    aspect-ratio: 3/4;
  }

  .key-wide {
    aspect-ratio: 9/8;
  }

  #lifetimeStats {
    font-size: 0.95rem;
    gap: 0.75rem;
  }

  .button  {
    font-size: 1.1rem;
    padding: 0.4em 0.5em;
  }

  #scoreBoardDiv{
    font-size: 1.2rem;
    width: 90vw;
  }
}
