/* ========================================= */
/* EXTRACTED TAILWIND CSS UTILITIES */
/* ========================================= */

/* Reset and base styles */
*,
::before,
::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: #e5e7eb;
}

/* Width utilities */
.w-full {
  width: 100%;
}
.w-14 {
  width: 3.5rem;
}
.w-\[280px\] {
  width: 280px;
}

/* Height utilities */
.h-14 {
  height: 3.5rem;
}
.h-full {
  height: 100%;
}
.h-\[280px\] {
  height: 280px;
}

/* Max-width utilities */
.max-w-md {
  max-width: 28rem;
}

/* Max-height utilities */
.max-h-\[50vh\] {
  max-height: 50vh;
}

/* Min-height utilities */
.min-h-\[60px\] {
  min-height: 60px;
}

/* Padding utilities */
.p-1 {
  padding: 0.25rem;
}
.p-2 {
  padding: 0.5rem;
}
.p-3 {
  padding: 0.75rem;
}
.p-4 {
  padding: 1rem;
}
.p-6 {
  padding: 1.5rem;
}
.px-3 {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.py-1 {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}
.py-1\.5 {
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
}
.pb-3 {
  padding-bottom: 0.75rem;
}

/* Margin utilities */
.mb-3 {
  margin-bottom: 0.75rem;
}
.mb-4 {
  margin-bottom: 1rem;
}
.mb-6 {
  margin-bottom: 1.5rem;
}
.mb-8 {
  margin-bottom: 2rem;
}
.ml-2 {
  margin-left: 0.5rem;
}
.mt-1 {
  margin-top: 0.25rem;
}
.mt-3 {
  margin-top: 0.75rem;
}

/* Display utilities */
.flex {
  display: flex;
}
.hidden {
  display: none;
}

/* Position utilities */
.relative {
  position: relative;
}

/* Z-index utilities */
.z-10 {
  z-index: 10;
}

/* Flex utilities */
.flex-nowrap {
  flex-wrap: nowrap;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-shrink-0 {
  flex-shrink: 0;
}
.items-center {
  align-items: center;
}
.items-start {
  align-items: flex-start;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-1 {
  gap: 0.25rem;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-4 {
  gap: 1rem;
}
.space-x-1 > :not([hidden]) ~ :not([hidden]) {
  margin-left: 0.25rem;
}
.space-x-2 > :not([hidden]) ~ :not([hidden]) {
  margin-left: 0.5rem;
}

/* Overflow utilities */
.overflow-y-auto {
  overflow-y: auto;
}

/* Border utilities */
.border {
  border-width: 1px;
}
.border-b {
  border-bottom-width: 1px;
}
.border-b-4 {
  border-bottom-width: 4px;
}
.border-gray-300 {
  border-color: #d1d5db;
}
.border-blue-500 {
  border-color: #3b82f6;
}
.rounded {
  border-radius: 0.25rem;
}
.rounded-lg {
  border-radius: 0.5rem;
}
.rounded-t {
  border-top-left-radius: 0.25rem;
  border-top-right-radius: 0.25rem;
}
.rounded-full {
  border-radius: 9999px;
}

/* Background color utilities */
.bg-white {
  background-color: #ffffff;
}
.bg-gray-50 {
  background-color: #f9fafb;
}
.bg-gray-100 {
  background-color: #f3f4f6;
}
.bg-gray-200 {
  background-color: #e5e7eb;
}
.bg-blue-50 {
  background-color: #eff6ff;
}
.bg-blue-600 {
  background-color: #2563eb;
}
.bg-green-600 {
  background-color: #16a34a;
}
.bg-green-800 {
  background-color: #166534;
}
.bg-red-500 {
  background-color: #ef4444;
}

/* Hover background colors */
.hover\:bg-gray-300:hover {
  background-color: #d1d5db;
}
.hover\:bg-blue-600:hover {
  background-color: #2563eb;
}
.hover\:bg-green-600:hover {
  background-color: #16a34a;
}
.hover\:bg-green-700:hover {
  background-color: #15803d;
}
.hover\:bg-green-800:hover {
  background-color: #166534;
}
.hover\:bg-red-700:hover {
  background-color: #dc2626;
}
.hover\:text-white:hover {
  color: #ffffff;
}
.hover\:text-blue-500:hover {
  color: #3b82f6;
}

/* Text color utilities */
.text-white {
  color: #ffffff;
}
.text-gray-600 {
  color: #4b5563;
}
.text-gray-700 {
  color: #374151;
}
.text-gray-800 {
  color: #1f2937;
}
.text-blue-600 {
  color: #2563eb;
}
.text-green-700 {
  color: #15803d;
}
.text-purple-600 {
  color: #9333ea;
}
.text-purple-700 {
  color: #7e22ce;
}

/* Font size utilities */
.text-sm {
  font-size: 0.875rem;
  line-height: 1.25rem;
}
.text-lg {
  font-size: 1.125rem;
  line-height: 1.75rem;
}
.text-3xl {
  font-size: 1.875rem;
  line-height: 2.25rem;
}

/* Font weight utilities */
.font-medium {
  font-weight: 500;
}
.font-semibold {
  font-weight: 600;
}
.font-bold {
  font-weight: 700;
}

/* Text alignment */
.text-center {
  text-align: center;
}

/* Text transform */
.whitespace-nowrap {
  white-space: nowrap;
}

/* Box shadow utilities */
.shadow {
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}
.shadow-sm {
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.shadow-md {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Transition utilities */
.transition-colors {
  transition-property: color, background-color, border-color,
    text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}
.transition-all {
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* Focus utilities */
.focus\:outline-none:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
}
.focus\:ring-2:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}
.focus\:ring-blue-500:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}
.focus\:ring-opacity-50:focus {
  --tw-ring-opacity: 0.5;
}
.focus\:ring-green-500:focus {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.5);
}
.focus\:ring-red-500:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.5);
}
.focus\:border-blue-500:focus {
  border-color: #3b82f6;
}

/* ========================================= */
/* SPELLYES GAME STYLES */
/* ========================================= */

/* --- 1. THEME PAGE WIDTH FIX (Ensure Game Can Expand) --- */
/* Overrides parent theme's max-width constraints on the content area */
.site-content > .content-area,
.site-content > .entry-content,
.site-content > .kadence-content-wrap,
main#content > .entry-content,
.entry-content,
.single-content,
.page-content {
  /* Set to full width and remove conflicting padding/margins */
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* --- NEW: Fullscreen Styles --- */
#game-container.is-fullscreen {
  /* Critical styles to take over the screen */
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  background-color: #f9fafb; /* Maintain a consistent background */
  /* Center all content on the screen */
  display: flex;
  flex-direction: column;
  /* FIX: Align content to the start (top) to ensure header is visible */
  justify-content: flex-start;
  align-items: center;
  /* Ensure the container is above all other page content */
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}

/* Ensure child elements inside fullscreen container don't get too large */
#game-container.is-fullscreen .game-wrapper {
  max-width: 100%;
  max-height: 100%;
  overflow: auto; /* Ensure content is scrollable if it exceeds screen size */
}

