/* Root Variables */
:root {
    --bg-color: #000044;
    --primary-color: #FF3366;
    --accent-color: #8A2BE2;
    --text-color: #0e0d0dea;
}

/* Base styles */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #000033, rgba(0, 0, 51, 0.95));
    color: var(--text-color);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* Allow text selection on inputs and text areas */
input, textarea {
    -webkit-user-select: text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Navbar Styles */
.navbar {
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 1000;
    background: rgba(0, 0, 51, 0.95);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.8rem 2rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2rem;
}

.corner-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.corner-logo span {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 600;
    text-decoration: none;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-right: auto;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    position: relative;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link i {
    font-size: 1.1rem;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

/* Mobile Menu Bar */
.mobile-menu-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 51, 0.95) !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
}

.mobile-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #fff !important;
    font-size: 0.8rem;
}

.mobile-menu-item i {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.mobile-menu-item.active {
    color: var(--primary-color) !important;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .mobile-menu-bar {
        display: block;
    }

    body {
        padding: 15px;
        padding-top: 80px;
        padding-bottom: 80px;
        font-size: 16px; /* Prevent zoom on iOS */
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }

    .nav-content {
        padding: 0.8rem 1rem;
    }

    .corner-logo span {
        font-size: 1rem;
    }

    .nav-logo-img {
        width: 32px;
        height: 32px;
    }

    /* Prevent zoom on inputs */
    input[type="text"],
    input[type="number"] {
        font-size: 16px !important;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 0;
    }

    /* Mobile-friendly button sizes */
    .button-group button {
        min-height: 44px;
        font-size: 14px;
        padding: 10px 15px;
        margin: 5px;
    }

    /* Responsive puzzle containers */
    .puzzle-container {
        padding: 10px;
    }

    .puzzle {
        margin-bottom: 20px;
        padding: 15px;
    }

    /* Sudoku grid mobile optimization */
    .sudoku-grid {
        max-width: 100%;
        overflow: visible;
    }

    .sudoku-cell {
        font-size: 14px;
        min-height: 35px;
        min-width: 35px;
    }
}

.navbar {
    background-color: #fff;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-logo-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.nav-links a {
    position: relative;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
}

/* Add highlighting effect for active page */
.nav-links a.active {
    color: var(--primary-color);
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

.nav-links a:hover {
    color: var(--primary-color);
}

:root {
    --primary-color: #ff3366;
    --secondary-color: #8a2be2;
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
}

header {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.puzzle-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 85%;  /* Reduced from 95% */
    max-width: 800px;  /* Reduced from 1000px */
    margin: 0 auto;
    padding: 20px;
}

.puzzle {
    width: 100%;
    background: white;
    padding: 30px;  /* Reduced from 40px */
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
    max-width: 700px;  /* Added max-width */
    margin-left: auto;
    margin-right: auto;
}

.puzzle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
}

.puzzle::after {
    content: attr(data-type);
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    background-color: var(--secondary-color);
}

.puzzle h2 {
    font-size: 24px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

#numberSequence { --puzzle-color: #4CAF50; }
#mathRiddle { --puzzle-color: #2196F3; }
#quickMath { --puzzle-color: #FF9800; }
#sudokuGame { --puzzle-color: #9C27B0; }
#patternPuzzle { --puzzle-color: #E91E63; }
#cryptoMath { --puzzle-color: #00BCD4; }
#visualLogic { --puzzle-color: #3F51B5; }

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

h2 {
    color: var(--secondary-color);
    margin-top: 0;
}

input {
    padding: 8px;
    margin: 10px 0;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    width: 150px;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 15px;  /* Reduced padding */
    border-radius: 4px;  /* Slightly reduced border radius */
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-size: 14px;    /* Reduced font size */
    min-height: 32px;   /* Added min-height for consistency */
}

button:hover {
    background-color: var(--secondary-color);
}

.show-answer {
    background-color: #666;
    margin-left: 10px;
}

.show-answer:hover {
    background-color: #888;
}

.reveal-btn {
    background-color: #dc3545;
    color: white;
}

.reveal-btn:hover {
    background-color: #c82333;
}

.explanation {
    margin-top: 8px;
    padding: 6px 8px;
    background-color: #f8f8f8;
    border-left: 2px solid var(--secondary-color);
    display: none;
    font-size: 12px;
    line-height: 1.3;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 1px;
    background-color: #666;
    padding: 2px;
    margin: 20px auto;
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1;
}

.sudoku-grid::before,
.sudoku-grid::after {
    content: '';
    position: absolute;
    background-color: #666;
}

/* Vertical lines */
.sudoku-cell:nth-child(3n) {
    border-right: 2px solid #666;
}

/* Horizontal lines */
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #666;
}

/* Add left border for first column of each 3x3 section */
.sudoku-cell:nth-child(3n + 1) {
    border-left: 2px solid #666;
}

/* Add top border for first row of each 3x3 section */
.sudoku-cell:nth-child(-n+9) {
    border-top: 2px solid #666;
}

.sudoku-cell {
    aspect-ratio: 1;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(14px, 3vw, 18px);
    position: relative;
    border: 1px solid #ccc;
}

.sudoku-cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: inherit;
    padding: 0;
    margin: 0;
    outline: none;
    background: transparent;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.fixed-cell {
    background-color: #f5f5f5;
    font-weight: bold;
}

.wrong-cell {
    background-color: #ffebee;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.correct-cell {
    background-color: #e8f5e9;
}

.correct-cell input {
    color: #2e7d32;
    font-weight: bold;
}

#attemptsCounter {
    text-align: center;
    color: var(--primary-color);
    font-weight: bold;
    margin: 10px 0;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 8px;           /* Reduced gap */
    flex-wrap: wrap;
}

