body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 100%);
    margin: 0;
    color: #2d3748;
    height: 100%;
}

.container {
    margin: auto;
    text-align: center;
    max-width: min(94vw, 400px);
    padding: 0.5rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    position: relative;
}


#room-code {
    font-size: 0.4rem;
    display: flex;
    flex-direction: column; /* Stack items vertically */
    align-items: center; /* Center align text if needed */
    text-align: center; /* Center align the text within each line */
}

/* Side Panel */
#side-panel {
    text-align: left;
    max-width: 0.4*min(90vw, 600px);
    margin: 0;
    padding: 1.5rem;
    position: absolute;
    top: 6px;
    left: -23px;
    height: min(90vh, 800px);
    border-radius: 16px;
    background-color: #2d3748;
    color: white;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    z-index: -999;
}

#side-panel.show {
    z-index: 999;
}



/* Hamburger menu icon */
#hamburger-menu {
    font-size: 1.5rem;
    cursor: pointer;
    color: #2d3748;
}

#side-panel ul {
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

#side-panel ul li {
    margin: 1rem 0;
}

#side-panel ul li a {
    text-decoration: none;
    color: white;
    font-size: 1.2rem;
    transition: color 0.3s ease;
}

#side-panel ul li a:hover {
    color: #4299e1;
}

#side-panel button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
}



/* Hidden class to hide elements */
.hidden {
    display: none !important;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

#difficulty {
    font-size: 0.7rem;
    border-radius: 4px;
}

.difficulty {
    font-size: 0.8rem;
}

#start-game{
    font-size: 0.8rem;
    border-radius: 4px;
}

#challenge-friend {
    font-size: 0.8rem;
    border-radius: 4px;
}

#timer {
    
    font-size: 0.8rem;
    cursor: default;
    padding: 0.25rem 0.25rem;
    font-family: monospace;
    background: #f7fafc;
    
    border-radius: 4px;
    color: #4a5568;
}

button {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background: #006f8c;
    color: white;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

button.clicked {
    background-color: #002f4b !important; /* Temporary clicked color */
    transform: scale(0.95); /* Slightly shrink */
}


/* Sudoku board styling */
#sudoku-board {
    display: grid;
    grid-template-rows: repeat(9, 1fr);
    margin: 1rem auto;
    width: min(100%, 400px);
    aspect-ratio: 1 / 1;
}


.row {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
}

.cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    font-size: 200%;
    font-weight: 200;
    line-height: 1;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 0.2px #cbd5e0;
    box-sizing: border-box;
    cursor: default;
}


/* Borders for the 3x3 grids */
.row:nth-child(3n) .cell {
    border-bottom: 1.2px solid #333;
}

.cell:nth-child(3n) {
    border-right: 1.2px solid #333;
}

.row:first-child .cell {
    border-top: 1.2px solid #333;
}

.cell:first-child {
    border-left: 1.2px solid #333;
}

.row:last-child .cell {
    border-bottom: 1.2px solid #333;
}

.cell:last-child {
    border-right: 1.2px solid #333;
}


/* Prefilled cells */
.cell.prefilled {
    color: #000;
}

.cell.user-entered {
    color: #2366ad;
}

.cell.selected {
    background-color: #568ec9;
}

.cell.highlight {
    background-color: #cfe4fbb5;
}

/* Number pad styling */
#number-pad {
    
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.number-btn {
    padding: 0.5rem;
    font-size: 1.25rem;
    width: 3rem;
    height: 3rem;
    cursor: pointer;
    border-radius: 8px;
    background-color: #006f8c;
    color: white;
    border: none;
}

.number-btn:hover {
    background-color: #002f4b;
}

.number-btn:disabled {
    cursor: not-allowed;
    opacity: 20%; /* Ensure buttons are visibly disabled */
}

button:disabled {
    cursor: not-allowed;   /* Show "not-allowed" cursor */
    opacity: 20%;          /* Reduce opacity */
}

.button-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 1rem;
    margin-bottom: 2.5rem;
    position: relative;    
}