/* Base Styles for the Game Container */
.game-wrapper {
  font-family: "Inter", sans-serif;
  max-width: 900px;
  margin: 20px auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Two-column layout using Flexbox */
.game-two-column-layout {
  display: flex;
  gap: 30px; /* Space between columns */
  align-items: flex-start; /* Align content at the top of each column */
}

.game-column-left {
  flex: 1; /* Takes up available space */
  min-width: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-column-right {
  flex: 1; /* Takes up available space */
  min-width: 300px;
}

/* --- 2. MESSAGES AND DIALOGS --- */

.message-box {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 2000;
  pointer-events: none;
  font-weight: 600;
  min-width: 250px;
  text-align: center;
}

.message-box.show {
  opacity: 1;
  transform: translateX(-50%);
}

.confirmation-dialog {
  display: none; /* Controlled by JS */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  z-index: 3000;
  min-width: 300px;
  text-align: center;
}

.confirmation-dialog p {
  margin-bottom: 20px;
  font-size: 1.1rem;
  color: #333;
}

.confirmation-dialog .button-group {
  display: flex;
  justify-content: space-around;
}

.confirm-yes,
.confirm-no {
  padding: 10px 20px;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s;
}

.confirm-yes {
  background-color: #ef4444;
  color: white;
}

.confirm-yes:hover {
  background-color: #dc2626;
}

.confirm-no {
  background-color: #d1d5db;
  color: #4b5563;
}

.confirm-no:hover {
  background-color: #9ca3af;
}

.congrats-animation {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px 40px;
  background-color: rgba(6, 95, 70, 0.95); /* Emerald Green */
  color: white;
  border-radius: 10px;
  font-size: 2rem;
  font-weight: bold;
  text-align: center;
  box-shadow: 0 0 20px rgba(6, 95, 70, 0.8);
  z-index: 5000;
  animation: pulse-grow 4s infinite;
}

.congrats-animation.hidden {
  display: none;
}

@keyframes pulse-grow {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* --- 3. LETTER CIRCLE STYLES --- */

.letter-circle {
  /* Base size and common styles */
  width: 80px;
  height: 80px;
  line-height: 80px;
  border-radius: 50%;
  border: 3px solid;
  display: flex; /* Used for content centering */
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: bold;
  text-transform: uppercase;
  user-select: none;
  transition: background-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Animation wrapper for letter circles */
.letter-circle-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.letter-circle:active .letter-circle-content {
  transform: scale(0.95);
}

/* Central Letter (Required) */
.central-letter {
  background-color: #fcd34d; /* Amber-400: brighter yellow */
  color: #1f2937; /* Gray-800: darker for contrast */
  border-color: #f59e0b; /* Amber-500: deeper border */
  z-index: 10;
  box-shadow: 0 4px 6px rgba(251, 191, 36, 0.3); /* Amber tinted shadow */

  /* FIX: Guaranteed perfect centering using absolute positioning (Issue 4 Fix Retained) */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Outer Letters (Optional) - Arranged in a circle */
.outer-letter {
  background-color: #f3f4f6; /* Light gray background */
  color: #4b5563; /* Gray-600 */
  position: absolute; /* CRITICAL: Enables top/left positioning within container */
  /* CRITICAL: Centers the element on the precise top/left point set by CSS below */
  transform: translate(-50%, -50%);
  cursor: pointer;
  border-color: #d1d5db; /* Gray-300: subtle border */
  transition: background-color 0.15s ease-in-out; /* Smooth transition just for background */
}

/* Subtle Hover State - just slightly darker */
.outer-letter:hover {
  background-color: #e5e7eb; /* Gray-200: slightly darker than normal state */
}

/* ---------------------------------------------------- */
/* REFACTOR: CSS Positioning for 6 Outer Letters (Desktop/Default: 280x280 container) */
/* Center = 140px, Radius = 110px. Positions calculated from 0,0 top-left of container. */
/* ---------------------------------------------------- */

#outer-letter-0 {
  /* Top */
  top: 30px;
  left: 140px;
}

#outer-letter-1 {
  /* Top-Right */
  top: 85px;
  left: 235px;
}

#outer-letter-2 {
  /* Bottom-Right */
  top: 195px;
  left: 235px;
}

#outer-letter-3 {
  /* Bottom */
  top: 250px;
  left: 140px;
}

#outer-letter-4 {
  /* Bottom-Left */
  top: 195px;
  left: 45px;
}

