@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #0f172a;
    --app-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-dark: #1d4ed8;
    --accent-light: #60a5fa;
    --border-color: #334155;

    --board-bg: #0f172a;
    /* Dark border lines */
    --cell-bg: #1e293b;
    --cell-bg-alt: #1e293b;

    --cell-text: #e2e8f0;
    --cell-fixed: #ffffff;
    --cell-hover: #334155;
    --cell-selected: #2563eb;
    --cell-selected-text: #ffffff;
    --cell-highlight: #1e3a8a;
    /* Same number highlight */
    --cell-related: #334155;
    /* Row/Col/Box highlight */

    --cell-error-bg: #450a0a;
    --cell-error-text: #f87171;

    --btn-bg: #334155;
    --btn-text: #f1f5f9;
    --btn-hover: #475569;

    --note-text: #94a3b8;

    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --header-bg: rgba(15, 23, 42, 0.9);
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --app-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-color: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-light: #3b82f6;
    --border-color: #cbd5e1;
    --board-bg: #e2e8f0;
    --cell-bg: #ffffff;
    --cell-bg-alt: #f1f5f9;
    --cell-text: #0f172a;
    --cell-fixed: #000000;
    --cell-hover: #e2e8f0;
    --cell-selected: #bfdbfe;
    --cell-selected-text: #1d4ed8;
    --cell-highlight: #dbeafe;
    --cell-related: #f1f5f9;
    --cell-error-bg: #fef2f2;
    --cell-error-text: #dc2626;
    --btn-bg: #e2e8f0;
    --btn-text: #0f172a;
    --btn-hover: #cbd5e1;
    --note-text: #64748b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --header-bg: rgba(255, 255, 255, 0.9);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Utilities */
.hidden {
    display: none !important;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    transition: all 0.2s ease;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Start Screen */
/* Hero Section */
.hero-section {
    width: 100%;
    padding: 60px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-section.hidden {
    display: none;
}

.hero-content {
    background: var(--app-bg);
    padding: 3rem;
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.difficulty-selection {
    margin-bottom: 2rem;
    text-align: left;
}

.difficulty-selection label {
    display: block;
    margin-bottom: 0.8rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.diff-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.difficulty-btn {
    padding: 12px;
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
}

.difficulty-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-dark));
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Game App Layout */
.game-app {
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
    padding: 10px 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-link {
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.header-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.text-btn {
    background: none;
    color: var(--accent-light);
    font-weight: 600;
    font-size: 1rem;
}

/* Info Bar */
.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    background: var(--btn-bg);
    padding: 4px 12px;
    border-radius: 20px;
    color: var(--accent-light);
    font-weight: 600;
    text-transform: capitalize;
}

.timer-item {
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.icon-btn-plain {
    background: none;
    color: var(--text-secondary);
    padding: 4px;
}

/* Board */
.board-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    width: 100%;
    aspect-ratio: 1/1;
    background-color: var(--board-bg);
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    overflow: hidden;
    gap: 1px;
    box-shadow: var(--shadow);
}

.sudoku-cell {
    background-color: var(--cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    position: relative;
    color: var(--cell-text);
}

/* Grid Borders */
.sudoku-cell:nth-child(3n) {
    border-right: 2px solid var(--board-bg);
}

.sudoku-cell:nth-child(9n) {
    border-right: none;
}

.sudoku-board>.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-board>.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--board-bg);
}

/* Cell States */
.sudoku-cell.fixed {
    color: var(--cell-fixed);
    font-weight: 700;
}

.sudoku-cell.selected {
    background-color: var(--cell-selected) !important;
    color: var(--cell-selected-text) !important;
}

.sudoku-cell.highlight {
    background-color: var(--cell-related);
}

.sudoku-cell.same-num {
    background-color: var(--cell-highlight);
    color: var(--text-primary);
}

.sudoku-cell.error {
    background-color: var(--cell-error-bg);
    color: var(--cell-error-text);
}

.sudoku-cell .notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
}

.sudoku-cell .notes span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--note-text);
    line-height: 1;
}

/* Controls */
.controls-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.numpad {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.num-btn {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 8px;
    /* Slightly rounded squares as used frequently in modern apps */
    background: var(--accent-color);
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 var(--accent-dark);
    /* Alternative style: Circular blue buttons from screenshot */
    /* Screenshot had filled blue circles/squares */
    background: #3b82f6;
}

.num-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--accent-dark);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.tool-btn {
    background: var(--btn-bg);
    color: var(--text-secondary);
    border-radius: 12px;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 500;
}