.button-with-label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* Pause and Notes Toggle button styling */
.icon-button {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 4rem;
    height: 3rem;
    border: none;
    border-radius: 8px;
    background-color: #006f8c;
}

.icon-button.multiplayer {
    width: 5rem
}

.icon-button:hover {
    background-color: #002f4b;
}

.cell.locked {
    background-color: #efecec87; /* Light gray to indicate locked state */
    color: #6b7280; /* Muted text color */
    cursor: not-allowed; /* Show not-allowed cursor */
}


/* Styling for cells in Notes mode */
.cell.note-mode {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    color: #2b6cb0;
}

.cell.note-mode div {
    font-size: 35%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    aspect-ratio: 1 / 1; /* Ensures the element remains a square */
    font-weight: 400;
    width: 80%;
    margin: auto;
    box-sizing: border-box;
}

html, body {
    touch-action: manipulation;
}

/* Positioning for each number in Notes mode */
#sudoku-board .note-mode .note-1 { grid-area: 1 / 1; }
#sudoku-board .note-mode .note-2 { grid-area: 1 / 2; }
#sudoku-board .note-mode .note-3 { grid-area: 1 / 3; }
#sudoku-board .note-mode .note-4 { grid-area: 2 / 1; }
#sudoku-board .note-mode .note-5 { grid-area: 2 / 2; }
#sudoku-board .note-mode .note-6 { grid-area: 2 / 3; }
#sudoku-board .note-mode .note-7 { grid-area: 3 / 1; }
#sudoku-board .note-mode .note-8 { grid-area: 3 / 2; }
#sudoku-board .note-mode .note-9 { grid-area: 3 / 3; }


/* Overlay text for Notes status */
#notes-toggle .notes-status {
    position: absolute;
    top: -0.06rem;
    width: 1.2rem;
    
    background-color: #ffffff00;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.2rem 0.3rem;
    border-radius: 50%;
    text-align: center;
    line-height: 1;
}




/* Highlight style for notes matching the selected number */
.highlight-note {
    border-radius: 50%; /* Rounded style for note highlights */
    color: #2366ad; /* Distinct color for highlighted note numbers */
    font-weight: bold;
    border: 1px solid #000;
}

#paint-button {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 3rem;
    height: 3rem;
    border: 2px solid #9d9d9d00;
    border-radius: 50%;
    background-color: #4299e1;
    cursor: pointer;
}

#paint-button:hover {
    background-color: #2b6cb0;
}

#color-palette {
    display: none; /* Start hidden by default */
    gap: 0.5rem;
    position: absolute;
    top: -3.5rem; /* Position below the paint icon */
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 100; /* Ensure it appears above other elements */
}

.color-option {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.color-option[data-color="#ff595e"] { background-color: #ff595e; }
.color-option[data-color="#9d9d9d"] { background-color: #9d9d9d; }
.color-option[data-color="#8ac926"] { background-color: #8ac926; }



/* Base modal styling for all modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal1 {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

/* Modal content */
.completion-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
}

/* Show the modal */
.modal1.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    position: relative;
    background-color: white;
    margin: 5vh auto;
    padding: 1.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: min(80vw, 400px);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.close {
    font-size: 2rem; /* Increase the size of the X */
    font-weight: bold; /* Make the X more prominent */
    color: #333; /* Set the color (you can adjust as needed) */
    position: absolute; /* Position the X relative to its nearest positioned ancestor */
    top: 10px; /* Move it slightly down from the top */
    right: 15px; /* Move it slightly left from the right edge */
    cursor: pointer; /* Change the cursor to a pointer for better UX */
    z-index: 1; /* Ensure it stays above other elements in the modal */
}

#room-code {
    font-size: 0.7rem;
    color: #2d3748;
    text-align: center;
    margin-top: -0.5rem;
}

#room-code.hidden {
    display: none;
}

#scoreboard {
    position: absolute;
    bottom: 0;
    max-width: min(94vw, 400px);
    width: 100%;
    height: 2.5rem; /* Height of the header only */
    border-radius: 10px 10px 0 0; /* Rounded corners for the top */
    background-color: white;
    box-shadow: 0px -5px 10px rgba(0, 0, 0, 0.2);
    border-top: 2px solid #006f8c;
    transition: all 0.5s ease-in-out;
    overflow: hidden; /* Hide content when collapsed */
    box-sizing: border-box;
}