#helpKeyBtn {
    background-color: var(--secondary-color);
}

#helpKeyBtn:disabled {
    background-color: #999;
    cursor: not-allowed;
}

.highlighted {
    background-color: #e6f3ff !important;
}

.popup-message {
    position: absolute;
    font-size: 16px;
    animation: fadeInOut 0.8s ease-in-out;
    pointer-events: none;
}

.popup-message.correct {
    color: #2e7d32;
}

.popup-message.wrong {
    color: #d32f2f;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: scale(0.8); }
    10% { opacity: 1; transform: scale(1.2); }
    20% { transform: scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

.pattern-grid, .crypto-puzzle, .shape-pattern {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
}

.hint {
    color: #666;
    font-style: italic;
    font-size: 0.8em;
    margin: 4px 0;
}

.shapes {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.puzzle-equation {
    font-size: 1.5em;
    margin: 15px 0;
}

.crypto-puzzle p {
    font-family: monospace;
    font-size: 1.2em;
    margin: 5px 0;
}

.back-button-container {
    text-align: center;
    margin: 40px 0;
}

.back-button {
    background-color: var(--secondary-color);
    font-size: 1.2em;
    padding: 15px 30px;
    border-radius: 25px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.back-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Mobile Menu Bar */
.mobile-menu-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.95);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
}

.mobile-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #fff;
    font-size: 0.8rem;
}

.mobile-menu-item i {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.mobile-menu-item.active {
    color: var(--primary-color);
}

/* Show mobile menu on small screens */
@media screen and (max-width: 768px) {
    .mobile-menu-bar {
        display: block;
    }

    /* Add padding to prevent content from being hidden behind mobile menu */
    body {
        padding-bottom: 70px;
    }

    /* Hide desktop nav on mobile */
    .nav-links {
        display: none;
    }

    /* Adjust puzzle container for mobile menu */
    .puzzle-container {
        margin-bottom: 80px;
    }

    /* Ensure footer doesn't get hidden behind mobile menu */
    footer {
        margin-bottom: 60px;
    }

    /* Adjust back button container */
    .back-button-container {
        margin-bottom: 80px;
    }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .puzzle-container {
        width: 92%;  /* Adjusted for mobile */
        padding: 10px;
    }

    .puzzle {
        padding: 20px;
        width: 100%;
        max-width: none;
    }

    input[type="number"],
    input[type="text"] {
        width: calc(100% - 20px);
        max-width: none;
        margin: 10px;
        box-sizing: border-box;
    }

    .sudoku-grid {
        max-width: min(95vw, 400px);
        margin: 10px auto;
    }

    .sudoku-cell {
        min-width: 30px;
        min-height: 30px;
    }

    .sudoku-cell input {
        font-size: 16px; /* Better touch target size */
    }

    /* Improve 3x3 grid borders for mobile */
    .sudoku-cell:nth-child(3n) {
        border-right: 2px solid #666;
    }

    .sudoku-cell:nth-child(n+19):nth-child(-n+27),
    .sudoku-cell:nth-child(n+46):nth-child(-n+54) {
        border-bottom: 2px solid #666;
    }

    #sudokuGame .button-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 10px;
        width: calc(100% - 20px);
        margin: 0 auto;
    }

    #sudokuGame button {
        width: 100%;
        min-height: 44px;
        padding: 10px;
        font-size: 14px;
        margin: 0;
    }

    .button-group {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0 10px;
    }

    button {
        flex: 1 1 calc(50% - 8px);
        min-width: 120px;
        margin: 0;
        white-space: nowrap;
        padding: 6px 12px;  /* Even smaller padding for mobile */
        font-size: 13px;    /* Slightly smaller font for mobile */
    }

    .sequence-numbers,
    .pattern-grid,
    .crypto-puzzle,
    .shape-pattern {
        width: 100%;
        padding: 10px;
        box-sizing: border-box;
    }

    header {
        padding: 60px 15px 30px;
        margin-bottom: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .puzzle h2 {
        font-size: 1.2rem;
        margin: 0 0 15px 0;
    }

    .explanation {
        margin: 8px 0;
        padding: 4px 6px;
        font-size: 11px;
    }

    .popup-message {
        font-size: 14px;
    }

    .hint {
        font-size: 0.75em;
    }

    .back-button-container {
        margin: 20px 10px;
        width: calc(100% - 20px);
        margin-bottom: 80px; /* Adjust bottom margin for back button container */
    }

    .navbar {
        padding: 0.5rem;
    }

    .nav-brand {
        gap: 0.5rem;
    }

    .nav-logo-img {
        width: 30px;
        height: 30px;
    }

    .puzzle-container {
        padding: 10px;
        gap: 15px;
        margin-bottom: 70px; /* Update puzzle container bottom margin */
    }

    .puzzle {
        padding: 15px;
        margin: 0;
    }

    input[type="number"],
    input[type="text"] {
        width: 100%;
        max-width: none;
        box-sizing: border-box;
        font-size: 16px;
    }

    .button-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    button {
        width: 100%;
        padding: 12px 8px;
        font-size: 14px;
        white-space: nowrap;
        margin: 0;
    }

    .sudoku-grid {
        width: 100%;
        max-width: 320px;
        gap: 1px;
    }

    .sudoku-cell {
        font-size: 14px;
        aspect-ratio: 1;
    }

    .sudoku-cell input {
        font-size: 14px;
    }

    .sequence-numbers,
    .pattern-grid,
    .crypto-puzzle,
    .shape-pattern {
        padding: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    #mathProblem {
        font-size: 1.2rem;
        margin: 10px 0;
    }

    .shapes {
        flex-wrap: wrap;
        gap: 10px;
    }

    .puzzle-equation {
        font-size: 1.2rem;
        margin: 10px 0;
    }

    #cryptoRules {
        font-size: 0.9rem;
    }

    h1 {
        font-size: 2rem;
        margin: 1rem 0;
    }

    .puzzle h2 {
        font-size: 1.2rem;
    }

    .puzzle::after {
        font-size: 10px;
        padding: 3px 8px;
        top: 10px;
        right: 10px;
    }

    .puzzle-container {
        width: 100%;
        padding: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .puzzle {
        width: 90%;  /* Changed from calc(100% - 20px) */
        max-width: 500px;  /* Added max-width for consistency */
        margin: 10px auto;  /* Changed from just margin: 10px */
        padding: 20px;
        box-sizing: border-box;
    }

    .pattern-grid, 
    .crypto-puzzle, 
    .shape-pattern,
    .sequence-numbers {
        width: 100%;
        margin: 10px auto;  /* Added auto margins */
        box-sizing: border-box;
    }

    .mobile-menu-bar {
        display: block;
    }

    /* Hide desktop nav on mobile */
    .nav-links {
        display: none;
    }
}

/* Small screen optimizations */
@media (max-width: 360px) {
    .button-group button {
        flex: 1 1 100%;
    }

    .sudoku-grid {
        max-width: 95vw;
        gap: 0;
    }

    .sudoku-cell {
        min-width: 25px;
        min-height: 25px;
    }

    .sudoku-cell input {
        font-size: 14px;
    }

    #sudokuGame .button-group {
        grid-template-columns: 1fr;
    }

    .sudoku-grid {
        grid-template-columns: repeat(9, minmax(20px, 30px));
    }

    .sudoku-cell {
        font-size: 14px;
    }

    .sudoku-cell input {
        font-size: 14px;
    }

    .sudoku-grid {
        max-width: 300px;
    }

    .sudoku-cell input {
        font-size: 12px;
    }

    .button-group {
        grid-template-columns: 1fr;
    }

    .sudoku-grid {
        max-width: 280px;
    }

    .puzzle {
        padding: 12px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .nav-logo {
        font-size: 1.2rem;
    }

    .puzzle {
        width: 95%;  /* Adjusted width */
        margin: 5px auto;  /* Changed to auto margins */
        padding: 15px;
    }
}

/* Desktop view optimizations */
@media (min-width: 769px) {
    .puzzle-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 90%;
        max-width: 1000px;
        margin: 0 auto;
        gap: 30px;
        padding: 40px 20px;
    }

    .puzzle {
        width: 100%;
        min-height: 350px;
        padding: 40px;
        margin: 0;
        display: flex;
        flex-direction: column;
    }

    .puzzle h2 {
        margin-bottom: 25px;
    }

    input[type="number"],
    input[type="text"] {
        width: 300px;
        margin: 15px auto;
        font-size: 16px;
        padding: 12px;
    }

    .button-group {
        margin-top: auto;
        display: flex;
        justify-content: center;
        gap: 15px;
        padding: 20px 0 0;
    }

    .sudoku-grid {
        margin: 30px auto;
        grid-template-columns: repeat(9, 45px);
    }

    .sequence-numbers,
    .pattern-grid,
    .crypto-puzzle,
    .shape-pattern {
        width: 80%;
        margin: 20px auto;
        padding: 20px;
    }
}