.tool-btn:hover {
    background: var(--btn-hover);
    color: var(--text-primary);
}

.tool-icon {
    font-size: 1.2rem;
}

.notes-btn-wide {
    width: 100%;
    background: var(--app-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.notes-btn-wide.active {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
}

/* Modal Overrides */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--app-bg);
    padding: 2.5rem;
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.modal-stats {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-around;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

.stat-value {
    color: var(--accent-light);
    font-size: 1.2rem;
    font-weight: 700;
}

.share-btns {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.share-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--btn-bg);
    color: var(--text-primary);
}

/* Mobile Menu */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 2000;
}

.hamburger-box {
    width: 24px;
    height: 18px;
    display: inline-block;
    position: relative;
}

.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    position: absolute;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.hamburger-inner {
    top: 50%;
    transform: translateY(-50%);
}

.hamburger-inner::before {
    content: "";
    top: -8px;
}

.hamburger-inner::after {
    content: "";
    top: 8px;
}

.mobile-menu-btn.open .hamburger-inner {
    background-color: transparent;
}

.mobile-menu-btn.open .hamburger-inner::before {
    transform: rotate(45deg);
    top: 0;
}

.mobile-menu-btn.open .hamburger-inner::after {
    transform: rotate(-45deg);
    top: 0;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

.theme-toggle:hover {
    color: var(--accent-light);
}

[data-theme="dark"] .moon-icon {
    display: none;
}

[data-theme="light"] .sun-icon {
    display: none;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .nav-links {
        position: fixed;
        top: 70px;
        /* Header height */
        left: 0;
        width: 100%;
        height: calc(100vh - 70px);
        background: var(--bg-color);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 30px;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        z-index: 1000;
    }

    .nav-links.active {
        transform: translateX(0);
    }

    .nav-links a {
        font-size: 1.5rem;
    }
}

/* Global Header */
.main-header {
    background-color: var(--header-bg);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.logo-icon {
    color: var(--accent-light);
}

.logo img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.footer-logo {
    margin-bottom: 1rem;
    display: inline-flex;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent-light);
}

.dropdown-toggle {
    display: none;
}

/* Dropdown */
.dropdown {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 200px;
    background: var(--app-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    border-radius: 12px;
    padding: 10px;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.dropdown:hover .dropdown-menu {
    display: flex;
}

/* Mobile Dropdown */
@media (max-width: 768px) {
    .dropdown {
        width: 100%;
        text-align: center;
        flex-direction: column;
    }

    .dropdown-toggle {
        display: inline-flex;
        background: none;
        border: none;
        padding: 8px;
        color: var(--text-secondary);
        margin-left: 5px;
        transition: transform 0.3s;
    }

    .dropdown.active .dropdown-toggle {
        transform: rotate(180deg);
        color: var(--accent-light);
    }

    .dropdown-menu {
        position: static;
        width: 100%;
        background: transparent;
        border: none;
        box-shadow: none;
        display: none;
        padding-left: 0;
        margin-top: 10px;
        transition: all 0.3s ease-out;
    }

    .dropdown.active .dropdown-menu {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .dropdown-menu li {
        width: 100%;
    }

    .dropdown-menu a {
        padding: 12px;
        background-color: var(--btn-bg);
        /* Add subtle background for clearer tap areas */
        border-radius: 8px;
        text-align: center;
        display: block;
    }
}

.dropdown-menu li {
    list-style: none;
}

.dropdown-menu a {
    display: block;
    padding: 10px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.dropdown-menu a:hover {
    background: var(--btn-bg);
    color: var(--text-primary);
}

/* Footer */
footer {
    border-top: 1px solid var(--border-color);
    background-color: var(--app-bg);
    padding: 60px 0 20px;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section h4 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.footer-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.8rem;
}

.footer-links a {
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--accent-light);
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* SEO Content - Visible for scrolling */
.seo-section {
    max-width: 900px;
    margin: 60px auto;
    padding: 0 20px;
}

.seo-section h2 {
    color: var(--text-primary);
    font-size: 1.8rem;
    margin: 2rem 0 1rem;
}

.seo-section p,
.seo-section li {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.faq-container {
    margin-top: 60px;
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
    background: var(--app-bg);
}

.faq-question {
    padding: 20px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.faq-item.active .faq-answer {
    padding: 0 20px 20px;
    max-height: 500px;
}