#outer-letter-5 {
  /* Top-Left */
  top: 85px;
  left: 45px;
}

/* --- 4. BUTTONS & ACTIONS --- */

.action-button {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
  cursor: pointer;
  border: none;
  text-align: center;
}

.action-button:active {
  transform: scale(0.98);
}

/* --- 5. ACHIEVEMENTS & FOUND WORDS PANEL --- */

.achievement-progress-bar {
  height: 10px;
  background-color: #e5e7eb;
  border-radius: 5px;
  overflow: hidden;
}

.achievement-progress-fill {
  height: 100%;
  background-color: #3b82f6; /* Blue-500 */
  transition: width 0.3s ease-in-out;
}

.found-word-item {
  padding: 4px 8px;
  background-color: #f9f9f9;
  border-radius: 4px;
  margin-right: 5px;
  margin-bottom: 5px;
  display: inline-block;
  font-size: 0.9rem;
  color: #333;
  font-weight: 500;
}

/* View mode toggle buttons */
#view-list-btn,
#view-groups-btn,
#export-csv-btn {
  cursor: pointer;
  border: none;
  transition: all 0.2s ease-in-out;
}

#view-list-btn:focus,
#view-groups-btn:focus,
#export-csv-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

#export-csv-btn:active {
  transform: scale(0.98);
}