/* Mobile view improvements */
@media (max-width: 768px) {
    .puzzle-container {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 10px;
        gap: 15px;
        margin: 0;
    }

    .puzzle {
        width: calc(100% - 20px);
        margin: 10px;
        min-height: 300px;
        box-sizing: border-box;
    }

    input[type="number"],
    input[type="text"] {
        width: 90%;
        max-width: none;
        margin: 10px auto;
    }

    .sudoku-grid {
        width: 100%;
        max-width: 400px;
        margin: 15px auto;
    }

    .button-group {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0;
    }

    .sequence-numbers,
    .pattern-grid,
    .crypto-puzzle,
    .shape-pattern {
        width: 100%;
        padding: 15px;
        box-sizing: border-box;
    }
}

/* Small screen optimizations */
@media (max-width: 360px) {
    .puzzle {
        width: calc(100% - 10px);
        margin: 5px;
        padding: 15px;
    }

    .button-group {
        grid-template-columns: 1fr;
    }
}

/* Mobile view improvements */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .puzzle-container {
        padding: 10px;
        width: 100%;
        max-width: 100%;
        gap: 15px;
    }

    .puzzle {
        margin: 0;
        padding: 15px;
        width: calc(100% - 20px);
        margin: 10px;
    }

    .sudoku-grid {
        width: 100%;
        max-width: none;
        aspect-ratio: 1;
    }

    .sudoku-cell {
        aspect-ratio: 1;
    }

    input[type="number"],
    input[type="text"] {
        width: calc(100% - 20px);
        margin: 10px;
    }

    .sequence-numbers,
    .pattern-grid,
    .crypto-puzzle,
    .shape-pattern {
        width: calc(100% - 20px);
        margin: 10px;
    }

    .button-group {
        width: 100%;
        padding: 0;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .puzzle {
        width: calc(100% - 10px);
        margin: 5px;
        padding: 10px;
    }

    .button-group {
        grid-template-columns: 1fr;
    }
}

