:root { --primary: #007AFF; --bg: #ffffff; --text: #1d1d1f; --muted: #6e6e73; --card-border: #e5e5ea; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Getsmore Bubble BG & Layout */
.bubble-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; z-index: 0; pointer-events: none; }
.bubble { position: absolute; border-radius: 50%; opacity: 0.4; filter: blur(60px); }
.bubble-1 { width: 400px; height: 400px; background: #ff9a9e; top: -100px; left: -100px; animation: float 10s infinite alternate; }
.bubble-2 { width: 500px; height: 500px; background: #a1c4fd; bottom: -150px; right: -100px; animation: float 12s infinite alternate-reverse; }
.bubble-3 { width: 300px; height: 300px; background: #d4fc79; top: 40%; left: 50%; animation: float 14s infinite alternate; }
@keyframes float { 0% { transform: translate(0, 0); } 100% { transform: translate(50px, 50px); } }

/* Focus Mode while playing */
body.playing-mode #global-header,
body.playing-mode .global-footer,
body.playing-mode .info-container,
body.playing-mode .bubble-bg,
body.playing-mode .header-container {
    display: none !important;
}
body.playing-mode .app-wrapper {
    padding: 10px 5px;
    justify-content: center;
}
body.playing-mode .game-box {
    box-shadow: none;
    border: none;
    padding: 10px 5px;
    background-color: transparent !important;
}

.app-wrapper { flex: 1; position: relative; z-index: 10; width: 100%; display: flex; flex-direction: column; align-items: center; padding: 20px 10px; }
.container { width: 98%; max-width: 1000px; margin: 0 auto; }
.game-box { background: #fff; border-radius: 20px; padding: 15px 10px; box-shadow: 0 10px 20px rgba(0,0,0,0.05); border: 1px solid var(--card-border); display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; }

.info-container { width: 100%; max-width: 95%; margin: 40px auto 0; background: #fff; border-radius: 30px; padding: 40px; box-shadow: 0 10px 30px rgba(0,0,0,0.05); border: 1px solid var(--card-border); text-align: left; position: relative; z-index: 10; }
.info-container h2 { font-size: 1.8rem; color: var(--text); margin-bottom: 20px; font-weight: 800; letter-spacing: -0.5px; }
.info-container ul { margin-bottom: 30px; padding-left: 20px; }
.info-container li { margin-bottom: 12px; color: #444; font-size: 1rem; line-height: 1.6; }
.faq-container { margin-top: 20px; }
.faq-item { border-bottom: 1px solid var(--card-border); margin-bottom: 10px; }
.faq-question { width: 100%; background: none; border: none; text-align: left; padding: 15px 0; font-size: 1.1rem; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--text); }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.faq-answer p { padding-bottom: 15px; color: var(--muted); line-height: 1.6; font-size: 0.95rem; }
.faq-item.active .faq-answer { max-height: 500px; }

h1 {
    color: #333;
    margin: 0;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
}

#settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    color: #333;
    cursor: pointer;
    padding: 0;
    margin: 0;
    min-width: auto;
}

#help-btn {
    position: absolute;
    top: 20px;
    right: 60px;
    background: none;
    border: none;
    font-size: 24px;
    color: #333;
    cursor: pointer;
    padding: 0;
    margin: 0;
    min-width: auto;
}

#header-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    max-width: 800px;
    padding: 0 2vw;
    box-sizing: border-box;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: normal;
}

#timer-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

#pause-btn, #back-btn {
    padding: 6px 8px;
    margin: 0;
    min-width: auto;
}

#game-board-container {
    position: relative;
    margin-bottom: 0;
}

.game-main-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.game-controls-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(9, min(40px, 9.5vw));
    grid-template-rows: repeat(9, min(40px, 9.5vw));
    border: 3px solid #333;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.cell {
    width: min(40px, 9.5vw);
    height: min(40px, 9.5vw);
    border: 1px solid #ccc;
    text-align: center;
    font-size: min(20px, 5.5vw);
    line-height: min(40px, 9.5vw);
    position: relative;
    box-sizing: border-box;
    touch-action: manipulation;
}

.cell[data-col="2"], .cell[data-col="5"] {
    border-right: 2px solid #333;
}

.cell[data-row="2"], .cell[data-row="5"] {
    border-bottom: 2px solid #333;
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: min(20px, 5.5vw);
    background-color: transparent;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    caret-color: transparent;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.cell input:focus {
    outline: none;
    background-color: transparent;
}

.row-col-highlight {
    background-color: #f3f4f6;
}

.highlighted-number {
    background-color: #c7d2fe;
}

.selected-cell {
    background-color: #bbdefb !important;
    box-shadow: inset 0 0 0 3px var(--primary) !important;
    z-index: 2;
}

.conflict-highlight {
    background-color: #fca5a5 !important;
    color: #991b1b !important;
}

.conflict-highlight input {
    color: #991b1b !important;
}

.input-incorrect {
    color: red;
}

.given-number {
    background-color: #ddd;
    font-weight: bold;
}

.user-correct {
    background-color: #ddd;
}

#controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

button {
    padding: 8px 10px;
    width: auto;
    min-width: 50px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f0f0f0;
    margin: 0;
    touch-action: manipulation;
}

button:hover {
    background-color: #e0e0e0;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:hover {
    background-color: #f0f0f0;
}

#number-pad {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    margin-bottom: 10px;
    width: 100%;
    max-width: 500px;
    padding: 0 5px;
    box-sizing: border-box;
    gap: 3px;
}

