* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Theme Variables */
:root {
    /* Default - Classic Soft Purple */
    --bg-gradient-start: #f0ebff;
    --bg-gradient-end: #e8e0ff;
    --primary-color: #9f7aea;
    --secondary-color: #b794f6;
    --text-color: #5a4a7a;
    --board-bg: rgba(255, 255, 255, 0.98);
    --cell-bg: #ffffff;
    --cell-border: #d4c8f0;
    --cell-hover: #f5f0ff;
    --cell-selected: #ebe5f7;
    --panel-bg-start: #f5f0ff;
    --panel-bg-end: #ebe5f7;
    --info-bg-start: #f5f0ff;
    --info-bg-end: #ebe5f7;
}

body[data-theme="dark"] {
    --bg-gradient-start: #2d2d2d;
    --bg-gradient-end: #1f1f1f;
    --primary-color: #ffffff;
    --secondary-color: #ffffff;
    --text-color: #ffffff;
    --board-bg: rgba(45, 45, 45, 0.95);
    --cell-bg: #3a3a3a;
    --cell-border: #505050;
    --cell-hover: #454545;
    --cell-selected: #555555;
    --panel-bg-start: #3a3a3a;
    --panel-bg-end: #2d2d2d;
    --info-bg-start: #3a3a3a;
    --info-bg-end: #2d2d2d;
}

body[data-theme="space"] {
    --bg-gradient-start: #2a1810;
    --bg-gradient-end: #3d2415;
    --primary-color: #d4843f;
    --secondary-color: #e8a764;
    --text-color: #f0e0d0;
    --board-bg: rgba(42, 24, 16, 0.92);
    --cell-bg: #3d2a1f;
    --cell-border: #5c3d28;
    --cell-hover: #4d3525;
    --cell-selected: #6d4e38;
    --panel-bg-start: #3d2a1f;
    --panel-bg-end: #2a1810;
    --info-bg-start: #3d2a1f;
    --info-bg-end: #2a1810;
}

body[data-theme="minimalist"] {
    --bg-gradient-start: #f5f0e6;
    --bg-gradient-end: #e8dcc8;
    --primary-color: #8b7355;
    --secondary-color: #a0826d;
    --text-color: #5d4e3a;
    --board-bg: rgba(250, 245, 235, 0.95);
    --cell-bg: #faf5eb;
    --cell-border: #d4c4a8;
    --cell-hover: #f0e8d8;
    --cell-selected: #e8dcc8;
    --panel-bg-start: #f5f0e6;
    --panel-bg-end: #e8dcc8;
    --info-bg-start: #f5f0e6;
    --info-bg-end: #e8dcc8;
}

body[data-theme="eye-rest"] {
    --bg-gradient-start: #c4b5a0;
    --bg-gradient-end: #9d8b73;
    --primary-color: #6b5d4f;
    --secondary-color: #8b7355;
    --text-color: #3d3427;
    --board-bg: rgba(245, 240, 230, 0.98);
    --cell-bg: #f5f0e8;
    --cell-border: #d4c4b0;
    --cell-hover: #ebe0d0;
    --cell-selected: #dccfbb;
    --panel-bg-start: #f5f0e8;
    --panel-bg-end: #ebe0d0;
    --info-bg-start: #f5f0e8;
    --info-bg-end: #ebe0d0;
    filter: sepia(0.15) saturate(0.85);
}

body[data-theme="ocean"] {
    --bg-gradient-start: #4a6fa5;
    --bg-gradient-end: #2c5282;
    --primary-color: #1a365d;
    --secondary-color: #2b6cb0;
    --text-color: #1a365d;
    --board-bg: rgba(74, 111, 165, 0.92);
    --cell-bg: #5a7faf;
    --cell-border: #3d5a80;
    --cell-hover: #6b8fc0;
    --cell-selected: #7b9fd0;
    --panel-bg-start: #5a7faf;
    --panel-bg-end: #4a6fa5;
    --info-bg-start: #5a7faf;
    --info-bg-end: #4a6fa5;
}

body[data-theme="forest"] {
    --bg-gradient-start: #3d7a1c;
    --bg-gradient-end: #2d5a14;
    --primary-color: #1a3a0c;
    --secondary-color: #4a8c2c;
    --text-color: #c8e8b8;
    --board-bg: rgba(61, 122, 28, 0.92);
    --cell-bg: #4a8a24;
    --cell-border: #2d5a14;
    --cell-hover: #5a9a34;
    --cell-selected: #6aaa44;
    --panel-bg-start: #4a8a24;
    --panel-bg-end: #3d7a1c;
    --info-bg-start: #4a8a24;
    --info-bg-end: #3d7a1c;
}

body[data-theme="sunset"] {
    --bg-gradient-start: #d4856a;
    --bg-gradient-end: #c47058;
    --primary-color: #8b4a3a;
    --secondary-color: #e8a080;
    --text-color: #f5e8e0;
    --board-bg: rgba(212, 133, 106, 0.92);
    --cell-bg: #d8907a;
    --cell-border: #b46858;
    --cell-hover: #e0a090;
    --cell-selected: #e8b0a0;
    --panel-bg-start: #d8907a;
    --panel-bg-end: #d4856a;
    --info-bg-start: #d8907a;
    --info-bg-end: #d4856a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s ease;
    position: relative;
}

