:root {
  --accent-yellow: #F9FF08;
  --header-height: 60px;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: Arial, sans-serif;
  background: var(--accent-yellow);
  color: #222;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

h1{ 
  font-size: 16px; 
  text-align: center; 
  margin: 20px 0 10px 0; /* Reduced bottom margin */
  color: #333; /* Dark text for white background */
}

/* Make h1 more compact on smaller screens */
@media (max-width: 600px) {
  h1 {
    margin: 10px 0 5px 0;
    font-size: 14px;
  }
}

main {
  background-color: white;
  min-height: 100dvh; /* dvh accounts for dynamic browser chrome */
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  margin: 0;
  padding: 0 15px; /* Add horizontal padding by default */
  /* Adjust for dynamic browser UI */
  min-height: calc(100dvh - env(safe-area-inset-bottom));
  overflow-x: hidden; /* Prevent horizontal scrolling */
  position: relative; /* For absolute positioning of elements if needed */
}

/* Update your header styles: */

header {
  background: var(--accent-yellow);
  height: var(--header-height);
  min-height: var(--header-height);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  padding: 0 0 0px 0;
  flex-shrink: 0;
  display: flex;
  align-items: center; /* Vertically center nav inside header */
}

/* Update nav to account for safe area */
nav {
  display: flex;
  align-items: center; /* Vertically center nav contents */
  justify-content: space-between;
  width: 100%;
  padding: 16px 32px;
  box-sizing: border-box;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0px; /* space between top-icons and hamburger */
}

.top-icons {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 10px;
}

.title-icon-text {
  display: flex;
  align-items: center; /* Align items vertically in the center */
}

.icon-ace-img {
  display: flex; /* Ensure the <a> tag is a flex container */
  align-items: center;
}

.icon-ace {
  width: auto; /* Adjust as necessary */
  height: 50px; /* Adjust as necessary */
  vertical-align: middle;
}

.title-text {
  text-align: left;
  font-family: "Anton", sans-serif;
  font-weight: 400;
  font-style: normal;
  text-transform: uppercase;
  color: #ffffff;
  font-size: 1.4em;
  padding-left: 5px;
  -webkit-text-stroke: 1.3px black;
}


.top-icons img{
  width: auto;
  height: 20px;
  cursor: pointer;

}

hr {
  border: 0.1px solid rgba(0, 0, 0, 0.1);
}


  /* Start of Slide Puzzle Styles */

:root{ --size: 320px; --gap: 6px; --tile-size: calc((var(--size) - var(--gap)*3)/4); }

/* Remove the duplicate body styles that conflict */
wrap{ 
  width: var(--size); 
  background-color: white;
  padding: 20px;
  margin: 0; /* Remove any default margins */
}

/* Update responsive breakpoint */

@media (max-width: 420px) { 
  :root { --size: 85vw; }
  h1 { 
    font-size: 14px;
    margin: 15px 0 15px 0;
  }
  
  header {
    height: 70px;
    padding-top: env(safe-area-inset-top);
  }
  
  main {
    padding-top: calc(2px + env(safe-area-inset-top));
    min-height: calc(100dvh - env(safe-area-inset-bottom));
  }
  
  body {
    height: 100dvh;
  }
}


  .meta{ 
    display:flex; 
    justify-content:center; 
    align-items:stretch; /* Changed from center to stretch to make all items same height */
    margin-bottom:10px; 
    gap:8px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
  }
  
  .meta .stat{ 
    font-size:13px; 
    background:#8d99ae; 
    padding:6px 10px; 
    border-radius:8px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  
  /* Style the preview button in the meta section */
  .meta button{ 
    background:#0b84ff; 
    color:white; 
    border:0; 
    padding:6px 10px; /* Match the stat padding */
    border-radius:8px; 
    cursor:pointer; 
    font-weight:600;
    font-size:13px; /* Match the stat font size */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Remove height: fit-content to allow stretching */
  }

 .tile{
  position:relative; 
  user-select:none; 
  cursor:pointer; 
  display:flex; 
  align-items:center; 
  justify-content:center; 
  font-weight:700; 
  font-size:18px; 
  border-radius:8px; 
  overflow:hidden; 
  transform:translateZ(0);
  transition: transform 260ms cubic-bezier(.2,.9,.3,1), box-shadow 220ms ease, opacity 200ms ease;
  box-shadow:0 6px 16px rgba(2,6,23,0.6);
  background:#0c1626;
  
  /* Prevent context menu and long-press behaviors */
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none; /* Safari */
  -khtml-user-select: none; /* Konqueror HTML */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* Internet Explorer/Edge */
  touch-action: manipulation; /* Prevent zoom and other touch behaviors */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

.tile img{ 
  position:absolute; 
  inset:0; 
  width:400%; 
  height:400%; 
  object-fit:none; 
  transform-origin:top left;
  
  /* Prevent context menu on images */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  pointer-events: none; /* Images don't need to be interactive */
}

    /* small responsive */
   /* Also update the small responsive section to match */
@media (max-width:420px){ 
  :root{ --size: 85vw; } /* Changed from 92vw to 85vw */
}

/* Remove the existing .modal rules and replace with this: */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: white;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: modalFadeIn 0.3s ease-out;
  position: relative; /* Ensure proper positioning */
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-content h2 {
  margin-top: 0;
  color: #333;
  font-size: 24px;
}

.modal-content p {
  color: #333;
  margin: 15px 0;
}

.completion-time {
  margin: 20px 0;
  font-size: 18px;
  color: #007bff;
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
}

.modal-content button {
  background: #007bff;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  margin-top: 15px;
  transition: background-color 0.2s;
}

.modal-content button:hover {
  background: #0056b3;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .modal-content {
    padding: 20px;
    margin: 10px;
    max-width: 95%;
  }
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin: 0px 0;
  flex-wrap: wrap; /* Allow wrapping on small screens */
}

.controls button {
  padding: 8px 16px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.controls button:hover {
  background: #0056b3;
}

.timer {
  font-size: 10px;
  color: #666;
  font-weight: 500;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  min-width: 80px;
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .controls {
    gap: 10px;
  }
  
  .controls button {
    padding: 6px 12px;
    font-size: 10px;
  }
  
  .timer {
    font-size: 10px;
    padding: 6px 10px;
    min-width: 70px;
  }
}


/* Create a wrapper for the crossword to handle scrolling while maintaining borders */
.crossword-wrapper {
  margin: 20px auto;
  overflow-x: auto; /* Enable horizontal scrolling */
  max-width: calc(100% - 10px); /* Ensure it doesn't overflow its container */
  align-self: center;
  border: 2px solid #333; /* Border for the container */
  min-height: 200px; /* Minimum height to ensure visibility */
  background: #f9f9f9; /* Light off-white background instead of black */
  
  /* Add some styling to make scrolling more obvious if needed */
  scrollbar-width: thin; /* For Firefox */
  scrollbar-color: #888 #f1f1f1; /* For Firefox */
  
  /* Enhance border visibility */
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  
  /* Smooth scrolling */
  scroll-behavior: smooth;
  
  /* Dynamic height adjustment based on available space */
  height: auto;
}

/* Style the scrollbar for Webkit browsers */
.crossword-wrapper::-webkit-scrollbar {
  height: 8px;
}

.crossword-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.crossword-wrapper::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.crossword-wrapper::-webkit-scrollbar-thumb:hover {
  background: #555;
}

#crossword {
  display: grid;
  gap: 1px;
  justify-content: center;
  margin: 0 auto; /* Remove margin as the wrapper handles it */
  box-sizing: border-box !important;
  padding: 0;
  border: none; /* Remove border as the wrapper handles it */
  background: #333; /* Background for the grid lines between cells */
}

/* Base cell styling - specific dimensions now set in JavaScript */
.cell {
  text-transform: uppercase;
  text-align: center;
  border: 1px solid #333;
  box-sizing: border-box;
  border-radius: 0;
  background: white;
  margin: 0;
  outline: none;
  padding: 0;
  /* Prevent text selection */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

@media (max-width: 600px) {
  .cell {
    width: min(35px, 15vw);
    height: min(35px, 15vw);
    font-size: 16px;
  }
}

.black {
  background: black;
  border: 1px solid #333;
}



.cell.black {
  background-color: #000000 !important;
  border: 1px solid #000000;
  cursor: default;
}

/* Ensure black cells stay black even with other classes */
.cell.black.clue-highlight,
.cell.black.active-cell {
  background-color: #000000 !important;
}

/* Make sure the cell wrapper for black cells also appears black */
div:has(.cell.black) {
  background-color: #000000;
}

/* Alternative approach if :has() isn't supported */
.black-cell-wrapper {
  background-color: #000000;
}



div.incorrect {
  position: relative;
}

div.incorrect::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom right,
    transparent 50%,
    #dc3545 45%,
    #dc3545 55%,
    transparent 55%
  );
  pointer-events: none;
  z-index: 1;
}



  .timer { font-size: 11px; 
    font-weight: bold; 
  }

  
  .clues-container {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 20px 10px;
    max-width: 100%;
    max-height: 300px;  /* Limit height to prevent obscuring crossword */
    overflow-y: auto;   /* Enable vertical scrolling */
    background: white;  /* Match the main background */
    border-top: 1px solid #eee; /* Light separator */
  }
  
  /* Ensure clues appear below the crossword on all screen sizes */
  @media (max-width: 800px) {
    .clues-container {
      order: 3; /* Place after the crossword in the flex layout */
      margin-bottom: 40px; /* Add space at the bottom */
    }
    
    .crossword-wrapper {
      order: 2; /* Ensure crossword comes before clues */
    }
    
    .controls {
      order: 1; /* Controls at the top */
    }
  }
  
 .clues-across, .clues-down {
  width: 50%; /* Each section takes 50% of container width */
  max-width: 300px; /* Optional: prevent them from getting too wide on large screens */
  padding-bottom: 20px; /* Add some padding at the bottom */
}

.clues-across h3, .clues-down h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  text-align: left;
  color: #333;
  position: relative;
  padding-right: 18px; /* Make room for scroll indicator */
}

