/* ============================================================
   WORD GUESSER — game stylesheet
   Loads after styles.css and page.css.
   ============================================================ */

/* ── Scoped box-model reset ──────────────────────────────────── */
#user_info_container *,
#gameplay_container *,
#scoreboard * {
  box-sizing: border-box;
}

/* ── Game form containers ────────────────────────────────────── */
.form_container {
  background-color: #ffffff;
  border: 1px solid var(--border-medium, #dee2e6);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  max-width: 500px;
  margin: 2rem auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* ── Game header ─────────────────────────────────────────────── */
.game-header h2 {
  color: var(--accent-primary, #2c3e50);
  border-bottom: 2px solid var(--accent-primary, #2c3e50);
  display: inline-block;
  font-size: 1.4rem;
  margin-bottom: 0;
  padding-bottom: 0.2rem;
}

#game_intro {
  font-size: 0.85rem;
  opacity: 0.7;
  margin: 0;
}

/* ── Notifications — locked height, never shifts layout ─────── */
#notifications {
  display: block;
  min-height: 1.5em;
  max-height: 1.5em;
  line-height: 1.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--status-error, #d33333);
  margin: 4px 0;
  padding: 0;
}

.success-msg {
  color: var(--status-success, #28a745);
}
.error-msg {
  color: var(--status-error, #d33333);
}

/* ── Word board ─────────────────────────────────────────────── */
#current_word {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 5px;
  list-style: none !important;
  padding: 1rem 0 !important;
  width: 100%;
  margin: 0 !important;
}

#current_word li {
  background-color: var(--bg-body, #f8f9fa);
  border: 2px solid var(--accent-primary, #2c3e50) !important;
  border-bottom: 3px solid var(--border-medium, #dee2e6) !important;
  border-radius: 4px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary, #2c3e50);
  box-shadow: 2px 2px 0 rgba(44, 62, 80, 0.2);
  text-transform: uppercase;
  width: 32px;
  height: 42px;
  font-weight: bold;
  font-size: 1.4rem;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.word-display-field {
  display: block !important;
  text-align: center;
  padding: 1rem 0;
  border-bottom: 2px solid #f1f3f5;
}

/* ── Form fields (scoped to game containers) ─────────────────── */
#gameplay_container .formField,
#splash_screen .formField {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 20px;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f3f5;
}

#gameplay_container .formField:last-of-type,
#splash_screen .formField:last-of-type {
  border-bottom: none;
}

#gameplay_container .formField label,
#splash_screen .formField label {
  font-weight: 600;
  color: #495057;
  font-size: 0.9rem;
}

/* ── How-to text ─────────────────────────────────────────────── */
#game-howto p {
  font-size: 0.875rem;
  color: var(--text-muted, #6c757d);
  text-align: center;
  margin: 0;
  padding: 0.5rem 0;
}

/* ── Guess letter input ─────────────────────────────────────── */
#guess_letter {
  width: 50px;
  padding: 10px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: bold;
  border: 2px solid var(--border-medium, #dee2e6);
  border-radius: 4px;
  transition: border-color 0.2s;
}

#guess_letter:focus {
  border-color: var(--accent-primary, #2c3e50);
  outline: none;
}

/* ── Guess button ────────────────────────────────────────────── */
.submitField {
  padding: 1rem 0;
  text-align: center;
}

#guess_button {
  background-color: var(--bg-header, #2c3e50);
  color: #ffffff;
  border: none;
  padding: 0.8rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#guess_button:hover {
  background-color: var(--bg-footer, #34495e);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ── Guess history pills ────────────────────────────────────── */
#guesses {
  display: flex !important;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 5px;
  padding: 5px 0 !important;
  margin: 0 !important;
  list-style: none !important;
  scrollbar-width: none;
}

#guesses::-webkit-scrollbar {
  display: none;
}

#guesses li {
  background: var(--bg-tag, #e3f2fd);
  color: var(--accent-tag, #1976d2);
  padding: 2px 8px !important;
  border-radius: 3px;
  font-size: 0.85rem;
  font-family: "Roboto Mono", monospace;
  font-weight: bold;
  flex-shrink: 0;
  border: 1px solid var(--border-tag, #bbdefb) !important;
  list-style: none !important;
  margin: 0 !important;
}

/* ── Alphabet grid ───────────────────────────────────────────── */
#alphabet_container.alphabet-grid {
  display: grid !important;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  background: #ebf3f9;
  padding: 8px !important;
  border-radius: 8px;
}

.letter-btn {
  aspect-ratio: 1 / 1.2;
  padding: 0 !important;
  font-size: 1.1rem;
  font-weight: bold;
  border: 1px solid #ced4da !important;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
  transition:
    transform 0.1s,
    background 0.1s;
  cursor: pointer;
  line-height: 1;
  margin: 0 !important;
}

.letter-btn:active {
  transform: translateY(2px);
  box-shadow: none;
  background: #dee2e6;
}

.letter-btn.selected {
  background: var(--bg-header, #2c3e50) !important;
  color: #fff;
  border-color: var(--bg-header, #2c3e50) !important;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.letter-btn:disabled {
  background: #e9ecef !important;
  color: #adb5bd;
  box-shadow: none;
  border-color: transparent !important;
  cursor: not-allowed;
}

/* ── Game metrics row ────────────────────────────────────────── */
#game_metrics {
  display: flex !important;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  padding: 10px !important;
  background: var(--bg-subtle, #f5f7fa);
  border-radius: 8px;
  margin: 10px 0 !important;
}

#game_metrics .formField {
  flex: 1;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 4px;
  min-width: 0;
  padding: 0 !important;
  border-bottom: none !important;
  grid-template-columns: unset;
}

#game_metrics .label {
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  color: var(--text-muted, #6c757d);
  letter-spacing: 0.05em;
}

#game_metrics #guess_count {
  width: 100%;
  padding: 8px !important;
  border: 1px solid var(--border-light, #e0e0e0) !important;
  border-radius: 4px;
  background: #fff;
  font-family: "Roboto Mono", monospace;
  font-size: 1.1rem;
  text-align: center;
  color: var(--text-main, #212529);
}

/* ── Splash / login ──────────────────────────────────────────── */
#user_info_container {
  display: flex;
}

#splash_screen {
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

#game_form {
  display: none;
}

/* ============================================================
   SCOREBOARD OVERLAY
   JS toggles display: none <-> flex on #scoreboard only.

   Expected HTML structure:
     #scoreboard
       div.sb-card > div.sb-label + div.sb-value#total_words_attempted
       div.sb-card > div.sb-label + div.sb-value#total_words_completed
       div.sb-card > div.sb-label + div.sb-value#total_incorrect_guesses
       div.sb-card > div.sb-label + div.sb-value#average_guesses_per_word
       div.sb-card > div.sb-label + div.sb-value#average_time_per_word
       div.sb-actions > #play_again + #quit_game
   ============================================================ */

#scoreboard {
  display: none; /* JS sets this to 'flex' */
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  z-index: 9999 !important;
  justify-content: center;
  align-items: flex-end; /* bottom-sheet on mobile */
  background: rgba(0, 0, 0, 0.55) !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  width: 100% !important;
  max-width: none !important;
}

/* ── Sheet / card ────────────────────────────────────────────── */
#scoreboard > div {
  position: relative !important;
  width: 100% !important;
  max-width: 500px !important;
  margin: 0 auto !important;
  padding: 0 !important;
  border-radius: 20px 20px 0 0 !important;
  background: #ffffff !important;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2) !important;
  border: none !important;
  overflow: hidden;
  animation: sb-rise 0.3s cubic-bezier(0.34, 1.1, 0.64, 1) both;

  /* 2-column grid: 5 cards + action row */
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "handle  handle"
    "card    card"
    "card    card"
    "actions actions";
}

@keyframes sb-rise {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Drag handle */
#scoreboard > div::before {
  content: "";
  grid-column: 1 / -1;
  display: block;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(44, 62, 80, 0.18);
  margin: 12px auto 8px;
  justify-self: center;
}

/* ── Stat cards ─────────────────────────────────────────────── */
#scoreboard .sb-card {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: flex-start !important;
  gap: 6px;
  padding: 16px !important;
  background: #f5f7fa !important;
  outline: 3px solid #ffffff; /* white gutter between cards */
  margin: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

#scoreboard .sb-label {
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6c757d !important;
  line-height: 1.3;
  margin: 0 !important;
  padding: 0 !important;
}

#scoreboard .sb-value {
  display: block !important;
  font-size: 2rem !important;
  font-weight: 700 !important;
  font-family: "Roboto Mono", monospace;
  color: #2c3e50 !important;
  line-height: 1;
  margin: 0 !important;
  padding: 0 !important;
  background: none !important;
  border: none !important;
  text-align: left !important;
  min-height: 2rem; /* prevents height jump before JS populates value */
}

