:root {
    --primary-color: #1e88e5;
    --primary-dark: #1565c0;
    --secondary-color: #f8fafc;
    --text-color: #1e293b;
    --border-color: #cbd5e1;
    --error-color: #ef4444;
    --success-color: #22c55e;
    --accent-color: #f59e0b;
    --background-color: #f1f5f9;
    --cell-size: 58px;
    --board-bg: #ffffff;
    --highlight-color: #bbdefb;
    --grid-color: #94a3b8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 20%);
    background-attachment: fixed;
}

.container {
    max-width: 800px;
    width: 95%;
    padding: 2.5rem;
    background: var(--board-bg);
    border-radius: 24px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 8px 10px -6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.container::before {
    display: none;
}

header {
    text-align: center;
    margin-bottom: 2.5rem;
}

h1 {
    color: transparent;
    font-size: 3.2rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    background-image: linear-gradient(
        90deg, 
        #1565c0 0%, 
        #42a5f5 25%, 
        #1e88e5 50%, 
        #1976d2 75%, 
        #1565c0 100%
    );
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    animation: gradient-shift 5s linear infinite;
}

.logo-underline {
    display: block;
    width: 250px;
    height: 4px;
    margin: 0 auto 2rem;
    background: linear-gradient(
        90deg, 
        transparent 0%,
        #bbdefb 15%,
        #1e88e5 50%,
        #bbdefb 85%,
        transparent 100%
    );
    position: relative;
    background-size: 200% auto;
    animation: underline-shift 5s linear infinite;
}

.logo-underline::before {
    content: '';
    position: absolute;
    width: 40%;
    height: 4px;
    left: 30%;
    top: 8px;
    background: linear-gradient(
        90deg, 
        transparent 0%,
        rgba(30, 136, 229, 0.1) 15%,
        rgba(30, 136, 229, 0.4) 50%,
        rgba(30, 136, 229, 0.1) 85%,
        transparent 100%
    );
    filter: blur(4px);
    background-size: 200% auto;
    animation: underline-shift 5s linear infinite;
}

@keyframes gradient-shift {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 200% center;
    }
}

@keyframes underline-shift {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 200% center;
    }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

button {
    padding: 0.8rem 1.8rem;
    border: none;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 60%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s ease;
    pointer-events: none;
}

button:hover::before {
    transform: translate(-50%, -50%) scale(2);
}

button:hover {
    transform: translateY(-2px);
    background-color: var(--primary-dark);
    box-shadow: 
        0 10px 15px -3px rgba(30, 136, 229, 0.3),
        0 4px 6px -4px rgba(30, 136, 229, 0.3);
}

.timer {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    background: var(--highlight-color);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.timer::before {
    content: '⏱';
    font-size: 1.4rem;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    padding: 2rem;
    border-radius: 16px;
    background: var(--secondary-color);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.game-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(30, 136, 229, 0.03),
        transparent
    );
    transform-origin: center;
    animation: rotate-bg 15s linear infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes rotate-bg {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

#board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
    background-color: #e2e8f0;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -2px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--board-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.6rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
    border-radius: 8px;
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cell:hover {
    background-color: var(--highlight-color);
    transform: scale(1.02);
    z-index: 1;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cell.selected {
    background-color: var(--highlight-color);
    box-shadow: 
        0 0 0 2px var(--primary-color),
        0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 2;
    transform: scale(1.05);
}

.cell.initial {
    font-weight: 600;
    color: #2563eb;
    background-color: #f8fafc;
}

.cell:not(.initial) {
    color: #64748b;
}

/* Remove the existing grid lines */
.cell:nth-child(3n) {
    border-right: none;
}

.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: none;
}

/* Add subtle 3x3 grid spacing */
.cell:nth-child(3n) {
    margin-right: 4px;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    margin-bottom: 4px;
}

/* Error state */
.cell.error {
    animation: error-fade 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    position: relative;
    overflow: hidden;
}

@keyframes error-fade {
    0% { 
        background-color: #fee2e2;
        color: var(--error-color);
        box-shadow: 0 0 0 2px var(--error-color), 0 2px 4px rgba(0, 0, 0, 0.1);
        transform: scale(1);
    }
    10% { 
        transform: scale(1.1) translateX(-4px) rotate(-1deg);
    }
    20% { 
        transform: scale(1.1) translateX(4px) rotate(1deg);
    }
    30% { 
        transform: scale(1.1) translateX(-4px) rotate(-1deg);
    }
    40% { 
        transform: scale(1.1) translateX(4px) rotate(1deg);
    }
    50% {
        background-color: #fee2e2;
        color: var(--error-color);
        box-shadow: 0 0 0 2px var(--error-color), 0 2px 4px rgba(0, 0, 0, 0.1);
        transform: scale(1.1);
    }
    60% {
        transform: scale(1.05);
    }
    70% {
        background-color: rgba(254, 226, 226, 0.7);
        color: rgba(239, 68, 68, 0.7);
        box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.7), 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    100% { 
        background-color: var(--board-bg); 
        color: #64748b;
        transform: scale(1);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }
}

.cell.error::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.2) 0%, transparent 70%);
    opacity: 0;
    z-index: -1;
    animation: pulse-out 1.5s ease-out;
}