/* Add a scroll indicator arrow to the headers */
.clues-across h3::after, .clues-down h3::after {
  content: "↓";
  position: absolute;
  right: 0;
  font-size: 14px;
  opacity: 0.7;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
  40% {transform: translateY(3px);}
  60% {transform: translateY(2px);}
}

.clues-across ul, .clues-down ul {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto; /* Enable scrolling within each clue list */
}

.clues-across li, .clues-down li {
  cursor: pointer;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

/* Add scrollbar styling for better visibility */
.clues-container::-webkit-scrollbar,
.clues-across ul::-webkit-scrollbar, 
.clues-down ul::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.clues-container::-webkit-scrollbar-thumb,
.clues-across ul::-webkit-scrollbar-thumb, 
.clues-down ul::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.clues-container::-webkit-scrollbar-thumb:hover,
.clues-across ul::-webkit-scrollbar-thumb:hover, 
.clues-down ul::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

.clues-across li:hover, .clues-down li:hover {
  background: #f0f0f0;
}

.clues-across li.active, .clues-down li.active {
  background: #ffe066;
  font-weight: bold;
}

.cell {
  width: 40px;
  height: 40px;
  text-transform: uppercase;
  text-align: center;
  font-size: 18px;
  border: 1px solid #333;
  box-sizing: border-box;
  border-radius: 0;
  background: white;
  margin: 0;
  outline: none;
  position: relative;
  caret-color: transparent; /* Hide the blinking cursor */
}

.cell-number {
  position: absolute;
  /* Base positioning - can be overridden by inline styles */
  top: 2px;
  left: 2px;
  font-size: 10px;
  color: #333;
  pointer-events: none;
  /* Ensure good contrast */
  font-weight: 600;
}

.cell:focus {
  outline: none;
  box-shadow: none;
  caret-color: transparent; /* Hide the blinking cursor on focus */
}

.cell.clue-highlight {
  background: #fff1b9 !important; /* All clue cells */
}

.cell.active-cell {
  background: #ffe066 !important; /* The cell being typed in */
  caret-color: transparent; /* Hide the blinking cursor for active cell too */
}

/* Replace the mobile keyboard section with this corrected version: */



.clue-nav-btn {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.clue-nav-btn:hover {
  background: #0056b3;
}

.clue-display {
  flex: 1;
  margin: 0 16px;
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.clue-number {
  font-weight: bold;
  color: #007bff;
  flex-shrink: 0;
}

.clue-separator {
  margin: 0 8px;
  color: #6c757d;
  flex-shrink: 0;
}

.clue-text {
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Mobile teleprompter effect for long clues */
body.mobile .clue-display {
  font-size: 12px;
  margin: 0 8px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Left align, no centering */
  white-space: nowrap;
  height: 20px; /* Fixed height to prevent layout shifts */
  padding-left: 15px; /* Padding to clear the left mask */
  padding-right: 15px; /* Padding to account for right mask */
}

body.mobile .clue-display .clue-content {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  transition: transform 0.3s ease;
}

body.mobile .clue-display .clue-content.sliding {
  animation: teleprompter 8s ease-in-out infinite;
}

body.mobile .clue-number {
  flex-shrink: 0;
}

body.mobile .clue-separator {
  flex-shrink: 0;
  margin: 0 6px;
}

body.mobile .clue-text {
  text-overflow: initial; /* Remove ellipsis on mobile */
  flex: none;
}

@keyframes teleprompter {
  0% { 
    transform: translateX(0); 
  }
  15% { 
    transform: translateX(0); 
  }
  50% { 
    transform: translateX(var(--translate-distance, calc(-100% + 100vw - 120px))); 
  }
  85% { 
    transform: translateX(var(--translate-distance, calc(-100% + 100vw - 120px))); 
  }
  100% { 
    transform: translateX(0); 
  }
}

/* Mask effect for mobile clue display */
body.mobile .clue-display {
  font-size: 12px;
  margin: 0 8px;
  position: relative;
  overflow: hidden;
}

/* Always show masks to create safe boundaries */
body.mobile .clue-display::before,
body.mobile .clue-display::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 15px;
  z-index: 2;
  pointer-events: none;
}

body.mobile .clue-display::before {
  left: 0;
  background: linear-gradient(to right, rgba(248, 249, 250, 1), rgba(248, 249, 250, 0));
}

body.mobile .clue-display::after {
  right: 0;
  background: linear-gradient(to left, rgba(248, 249, 250, 1), rgba(248, 249, 250, 0));
}

.mobile-keyboard {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
  padding: 12px 8px; /* Reduced padding */
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  height: 10px; /* Fixed height for consistency */
  box-sizing: border-box;
}

/* Update the keyboard styling to handle the new layout: */

.keyboard-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  width: 100%;
  max-width: 100%;
  flex-wrap: nowrap;
}

.keyboard-row:last-child {
  margin-bottom: 0;
}

.key-btn {
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.1s;
  min-width: 28px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  flex: 1;
  max-width: 40px;
}

.key-btn:active {
  background: #e9ecef;
  transform: scale(0.95);
}

.key-backspace {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
  flex: 1.5; /* Slightly wider than regular keys */
  max-width: 60px;
}

.key-check {
  background: #28a745;
  color: white;
  border-color: #28a745;
  flex: 1.5;
  max-width: 60px;
  display: none !important; /* Hide the check key completely */
}



/* Responsive Design */
/* For desktop screens at 600px and lower but above mobile size */
@media (max-width: 600px) and (min-width: 481px) {
  .clues-container {
    gap: 15px;
    max-height: 200px; /* Smaller max-height to ensure crossword visibility */
    padding: 15px 10px;
    margin-top: 15px;
  }
  
  .clues-across, .clues-down {
    min-width: auto;
    width: 48%; /* Slightly narrower */
  }
  
  /* Make the crossword section more prominent */
  .crossword-wrapper {
    margin: 10px auto; /* Reduced margin */
  }
  
  /* More compact controls */
  .controls {
    gap: 10px;
    margin: 5px 0;
  }
  
  /* Adjust main container padding */
  main {
    padding: 0 10px;
  }
}

/* For mobile screens */
@media (max-width: 480px) {
  .clues-container {
    gap: 15px;
    max-height: none; /* Don't limit height on mobile */
    overflow-y: visible; /* Don't need scrolling as it will flow naturally */
    border-top: none;
    padding-top: 10px;
  }
  
  .clues-across, .clues-down {
    min-width: auto;
    width: 100%;
  }
  
  /* Hide scroll indicators on mobile */
  .clues-across h3::after, .clues-down h3::after {
    display: none;
  }
}

@media (max-width: 480px) {
  header {
    height: 60px;
  }
  
  main {
    padding-top: 2px;
  }
  
  .controls {
    gap: 10px;
  }
  
  .controls button {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  .timer {
    font-size: 11px;
    padding: 6px 10px;
    min-width: 70px;
  }
  
  .modal-content {
    padding: 20px;
    margin: 10px;
    max-width: 95%;
  }
  
  /* Ensure crossword wrapper is properly displayed */
  .crossword-wrapper {
    margin: 10px auto;
  }

  .mobile body {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}
  
  body.mobile .mobile-clue-bar {
    bottom: 180px;
    padding: 8px 12px;
  }
  
  body.mobile .key-btn {
    min-width: 24px;
    height: 36px;
    font-size: 12px;
    padding: 6px 3px;
    max-width: 36px;
  }
  
  body.mobile .key-backspace {
    max-width: 50px;
  }
  
  body.mobile .keyboard-row {
    gap: 2px;
    margin-bottom: 4px;
  }
  
  body.mobile main {
    padding-bottom: 200px;
  }
}

/* Narrow desktop windows */
@media (max-width: 800px) and (min-width: 601px) {
  .clues-container {
    gap: 15px;
    max-height: 250px; /* Slightly smaller height for narrow desktop */
  }
  
  .clues-across, .clues-down {
    min-width: 200px;
  }
}

/* Larger desktop screens - provide more space for clues */
@media (min-width: 1200px) {
  .clues-container {
    max-height: 400px; /* Larger height on bigger screens */
    max-width: 800px; /* Wider container on larger screens */
  }
  
  .clues-across, .clues-down {
    max-width: 380px; /* Allow clues to be wider on large screens */
  }
}

/* Desktop layout with pinned clues container - All non-mobile widths */
@media (min-width: 481px) {
  body {
    height: 100vh;
    overflow: hidden;
  }
  
  main {
    height: 100vh;
    min-height: 100vh;
    padding-bottom: calc(24vh + 30vh); /* Reserve space for clues + extra scroll room */
    box-sizing: border-box;
    overflow-y: auto;
  }
  
  .clues-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24vh; /* Default height */
    max-height: 24vh;
    z-index: 1000;
    margin: auto;
    padding: 20px;
    background: white;
    border-top: 2px solid #333;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    overflow-y: auto;
  }
  
  .crossword-wrapper {
    /* Ensure crossword can scroll behind the pinned clues */
    margin-bottom: 20px;
    /* Provide lots of room for scrolling */
    overflow: auto;
    max-height: calc(100vh - 26vh); /* Leave room for header, controls, and clues */
    /* Ensure content has breathing room */
    min-height: 80vh;
    /* Allow horizontal scrolling for large crosswords */
    overflow-x: auto;
    overflow-y: auto;
  }
  
  /* Add extra scroll space to main container instead */
  main {
    height: 100vh;
    min-height: 100vh;
    padding-bottom: calc(24vh + 30vh); /* Reserve space for clues + extra scroll room */
    box-sizing: border-box;
    overflow-y: auto;
  }
}

/* Tall narrow desktop windows (like 9:16 ratio) - reduce clue container height */
@media (min-width: 481px) and (max-aspect-ratio: 10/16) {
  main {
    padding-bottom: calc(17vh + 30vh); /* Reduced space for narrow tall windows + scroll room */
  }
  
  .clues-container {
    height: 17vh; /* About 2.7/16 of viewport for 9:16 ratio */
    max-height: 17vh;
  }
}

/* Very tall narrow windows (like phone in landscape held vertically) */
@media (min-width: 481px) and (max-aspect-ratio: 8/16) {
  main {
    padding-bottom: calc(15vh + 30vh); /* Even smaller for very narrow windows + scroll room */
  }
  
  .clues-container {
    height: 15vh;
    max-height: 15vh;
  }
}

/* Wide desktop windows - can afford more space for clues */
@media (min-width: 481px) and (min-aspect-ratio: 16/10) {
  main {
    padding-bottom: calc(28vh + 30vh); /* More space for wide screens + scroll room */
  }
  
  .clues-container {
    height: 28vh;
    max-height: 28vh;
  }
}

/* iPad/Tablet specific styles */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
  .crossword-wrapper {
    /* Remove fixed min-height - let JavaScript calculate optimal height */
    margin: 15px auto;
    height: auto;
  }
  
  /* Adjust cell size for better visibility on tablets */
  .cell {
    font-size: 20px; /* Larger font for better readability */
  }
  
  /* Make better use of available space */
  .clues-container {
    max-height: 350px; /* More space for clues */
    margin-top: 10px;
  }
  
  /* Reduce gap between title and controls on iPad Mini and similar devices */
  h1 {
    margin: 10px 0 5px 0; /* Reduced margin */
  }
  
  .controls {
    margin: 5px 0 10px 0; /* Reduced top margin */
  }
}

/* iPad Mini and similar smaller tablets (portrait) - maximize crossword height */
@media only screen and (min-device-width: 768px) and (max-device-width: 820px) and (orientation: portrait) {
  h1 {
    margin: 5px 0 2px 0; /* Minimal spacing */
    font-size: 14px;
  }
  
  .controls {
    margin: 2px 0 5px 0; /* Minimal spacing */
  }
  
  .clues-container {
    margin-top: 5px;
    max-height: 25vh; /* Use remaining space efficiently */
  }
}

/* Similar devices with comparable screen sizes (portrait) */
@media only screen and (min-width: 768px) and (max-width: 834px) and (orientation: portrait) {
  h1 {
    margin: 5px 0 2px 0;
    font-size: 14px;
  }
  
  .controls {
    margin: 2px 0 5px 0;
  }
  
  .clues-container {
    margin-top: 5px;
    max-height: 27vh;
  }
}

/* iPad/Tablet in landscape orientation */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
  main {
    padding-bottom: 30px; /* Add space at the bottom */
  }
  
  /* Adjust positioning for landscape view */
  .controls {
    margin: 10px 0;
  }
}

