/* Sudoku page styles with light/dark theme variables */
:root {
    /* Light page theme: page text is dark, board is dark with light numbers for contrast */
    --bg: #1708e67a;
    /* page background */
    --page-text: #000407;
    /* general page text */
    --board-bg: rgba(255, 255, 255, 0.96);
    /* board is light in light theme */
    --board-text: #0b1b26;
    /* numbers/text on board are dark */
    --muted: rgba(11, 27, 38, 0.7);
    --card-border: rgba(11, 27, 38, 0.06);
    --cell-focus: rgba(0, 229, 255, 0.12);
    --grid-line: rgba(0, 0, 0, 0.9);
    --header-color: var(--page-text);
}

.theme-dark {
    /* Dark page theme: page text is light, board is light with dark numbers for contrast */
    --bg: #1667e0;
    /* page background */
    --page-text: rgba(255, 255, 255, 0.95);
    /* general page text */
    --board-bg: rgba(255, 255, 255, 0.92);
    /* board is light in dark theme */
    --board-text: #0b1b26;
    /* numbers/text on board are dark */
    --muted: rgba(255, 255, 255, 0.78);
    --card-border: rgba(255, 255, 255, 0.06);
    --cell-focus: rgba(0, 229, 255, 0.06);
    --grid-line: rgba(0, 0, 0, 0.18);
    --header-color: var(--page-text);
}

/* GameHub navigation in top-left corner */
.gamehub-nav {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
}

.gamehub-link {
    display: inline-block;
    padding: 8px 12px;
    background: var(--board-bg);
    color: var(--board-text);
    text-decoration: none;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gamehub-link:hover {
    background: var(--cell-focus);
    transform: translateY(-2px);
}

.sudoku-app {
    max-width: 1100px;
    margin: 12px auto;
    padding: 12px 12px;
    color: var(--page-text);
    display: flex;
    flex-direction: column
}

.sudoku-menu {
    position: fixed;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    z-index: 99;
    background: var(--board-bg);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--card-border);
}

.sudoku-title-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px
}

.sudoku-title {
    font-size: 2rem;
    margin: 0;
    color: var(--header-color)
}

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

.controls button {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    background: var(--board-bg);
    color: var(--board-text);
    cursor: pointer;
    transition: all 0.3s ease;
}

.controls button:hover {
    background: var(--cell-focus);
}

.settings-dropdown {
    position: relative;
}

.settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--board-bg);
    color: #ffffff;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: var(--cell-focus);
    color: #ffffff;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--board-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 8px 0;
    min-width: 150px;
    z-index: 101;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dropdown-menu.active {
    display: flex;
    flex-direction: column;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
}

.settings-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--board-text);
}

.settings-group select {
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid var(--card-border);
    background: var(--board-bg);
    color: var(--board-text);
    cursor: pointer;
}

.dropdown-item {
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--board-text);
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: var(--cell-focus);
}

.sudoku-board-wrap {
    position: relative;
    margin-top: 5px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center
}

.sudoku-board {
    width: min(90vw, 720px);
    height: auto;
    aspect-ratio: 1/1;
    max-width: 720px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 0;
    border-radius: 2px;
    overflow: hidden;
    border: 3px solid var(--card-border);
    /* box-shadow: 0 22px 50px rgba(2, 6, 23, 0.12); */
    backdrop-filter: blur(6px);
    position: relative;
    background: var(--board-bg);
    max-height: calc(100vh - 180px);
    z-index: 1
}

/* decorative tilted Sudoku SVG behind the board */
.sudoku-board-wrap::before {
    display: none
}

.sudoku-board .cell {
    position: relative;
    border: 1px solid var(--grid-line, rgba(192, 168, 168, 0.9));
    box-sizing: border-box;
    background: var(--cell-bg, #ffffff);
}

.sudoku-board input {
    width: 100%;
    height: 100%;
    font-size: 20px;
    font-weight: 700;
    color: var(--board-text);
    border: 0;
    background: transparent;
    text-align: center;
    outline: none
}

.sudoku-board .cell:nth-child(3n) {
    border-right: 2px solid var(--grid-line, rgba(0, 0, 0, 0.9))
}

.sudoku-board .cell:nth-child(n+19):nth-child(-n+27),
.sudoku-board .cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--grid-line, rgba(0, 0, 0, 0.9))
}

.sudoku-board .cell .given {
    pointer-events: none;
    color: var(--board-text);
}

.sudoku-board .cell input:focus {
    background: var(--cell-focus);
    box-shadow: inset 0 0 0 2px var(--cell-focus)
}

.ripple-overlay {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    pointer-events: none;
    z-index: 4
}

.ripple-effect {
    animation: rippleAnim 800ms ease-out forwards
}

@keyframes rippleAnim {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.25), inset 0 0 0 0 rgba(0, 229, 255, 0.1)
    }

    50% {
        box-shadow: 0 40px 120px 20px rgba(0, 229, 255, 0.06), inset 0 0 0 8px rgba(0, 229, 255, 0.06);
        opacity: 1
    }

    100% {
        box-shadow: 0 120px 220px 40px rgba(0, 229, 255, 0.02);
        opacity: 0
    }
}

.sudoku-footer {
    margin-top: 18px;
    text-align: center;
    color: var(--muted)
}

/* Number palette styles */
.sudoku-palette-wrap {
    display: flex;
    justify-content: center;
    margin-top: 18px;
    margin-bottom: 8px
}

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

.num-btn {
    position: relative;
    min-width: 64px;
    height: 64px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: var(--board-bg);
    color: var(--page-text);
    font-weight: 700;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 6px 10px
}

.num-btn .num {
    z-index: 1
}

.num-btn .count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--board-bg);
    color: var(--board-text);
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06)
}

.num-btn.selected {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.num-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed
}

/* invalid cell highlight + flashing input */
.sudoku-board .cell.invalid{background: rgba(139,0,0,0.18);border-color: rgba(139,0,0,0.45)}
.sudoku-board .cell.invalid input{background: rgba(139,0,0,0.22);color:#fff}

/* thin 3x3 box borders */
.sudoku-board .thick-right {
    border-right: 3px solid var(--card-border)
}

.sudoku-board .thick-bottom {
    border-bottom: 3px solid var(--card-border)
}

/* responsive */
@media (max-width:520px) {
    .sudoku-board {
        width: 92vw;
        height: auto;
        aspect-ratio: 1/1;
        max-height: calc(100vh - 140px)
    }

    .sudoku-app {
        margin: 8px auto;
        padding: 8px
    }
}

/* Ensure page doesn't cause overflow on small devices */
html,
body {
    height: 98%;
    margin: 0;
    padding: 0
}

/* Use the decorative SVG as the page background with a color fallback */
body {
    min-height: 98vh;
    /* base color from theme, then layered colored radial gradients for ambience */
    background-color: var(--bg);
    background-image: radial-gradient(400px 300px at 8% 18%, rgba(0, 229, 255, 0.10), transparent 25%),
        radial-gradient(500px 360px at 88% 80%, rgba(255, 61, 129, 0.09), transparent 20%),
        radial-gradient(600px 420px at 58% 38%, rgba(120, 86, 255, 0.06), transparent 30%);
    background-repeat: no-repeat;
    background-position: left top, right bottom, center;
    background-size: 40% auto, 45% auto, 70% auto;
    background-blend-mode: screen;
    color: var(--page-text);
}