@keyframes pulse-out {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(0.9);
    }
    100% {
        opacity: 0;
        transform: scale(1.5);
    }
}

/* Number pad styling */
.number-controls {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 500px;
    justify-content: center;
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 1.5rem;
    background: var(--board-bg);
    border-radius: 20px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -2px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1;
}

.clear-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--board-bg);
    border-radius: 20px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -2px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1;
    width: 133px;
    height: 133px;
}

.number {
    aspect-ratio: 1;
    font-size: 1.8rem;
    font-weight: 500;
    background: var(--secondary-color);
    color: var(--text-color);
    border-radius: 12px;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    min-height: 60px;
}

.number:hover {
    background: var(--highlight-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.15);
}

.number.clear {
    background-color: var(--accent-color);
    color: white;
    font-size: 1.4rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    aspect-ratio: 1;
    height: 100px;
    width: 100px;
    min-width: unset;
    padding: 0;
}

.number.clear:hover {
    background-color: #ea580c;
    box-shadow: 0 2px 4px rgba(234, 88, 12, 0.2);
}

.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2.5rem;
    padding: 1.2rem;
    background: var(--secondary-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1;
}

.difficulty {
    background-color: #e6f0fb;
    color: var(--primary-color);
    min-width: 120px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.difficulty:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.difficulty.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 
        0 10px 15px -3px rgba(30, 136, 229, 0.3),
        0 4px 6px -4px rgba(30, 136, 229, 0.3);
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--error-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    font-weight: 600;
    text-align: center;
    max-width: 80%;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 600px) {
    :root {
        --cell-size: 36px;
    }

    .container {
        padding: 1.5rem;
        border-radius: 20px;
    }

    .cell {
        font-size: 1.3rem;
        border-radius: 6px;
    }

    .cell:nth-child(3n) {
        margin-right: 3px;
    }

    .cell:nth-child(n+19):nth-child(-n+27),
    .cell:nth-child(n+46):nth-child(-n+54) {
        margin-bottom: 3px;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    button {
        width: 100%;
        max-width: 200px;
    }

    h1 {
        font-size: 2.4rem;
    }

    .game-container {
        padding: 1rem;
    }

    .number-controls {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .number-pad {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 1rem;
    }
    
    .clear-container {
        padding: 0;
        width: 106px;
        height: 106px;
    }
    
    .number {
        font-size: 1.5rem;
        min-height: 48px;
        padding: 0.8rem;
    }
    
    .number.clear {
        height: 80px;
        width: 80px;
        font-size: 1.2rem;
    }

    .difficulty {
        min-width: 100px;
        padding: 0.6rem 1.2rem;
    }

    .toast {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* Add highlight style for matching numbers */
.cell.highlight-match {
    background-color: rgba(30, 136, 229, 0.15);
    transition: background-color 0.2s ease;
}

.cell.highlight-match.initial {
    background-color: rgba(30, 136, 229, 0.25);
}

.cell.highlight-match:hover {
    background-color: rgba(30, 136, 229, 0.25);
}

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

/* Ensure this doesn't override error states */
.cell.error {
    /* Keep existing error styles */
}

/* Top bar and menu styles */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0.5rem;
}

.spacer {
    width: 40px; /* Match menu button width */
}

.menu-btn {
    background: none;
    color: var(--primary-color);
    font-size: 1.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    box-shadow: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-btn:hover {
    background-color: var(--highlight-color);
    transform: translateY(0);
    box-shadow: none;
}

/* Menu panel */
.menu-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100%;
    background-color: var(--board-bg);
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.menu-panel.active {
    transform: translateX(0);
}

.menu-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.menu-header h2 {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.6rem;
    margin: 0;
}

#close-menu {
    background: none;
    color: var(--text-color);
    font-size: 2rem;
    padding: 0.2rem 0.6rem;
    box-shadow: none;
}

#close-menu:hover {
    background-color: var(--highlight-color);
    transform: translateY(0);
    box-shadow: none;
}

.menu-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-item {
    background-color: var(--secondary-color);
    color: var(--text-color);
    text-align: left;
    justify-content: flex-start;
    border-radius: 8px;
    padding: 1rem 1.2rem;
    font-size: 1rem;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

.menu-item:hover {
    background-color: var(--highlight-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(30, 136, 229, 0.15);
}

/* Overlay for menu background */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .menu-panel {
        width: 85%;
    }
    
    .menu-btn {
        width: 36px;
        height: 36px;
        font-size: 1.5rem;
    }
    
    .spacer {
        width: 36px;
    }
    
    .menu-header {
        padding: 1.2rem;
    }
}

/* Dark mode styles */
body.dark-mode {
    --board-bg: #1e293b;
    --secondary-color: #334155;
    --text-color: #e2e8f0;
    --border-color: #475569;
    --highlight-color: rgba(30, 136, 229, 0.2);
    --background-color: #0f172a;
    --grid-color: #64748b;
}

body.dark-mode .cell {
    background: #334155;
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

body.dark-mode .cell.initial {
    color: #60a5fa;
    background-color: #1e293b;
}

body.dark-mode .cell:not(.initial) {
    color: #cbd5e1;
}

body.dark-mode .number {
    background: #293548;
    color: #e2e8f0;
}

body.dark-mode .logo-underline {
    background: linear-gradient(
        90deg, 
        transparent 0%,
        #1e40af 15%,
        #3b82f6 50%,
        #1e40af 85%,
        transparent 100%
    );
}

body.dark-mode h1 {
    background-image: linear-gradient(
        90deg, 
        #1e40af 0%, 
        #60a5fa 25%, 
        #3b82f6 50%, 
        #2563eb 75%, 
        #1e40af 100%
    );
}

body.dark-mode .menu-item {
    background-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .menu-panel {
    background-color: #1e293b;
}

body.dark-mode #close-menu {
    color: #e2e8f0;
}

body.dark-mode .cell.highlight-match {
    background-color: rgba(59, 130, 246, 0.2);
}

body.dark-mode .cell.highlight-match.initial {
    background-color: rgba(59, 130, 246, 0.3);
}

body.dark-mode .menu-btn {
    color: #3b82f6;
}

/* Home screen styles */
.home-screen {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--background-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 20%);
    background-attachment: fixed;
}

.home-container {
    max-width: 500px;
    width: 90%;
    padding: 3rem 2rem;
    background: var(--board-bg);
    border-radius: 24px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.home-title {
    color: transparent;
    font-size: 4rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    background-image: linear-gradient(
        90deg, 
        #1565c0 0%, 
        #42a5f5 25%, 
        #1e88e5 50%, 
        #1976d2 75%, 
        #1565c0 100%
    );
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    animation: gradient-shift 5s linear infinite;
}

.start-button {
    width: 100%;
    max-width: 300px;
    margin: 2rem 0;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 12px;
    background-color: var(--primary-color);
    color: white;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.start-button:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 15px 20px -3px rgba(30, 136, 229, 0.3),
        0 8px 16px -8px rgba(30, 136, 229, 0.3);
}

.theme-button {
    width: 100%;
    max-width: 300px;
    margin: 0.5rem 0 2rem;
    padding: 0.8rem 1rem;
    background-color: var(--secondary-color);
    color: var(--text-color);
    font-size: 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.theme-button:hover {
    background-color: var(--highlight-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.theme-icon {
    font-size: 1.2rem;
}

.how-to-play-box {
    margin-top: 0.5rem;
    width: 100%;
    padding: 1.5rem;
    background-color: var(--secondary-color);
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.how-to-play-box h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.how-to-play-box p {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.8rem;
    color: var(--text-color);
}

.how-to-play-box p:last-child {
    margin-bottom: 0;
}

/* Dark mode specific styles for home screen */
body.dark-mode .how-to-play-box {
    background-color: #334155;
}

body.dark-mode .theme-button {
    background-color: #334155;
    color: #e2e8f0;
}

/* Responsive design for home screen */
@media (max-width: 600px) {
    .home-container {
        padding: 2rem 1.5rem;
    }
    
    .home-title {
        font-size: 3rem;
    }
    
    .start-button, .theme-button {
        max-width: 250px;
    }
} 