/* iPad Mini and similar devices in landscape - calculate optimal height */
@media only screen and (min-device-width: 768px) and (max-device-width: 820px) and (orientation: landscape) {
  .crossword-wrapper {
    /* Remove fixed min-height calc - let JavaScript calculate optimal height */
    max-height: calc(100vh - 280px); /* Leave room for clues with padding */
  }
  
  h1 {
    margin: 3px 0 2px 0;
    font-size: 13px;
  }
  
  .controls {
    margin: 2px 0 3px 0;
  }
  
  .clues-container {
    max-height: 160px; /* Compact clues in landscape */
    margin-top: 3px;
  }
  
  main {
    padding-bottom: 15px;
  }
}

/* Similar landscape devices */
@media only screen and (min-width: 768px) and (max-width: 834px) and (orientation: landscape) {
  .crossword-wrapper {
    /* Remove fixed min-height calc - let JavaScript calculate optimal height */
    max-height: calc(100vh - 290px);
  }
  
  h1 {
    margin: 3px 0 2px 0;
    font-size: 13px;
  }
  
  .controls {
    margin: 2px 0 3px 0;
  }
  
  .clues-container {
    max-height: 170px;
    margin-top: 3px;
  }
  
  main {
    padding-bottom: 15px;
  }
}

/* Replace the @media query with a device-based approach: */