#scoreboard-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

#scoreboard-controls {
    display: flex;
    padding-left: 1rem;
    padding-right: 1rem;
    box-sizing: border-box;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background-color: #006f8c;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

#refresh-scoreboard {
    margin-right: 10px;
    background-color: white;
    color: #4299e1;
    border: 1px solid #4299e1;
    border-radius: 5px;
    padding: 0.5rem;
    cursor: pointer;
}

#toggle-arrow {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
}

#scoreboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    visibility: hidden; /* Hidden initially */
    opacity: 0;
    transition: visibility 0s, opacity 0.3s ease-in-out;
}

#scoreboard-table th,
#scoreboard-table td {
    border: 1px solid #ccc;
    padding: 0.5rem;
}

#scoreboard-table th {
    background-color: #f7f7f7;
}

/* Expanded scoreboard styles */
#scoreboard.expanded {
    top: 20px;
    height: auto; /* Full scoreboard height */
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#scoreboard.expanded #scoreboard-table {
    visibility: visible;
    opacity: 1;
}

/* Show refresh button when expanded */
#scoreboard.expanded #refresh-scoreboard {
    display: inline-block;
}

#collapse-button {
    display: none;
    text-align: center;
    bottom: 0;
    padding: 10px;
    background-color: #006f8c;
    color: white;
    border: none;
    border-radius: 0 0 15px 15px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 2s ease-in-out;
}

#collapse-button:hover {
    background-color: #004d63;
}

#scoreboard.expanded #collapse-button {
    display: block;
}

#notification {
    position: fixed;
    top: 10%;
    left: 50%;
    z-index: 1000;
    transform: translateX(-50%);
    background-color: #ffffff;
    color: rgb(83, 83, 83);
    border-radius: 8px;
    font-size: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#notification.show {
    opacity: 1;
    visibility: visible;
}

#notification.fade-out {
    opacity: 0;
    visibility: hidden;
}


#pull-down-indicator {
    position: fixed;
    top: -60px; /* Initially hidden above the screen */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    background-color: #f5f5f5;
    color: #4299e1;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    border-radius: 0 0 8px 8px;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
    transition: top 0.3s ease-in-out;
    z-index: 9999;
}

#pull-down-indicator.visible {
    top: 0; /* Slide into view */
}

.spinner {
    width: 1.2rem;
    height: 1.2rem;
    border: 3px solid #4299e1;
    border-top: 3px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#difficulty-display2 {
    font-size: 1.2rem;
    color: #333;
    margin: 10px 0;
}

.button-label {
    font-size: 0.7rem;
    text-align: center;
}

.how-to-play {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    margin: auto;
    color: #333;
    max-width: min(90vw, 600px);
    text-align: justify; /* Justify text alignment */
}

.how-to-play h2, .how-to-play h3 {
    color: #2B4157; /* Dark blue for headings */
    text-align: left; /* Headings remain left-aligned */
}

.how-to-play p, .how-to-play li {
    text-align: justify; /* Justify paragraphs and list items */
    margin: 10px 0;
}

.how-to-play ul, .how-to-play ol {
    margin: 0 0 10px 20px; /* Align list items closer to the text */
    padding: 0;
}

.how-to-play li {
    margin-left: 0; /* Prevent extra indentation for list items */
    text-align: justify; /* Justify the list items' content */
}

.how-to-play strong {
    color: #006f8c; /* Highlighted text */
}

