:root {
    --matrix-green: #00FF41;
    --matrix-dark-green: #003B00;
    --matrix-light-green: #39FF14; /* A slightly brighter green for highlights */
    --matrix-bg: #0D0208; /* Deep, almost black for primary background */
    --error-red: #FF3333; /* Bright red for errors */
    --conflict-yellow: #FFD700; /* Yellow for temporary conflicts */
}

body {
    font-family: 'Share Tech Mono', monospace;
    background-image: url('https://r2.flowith.net/files/o/1747784766519-Matrix_Theme_Digital_Rain_Background_for_Sudoku_Game@1536x1024.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--matrix-green);
}

.matrix-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.75; /* Adjusted for better balance with static background */
}

.sudoku-cell {
    background-color: rgba(0, 0, 0, 0.7); /* Slightly less opaque */
    border: 1px solid rgba(0, 59, 0, 0.4); /* Softer border */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    aspect-ratio: 1/1;
    font-size: clamp(1rem, 4vw, 1.5rem); /* Responsive font size for cells */
    transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
    color: var(--matrix-green);
    font-family: 'Share Tech Mono', monospace;
    font-weight: bold;
    caret-color: var(--matrix-light-green); /* Cursor color */
}

.sudoku-cell:hover:not(.prefilled):not(:focus) { /* Hover only on editable, non-focused cells */
    background-color: rgba(0, 59, 0, 0.6);
}

.sudoku-cell.user-input:focus {
    background-color: rgba(0, 255, 65, 0.2) !important;
    outline: none;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.6) inset, 0 0 5px var(--matrix-light-green);
    color: var(--matrix-light-green);
}

.prefilled {
    color: var(--matrix-light-green);
    text-shadow: 0 0 5px var(--matrix-light-green), 0 0 2px var(--matrix-light-green); /* Enhanced prefilled glow */
    background-color: rgba(0, 20, 0, 0.5); /* Slightly different bg for prefilled */
}

.user-input {
    color: var(--matrix-green);
}

/* Cell states */
.cell-conflict {
    background-color: rgba(255, 215, 0, 0.25) !important; /* Yellowish conflict */
    color: var(--conflict-yellow) !important;
    text-shadow: 0 0 4px var(--conflict-yellow);
    box-shadow: 0 0 6px var(--conflict-yellow) inset;
}

.cell-error { /* Used when check solution fails for a cell */
    background-color: rgba(180, 0, 0, 0.4) !important;
    color: var(--error-red) !important;
    text-shadow: 0 0 5px var(--error-red);
    box-shadow: 0 0 8px var(--error-red) inset;
}

.cell-correct { /* Used when check solution passes for a user-input cell */
    color: var(--matrix-light-green) !important;
    background-color: rgba(0, 100, 0, 0.3) !important; /* Subtle green confirmation */
    text-shadow: 0 0 5px var(--matrix-light-green);
}


/* Status Message Styling */
#status-message.status-success {
    background-color: rgba(0, 255, 65, 0.15);
    border-color: var(--matrix-light-green);
    color: var(--matrix-light-green);
    text-shadow: 0 0 7px var(--matrix-light-green);
    animation: statusGlowSuccess 1.5s infinite alternate;
}

#status-message.status-error {
    background-color: rgba(255, 51, 51, 0.15);
    border-color: var(--error-red);
    color: var(--error-red);
    text-shadow: 0 0 7px var(--error-red);
    animation: statusGlowError 1.5s infinite alternate;
}

@keyframes statusGlowSuccess {
    from { box-shadow: 0 0 4px rgba(0, 255, 65, 0.2), 0 0 2px var(--matrix-light-green) inset; }
    to { box-shadow: 0 0 12px rgba(0, 255, 65, 0.6), 0 0 5px var(--matrix-light-green) inset; }
}

@keyframes statusGlowError {
    from { box-shadow: 0 0 4px rgba(255, 51, 51, 0.2), 0 0 2px var(--error-red) inset; }
    to { box-shadow: 0 0 12px rgba(255, 51, 51, 0.6), 0 0 5px var(--error-red) inset; }
}