/* Hide mobile elements by default */
.mobile-clue-bar,
.mobile-keyboard {
  display: none;
}

/* Show mobile elements only when the mobile class is added to body */
body.mobile .clues-container {
  display: none !important;
  visibility: hidden;
  position: absolute;
  left: -9999px;
  height: 0;
  overflow: hidden;
}

body.mobile .mobile-clue-bar,
body.mobile .mobile-keyboard {
  display: flex;
}

body.mobile .mobile-keyboard {
  display: block; /* Change to block for proper keyboard layout */
}

/* Prevent device keyboard from showing on mobile */
body.mobile #crossword input {
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
}

/* Add bottom padding on mobile to prevent content from being hidden behind keyboard */
body.mobile main {
  padding-bottom: 420px;
}

/* ... rest of your existing mobile keyboard styles ... */

/* Hamburger styles */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  margin-left: auto;
  margin-right: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  width: 18px;
  background: #222;
  border-radius: 2px;
  transition: all 0.3s;
}

/* Side menu styles */
.side-menu {
  position: fixed;
  top: 0;
  right: -320px;
  width: 280px;
  height: 100%;
  background: #fff;
  box-shadow: -2px 0 16px rgba(0,0,0,0.08);
  transition: right 0.3s;
  z-index: 1000;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.side-menu.open {
  right: 0;
}
.side-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0px 24px 0px 24px;
  font-family: 'Anton', Arial, sans-serif;
  font-size: 1.2em;
  border-bottom: 1px solid #eee;
  height: 60px;
}

