:root {
    --neon-pink: #ff00ff;
    --neon-blue: #00ffff;
    --neon-green: #00ff00;
    --neon-yellow: #ffff00;
    --grid-bg: #000033;
    --cell-bg: #000066;
    --cell-selected: #330066;
    --cell-highlight: #003366;
    --cell-error: #660033;
    --text-color: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: #000;
    color: var(--text-color);
    background-image: 
        radial-gradient(var(--neon-blue) 1px, transparent 1px),
        radial-gradient(var(--neon-pink) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: 0 0, 25px 25px;
    overflow-y: auto; /* Allow scrolling */
    min-height: 100vh;
    padding-bottom: 80px; /* Add padding at bottom for footer */
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    animation: pulse 2s infinite alternate;
    position: relative;
    z-index: 2000; /* Ensure header is above animations */
}

.title {
    font-size: 2.5rem;
    color: var(--neon-green);
    text-shadow: 
        0 0 5px var(--neon-green),
        0 0 10px var(--neon-green),
        0 0 20px var(--neon-green);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.neon-subtitle {
    font-size: 1rem;
    color: var(--neon-pink);
    text-shadow: 
        0 0 5px var(--neon-pink),
        0 0 10px var(--neon-pink);
    letter-spacing: 1px;
}

.game-controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 10px var(--neon-blue);
    position: relative;
    z-index: 2000; /* Ensure controls are above animations */
}

.timer-container, .score-container {
    text-align: center;
}

.timer-label, .score-label {
    font-size: 0.7rem;
    color: var(--neon-yellow);
    margin-bottom: 5px;
}

#timer, #score {
    font-size: 1.2rem;
    color: var(--neon-blue);
    text-shadow: 0 0 5px var(--neon-blue);
}

.difficulty-container {
    display: flex;
    gap: 10px;
}

.difficulty-btn {
    background: #330066;
    color: white;
    border: 2px solid var(--neon-pink);
    padding: 5px 10px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s;
}

.difficulty-btn:hover, .difficulty-btn.active {
    background: var(--neon-pink);
    color: black;
    box-shadow: 0 0 10px var(--neon-pink);
}

.game-board-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    position: relative;
    z-index: 1000; /* Increased z-index to ensure visibility */
    margin: 0 auto;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background-color: var(--neon-blue);
    padding: 2px;
    border: 3px solid var(--neon-blue);
    box-shadow: 
        0 0 10px var(--neon-blue),
        0 0 20px var(--neon-blue);
    width: 450px;
    height: 450px;
}

.cell {
    background-color: var(--cell-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    color: white;
}

.cell.given {
    color: var(--neon-yellow);
    text-shadow: 0 0 5px var(--neon-yellow);
}

.cell.selected {
    background-color: var(--cell-selected);
    box-shadow: inset 0 0 5px var(--neon-pink);
}

.cell.highlighted {
    background-color: var(--cell-highlight);
}

.cell.error {
    background-color: var(--cell-error);
    animation: shake 0.5s;
}

/* Add borders to separate 3x3 boxes */
.cell:nth-child(3n) {
    border-right: 2px solid var(--neon-blue);
}

.cell:nth-child(9n) {
    border-right: none;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--neon-blue);
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 5px;
    width: 100px;
}

.number-btn {
    background-color: #330066;
    color: white;
    border: 2px solid var(--neon-green);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.number-btn:hover {
    background-color: var(--neon-green);
    color: black;
    box-shadow: 0 0 10px var(--neon-green);
}

.erase-btn {
    border-color: var(--neon-pink);
    color: var(--neon-pink);
}

.erase-btn:hover {
    background-color: var(--neon-pink);
    color: black;
    box-shadow: 0 0 10px var(--neon-pink);
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.action-btn {
    background: #330066;
    color: white;
    border: 2px solid var(--neon-blue);
    padding: 10px 20px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    z-index: 5002; /* Ensure buttons are clickable */
}

.action-btn:hover {
    background: var(--neon-blue);
    color: black;
    box-shadow: 0 0 10px var(--neon-blue);
}

.message-box {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000; /* Very high z-index to ensure it's on top */
}

.message-box.hidden {
    display: none;
}

.message-content {
    background-color: #000033;
    border: 3px solid var(--neon-green);
    box-shadow: 
        0 0 10px var(--neon-green),
        0 0 20px var(--neon-green);
    padding: 30px;
    text-align: center;
    max-width: 80%;
    z-index: 5001; /* Even higher than the message box */
    border-radius: 10px;
}

#message-title {
    color: var(--neon-yellow);
    margin-bottom: 20px;
    font-size: 2rem;
    text-shadow: 0 0 10px var(--neon-yellow);
}

#message-text {
    color: white;
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.5;
}