.matrix-btn {
    background-color: rgba(0, 59, 0, 0.6); /* Slightly darker */
    color: var(--matrix-green);
    border: 1px solid var(--matrix-green);
    padding: 10px 16px; /* Increased padding */
    font-family: 'Share Tech Mono', monospace;
    text-transform: uppercase;
    font-weight: bold;
    transition: all 0.2s ease-out;
    text-shadow: 0 0 5px var(--matrix-green);
    position: relative;
    overflow: hidden;
    border-radius: 3px; /* Subtle rounding */
    box-shadow: 0 0 3px rgba(0, 255, 65, 0.2), 0 1px 2px rgba(0,0,0,0.3); /* Base shadow */
}

.matrix-btn:hover {
    background-color: rgba(0, 255, 65, 0.15);
    color: var(--matrix-light-green);
    box-shadow: 0 0 12px rgba(0, 255, 65, 0.6), 0 0 6px var(--matrix-light-green) inset, 0 2px 4px rgba(0,0,0,0.2);
    text-shadow: 0 0 8px var(--matrix-light-green);
}

.matrix-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 0 5px rgba(0, 255, 65, 0.4), 0 0 3px var(--matrix-light-green) inset;
}

/* Existing sweep animation for buttons */
.matrix-btn:after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.05) 40%, /* More subtle sweep */
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(45deg);
    transition: all 0.4s ease; /* Slightly slower sweep */
    opacity: 0;
}

.matrix-btn:hover:after {
    left: 100%;
    opacity: 1;
}

.border-3x3-right {
    border-right: 2px solid var(--matrix-light-green) !important;
}

.border-3x3-bottom {
    border-bottom: 2px solid var(--matrix-light-green) !important;
}

.terminal {
    font-family: 'Share Tech Mono', monospace;
    line-height: 1.3; /* Improved line spacing */
}

/* Glitch text effect - existing, ensure it's targeting the correct element if needed */
.glitch-text {
    text-shadow: 
        0 0 5px var(--matrix-green),
        0 0 10px var(--matrix-green),
        0 0 15px var(--matrix-light-green); /* Use lighter green for outer glow */
    position: relative;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text) 'MATRIX SUDOKU'; /* Use data-text if dynamic, or hardcode */
    content: 'MATRIX SUDOKU'; /* Content must be same as element */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* Ensure it doesn't cover text if bg is black */
    clip: rect(auto, auto, auto, auto); /* For glitch effect */
}

.glitch-text::before {
    animation: glitch 3s infinite linear alternate-reverse;
    color: rgba(57, 255, 20, 0.8); /* Slightly more opaque glitch layer */
    left: 2px;
    text-shadow: -1px 0 var(--error-red); /* Add a hint of red for matrix effect */
}

.glitch-text::after {
    animation: glitch 2.5s infinite linear alternate-reverse; /* Different timing */
    color: rgba(0, 255, 65, 0.6);
    left: -2px;
    text-shadow: 1px 0 var(--conflict-yellow); /* Add a hint of yellow */
}

@keyframes glitch { /* Refined glitch keyframes for more subtle effect */
    0% { clip-path: inset(20% 0 70% 0); transform: translateX(-1px) translateY(1px); opacity: 0.7; }
    10% { clip-path: inset(80% 0 5% 0); transform: translateX(1px) translateY(-1px); }
    20% { clip-path: inset(30% 0 40% 0); transform: translateX(-1px) translateY(1px); opacity: 0.5; }
    30% { clip-path: inset(50% 0 20% 0); transform: translateX(1px) translateY(-1px); }
    40% { clip-path: inset(10% 0 75% 0); transform: translateX(-1px); opacity: 0.8; }
    50% { clip-path: inset(90% 0 2% 0); transform: translateX(1px); }
    60% { clip-path: inset(40% 0 30% 0); transform: translateY(1px); opacity: 0.4; }
    70% { clip-path: inset(65% 0 10% 0); transform: translateY(-1px); }
    80% { clip-path: inset(25% 0 50% 0); transform: translateX(-1px); opacity: 0.9; }
    90% { clip-path: inset(70% 0 8% 0); transform: translateX(1px); }
    100% { clip-path: inset(45% 0 35% 0); transform: translateY(-1px); opacity: 0.6; }
}

/* Scrollbar styling for terminal */
.terminal::-webkit-scrollbar {
    width: 6px;
}
.terminal::-webkit-scrollbar-track {
    background: rgba(0,20,0,0.5);
    border-radius: 3px;
}
.terminal::-webkit-scrollbar-thumb {
    background: var(--matrix-green);
    border-radius: 3px;
}
.terminal::-webkit-scrollbar-thumb:hover {
    background: var(--matrix-light-green);
}


