/* Frontend Styles */
.main-content{
    min-height:75vh;
}
/* Games Landing */
.games-landing {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.game-header{
    display:flex;
    flex-direction: row;
    align-items:center;
    justify-content:space-between;
    width:100%;
}

.game-navigation{
    display:flex;
    align-items:flex-end;
    align-items:center;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.game-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.game-card:hover {
    transform: translateY(-5px);
}

.game-card h2 {
    margin-top: 0;
    color: #333;
}

.game-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* Games Archive */
.games-archive {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.games-list {
    margin-top: 30px;
}

.game-version {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.game-version h3 {
    margin-top: 0;
    color: #333;
}

.version-date {
    color: #666;
    font-style: italic;
    margin: 10px 0;
}

/* Game Container */
.game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    border-radius: 5px;
}



/* Buttons */
.button {
    display: inline-block;
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    transition: background 0.2s ease;
}

.button:hover {
    background: #005177;
    color: #fff;
}

.button.secondary {
    background: #f7f7f7;
    color: #333;
    border: 1px solid #ddd;
}

.button.secondary:hover {
    background: #f0f0f0;
}

/* Game Completion Message */
.game-completion-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    text-align: center;
    z-index: 1000;
}

.game-completion-message h2 {
    color: #46b450;
    margin-top: 0;
}

.game-completion-message .button {
    margin: 10px;
}

/* Back Link */
.back-link {
    margin-top: 20px;
}

.back-link a {
    color: #666;
    text-decoration: none;
}

.back-link a:hover {
    color: #333;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .games-grid {
        grid-template-columns: 1fr;
    }

    .game-container {
        padding: 0px;
    }

    .game-content {
        padding: 0px;
    }

    .game-navigation {
        flex-direction: column;
    }

    .button {
        width: 100%;
    }
}

/* Touch Device Specific */
.touch-device .game-content {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Word Puzzle */
#word-puzzle-game {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

#puzzle-container {
    flex: 2;
    min-height: 300px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 4px;

    @media (max-width: 600px) {
        padding:0px;
    }
}

#word-list {
    flex: 1;
    padding: 15px;
    background: #f0f8ff;
    border-radius: 4px;
}

#word-list ul {
    list-style-type: none;
    padding: 0;
}

#word-list li {
    padding: 5px 0;
    border-bottom: 1px dashed #ccc;
}

/* Slider Puzzle */
#slider-puzzle-game {
    text-align: center;
}

#slider-puzzle-container {
    min-height: 300px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 4px;
}

#reset-slider {
    padding: 8px 15px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

#reset-slider:hover {
    background: #005177;
}

.slider-puzzle .puzzle-image img {
    max-width: 100%;
    height: auto;
}

/* Game Completion */
.game-completion {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.game-completion-content {
    background: white;
    padding: 30px;
    border-radius: 5px;
    text-align: center;
    max-width: 80%;
}

/* Responsive styles */
@media (max-width: 768px) {
    #word-puzzle-game {
        flex-direction: column;
    }
    
    .game-container.mobile {
        padding: 0px !important;
    }

    .game-header-v2 {
        border-top-right-radius:0px !important;
        border-top-left-radius:0px !important;
        top:0px !important;
        position:relative !important;
    }
} 



h1 {
    margin-bottom: 20px;
}

.crossword-box {
    background: #fff;
    border-radius: 12px;
    padding: 24px 18px 18px 18px;
    margin: 0px auto 0 auto;
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

#crossword-grid {
    background: #000;
    margin: 0 auto;
    width: fit-content;
    height: auto;
    box-sizing: border-box;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 0;
}

#crossword-title{
    font-size:1.2rem;
    padding:0px;
    margin:0px;
}