/* Theme Background Images */
body[data-theme="dark"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('themes/darkmode.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 0.85;
}

body[data-theme="space"] {
    background: none;
}

body[data-theme="space"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('themes/mars.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
}

body[data-theme="minimalist"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('themes/minimalist.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 0.9;
}

body[data-theme="ocean"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('themes/ocean-breeze.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 0.85;
}

body[data-theme="forest"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('themes/forest.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 0.85;
}

body[data-theme="sunset"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('themes/sunset.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 0.85;
}

/* Main Menu Styles */
.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

/* Default theme gradient background for main menu */
body[data-theme="default"] .main-menu {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
}

.main-menu.hidden {
    display: none;
}

.main-menu-content {
    background: var(--board-bg);
    border-radius: 24px;
    padding: 40px 30px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-logo {
    max-width: 450px;
    width: 100%;
    height: auto;
    margin-bottom: 5px;
}

.game-subtitle {
    font-size: 1.1rem;
    color: #8B5A2B;
    font-weight: 600;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.main-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.main-menu-btn {
    width: 100%;
    padding: 16px 24px;
    background: var(--secondary-color);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.main-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.main-menu-btn.secondary-btn {
    background: var(--cell-bg);
    color: var(--primary-color);
    border: 2px solid var(--secondary-color);
}

.main-menu-btn.secondary-btn:hover {
    background: var(--cell-hover);
}

.menu-btn-icon {
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    flex-shrink: 0;
}

.menu-btn-icon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.menu-btn-text {
    font-size: 1.1rem;
    line-height: 1;
    text-align: left;
    width: 120px;
    flex-shrink: 0;
}

.main-menu-section {
    margin: 12px 0;
    text-align: left;
}

.main-menu-label {
    display: block;
    color: var(--text-color);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 10px;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.difficulty-btn {
    padding: 12px 16px;
    background: var(--cell-bg);
    border: 2px solid var(--cell-border);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-btn:hover {
    background: var(--cell-hover);
    border-color: var(--secondary-color);
}

.difficulty-btn.active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.main-menu-dropdown {
    width: 100%;
    padding: 12px;
    padding-right: 36px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--primary-color);
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.main-menu-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(159, 122, 234, 0.2);
}

/* Dark theme overrides for main menu */
body[data-theme="dark"] .main-menu-btn.start-game-btn {
    background: #1a1a1a;
    color: white;
}

body[data-theme="dark"] .difficulty-btn {
    background: #1a1a1a;
    border-color: #333333;
    color: white;
}

body[data-theme="dark"] .difficulty-btn.active {
    background: #1a1a1a;
    border-color: white;
    color: white;
}

/* Responsive Main Menu */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }

    .game-logo {
        max-width: 240px;
    }

    .game-subtitle {
        font-size: 0.9rem;
        margin-bottom: 15px;
    }

    .main-menu-content {
        padding: 30px 20px;
        /* iOS safe area: Add extra padding at top for notch/Dynamic Island */
        padding-top: max(30px, calc(30px + env(safe-area-inset-top, 0px)));
    }

    .main-menu-btn {
        padding: 14px 20px;
        font-size: 1rem;
    }

    .menu-btn-icon {
        font-size: 1.2rem;
    }

    .menu-btn-text {
        font-size: 1rem;
    }
}

.game-layout {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--board-bg);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    padding: 30px;
    transition: background 0.3s ease;
}

/* Hide game layout when main menu is visible */
.main-menu:not(.hidden) ~ .game-layout {
    display: none;
}
 
.game-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 4px solid var(--primary-color);
    width: min(1050px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.game-header-logo {
    max-width: 180px;
    height: auto;
}

.svg {
    margin-right: 8px;
}

h1 {
    color: var(--primary-color);
    font-size: 2.0rem;
    font-weight: 500;
    letter-spacing: 2px;
    transition: color 0.3s ease;
}

.icon-btn {
    width: 50px;
    height: 50px;
    font-size: 16px;
    padding: 0;
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-btn svg {
    display: block;
    margin: 0 auto;
}

.icon-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(159, 122, 234, 0.4);
}

.icon-btn:active {
    transform: translateY(0);
}

/* Notes button active state */
.notes-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(159, 122, 234, 0.3);
}

.notes-btn.active:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* Erase button active state */
.erase-notes-btn.active {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3);
}

.erase-notes-btn.active:hover {
    background: #c0392b;
    border-color: #c0392b;
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
    /* Match the width of board (max 600px) + gap (30px) + dog panel (280px) */
    width: min(1050px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.right-controls-group {
    display: flex;
    align-items: center;
    gap: 20px; /* Space between timer group and pause */
}

.timer-control-group {
    display: flex;
    align-items: center;
    gap: 12px; /* Space between toggle and time display */
}

.game-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
}

.difficulty-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 600;
}

.difficulty-label {
    color: var(--text-color);
}

.difficulty-value {
    color: var(--secondary-color);
    font-weight: 700;
    text-transform: capitalize;
}

.btn {
    padding: 12px 24px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--primary-color);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-wrap: nowrap;
}

.btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(159, 122, 234, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.new-game-btn {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

.new-game-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-label {
    font-size: 0.95rem;
    color: var(--text-color);
    font-weight: 600;
    transition: color 0.3s ease;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    display: inline-block;
}

.toggle-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 34px;
    border: 2px solid var(--cell-border);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-checkbox:checked + .toggle-slider {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.toggle-checkbox:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch:hover .toggle-slider {
    box-shadow: 0 0 8px rgba(159, 122, 234, 0.4);
}

/* Restart toggle button styling */
.toggle-btn {
    width: 50px;
    height: 26px;
    border-radius: 34px;
    border: 2px solid var(--cell-border);
    background-color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.toggle-btn:hover {
    box-shadow: 0 0 8px rgba(159, 122, 234, 0.4);
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.toggle-btn svg {
    color: white;
    transition: transform 0.3s ease;
}

.toggle-btn:hover svg {
    transform: rotate(180deg);
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 25px;
    /* padding: 15px; */
    background: linear-gradient(135deg, var(--info-bg-start) 0%, var(--info-bg-end) 100%);
    border-radius: 12px;
    transition: background 0.3s ease;
}

.game-info > div {
    display: flex;
    gap: 10px;
    align-items: center;
}

.game-info .label {
    font-weight: 600;
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.mistakes-icon {
    color: var(--primary-color);
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.mistakes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 50px;
    height: 50px;
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.time-display {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--secondary-color);
    min-width: 55px; /* Reserve space for "99:99" */
    text-align: left;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.time-display.hidden {
    visibility: hidden; /* Maintains space but invisible */
}

.mistakes-count {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary-color);
    transition: color 0.3s ease;
}

.main-content {
    display: flex;
    gap: 30px;
    margin-bottom: 25px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    align-items: flex-start;
    justify-content: center;
}

.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin-top: 0;
    flex-shrink: 0;
}

.board-controls {
    display: none;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

.control-with-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.control-label {
    font-size: 0.65rem;
    color: var(--text-color);
    opacity: 0.5;
    text-transform: capitalize;
    letter-spacing: 0.3px;
    font-weight: 500;
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    width: 100%;
    max-width: 620px;
    aspect-ratio: 1;
    border: 4px solid var(--primary-color);
    overflow: hidden;
    background: var(--cell-bg);
    box-shadow: 0 10px 40px rgba(118, 75, 162, 0.2);
    position: relative;
    transition: all 0.3s ease;
}

.cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cell-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--cell-border);
    position: relative;
    padding: 2px;
    overflow: hidden;
}

.cell-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
    background: var(--cell-bg);
    transition: background 0.3s ease;
}

.cell:nth-child(3n):not(:nth-child(9n)) {
    border-right: 4px solid var(--primary-color);
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 4px solid var(--primary-color);
}

.cell.alt-block {
    background: var(--cell-bg);
}

.cell:hover:not(.given) {
    background: var(--cell-hover);
    transform: scale(1.05);
    z-index: 10;
}

.cell.selected {
    background: var(--cell-selected) !important;
    box-shadow: inset 0 0 0 3px var(--secondary-color);
}

.cell.given {
    cursor: default !important;
    pointer-events: none;
}

.cell.locked {
    cursor: default !important;
    pointer-events: none;
}

.cell.sleep-cell {
    cursor: default;
    pointer-events: none;
}

.cell.error {
    background: #ff4444 !important;
}

.cell.error-shake {
    animation: shake 0.3s ease;
}

.cell.correct {
    animation: correctPulse 0.5s ease, correctGlow 0.6s ease;
}

.cell.success-glow {
    animation: successGlow 0.6s ease;
}

.cell.hint-highlight {
    background: rgba(255, 215, 0, 0.5) !important;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.8), inset 0 0 8px rgba(255, 215, 0, 0.4);
    animation: hintPulse 1.5s ease-in-out infinite;
    z-index: 10;
}

@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.8), inset 0 0 8px rgba(255, 215, 0, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 1), inset 0 0 12px rgba(255, 215, 0, 0.6);
    }
}

/* Hint reasoning highlights - show why dogs are eliminated */
.cell.hint-reason-row {
    box-shadow: inset 0 0 0 2px rgba(66, 153, 225, 0.7);
}

.cell.hint-reason-col {
    box-shadow: inset 0 0 0 2px rgba(72, 187, 120, 0.7);
}

.cell.hint-reason-box {
    box-shadow: inset 0 0 0 2px rgba(237, 137, 54, 0.7);
}

/* Combined highlights when cell is in multiple groups */
.cell.hint-reason-row.hint-reason-box {
    box-shadow: inset 0 0 0 2px rgba(66, 153, 225, 0.5), inset 0 0 0 4px rgba(237, 137, 54, 0.5);
}

.cell.hint-reason-col.hint-reason-box {
    box-shadow: inset 0 0 0 2px rgba(72, 187, 120, 0.5), inset 0 0 0 4px rgba(237, 137, 54, 0.5);
}

/* Preview of possible dogs in hint cell */
.hint-dogs-preview {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 2px;
    padding: 2px;
    z-index: 15;
    max-width: 90%;
    max-height: 90%;
}

.hint-dog-option {
    width: 30%;
    height: auto;
    max-width: 28px;
    max-height: 28px;
    object-fit: contain;
    border-radius: 4px;
    opacity: 0.9;
    animation: hintDogBounce 0.8s ease-in-out infinite;
}

.hint-dog-option:nth-child(2) {
    animation-delay: 0.2s;
}

.hint-dog-option:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes hintDogBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Highlight possible dogs in the dog panel */
.dog-item.hint-possible-dog {
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.8) !important;
    animation: hintDogPanelPulse 1s ease-in-out infinite;
}

@keyframes hintDogPanelPulse {
    0%, 100% {
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 18px rgba(255, 215, 0, 1), 0 0 28px rgba(255, 215, 0, 0.7);
    }
}

.cell.hint-reveal {
    animation: hintReveal 1.5s ease;
}

@keyframes hintReveal {
    0% {
        background: var(--cell-bg);
        transform: scale(1);
    }
    20% {
        background: rgba(255, 215, 0, 0.6);
        transform: scale(1.08);
    }
    50% {
        background: rgba(255, 215, 0, 0.4);
        transform: scale(1.04);
    }
    100% {
        background: var(--cell-bg);
        transform: scale(1);
    }
}

/* Notes display in cells */
.cell-notes {
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    pointer-events: none;
    z-index: 1;
}

.note-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.6;
    filter: grayscale(20%);
}

.star {
    position: absolute;
    font-size: 12px;
    pointer-events: none;
    animation: starFloat 1s ease-out forwards;
}

.desktop-icon-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: 24px;
}

.board-controls-compact {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
}

@keyframes starFloat {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0);
    }
    50% {
        opacity: 1;
        transform: translate(var(--tx), var(--ty)) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), calc(var(--ty) - 20px)) scale(0.5);
    }
}