.num-btn {
    flex: 1;
    height: 48px;
    font-size: min(20px, 5vw);
    margin: 0;
    padding: 0;
    border-radius: 5px;
    min-width: 0;
    position: relative;
    touch-action: manipulation;
}

@keyframes btnPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.btn-animate {
    animation: btnPress 0.15s ease-in-out;
}

@keyframes cascadePop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.cell-cascade {
    animation: cascadePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
}

.correct {
    background-color: #a7f3d0;
}

.incorrect {
    background-color: #fecaca;
}

.notes {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    pointer-events: none;
    padding: 1px;
}

.note-num {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: min(11px, 2.5vw);
    color: #666;
    line-height: 1;
}

.cell.has-value .notes {
    display: none;
}

.floating-text {
    position: absolute;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: min(24px, 5vw);
    pointer-events: none;
    z-index: 1000;
    transition: all 0.8s ease-out;
}

.floating-positive {
    color: #10b981;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.floating-negative {
    color: #ef4444;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.remaining-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: min(11px, 3vw);
    color: #666;
}

.active-mode {
    background-color: #3b82f6 !important;
    color: white;
    border-color: #2563eb !important;
}

#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(244, 244, 244, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    font-weight: bold;
    color: #333;
    z-index: 10;
}

@media (min-width: 800px) {
    .game-main-area {
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        gap: 50px;
        margin-top: 10px;
    }
    .game-controls-wrapper {
        max-width: 320px;
        justify-content: center;
    }
    #game-board {
        grid-template-columns: repeat(9, 55px);
        grid-template-rows: repeat(9, 55px);
    }
    .cell {
        width: 55px;
        height: 55px;
        font-size: 28px;
        line-height: 55px;
    }
    .cell input {
        font-size: 28px;
    }
    #controls {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        width: 100%;
        margin-bottom: 20px;
    }
    #controls button {
        width: 100%;
        height: 50px;
    }
    #number-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    .num-btn {
        height: 70px;
        font-size: 26px;
    }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 30px 50px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none !important;
    border: none !important;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    min-width: auto;
    color: inherit;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    text-align: left;
    font-size: 16px;
}

.setting-row select, .setting-row input[type="number"] {
    padding: 5px;
    border-radius: 5px;
    font-size: 14px;
    width: 80px;
    box-sizing: border-box;
    border: 1px solid #ccc;
}

/* Dark Theme Support */
body.dark-theme { background-color: #000; color: #f5f5f7; --bg: #000; --text: #f5f5f7; --card-border: #38383a; }
body.dark-theme .game-box, body.dark-theme .info-container { background-color: #1c1c1e; }
body.dark-theme .info-container h2 { color: #eee; }
body.dark-theme .info-container li, body.dark-theme .faq-answer p { color: #aaa; }
body.dark-theme .faq-question { color: #eee; }

body.dark-theme {
    background-color: #222;
    color: #eee;
}
body.dark-theme h1, body.dark-theme .modal-content, body.dark-theme #pause-overlay {
    color: #eee;
    background-color: #333;
}
body.dark-theme .cell {
    border-color: #666;
}
body.dark-theme .cell[data-col="2"], body.dark-theme .cell[data-col="5"] {
    border-right: 2px solid #aaa;
}
body.dark-theme .cell[data-row="2"], body.dark-theme .cell[data-row="5"] {
    border-bottom: 2px solid #aaa;
}
body.dark-theme #game-board {
    border: 3px solid #aaa;
}
body.dark-theme .cell input {
    color: #eee;
}
body.dark-theme .cell input:focus {
    background-color: transparent;
}
body.dark-theme .selected-cell {
    background-color: #1e40af !important;
    box-shadow: inset 0 0 0 3px #60a5fa !important;
    z-index: 2;
}
body.dark-theme .highlighted-number {
    background-color: #4a5568;
}
body.dark-theme .row-col-highlight {
    background-color: #374151;
}
body.dark-theme .conflict-highlight {
    background-color: #7f1d1d !important;
    color: #fca5a5 !important;
}
body.dark-theme .conflict-highlight input {
    color: #fca5a5 !important;
}
body.dark-theme .given-number,
body.dark-theme .user-correct {
    background-color: #444;
}
body.dark-theme button {
    background-color: #555;
    color: #eee;
    border-color: #777;
}
body.dark-theme button:hover {
    background-color: #666;
}
body.dark-theme #settings-btn:hover, body.dark-theme #help-btn:hover {
    background-color: transparent;
}
body.dark-theme button:disabled:hover {
    background-color: #555;
}
body.dark-theme .note-num {
    color: #aaa;
}
body.dark-theme .remaining-count {
    color: #aaa;
}
body.dark-theme .floating-positive {
    color: #34d399;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}
body.dark-theme .floating-negative {
    color: #f87171;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}
body.dark-theme select, 
body.dark-theme input[type="number"],
body.dark-theme input[type="text"] {
    background-color: #555;
    color: #eee;
    border-color: #777;
}
body.dark-theme #settings-btn, 
body.dark-theme #help-btn {
    color: #eee;
}