.puzzle-container {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.cell {
    width: clamp(35px, 6vw, 45px);
    height: clamp(35px, 6vw, 45px);
    min-width: clamp(35px, 6vw, 45px);
    min-height: clamp(35px, 6vw, 45px);
    background-color: white;
    border: 1px solid #333;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    aspect-ratio: 1;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

.cell.black {
    background-color: black;
    border: 1px solid black;
}

.cell-input {
    width: 100%;
    height: 100%;
    text-align: center;
    border: none;
    font-size: clamp(14px, 4vw, 20px);
    text-transform: uppercase;
    padding: 0;
    margin: 0;
    background: transparent;
    outline: none;
    font-weight: bold;
}

.cell-number {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: clamp(8px, 2vw, 12px);
    font-weight: bold;
    color: #555;
    z-index: 1;
    line-height: 1;
}

.cell.highlight {
    background-color: #e0f7fa;
}

.cell.current {
  outline: 3px solid #0056b3; /* Make selection clear (Mobile only) */
  z-index: 10;
}

/* Style for the cell containing the focused input (Desktop) or selected div (Mobile) */
.cell.current-temp-highlight {
    box-shadow: inset 0 0 0 2px #0056b3; /* Use inset shadow for desktop */
    z-index: 5; /* Lower than .current */
}

.clues-container {
    min-width: 220px;
    max-width: 300px;
    border-radius: 8px;
    padding: 16px;
    z-index: 10;
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.clues {
    background-color: #fff;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-y: auto;
    min-height: 60px;
}

.clues h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

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

.clues li {
    margin-bottom: 8px;
    font-size: 0.9em;
    cursor: pointer;
}

.clues li:hover {
    color: #007bff;
}

.clues li.active {
    font-weight: bold;
    color: #0056b3;
}

.controls {
    margin-top: 20px;
    display: flex;
    justify-content:space-evenly;
    gap: 10px;
}

button {
    padding: 10px 15px;
    font-size: 1em;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    transition: background-color 0.2s ease;
}

button:hover {
    background-color: #0056b3;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .crossword-box {
        padding: 16px;
        max-width: 100%;
    }
    
    .puzzle-container {
        flex-direction: column;
        align-items: center;
        gap: 24px;
        padding: 0 16px;
    }
    
    #crossword-grid {
        width: fit-content;
        height: auto;
        margin: 0 auto;
    }
    
    .clues-container {
        max-width: 100%;
        width: 100%;
        min-width: auto;
    }
}
@media (max-width: 600px) {

    .game-header-v2 {
        border-top-right-radius:0px !important;
        border-top-left-radius:0px !important;
        top:0px !important;
        height:auto !important;
        padding:10px !important;
        position:relative !important;
        text-shadow:0px 0px 6px #fff, 0px 0px 10px #fff !important;
    }

    .game-header-v2 h1{
        font-size:1.3em !important;
        line-height:1.1em !important;
    }

    .crossword-box {
        padding: 0px !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .puzzle-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 20px !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    #crossword-grid {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: auto !important;
        height: auto !important;
        max-height: none !important;
        min-height: auto !important;
        margin: 0 auto !important;
        padding: 16px !important;
        border-radius: 0px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
        background: #000 !important;
        display: grid !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        touch-action: manipulation !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .game-container {
        padding: 16px !important;
        padding-bottom: 200px !important;
        box-sizing: border-box !important;
    }
}

/* --- Current Clue Display --- */
.clue-display {
    position: relative;
    padding-left: 56px;
    padding-right: 56px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    word-break: break-word;
    white-space: normal;
    position: fixed;
    bottom: 0px;
    left: 0px;
    width: 100%;
    z-index: 1000;
}

.clue-display.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    background:rgba(0,0,0,0.8);
}

.clue-display .clue-number{
    font-weight:bold;
    font-size:0.8em;
    margin-right:5px;
    white-space:nowrap;
}

.clue-display .clue-number,
.clue-display .clue-text {
    display: inline;
    font-size: 1.1em;
    vertical-align: middle;
    color:#fff;
}

/* Adjustments for when clue display is active */
body.clue-visible {
    /* Add some padding to the bottom of the body to prevent
       the fixed clue display from overlapping the lowest content
       (like the control buttons when scrolled down) */
    padding-bottom: 60px; /* Adjust height based on .clue-display padding/font */
}

/* Optional: Slightly smaller font on very small screens */
@media (max-width: 480px) {
    .clue-display {
        font-size: 0.9em;
        padding: 8px 15px;
    }
    body.clue-visible {
        padding-bottom: 50px;
    }
}

/* Grid Cell Content (Replaces Input Styling) */
.cell-content {
    position: relative; /* For number positioning */
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Hide overflow */
}

.cell-letter {
    font-size: clamp(14px, 4vw, 20px);
    font-weight: bold;
    text-transform: uppercase;
    line-height: 1;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Keep cell number styling */
.cell-number {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 0.6em;
    font-weight: bold;
    color: #555;
    z-index: 1; /* Ensure number is above letter bg? maybe not needed */
}

/* --- Virtual Keyboard Styles --- */
.virtual-keyboard {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #d1d5db; /* Light gray background */
    padding: 5px;
    box-sizing: border-box;
    z-index: 200; /* Above clue display */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;

    /* Initially hidden */
    visibility: hidden;
    opacity: 0;
    transform: translateY(100%);
    transition: visibility 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.virtual-keyboard.visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 5px; /* Spacing between keys */
    width: 100%; /* Ensure rows take full width */
}

.keyboard-key {
    padding: 10px 0; /* Vertical padding */
    min-width: 28px; /* Minimum width, adjust as needed */
    height: 40px; /* Fixed height */
    flex-grow: 1; /* Allow keys to grow */
    flex-basis: 0; /* Distribute space evenly */
    max-width: 40px; /* Max width for standard keys */
    font-size: 1em;
    font-weight: bold;
    border: none;
    background-color: #ffffff; /* White keys */
    color: #000000;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);

    /* Prevent double-tap zoom and text selection */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
}

.keyboard-key:active {
    background-color: #e5e7eb; /* Slightly darker on press */
}

/* Wider keys for utility buttons */
.keyboard-key.keyboard-key-utility {
    flex-grow: 1.5; /* Make utility keys slightly wider */
    max-width: 60px;
    background-color: #a7abb1;
}
.keyboard-key.keyboard-key-utility:active {
    background-color: #989ca2;
}

/* Adjustments for when keyboard is active */
body.keyboard-visible {
    /* Add padding to prevent overlap with controls/clue display */
    /* Height depends on keyboard height, adjust as needed */
    padding-bottom: 180px; 
}

/* Ensure proper spacing on mobile when keyboard is visible */
@media (max-width: 600px) {
    body.keyboard-visible {
        padding-bottom: 200px;
    }
    
    body.keyboard-visible .game-container {
        padding-bottom: 220px !important;
    }
}

/* --- Adjust clue display positioning with keyboard --- */
body.keyboard-visible .clue-display.active {
    /* When keyboard is up, move clue display above it */
    bottom: 140px; 
    transition: bottom 0.2s ease; /* Smooth transition */
}

@media (max-width: 600px) {
    body.keyboard-visible .clue-display.active {
        bottom: 140px;
    }
}

@media (max-width: 600px) {
  .puzzle-container {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 0;
    margin: 0;
    width: 100%;
  }
  
  #crossword-grid {
    max-width: 100%;
    width: 100%;
    overflow: visible;
    touch-action: manipulation;
    margin: 0 auto;
    padding: 16px;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
  }
  
  .cell {
    width: clamp(32px, 8vw, 40px);
    height: clamp(32px, 8vw, 40px);
    min-width: clamp(32px, 8vw, 40px);
    min-height: clamp(32px, 8vw, 40px);
    font-size: clamp(14px, 4vw, 18px);
    border: 1px solid #333;
    box-sizing: border-box;
  }
  
  .cell-input {
    font-size: clamp(14px, 4vw, 18px);
  }
  
  .cell-letter {
    font-size: clamp(14px, 4vw, 18px);
  }
  
  .cell-number {
    font-size: clamp(8px, 2vw, 10px);
  }
  
  .clues-container {
    max-width: 100%;
    min-width: 0;
    padding: 0 16px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
  }
  
  .virtual-keyboard,
  .clue-display {
    position: fixed;
    left: 0;
    width: 100vw;
    z-index: 1000;
  }
  
  .virtual-keyboard {
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  }
  
  .clue-display {
    padding-left: 56px !important;
    padding-right: 56px !important;
    font-size: 1.08em !important;
  }
  
  .controls {
    flex-direction: column;
    gap: 12px;
    margin: 20px 0 100px 0;
    padding: 0 16px;
    width: 100%;
    box-sizing: border-box;
  }
  
  .game-container {
    padding: 16px !important;
    padding-bottom: 200px !important;
    box-sizing: border-box !important;
  }
}

/* Modal for all clues (hidden by default) */
#all-clues-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
}
#all-clues-modal .modal-content {
  background: #fff;
  border-radius: 12px;
  max-width: 95vw;
  max-height: 80vh;
  overflow-y: auto;
  margin: 40px auto;
  padding: 18px 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