/* ── Action buttons ──────────────────────────────────────────── */
#scoreboard .sb-actions {
  grid-column: 1 / -1;
  display: flex !important;
  flex-direction: row !important;
  gap: 10px;
  padding: 14px 16px 28px !important;
  background: #ffffff !important;
  border-top: 1px solid #e9ecef !important;
  border-bottom: none !important;
  margin: 0 !important;
  box-shadow: none !important;
}

#scoreboard #play_again,
#scoreboard #quit_game {
  padding: 13px 0 !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  border: none !important;
  border-radius: 8px;
  cursor: pointer;
  transition:
    opacity 0.15s,
    transform 0.1s;
  margin: 0 !important;
  box-shadow: none !important;
}

#scoreboard #play_again {
  flex: 1;
  background: #2c3e50 !important;
  color: #ffffff !important;
}

#scoreboard #quit_game {
  width: 90px;
  background: #e9ecef !important;
  color: #212529 !important;
}

#scoreboard #play_again:hover,
#scoreboard #quit_game:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

/* ── Desktop: centred modal ──────────────────────────────────── */
@media (min-width: 601px) {
  #scoreboard {
    align-items: center !important;
  }

  #scoreboard > div {
    border-radius: 16px !important;
    max-width: 440px !important;
    animation: sb-pop 0.25s cubic-bezier(0.34, 1.1, 0.64, 1) both;
  }

  #scoreboard .sb-actions {
    padding-bottom: 20px !important;
  }
}

@keyframes sb-pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .form_container {
    padding: 1rem;
    margin: 0.5rem;
  }

  #site-header,
  footer,
  #guesses,
  #guess_letter_container {
    display: none !important;
  }
}