.how-to-play hr {
    border: 1px solid #ddd;
    margin: 20px 0;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

@keyframes colorChain {
    0% {
        background-color: #ffd700; /* Gold */
    }
    50% {
        background-color: #87a3cc; /* Light blue */
    }
    100% {
        background-color: #f8f9fa; /* Original color (Light gray) */
    }
}

.cell.animate {
    animation: colorChain 2s ease-in-out;
}

.container.blurred {
    filter: blur(5px); /* Apply blur effect */
    pointer-events: none; /* Disable interactions while blurred */
    user-select: none; /* Prevent text selection while blurred */
}

#pause-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    z-index: 9999;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

#pause-overlay .play-icon {
    font-size: 2rem;
    color: white;
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
}

#pause-overlay .play-icon:hover {
    transform: scale(1.1);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#settings-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #006f8c;
}

#game-mode-header {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0.5rem auto;
    color: #1a365d;
    text-align: center;
}

#settings-modal {
    position: absolute;
    width: 250px; /* Fixed width */
    transform: scale(0); /* Start hidden and scaled down */
    transform-origin: top right; /* Expand from top-right corner */
    transition: transform 0.2s ease-in-out; /* Smooth expand animation */
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    padding: 10px;
    visibility: hidden; /* Hidden by default */
}

#settings-modal.show {
    transform: scale(1); /* Expand to full size */
    visibility: visible;
}

.settings-modal-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    width: auto; /* Occupy only as much space as needed */
    min-width: 200px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

#edit-name-button, #save-name-button {
    background: none;
    border: none;
    color: #006f8c;
    cursor: pointer;
    font-size: 1rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 34px;
    transition: 0.4s;
}

.slider:before {
    position: absolute;
    content: '';
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.4s;
}

input:checked + .slider {
    background-color: #2B4157;
}

input:checked + .slider:before {
    transform: translateX(14px);
}

.cell.error {
    color: #ff0000; /* Red text */
}

@keyframes pop {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.number-pop {
    position: absolute;
    animation: pop 1s ease-out forwards; /* Animation lasts 0.5 seconds */
    font-size: 1.5rem; /* Adjust font size to match your design */
    color: red; /* Optional: Change color for better visibility */
    pointer-events: none; /* Ensure it doesn't interfere with clicks */
    z-index: 100; /* Ensure it appears above other elements */
}

.new-game-container {
    position: relative;
    display: inline-block;
}

#difficulty-menu {
    position: absolute;
    top: 100%;
    left: 0;
    text-align: left;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
    padding: 0.5rem;
}

.difficulty-option {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

.difficulty-option:hover {
    background-color: #f0f0f0;
}

#difficulty-display {
    font-size: 0.8rem;
    cursor: default;
    padding: 0.25rem 0.25rem;
    font-family: monospace;
    background: #f7fafc;
    
    border-radius: 4px;
    color: #4a5568;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 8px;
}

.status-dot.online {
    background-color: green;
}

.status-dot.offline {
    background-color: red;
}

#hint-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.1); /* Semi-transparent black */
    z-index: 999; /* Higher than other elements */
    pointer-events: auto; /* Allow blocking interactions */
}

#hint-popup {
    position: absolute;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: min(94vw, 400px);
    width: 100%;
    padding: 1rem;
    box-sizing: border-box;
}

.hint-popup-content {
    text-align: justify;
    height: 6.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hint-popup-navigation {
    display: flex;
    justify-content: space-between;
}

#hint-left-arrow,
#hint-right-arrow {
    background-color: #006f8c;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    cursor: pointer;
}

#hint-left-arrow:hover,
#hint-right-arrow:hover {
    background-color: #004f6c;
}

.cell.hint-highlight {
    background-color: #f8f533;
}

#congrats-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /*background-color: #f8f533;  Green for success */
    color: #ffd700;
    text-shadow: 0 2px 3px #004f6c;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 20px 30px;
    border-radius: 8px;
    
    z-index: 1000;
    text-align: center;
    animation: slide-in 0.5s ease, fade-out 3s 2.5s forwards; /* Show and fade out */
}

#congrats-message p {
    margin: 0;
}

.hidden {
    display: none;
}

/* Slide-in animation */
@keyframes slide-in {
    from {
        transform: translate(-50%, -60%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* Fade-out animation */
@keyframes fade-out {
    to {
        opacity: 0;
    }
}