.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.7);
    border-top: 2px solid var(--neon-blue);
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 3000; /* Even higher z-index for footer */
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--neon-blue);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.icon-btn:hover {
    text-shadow: 0 0 10px var(--neon-blue);
}

.credits {
    font-size: 0.6rem;
    color: #666;
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    20%, 60% {
        transform: translateX(-5px);
    }
    40%, 80% {
        transform: translateX(5px);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 5px var(--neon-blue);
    }
    100% {
        box-shadow: 0 0 20px var(--neon-blue);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .game-board-container {
        flex-direction: column;
        align-items: center;
    }
    
    .game-board {
        width: 100%;
        height: auto;
        aspect-ratio: 1/1;
    }
    
    .number-pad {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(2, 1fr);
        width: 100%;
        margin-top: 20px;
    }
    
    .title {
        font-size: 1.8rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }
}
.error-message {
    color: var(--neon-pink);
    text-align: center;
    padding: 20px;
    font-size: 1rem;
    border: 2px solid var(--neon-pink);
    background-color: rgba(0, 0, 0, 0.7);
}
/* Level selection screen */
.level-select-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: pulse 2s infinite alternate;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.level-select-screen h2 {
    color: var(--neon-green);
    text-shadow: 
        0 0 5px var(--neon-green),
        0 0 10px var(--neon-green);
    margin-bottom: 30px;
    font-size: 1.8rem;
    letter-spacing: 2px;
}

.level-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    max-width: 600px;
}

.level-btn {
    background: #330066;
    color: white;
    border: 2px solid var(--neon-blue);
    padding: 15px 10px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.level-btn:hover {
    background: var(--neon-blue);
    color: black;
    box-shadow: 0 0 10px var(--neon-blue);
    transform: scale(1.05);
}

/* Game screen */
.game-screen {
    display: block;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Level display */
.level-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.level-label {
    font-size: 0.7rem;
    color: var(--neon-yellow);
    margin-bottom: 5px;
}

#current-level {
    font-size: 1.2rem;
    color: var(--neon-blue);
    text-shadow: 0 0 5px var(--neon-blue);
}

/* Mistakes display */
.mistakes-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

.mistake-label {
    font-size: 0.7rem;
    color: var(--neon-pink);
    margin-bottom: 5px;
}

.mistake-icons {
    display: flex;
    gap: 10px;
}

.mistake-icon {
    color: rgba(255, 0, 0, 0.3);
    font-size: 1.2rem;
    transition: all 0.3s;
}

.mistake-icon.active {
    color: red;
    text-shadow: 0 0 5px red;
    animation: pulse-mistake 0.5s;
}

@keyframes pulse-mistake {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* Responsive design for level selection */
@media (max-width: 768px) {
    .level-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
}
/* Floating score animation */
.floating-score {
    position: absolute;
    color: var(--neon-green);
    font-family: 'Press Start 2P', cursive;
    font-size: 1.2rem;
    text-shadow: 0 0 5px var(--neon-green);
    pointer-events: none;
    z-index: 100;
    animation: float-up 1s forwards;
    transform: translateX(-50%);
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-50px);
    }
}
/* Pause overlay */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 5000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pause-overlay.hidden {
    display: none;
}

.pause-content {
    background-color: var(--grid-bg);
    border: 3px solid var(--neon-green);
    box-shadow: 0 0 20px var(--neon-green);
    padding: 30px;
    text-align: center;
    border-radius: 10px;
    max-width: 80%;
    z-index: 5001; /* Even higher than the pause overlay */
    position: relative;
}

.pause-content h2 {
    color: var(--neon-yellow);
    margin-bottom: 20px;
    font-size: 2rem;
    text-shadow: 0 0 10px var(--neon-yellow);
    animation: pulse 2s infinite alternate;
}

.pause-content p {
    color: var(--text-color);
    font-size: 1rem;
}

/* Global scrollbar styling */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--neon-blue) var(--grid-bg);
}

html::-webkit-scrollbar {
    width: 12px;
}

html::-webkit-scrollbar-track {
    background: var(--grid-bg);
}

html::-webkit-scrollbar-thumb {
    background-color: var(--neon-blue);
    border-radius: 6px;
    border: 3px solid var(--grid-bg);
}

html::-webkit-scrollbar-thumb:hover {
    background-color: var(--neon-pink);
}
/* Override for light theme to ensure scrolling works */
body.theme-light {
    overflow-y: auto !important;
}
/* Styling for completed numbers */
.number-btn.completed {
    position: relative;
    opacity: 0.7;
    text-decoration: line-through;
    background: linear-gradient(to bottom right, #330066, #660066);
}

.complete-mark {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--neon-green);
    color: black;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    font-size: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 5px var(--neon-green);
}