.side-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.side-menu li {
  margin: 0;
  padding: 12px 24px;
  width: 100%;
  box-sizing: border-box;
  border-radius: 0;
  transition: background 0.2s;
}

.side-menu li:hover {
  background-color: #8d99ae;
}

.side-menu a {
  text-decoration: none;
  color: #222;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
.side-menu a:hover {
  color: #222; /* Keep link text black on hover */
}

#closeMenu {
  background: none;
  border: none;
  font-size: 2em;
  cursor: pointer;
  color: #222;
  line-height: 1;
  padding: 0;
}

/* Responsive: hide hamburger on wide screens if desired */
@media (max-width: 900px) {
  .hamburger {
    display: flex;
  }
}
@media (min-width: 901px) {
  .hamburger {
    display: flex;
  }
}

/* Remove ALL existing .mobile rules and replace with this clean version */

/* Universal mobile styles */
.mobile {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.mobile header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  overflow: hidden;
}

.mobile main {
  height: calc(100vh - var(--header-height) - 200px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-top: calc(var(--header-height) ); /* Account for fixed header */
  box-sizing: border-box;
  scroll-behavior: smooth;
}

/* Massive scroll space at bottom - 10x the original */
.mobile main::after {
  content: '';
  display: block;
  height: 1000px; /* Increased from 300px to 1000px for huge scroll range */
}

/* Hide clues completely on mobile */
.mobile .clues-container {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  left: -9999px !important;
  height: 0 !important;
  overflow: hidden !important;
  max-height: none !important; /* Override desktop max-height */
}

/* Removed fade effect code */

/* Mobile keyboard and clue bar */
.mobile .mobile-clue-bar {
  display: flex;
  position: fixed;
  bottom: 180px;
  left: 0;
  right: 0;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
  padding: 12px 16px;
  z-index: 1000;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.mobile .mobile-keyboard {
  display: block;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 180px;
  z-index: 1000;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
  overflow: hidden;
  padding: 12px 8px 0px 8px;
}

/* Crossword styling on mobile */
.mobile .crossword-wrapper {
  overflow-x: auto;
  margin: 20px 0 40px 0; /* Extra bottom margin */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.mobile #crossword {
  overflow: visible;
  margin: 0 auto; /* Center the grid inside the wrapper */
}

/* Modal styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 999999;
}

.modal-instructions {
  background: white;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  width: 80%;
  font-size: 0.8em;
  position: relative; 
}



.modal-instructions h2 {
  margin-top: 0;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
}

.close-btn:hover {
  color: #000;
}

/* Stats styles */
.stats-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 999999;
}

.stats-modal {
  background: white;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  width: 80%;
  font-size: 0.8em;
  position: relative; 
}



.stats-modal h2 {
  margin-top: 0;
}

@media (min-width: 500px) {}
.all-time-stats-container {
align-self: center;
}

.all-time-stats-container {
  display: flex;
  width: 100%;
  margin-bottom: 10px;
  }

  .all-time-stats {
    flex: 1;
    display: inline-grid;
   /* margin-left: 12px; */
    }

  ol, ul {
    list-style: none;
    }

    ul {
      padding-inline-start: 0px !important;
      margin-block-start: 0em !important;
      margin-block-end: 0em !important;
    }


      @media (min-width: 500px) {}
      .all-time-stats .single-stat:not(.Stats-module_small__zkkbW) {
      font-size: 34px;
      font-weight: 500;
      }
      .all-time-stats .single-stat {
      font-size: 24px;
      font-weight: 400;
      display: flex;
     /* align-items: center; */
      justify-content: center;
      text-align: center;
      letter-spacing: .05em;
      font-variant-numeric: proportional-nums;
      line-height: 34px;
      }

      @media (min-width: 500px) {}
.all-time-stats .stat-label {
margin-top: 4px;
}
.all-time-stats .stat-label {
color: gray;
font-size: 12px;
font-weight: 400;
display: flex;
/* align-items: center; */
justify-content: center;
text-align: center;
line-height: 14px;
letter-spacing: .1em;
}