/* Button container layout - separates toggle buttons from export button */
.button-container-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toggle-buttons-group {
  display: flex;
  gap: 0.5rem;
}

/* Link styling for found words */
.found-word-link {
  color: #2563eb;
  text-decoration: none;
  transition: color 0.2s;
}

.found-word-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* --- 6. HINTS/DEBUG PANEL --- */
#candidate-words-container {
  max-height: 200px;
  overflow-y: auto;
  background-color: #f7f7f7;
  padding: 10px;
  border-radius: 6px;
  margin-top: 10px;
  border: 1px solid #ddd;
}
.candidate-word-item {
  font-size: 0.9rem;
  color: #666;
  border-bottom: 1px dashed #eee;
  padding: 3px 0;
}
.candidate-word-item:last-child {
  border-bottom: none;
}
.candidate-word-item .hint {
  font-style: italic;
  color: #999;
  margin-left: 10px;
}
.candidate-word-item .hint b {
  color: #444;
  font-weight: 700;
}
.candidate-word-item .level-tag {
  font-size: 0.7rem;
  background-color: #eee;
  padding: 2px 5px;
  border-radius: 3px;
  margin-left: 5px;
}

/* --- 7. RESPONSIVE ADJUSTMENTS (Mobile Screens) --- */
@media (max-width: 768px) {
  /* Layout: Stack columns vertically */
  .game-two-column-layout {
    flex-direction: column;
    gap: 0;
    padding: 0 10px;
  }

  .game-column-left,
  .game-column-right {
    /* Allow both columns to take full width when stacked */
    flex: 0 0 auto;
    width: 100%;
    min-width: auto;
    padding-left: 10px;
    padding-right: 10px;
  }

  /* Letter Grid and Circles adjustment for smaller screens */
  .game-column-left > div:nth-child(2) {
    /* Target the letter grid container for smaller size */
    width: 250px;
    height: 250px;
  }

  /* Letter Circle Size adjustment */
  .letter-circle {
    width: 70px;
    height: 70px;
    line-height: 70px;
    font-size: 2rem;
  }

  /* ---------------------------------------------------- */
  /* REFACTOR: CSS Positioning for 6 Outer Letters (Mobile: 250x250 container) */
  /* Center = 125px, Radius = 98px. */
  /* ---------------------------------------------------- */

  #outer-letter-0 {
    top: 27px;
    left: 125px;
  }

  #outer-letter-1 {
    top: 76px;
    left: 210px;
  }

  #outer-letter-2 {
    top: 174px;
    left: 210px;
  }

  #outer-letter-3 {
    top: 223px;
    left: 125px;
  }

  #outer-letter-4 {
    top: 174px;
    left: 40px;
  }

  #outer-letter-5 {
    top: 76px;
    left: 40px;
  }

  .action-button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  #achievements-scroll {
    max-height: 35vh !important; /* Adjust max height for mobile view */
  }

  /* Ensure toggle buttons are responsive on mobile */
  #view-list-btn,
  #view-groups-btn,
  #export-csv-btn {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }

  /* Stack buttons on very small screens if needed */
  @media (max-width: 380px) {
    .button-container-row {
      flex-direction: column;
      align-items: stretch;
    }

    .toggle-buttons-group {
      width: 100%;
    }

    #view-list-btn,
    #view-groups-btn {
      flex: 1;
    }

    #export-csv-btn {
      width: 100%;
      justify-content: center;
    }
  }
}