/* Desktop view optimizations */
@media (min-width: 769px) {
    body {
        padding: 0;
    }

    .puzzle-container {
        grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
        width: 98%;
        max-width: 2000px;
        gap: 25px;
        padding: 20px 1%;
        margin: 0 auto;
    }

    .puzzle {
        min-height: 400px;
        padding: 40px;
        margin: 0;
    }

    .sudoku-grid {
        grid-template-columns: repeat(9, 50px);
        gap: 2px;
    }

    .sudoku-cell {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    input[type="number"],
    input[type="text"] {
        width: 250px;
        font-size: 18px;
        padding: 12px;
    }

    .button-group {
        margin-top: auto;
        gap: 15px;
    }

    button {
        padding: 15px 25px;
        font-size: 16px;
    }
}

/* Tablet view optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .puzzle-container {
        grid-template-columns: repeat(2, 1fr);
        width: 95%;
        gap: 20px;
    }

    .puzzle {
        min-height: 350px;
    }
}

/* Mobile view improvements */
@media (max-width: 767px) {
    .puzzle-container {
        width: 100%;
        padding: 10px;
        gap: 15px;
    }

    .puzzle {
        width: calc(100% - 20px);
        margin: 10px;
        min-height: 300px;
    }

    .sudoku-grid {
        width: 100%;
        max-width: none;
        aspect-ratio: 1;
    }
}

/* Mobile view improvements */
@media (max-width: 768px) {
    .puzzle-container {
        width: 100%;
        padding: 10px;
        margin: 0;
    }

    .puzzle {
        width: 100%;
        margin: 0 0 20px 0;
        padding: 20px;
        box-sizing: border-box;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }

    .nav-links {
        display: none;  /* Hide nav links on mobile - assuming you have a mobile menu */
    }

    input[type="number"],
    input[type="text"] {
        width: 100%;
        max-width: none;
        margin: 10px 0;
        padding: 12px;
        box-sizing: border-box;
        font-size: 16px;
    }

    .button-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        width: 100%;
        padding: 10px 0;
    }

    button {
        width: 100%;
        padding: 12px;
        font-size: 14px;
        margin: 0;
    }

    .sudoku-grid {
        width: 100%;
        max-width: 320px;
        margin: 15px auto;
    }

    .sequence-numbers,
    .pattern-grid,
    .crypto-puzzle,
    .shape-pattern {
        width: 100%;
        padding: 15px;
        margin: 10px 0;
        box-sizing: border-box;
    }

    .puzzle::after {
        top: 15px;
        right: 15px;
        font-size: 11px;
        padding: 3px 8px;
    }

    .explanation {
        width: 100%;
        margin: 10px 0;
        box-sizing: border-box;
    }

    /* Adjust navbar for mobile */
    .navbar {
        padding: 10px;
    }

    .nav-brand {
        gap: 8px;
    }

    .nav-logo-img {
        width: 32px;
        height: 32px;
    }

    .nav-logo {
        font-size: 1.2rem;
    }
}