#all-clues-modal h2 {
  margin-top: 0;
  font-size: 1.2em;
}
#all-clues-modal ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
#all-clues-modal li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 1em;
  cursor: pointer;
}
#all-clues-modal li:last-child {
  border-bottom: none;
}
#all-clues-modal .close-modal {
  position: absolute;
  top: 10px;
  right: 18px;
  background: none;
  border: none;
  font-size: 2em;
  color: #888;
  cursor: pointer;
}

.clue-display .button {
  font-size: 0.95em;
  padding: 6px 16px;
  min-width: unset;
  max-width: 120px;
  display: inline-block;
  margin: 0 6px;
  box-sizing: border-box;
}
@media (max-width: 600px) {
  .clue-display .button {
    width: auto !important;
    min-width: unset !important;
    max-width: 120px !important;
    font-size: 0.95em !important;
    padding: 6px 16px !important;
    margin: 0 6px !important;
    display: inline-block !important;
  }
}

.clue-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  max-width: 36px;
  max-height: 36px;
  border-radius: 50%;
  background: #222;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4em;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: background 0.2s;
}
.clue-nav-btn:active, .clue-nav-btn:focus {
  background: #444;
}
.clue-nav-btn.prev {
  left: 8px;
}
.clue-nav-btn.next {
  right: 8px;
}
/* Additional mobile optimizations for very small screens */
@media (max-width: 480px) {
  .cell {
    width: clamp(28px, 7vw, 36px);
    height: clamp(28px, 7vw, 36px);
    min-width: clamp(28px, 7vw, 36px);
    min-height: clamp(28px, 7vw, 36px);
  }
  
  .cell-input,
  .cell-letter {
    font-size: clamp(12px, 3.5vw, 16px);
  }
  
  .cell-number {
    font-size: clamp(7px, 1.8vw, 9px);
  }
  
  #crossword-grid {
    padding: 12px;
  }
  
  .clues-container {
    padding: 0 12px;
  }
  
  .controls {
    padding: 0 12px;
  }
} 