#toast-notification-container,
.auth-modal-overlay {
    z-index: 1000000 !important;
}

/* CSS Variables & Theme */
:root {
    /* Sudoku Specific Grid & Cell Colors */
    --grid-border: rgba(255, 255, 255, 0.1);
    --cell-bg: rgba(255, 255, 255, 0.03);
    --cell-bg-selected: rgba(188, 140, 242, 0.25);
    --cell-bg-highlight: rgba(255, 255, 255, 0.08);
    --cell-error: #ff5252;
    --btn-bg: rgba(255, 255, 255, 0.05);
    --btn-hover: rgba(255, 255, 255, 0.1);
}

/* Fix for overlapping seasonal effects (Snow, Stars) */
.snow-wrapper,
.snow-cap,
.snow-drip,
#star-canvas,
#snowflake-container {
    pointer-events: none !important;
}

.diff-btn,
.new-game-btn,
.num-btn,
.icon-btn,
.difficulty-badge {
    pointer-events: auto !important;
    position: relative;
    z-index: 1001 !important;
}

/* ===================== BASE STYLES ===================== */
body {
    margin: 0 !important;
    padding: 0 !important;
    background-color: var(--body-bg-color, #0B1020) !important;
    background-image: var(--body-bg-image) !important;
    color: var(--text-color, #ffffff) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    overflow: hidden !important;
    user-select: none !important;
    height: 100dvh !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    gap: 10px;
}

/* ===================== HEADER ===================== */
.game-header {
    flex-shrink: 0;
    /* Reset global header styles from _header.css */
    position: static !important;
    transform: none !important;
    left: auto !important;
    margin-top: 0 !important;
    width: auto !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 10px 0 !important;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.back-btn {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.2s;
}

.back-btn:hover {
    opacity: 1;
}

.game-title {
    margin: 0 !important;
    font-size: 1.4rem !important;
    font-weight: 800 !important;
    letter-spacing: 3px !important;
    background: linear-gradient(135deg, #fff, var(--primary, #bc8cf2)) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.icon-btn {
    background: var(--btn-bg, #1a1a2e);
    border: none;
    color: var(--text-color);
    font-size: 1.1rem;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--btn-hover, #2a2a3e);
    transform: rotate(45deg);
}

.game-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none !important;
    padding: 8px 0;
    font-size: 0.85rem;
    border: none !important;
    flex-wrap: wrap;
    gap: 8px;
}

.timer,
.mistakes,
.score {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.timer i,
.mistakes i {
    color: var(--primary, #bc8cf2);
}

/* ===================== GAME BOARD ===================== */
.game-board-container {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    /* Reset global main styles */
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    max-width: none;
    /* Will be refined in media queries */
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background-color: var(--grid-border);
    border: 2px solid var(--grid-border);
    aspect-ratio: 1/1;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
}

.cell {
    background-color: var(--cell-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1rem, 5vmin, 2.5rem);
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: all 0.15s ease;
    color: var(--text-color, #ffffff);
}

/* Thicker borders for 3x3 blocks */
.cell:nth-child(3n) {
    border-right: 2px solid var(--grid-border);
}

.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(--grid-border);
}

/* Cell States */
.cell.selected {
    background-color: var(--cell-bg-selected) !important;
    color: var(--primary, #bc8cf2);
    box-shadow: inset 0 0 0 2px var(--primary, #bc8cf2);
    z-index: 5;
}

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

.cell.same-number {
    background-color: rgba(188, 140, 242, 0.15);
    color: var(--primary, #bc8cf2);
}

.cell.initial {
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* ===================== CONTROLS / NUMPAD ===================== */
.controls-area {
    flex-shrink: 0;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.num-btn {
    background: var(--btn-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    aspect-ratio: 1/1;
    border-radius: 10px;
    font-size: clamp(1rem, 4vmin, 1.8rem);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.num-btn:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
    border-color: var(--primary, #bc8cf2);
}

.num-btn:active {
    transform: translateY(1px);
}

.num-btn i {
    font-size: 0.9em;
}

.num-btn.active,
.num-btn.notes-active {
    background: var(--primary, #bc8cf2);
    color: #000;
    border-color: var(--primary, #bc8cf2);
}

.num-btn.notes-active {
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.num-btn .remaining-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.55em;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1;
}

.num-btn {
    position: relative;
}

.new-game-btn {
    background: var(--accent-color);
    color: #000;
    padding: 12px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(188, 140, 242, 0.3);
    border: none;
    margin-top: 10px;
}

.new-game-btn:hover {
    background: var(--secondary, #9d5ce5);
    transform: translateY(-2px);
}

/* ===================== MODALS ===================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999 !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(10px);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto !important;
}

.modal-content {
    background: rgba(30, 30, 38, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 30px;
    border-radius: 24px;
    text-align: center;
    width: 90%;
    max-width: 420px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    pointer-events: auto !important;
    position: relative;
    z-index: 10000 !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content.large-modal {
    max-width: 550px;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary, #bc8cf2);
    font-weight: 800;
}

.modal-content * {
    pointer-events: auto !important;
}

.difficulty-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 18px 0;
    position: relative;
    z-index: 10001 !important;
}

.diff-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer !important;
    font-weight: 600;
    transition: all 0.2s;
    position: relative;
    z-index: 10002 !important;
    pointer-events: auto !important;
}

.diff-btn:hover {
    background: rgba(188, 140, 242, 0.1);
    border-color: var(--primary, #bc8cf2);
    color: var(--primary, #bc8cf2);
}

.diff-btn.active {
    background: var(--primary, #bc8cf2);
    color: #000;
    border-color: var(--primary, #bc8cf2);
}

.close-modal-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer !important;
    text-decoration: underline;
    font-size: 0.9rem;
    pointer-events: auto !important;
    position: relative;
    z-index: 10002 !important;
}

/* ===================== LEADERBOARD ===================== */
.leaderboard-list {
    margin-top: 15px;
}

.leaderboard-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.leaderboard-rank {
    font-weight: 800;
    color: var(--primary, #bc8cf2);
    width: 28px;
}

.leaderboard-name {
    font-weight: 600;
    color: #fff;
}

.leaderboard-score {
    font-weight: 800;
    color: #fff;
    text-align: right;
}

.leaderboard-meta {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    display: block;
}

/* ===================== COMPLETED NUMBER BUTTONS ===================== */
.num-btn.completed {
    opacity: 0.2;
    pointer-events: none;
    filter: grayscale(1);
    transform: scale(0.95);
}

/* ===================== SHORTCUT BADGE ===================== */
.num-btn {
    position: relative;
    overflow: visible;
}

.shortcut-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--primary, #bc8cf2);
    color: #000;
    font-size: 0.55rem;
    font-weight: 800;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 10;
}

.num-btn:hover .shortcut-badge {
    opacity: 1;
    transform: scale(1);
}

/* ===================== SHORTCUTS MODAL ===================== */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    gap: 8px;
}

.shortcut-keys {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.shortcut-row span:last-child {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    text-align: right;
}

kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.75rem;
    font-family: monospace;
    color: #fff;
    white-space: nowrap;
}

/* ===================== STATS MODAL ===================== */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.stats-table th {
    color: var(--primary, #bc8cf2);
    font-weight: 700;
    padding: 8px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
    white-space: nowrap;
}

.stats-table td {
    padding: 9px 6px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-diff-label {
    text-align: left !important;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

/* ===================== DAILY MODE ===================== */
.daily-btn {
    background: linear-gradient(135deg, #bc8cf2, #8b44e8) !important;
    border-color: #bc8cf2 !important;
    color: #fff !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 16px rgba(188, 140, 242, 0.35) !important;
}

.daily-btn:hover {
    background: linear-gradient(135deg, #d0aaff, #bc8cf2) !important;
    border-color: #d0aaff !important;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(188, 140, 242, 0.5) !important;
}

.daily-btn.active {
    background: linear-gradient(135deg, #d0aaff, #bc8cf2) !important;
    border-color: #d0aaff !important;
    color: #fff !important;
}

/* Subtle golden accent when playing daily puzzle */
.daily-mode .game-title {
    background: linear-gradient(135deg, #ffd84d, #ffa500) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.daily-mode .cell.selected {
    background-color: rgba(255, 200, 0, 0.2) !important;
    color: #ffc800 !important;
    box-shadow: inset 0 0 0 2px #ffc800 !important;
}

.daily-mode .cell.same-number {
    background-color: rgba(255, 200, 0, 0.1) !important;
    color: #ffc800 !important;
}

/* ===================== UTILITIES ===================== */
.text-accent {
    color: var(--primary, #bc8cf2) !important;
}

/* ===================== ANIMATIONS ===================== */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

/* ===================== ENHANCED ERROR EFFECT ===================== */
.cell.error {
    background-color: rgba(255, 82, 82, 0.25) !important;
    color: var(--cell-error) !important;
    animation: shake 0.4s ease, error-pulse 0.6s ease;
    box-shadow: inset 0 0 0 2px var(--cell-error), 0 0 15px rgba(255, 82, 82, 0.4);
    z-index: 5;
}

.cell.error-number {
    color: var(--cell-error) !important;
    font-weight: 800;
}

@keyframes error-pulse {
    0% {
        box-shadow: inset 0 0 0 2px var(--cell-error), 0 0 0px rgba(255, 82, 82, 0);
    }

    30% {
        box-shadow: inset 0 0 0 2px var(--cell-error), 0 0 20px rgba(255, 82, 82, 0.6);
    }

    100% {
        box-shadow: inset 0 0 0 2px var(--cell-error), 0 0 0px rgba(255, 82, 82, 0);
    }
}

/* ===================== LINE/BOX COMPLETION ANIMATION ===================== */
.cell.line-complete {
    animation: line-glow 0.8s ease var(--delay, 0s) forwards;
}

@keyframes line-glow {
    0% {
        box-shadow: inset 0 0 0 0 rgba(100, 255, 170, 0);
        background-color: var(--cell-bg);
    }

    40% {
        box-shadow: inset 0 0 12px 2px rgba(100, 255, 170, 0.5), 0 0 10px rgba(100, 255, 170, 0.3);
        background-color: rgba(100, 255, 170, 0.12);
    }

    100% {
        box-shadow: inset 0 0 0 0 rgba(100, 255, 170, 0);
        background-color: var(--cell-bg);
    }
}

/* ===================== NOTES FEATURE ===================== */
.notes-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    pointer-events: none !important;
    padding: 2px;
    box-sizing: border-box;
}

.notes-grid * {
    pointer-events: none !important;
}

.notes-grid span {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(0.4rem, 1.5vmin, 0.75rem);
    color: #bc8cf2;
    font-weight: 800;
    line-height: 1;
}

.cell.has-notes .notes-grid {
    opacity: 1;
}

/* =====================================================================
   RESPONSIVE LAYOUTS
   ===================================================================== */

/* ===================== MOBILE (Portrait) ===================== */
/* Default: Column layout - Header, Grid, Numpad stacked */
@media (max-width: 599px) {
    body {
        overflow: auto !important;
    }

    .app-container {
        padding: 8px;
        gap: 8px;
        height: auto;
        min-height: 100dvh;
    }

    .header-top {
        margin-bottom: 3px;
    }

    .game-title {
        font-size: 1.6rem !important;
        margin-bottom: 5px !important;
    }

    .game-info-bar {
        padding: 5px 0;
        font-size: 1rem;
        justify-content: center;
        gap: 15px;
    }

    .game-board-container {
        flex: 0 0 auto;
        width: 100%;
        max-width: calc(100vw - 16px);
        max-height: calc(100vw - 16px);
    }

    .sudoku-grid {
        border-width: 2px;
    }

    .cell {
        font-size: clamp(1rem, 8vw, 1.6rem);
    }

    .controls-area {
        padding: 8px;
    }

    .numpad {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .num-btn {
        font-size: clamp(1.2rem, 6vw, 1.6rem);
        border-radius: 12px;
    }
}

/* ===================== MOBILE (Larger phones / Small tablets) ===================== */
@media (min-width: 600px) and (max-width: 799px) {
    .app-container {
        padding: 12px;
        gap: 12px;
        max-width: 600px;
        margin: 0 auto;
    }

    .game-board-container {
        flex: 0 0 auto;
        width: 100%;
        max-width: min(calc(100vw - 24px), calc(100dvh - 280px));
        max-height: min(calc(100vw - 24px), calc(100dvh - 280px));
    }

    .numpad {
        grid-template-columns: repeat(6, 1fr);
        gap: 10px;
    }

    .num-btn {
        font-size: 1.4rem;
    }
}

/* ===================== TABLET & DESKTOP (≥800px) - 3 Column Layout ===================== */
/* Header LEFT | Grid CENTER | Numpad RIGHT */
@media (min-width: 800px) {
    .app-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 20px;
        gap: 25px;
        max-width: 1400px;
        margin: 0 auto;
    }

    .game-header {
        flex: 0 0 auto !important;
        width: clamp(200px, 20vw, 300px) !important;
        order: 1 !important;
    }

    .header-top {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
        margin-bottom: 15px;
    }

    .game-title {
        font-size: clamp(1.4rem, 2vw, 2.2rem) !important;
    }

    .game-info-bar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px;
        font-size: clamp(0.8rem, 1vw, 1rem);
    }

    .game-board-container {
        order: 2 !important;
        flex: 1 1 auto !important;
        max-width: min(calc(100dvh - 80px), 70vw);
        max-height: calc(100dvh - 80px);
    }

    .sudoku-grid {
        border-width: 3px;
    }

    .cell {
        font-size: clamp(1.2rem, 4vmin, 2.5rem);
    }

    .controls-area {
        order: 3 !important;
        flex: 0 0 auto !important;
        width: clamp(180px, 18vw, 300px) !important;
    }

    .numpad {
        grid-template-columns: repeat(3, 1fr);
        gap: clamp(8px, 1vw, 15px);
    }

    .num-btn {
        font-size: clamp(1.2rem, 2vmin, 2rem);
        border-radius: 14px;
    }
}

/* ===================== LARGER DESKTOP (≥1200px) ===================== */
@media (min-width: 1200px) {
    .app-container {
        gap: 35px;
        padding: 30px;
    }

    .sudoku-grid {
        border-width: 4px;
    }
}

/* ===================== ULTRA-WIDE / 4K (≥1600px) ===================== */
@media (min-width: 1600px) {
    .app-container {
        gap: 50px;
        padding: 40px;
        max-width: 1800px;
    }

    .modal-content {
        max-width: 500px;
        padding: 40px;
    }

    .modal-content.large-modal {
        max-width: 700px;
    }
}

/* ===================== SHORT SCREENS (Landscape phones) ===================== */
@media (max-height: 500px) and (orientation: landscape) {
    .app-container {
        flex-direction: row;
        padding: 10px;
        gap: 15px;
    }

    .game-header {
        display: none;
    }

    .game-board-container {
        flex: 0 0 auto;
        width: calc(100dvh - 30px);
        max-width: calc(100dvh - 30px);
        max-height: calc(100dvh - 30px);
    }

    .controls-area {
        flex: 1 1 auto;
        max-width: 300px;
    }

    .numpad {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .num-btn {
        font-size: 1.2rem;
    }
}

/* ===================== MEDIUM HEIGHT LANDSCAPE ===================== */
@media (min-height: 501px) and (max-height: 700px) and (min-width: 900px) {
    .game-board-container {
        max-width: calc(100dvh - 100px);
        max-height: calc(100dvh - 100px);
    }
}