/* Extra small screens optimization */
@media (max-width: 360px) {
    .button-group {
        grid-template-columns: 1fr;
    }

    .puzzle {
        padding: 15px;
    }

    button {
        padding: 10px;
        font-size: 13px;
    }

    .sudoku-grid {
        max-width: 280px;
    }

    .puzzle h2 {
        font-size: 1.1rem;
    }
}

#sudokuGame {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 30px 20px;
}

#sudokuMessage {
    width: 100%;
    text-align: center;
    margin-top: 10px;
}

#mathProblem {
    font-size: 1.8rem;
    margin: 20px 0;
}

#sequenceDisplay {
    font-size: 1.5rem;
}

#riddleQuestion {
    font-size: 1.4rem;
    line-height: 1.6;
    margin: 15px 0;
}

#patternDisplay {
    font-size: 1.5rem;
    margin: 15px 0;
}

#cryptoRules {
    font-size: 1.4rem;
    margin: 15px 0;
}

#cryptoRules p {
    margin: 10px 0;
}

#visualEquation {
    font-size: 1.8rem;
    margin: 20px 0;
}

.shapes span {
    font-size: 1.4rem;
    margin: 0 15px;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    #mathProblem {
        font-size: 1.5rem;
    }
    
    #sequenceDisplay,
    #patternDisplay,
    #cryptoRules,
    #riddleQuestion {
        font-size: 1.2rem;
    }
    
    #visualEquation {
        font-size: 1.5rem;
    }
    
    .shapes span {
        font-size: 1.2rem;
        margin: 0 10px;
    }
}