@keyframes correctPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes correctGlow {
    0% {
        background-color: rgba(46, 204, 113, 0.6);
        box-shadow: 0 0 15px rgba(46, 204, 113, 0.8);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

@keyframes successGlow {
    0% {
        background-color: rgba(46, 204, 113, 0.6);
        box-shadow: 0 0 15px rgba(46, 204, 113, 0.8);
    }
    50% {
        background-color: rgba(46, 204, 113, 0.8);
        box-shadow: 0 0 20px rgba(46, 204, 113, 1);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

/* Note conflict pulse - shows when trying to add invalid note */
.cell.note-conflict-pulse {
    animation: noteConflictPulse 1.5s ease;
}

@keyframes noteConflictPulse {
    0%, 100% {
        background-color: transparent;
        box-shadow: none;
        transform: scale(1);
    }
    15% {
        background-color: rgba(255, 50, 50, 0.7);
        box-shadow: 0 0 25px rgba(255, 50, 50, 1), 0 0 50px rgba(255, 50, 50, 0.5);
        transform: scale(1.15);
    }
    30% {
        background-color: rgba(255, 50, 50, 0.5);
        box-shadow: 0 0 20px rgba(255, 50, 50, 0.8);
        transform: scale(1.1);
    }
    50% {
        background-color: rgba(255, 50, 50, 0.8);
        box-shadow: 0 0 30px rgba(255, 50, 50, 1), 0 0 60px rgba(255, 50, 50, 0.6);
        transform: scale(1.2);
    }
    65% {
        background-color: rgba(255, 50, 50, 0.5);
        box-shadow: 0 0 20px rgba(255, 50, 50, 0.8);
        transform: scale(1.1);
    }
    80% {
        background-color: rgba(255, 50, 50, 0.7);
        box-shadow: 0 0 25px rgba(255, 50, 50, 1);
        transform: scale(1.15);
    }
}

.cell.drag-over {
    background: var(--cell-selected) !important;
    transform: scale(1.1);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Conflict hint animations for Easy mode */
.cell.hint-highlight {
    background-color: rgba(255, 200, 0, 0.4) !important;
    animation: hintFade 2s ease-in-out forwards;
}

.cell.hint-conflict {
    background-color: rgba(255, 100, 100, 0.6) !important;
    animation: hintConflictPulse 2s ease-in-out forwards;
    z-index: 10;
}

@keyframes hintFade {
    0% {
        background-color: rgba(255, 200, 0, 0.5);
    }
    100% {
        background-color: transparent;
    }
}

@keyframes hintConflictPulse {
    0%, 100% {
        background-color: rgba(255, 100, 100, 0.7);
        transform: scale(1);
    }
    25% {
        background-color: rgba(255, 100, 100, 0.9);
        transform: scale(1.08);
    }
    50% {
        background-color: rgba(255, 100, 100, 0.7);
        transform: scale(1);
    }
    75% {
        background-color: rgba(255, 100, 100, 0.5);
        transform: scale(1);
    }
}

.dog-panel {
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    /* border-radius: 16px; */
    padding: 15px;
    width: 400px;
    min-height: 620px;
    border: 4px solid var(--primary-color);
    box-shadow: 0 10px 30px rgba(159, 122, 234, 0.2);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    margin-bottom: 16px;
}

.panel-title {
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    text-align: center;
    transition: color 0.3s ease;
}

.dog-list {
    display: grid;
    grid-template-columns: repeat(3, 84px);
    gap: 20px;
    justify-content: center;
}

.dog-item {
    background: var(--cell-bg);
    border-radius: 0px;
    padding: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    border: 2px solid var(--cell-border);
    width: 85px;
    height: 85px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.dog-item:hover:not(.completed) {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(159, 122, 234, 0.3);
    border-color: var(--secondary-color);
}

.dog-item:active {
    cursor: grabbing;
}

.dog-item.completed {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #48bb78;
}

.dog-item.selected {
    background: var(--cell-selected) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px var(--secondary-color), 0 8px 25px rgba(159, 122, 234, 0.5) !important;
    transform: scale(1.1) !important;
    z-index: 10;
}

.dog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    min-height: 16px;
    width: 100%;
}

.dog-name {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.65rem;
    line-height: 1;
    flex: 1;
    text-align: center;
    transition: color 0.3s ease;
}

.dog-item .checkmark {
    font-size: 0.9rem;
    color: #48bb78;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dog-item.completed .checkmark {
    opacity: 1;
}

.dog-item img {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    display: block;
}

.message {
    text-align: center;
    padding: 15px;
    border-radius: 12px;
    font-weight: 600;
    margin-top: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message.show {
    opacity: 1;
}

.message.success {
    background: #c6f6d5;
    color: #22543d;
    border: 2px solid #48bb78;
}

.message.error {
    background: #fed7d7;
    color: #742a2a;
    border: 2px solid #f56565;
}

.achievement-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(118, 75, 162, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
    cursor: pointer;
}

.achievement-overlay.show {
    display: flex;
}

.achievement-content {
    position: relative;
    text-align: center;
    padding: 50px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 15px 60px rgba(0, 0, 0, 0.4);
    animation: bounceIn 0.6s ease-out;
    border: 4px solid #9f7aea;
}

.achievement-icon {
    font-size: 6rem;
    margin-bottom: 20px;
    animation: rotate 0.8s ease-in-out;
}

.achievement-text {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.achievement-text::after {
    content: 'Click anywhere to close';
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: white;
    margin-top: 15px;
    opacity: 0.9;
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 40px;
    height: 40px;
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    filter: blur(1px);
    animation: confettiFall 5s ease-in forwards;
    pointer-events: none;
}

.firework {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

.firework-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: fireworkExpand 1.5s ease-out forwards;
}

@keyframes fireworkExpand {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(
            calc(cos(var(--angle)) * 150px),
            calc(sin(var(--angle)) * 150px)
        ) scale(0);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes rotate {
    0% { transform: rotate(0deg) scale(0.5); }
    50% { transform: rotate(180deg) scale(1.3); }
    100% { transform: rotate(360deg) scale(1); }
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.bouncing-dog {
    position: fixed;
    top: -100px;
    z-index: 9999;
    pointer-events: none;
    animation: bounceDog 4s ease-in forwards;
}

@keyframes bounceDog {
    0% {
        top: -100px;
        transform: translateX(0) rotate(0deg);
    }
    10% {
        top: 30%;
    }
    20% {
        top: 35%;
    }
    30% {
        top: 50%;
    }
    40% {
        top: 52%;
    }
    50% {
        top: 65%;
    }
    60% {
        top: 66%;
    }
    70% {
        top: 75%;
    }
    80% {
        top: 75.5%;
    }
    90% {
        top: 82%;
    }
    95% {
        top: 82.2%;
    }
    100% {
        top: 100%;
        transform: translateX(calc(var(--vx) * 100px)) rotate(var(--rotation));
        opacity: 0;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .dog-panel {
        width: 100%;
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .sudoku-board {
        max-width: 500px;
    }

    .dog-panel {
        max-width: 350px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
}

@media (max-width: 600px) {
    .game-layout {
        padding: 15px;
    }

    h1 {
        font-size: 1.6rem;
    }

    .difficulty {
        width: 100%;
        justify-content: center;
    }

    .game-info {
        flex-direction: column;
        gap: 10px;
    }
}

/* How to Play Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    position: relative;
    background: var(--board-bg);
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: bounceIn 0.5s ease-out;
    border: 3px solid var(--secondary-color);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--primary-color);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--cell-hover);
    transform: rotate(90deg);
}

.modal-title {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 20px;
    text-align: center;
    transition: color 0.3s ease;
}

.modal-body {
    color: var(--text-color);
    line-height: 1.8;
}

.modal-subtitle {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 20px;
    text-align: center;
    transition: color 0.3s ease;
}

.modal-instructions {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.modal-instructions li {
    padding: 10px 0;
    padding-left: 30px;
    position: relative;
    font-size: 1rem;
    color: var(--text-color);
    transition: color 0.3s ease;
}

.modal-instructions li:before {
    content: "🐾";
    position: absolute;
    left: 0;
    font-size: 1.2rem;
}

.modal-note {
    margin-top: 20px;
    padding: 15px;
    background: var(--cell-bg);
    border-left: 4px solid var(--secondary-color);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.modal-note strong {
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.how-to-play-btn {
    background: var(--cell-bg);
    border-color: var(--secondary-color);
    color: var(--primary-color);
}

.how-to-play-btn:hover {
    background: var(--secondary-color);
    color: white;
}

/* Game Over Modal */
.game-over-content {
    text-align: center;
    padding: 20px;
}

.game-over-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: shake 0.5s ease;
}

.game-over-message {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 30px;
    line-height: 1.6;
}

.game-over-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-over-buttons .btn {
    min-width: 140px;
}

/* Demo Section */
.demo-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--cell-border);
}

.demo-title {
    color: var(--primary-color);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
    transition: color 0.3s ease;
}

.demo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
    background: var(--primary-color);
    border: 3px solid var(--primary-color);
    border-radius: 8px;
    overflow: hidden;
}

.demo-cell {
    background: var(--cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.demo-cell-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}

.demo-cell.demo-correct {
    background: #48bb78 !important;
    animation: correctPulse 0.5s ease;
}

.demo-cell.demo-wrong {
    background: #ff4444 !important;
    animation: shake 0.3s ease;
}

.demo-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.demo-btn {
    padding: 10px 20px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.demo-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(159, 122, 234, 0.3);
}

.demo-btn:active {
    transform: translateY(0);
}

.demo-explanation {
    min-height: 60px;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
}

.demo-explanation.correct {
    background: #c6f6d5;
    color: #22543d;
    border: 2px solid #48bb78;
}

.demo-explanation.wrong {
    background: #fed7d7;
    color: #742a2a;
    border: 2px solid #f56565;
}

/* Leaderboard Styles */
.leaderboard-btn {
    background: var(--cell-bg);
    border-color: var(--secondary-color);
    color: var(--primary-color);
}

.leaderboard-btn:hover {
    background: var(--secondary-color);
    color: white;
}

.leaderboard-content {
    max-width: 600px;
}

.difficulty-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.tab-btn {
    padding: 10px 20px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: var(--cell-hover);
}

.tab-btn.active {
    background: var(--secondary-color);
    color: white;
}

.leaderboard-list {
    max-height: 400px;
    overflow-y: auto;
}

.no-scores {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 40px 1fr 70px 50px;
    gap: 10px;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--cell-bg);
    border-radius: 8px;
    border: 2px solid var(--cell-border);
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    border-color: var(--secondary-color);
    transform: translateX(5px);
}

.leaderboard-item.top-3 {
    border-color: var(--secondary-color);
    background: linear-gradient(135deg, var(--panel-bg-start), var(--panel-bg-end));
}

.leaderboard-item .rank {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary-color);
    text-align: center;
}

.leaderboard-item .player-name {
    font-weight: 600;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-item .score-time {
    font-size: 0.9rem;
    color: var(--text-color);
    text-align: right;
}

.leaderboard-item .score-mistakes {
    font-size: 0.75rem;
    color: var(--text-color);
    text-align: center;
    opacity: 0.6;
}

.leaderboard-item .score-mistakes .mistake-icon {
    font-size: 0.5rem;
    opacity: 0.5;
}

.leaderboard-item .score-hints {
    font-size: 0.75rem;
    color: var(--text-color);
    text-align: center;
    opacity: 0.6;
}

.leaderboard-item .score-hints .hint-icon {
    font-size: 0.5rem;
    opacity: 0.5;
}

.leaderboard-item .total-score {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary-color);
    text-align: right;
}

.leaderboard-rank {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary-color);
    min-width: 40px;
}

.leaderboard-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 15px;
}

.leaderboard-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: var(--text-color);
}

.loading-text {
    text-align: center;
    color: var(--text-color);
    padding: 20px;
}

.empty-leaderboard {
    text-align: center;
    color: var(--text-color);
    padding: 40px 20px;
    font-style: italic;
}

/* Win Modal Styles */
.win-stats {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 20px;
}

.name-input-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.name-input-section label {
    color: var(--text-color);
    font-weight: 600;
    font-size: 1rem;
}

.player-name-input {
    padding: 12px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--text-color);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.player-name-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(159, 122, 234, 0.2);
}

.player-name-input.shake-highlight {
    animation: shakeHighlight 0.5s ease;
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3);
}

@keyframes shakeHighlight {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.submit-score-btn {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

.submit-score-btn:hover {
    background: var(--primary-color);
}

.submit-score-btn.submitting {
    opacity: 0.6;
    cursor: not-allowed;
}

.submit-score-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.skip-submit-btn {
    background: var(--cell-bg);
    border-color: var(--cell-border);
    color: var(--text-color);
}

.skip-submit-btn:hover {
    background: var(--cell-hover);
}

/* About Us Modal Styles */
.about-us-content {
    max-width: 800px;
    width: 90%;
}

.about-us-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 10px 0;
}

.team-member {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 5px;
}

.member-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    min-height: 42px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.member-name {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin: 0 0 8px 0;
    font-weight: 600;
}

.member-photo-container {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--secondary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.member-photo-container:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.member-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

.member-photo:hover {
    opacity: 1;
}

/* Mobile difficulty selector - hidden on desktop */
.mobile-difficulty {
    display: none;
}

/* Mobile controls row - hidden on desktop */
.mobile-controls-row {
    display: none;
}

/* Mobile mistakes display - hidden on desktop */
.mobile-mistakes {
    display: none;
}

/* Hamburger Menu (Visible on Desktop and Mobile) */
.hamburger-btn {
    display: flex;
    position: absolute;
    z-index: 1000;
    background: var(--primary-color);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: background 0.3s ease;
}

.hamburger-btn:hover {
    background: var(--primary-color);
}

.hamburger-btn span {
    display: block;
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn:active {
    transform: scale(0.95);
}

/* Dark mode hamburger button */
body[data-theme="dark"] .hamburger-btn {
    background: #3a3a3a;
}

body[data-theme="dark"] .hamburger-btn:hover {
    background: #454545;
}

body[data-theme="dark"] .hamburger-btn span {
    background: white;
}

/* Side Menu */
.side-menu {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: var(--board-bg);
    z-index: 2001;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.side-menu.open {
    left: 0;
}

.side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    /* iOS safe area: Account for notch/Dynamic Island */
    padding-top: max(20px, env(safe-area-inset-top, 20px));
    border-bottom: 2px solid var(--cell-border);
}

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

.close-menu-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--primary-color);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-menu-btn:hover {
    background: var(--cell-hover);
}

.side-menu-content {
    flex: 1;
    padding: 20px;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    /* Force GPU acceleration for smooth scrolling */
    will-change: scroll-position;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.menu-item-btn {
    width: 100%;
    height: 48px;
    padding: 15px 20px;
    margin-bottom: 10px;
    background: var(--cell-bg);
    border: 2px solid var(--secondary-color);
    border-radius: 10px;
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.menu-item-btn:hover {
    border-color: var(--secondary-color);
    border-width: 3px;
    transform: translateX(5px);
}

body[data-theme="dark"] .menu-item-btn:hover {
    border-color: white;
    border-width: 3px;
}

.menu-icon {
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-icon svg {
    stroke: currentColor;
}

.menu-icon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.menu-divider {
    height: 2px;
    background: var(--cell-border);
    margin: 20px 0;
}

.menu-theme-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-label {
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
}

.menu-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

/* Select wrapper for custom arrow positioning */
.select-wrapper {
    position: relative;
    width: 100%;
}

.menu-dropdown {
    width: 100%;
    padding: 12px;
    height: 48px;
    padding-right: 36px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.menu-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(159, 122, 234, 0.2);
}

.select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.select-arrow svg {
    stroke: currentColor;
}

/* Custom Dropdown for Favorite Dog */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-selected {
    padding: 12px;
    height: 48px;
    border: 2px solid var(--secondary-color);
    background: var(--cell-bg);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown-selected:hover {
    border-color: var(--primary-color);
}

.dropdown-selected.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(159, 122, 234, 0.2);
}

.dropdown-text {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.dropdown-dog-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--secondary-color);
}

.dropdown-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.dropdown-arrow svg {
    stroke: currentColor;
}

.dropdown-selected.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--cell-bg);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: scroll;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    /* Force GPU acceleration for smooth scrolling */
    will-change: scroll-position;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.dropdown-options.show {
    display: block;
}

.dropdown-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-color);
    font-size: 0.9rem;
}

.dropdown-option:hover {
    background: var(--primary-color);
    color: white;
}

.dropdown-option.selected {
    background: rgba(159, 122, 234, 0.2);
    font-weight: 600;
}

.dropdown-options::-webkit-scrollbar {
    width: 8px;
}

.dropdown-options::-webkit-scrollbar-track {
    background: var(--board-bg);
    border-radius: 4px;
}

.dropdown-options::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

.dropdown-options::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.menu-hint {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin: 4px 0 0 0;
    font-style: italic;
}

/* Menu Overlay */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
}

.menu-overlay.show {
    display: block;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* WEBVIEW COMPATIBLE: No fixed positioning, uses flexbox */
    body {
        padding: 0;
        overflow-x: hidden; /* Prevent horizontal scroll only */
        overflow-y: auto; /* Allow vertical scroll */
        /* Use calculated viewport height from JS */
        min-height: calc(var(--vh, 1vh) * 100);
        min-height: 100dvh;
        min-height: -webkit-fill-available;
    }

    /* Show hamburger menu on mobile */
    .hamburger-btn {
        display: flex;
        /* WEBVIEW FIX: absolute instead of fixed */
        position: absolute;
        top: max(8px, env(safe-area-inset-top, 8px));
        left: max(8px, env(safe-area-inset-left, 8px));
        width: 32px;
        height: 32px;
        z-index: 1000;
    }

    .side-menu {
        display: flex;
    }

    /* Ensure main menu has opaque background on mobile */
    .main-menu {
        background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%) !important;
    }

    .game-layout {
        padding: 5px;
        padding-left: 45px;
        padding-top: 8px;
        /* WEBVIEW FIX: Use modern viewport units with fallbacks */
        min-height: calc(var(--vh, 1vh) * 100);
        min-height: 100dvh;
        min-height: 100svh;
        min-height: -webkit-fill-available;
        overflow-x: hidden; /* Prevent horizontal scroll only */
        overflow-y: auto; /* Allow vertical scroll */
        display: flex;
        flex-direction: column;
        /* Account for safe areas with reduced horizontal padding for more space */
        padding-top: max(8px, env(safe-area-inset-top, 8px));
        padding-left: max(10px, calc(10px + env(safe-area-inset-left, 0px)));
        padding-right: max(10px, calc(10px + env(safe-area-inset-right, 0px)));
        padding-bottom: max(5px, env(safe-area-inset-bottom, 5px));
    }

    .game-header {
        padding-bottom: 0;
        margin-bottom: 5px;
        width: auto;
        border-bottom: none;
    }

    .game-header h1 {
        font-size: 0.9rem;
        margin: 0;
        padding: 0;
        line-height: 35px;
    }

    .game-header-logo {
        max-width: 120px;
        height: auto;
    }

    /* Show controls on mobile - compact horizontal layout */
    .controls-bar {
        display: flex !important;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 5px;
        padding: 0 5px;
        row-gap: 4px;
    }

    .desktop-icon-buttons {
        display: none;
    }

    .difficulty-display {
        gap: 4px;
        font-size: 0.7rem;
    }

    .difficulty-label {
        font-size: 0.7rem;
    }

    .difficulty-value {
        font-size: 0.7rem;
    }

    .game-buttons {
        gap: 6px;
    }

    .game-buttons .btn {
        padding: 6px 12px;
        font-size: 0.75rem;
        border-radius: 6px;
    }

    .right-controls-group {
        gap: 6px;
    }

    .timer-control-group {
        gap: 4px;
    }

    .toggle-item {
        gap: 4px;
    }

    .toggle-label {
        font-size: 0.7rem;
    }

    .toggle-switch {
        width: 40px;
        height: 20px;
    }

    .toggle-slider:before {
        height: 14px;
        width: 14px;
        left: 2px;
        bottom: 1px;
    }

    .toggle-checkbox:checked + .toggle-slider:before {
        transform: translateX(20px);
    }

    .time-display {
        font-size: 0.75rem;
        min-width: 45px;
    }

    .leaderboard-btn {
        display: none;
    }

    /* Mobile difficulty selector - hidden */
    .mobile-difficulty {
        display: none !important;
    }

    /* Hide desktop game info on mobile */
    .game-info {
        display: none;
    }

    /* Hide mobile controls row on mobile */
    .mobile-controls-row {
        display: none !important;
    }

    /* Main content - board and dogs in single page */
    .main-content {
        flex-direction: column;
        gap: 4px;
        flex: 1 1 auto;
        min-height: 0;
        overflow: visible; /* Allow content to flow naturally */
        justify-content: flex-start;
    }

    .board-container {
        flex: 0 0 auto;
        max-width: 100%;
    }

    .sudoku-board {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        margin: 0 auto;
        gap: 1px;
    }

    .cell {
        border-width: 1px;
    }

    .cell-img {
        padding: 1px;
    }

    /* Show desktop board controls on mobile, but style them differently */
    .board-controls {
        display: flex !important;
        flex-direction: row;
        gap: 12px;
        margin: 3px 0;
        justify-content: center;
    }

    .board-controls .control-with-label {
        gap: 2px;
    }

    .board-controls .control-label {
        font-size: 0.5rem;
        opacity: 0.4;
    }

    .board-controls .icon-btn {
        width: 32px;
        height: 32px;
        padding: 0;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .board-controls .icon-btn svg {
        width: 16px;
        height: 16px;
    }

    .board-controls .icon-btn svg {
        width: 18px;
        height: 18px;
        display: block;
        margin: 0;
    }

    .board-controls .mistakes {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        gap: 2px;
        font-size: 10px;
    }

    .board-controls .mistakes-icon {
        width: 10px;
        height: 10px;
    }

    .board-controls-compact {
        display: none;
    }

    .mobile-mistakes {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 2px;
        width: 32px;
        height: 32px;
        font-size: 10px;
        font-weight: 600;
        color: var(--primary-color);
        background: var(--cell-bg);
        padding: 0;
        border-radius: 8px;
        border: 2px solid var(--secondary-color);
    }

    .mobile-mistakes .label {
        display: none;
    }

    .mobile-mistakes .mistakes-count {
        font-size: 10px;
        font-weight: 600;
        color: var(--primary-color);
    }

    .mobile-mistakes .mistakes-icon {
        width: 10px;
        height: 10px;
    }

    /* Hint preview on mobile - smaller dogs */
    .hint-dogs-preview {
        gap: 1px;
        padding: 1px;
    }

    .hint-dog-option {
        max-width: 18px;
        max-height: 18px;
    }

    /* Side panel becomes bottom panel with horizontal dogs */
    .side-panel {
        width: 100%;
        flex: 0 1 auto;
        display: flex;
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
    }

    .dog-panel {
        height: fit-content;
        min-height: 0;
        width: fit-content;
        max-width: 100%;
        padding: 4px;
        box-shadow: none;
        background: transparent;
        margin: 0 auto;
    }

    .panel-title {
        display: none;
    }

    /* Dogs in 2 rows: 5 dogs in first row, 4 dogs in second row (centered) */
    .dog-list {
        display: grid;
        grid-template-columns: repeat(10, 1fr); /* 10 columns for easy centering */
        gap: 4px;
        max-width: 320px; /* Match board width */
        margin: 0 auto;
        padding: 0;
    }

    /* First row: 5 dogs - each takes 2 columns */
    .dog-item:nth-child(1) { grid-column: 1 / 3; }
    .dog-item:nth-child(2) { grid-column: 3 / 5; }
    .dog-item:nth-child(3) { grid-column: 5 / 7; }
    .dog-item:nth-child(4) { grid-column: 7 / 9; }
    .dog-item:nth-child(5) { grid-column: 9 / 11; }

    /* Second row: 4 dogs centered - each takes 2 columns, starting from column 2 */
    .dog-item:nth-child(6) { grid-column: 2 / 4; }
    .dog-item:nth-child(7) { grid-column: 4 / 6; }
    .dog-item:nth-child(8) { grid-column: 6 / 8; }
    .dog-item:nth-child(9) { grid-column: 8 / 10; }

    .dog-item {
        width: 58px;
        height: 58px;
        border-width: 2px;
        cursor: pointer;
    }

    .dog-header {
        margin-bottom: 0;
        font-size: 0.55rem;
        height: 12px;
    }

    .dog-name {
        font-size: 0.55rem;
    }

    .dog-item img {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .checkmark {
        font-size: 0.65rem;
    }

    /* Message smaller */
    .message {
        padding: 4px 10px;
        font-size: 0.7rem;
        margin-top: 2px;
    }

    /* Modal adjustments */
    .modal-content {
        padding: 20px;
        max-width: 90%;
        width: 90%;
    }

    .modal-title {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .modal-subtitle {
        font-size: 1rem;
    }

    .modal-instructions li {
        font-size: 0.85rem;
        padding: 8px 0 8px 25px;
    }

    .modal-note {
        font-size: 0.8rem;
        padding: 10px;
    }

    /* About Us mobile styles */
    .about-us-content {
        max-height: 85vh;
        max-height: 85dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }

    .about-us-content .modal-body {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }

    .about-us-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 5px 0;
    }

    .team-member {
        gap: 4px;
    }

    .member-title {
        font-size: 0.85rem;
        min-height: 38px;
    }

    .member-name {
        font-size: 0.8rem;
        margin: -10px 0 6px 0;
    }

    .member-photo-container {
        width: 140px;
        height: 140px;
    }

    /* Leaderboard on mobile */
    .leaderboard-content {
        max-width: 95%;
    }

    .difficulty-tabs {
        gap: 5px;
    }

    .tab-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .leaderboard-item {
        grid-template-columns: 30px 1fr 55px 45px;
        gap: 6px;
        padding: 8px;
        font-size: 0.8rem;
    }

    .leaderboard-item .rank {
        font-size: 0.9rem;
    }

    .leaderboard-item .player-name {
        font-size: 0.8rem;
    }

    .leaderboard-item .score-time {
        font-size: 0.8rem;
    }

    .leaderboard-item .score-mistakes {
        font-size: 0.65rem;
    }

    /* Win modal on mobile */
    .win-stats {
        font-size: 0.95rem;
    }

    .player-name-input {
        padding: 8px;
        font-size: 0.9rem;
    }

    /* Achievement overlay */
    .achievement-overlay {
        padding: 10px;
    }

    .achievement-content {
        padding: 15px;
        max-width: 90%;
    }

    .achievement-icon {
        font-size: 3rem;
        margin-bottom: 10px;
    }

    .achievement-icon img {
        width: 100px !important;
        height: 100px !important;
    }

    .achievement-text {
        font-size: 1rem;
    }

    /* Touch action controls for better WebView behavior */
    html {
        touch-action: pan-y pinch-zoom;
    }

    body {
        touch-action: pan-y;
    }

    /* Game board should prevent scrolling (only game interactions) */
    .board-container {
        touch-action: none;
    }
}
