:root {
    --bg: #1a1a2e;
    --bg-cell: #16213e;
    --text: #eee;
    --text-dim: #aaa;
    --accent: #e94560;
    --correct: #4ecca3;
    --border: #444;
    --btn-bg: #e94560;
    --btn-text: white;
}

:root.light {
    --bg: #f0f4f8;
    --bg-cell: #ffffff;
    --text: #1a1a2e;
    --text-dim: #666;
    --accent: #e94560;
    --correct: #2a9d78;
    --border: #ccc;
    --btn-bg: #e94560;
    --btn-text: white;
}

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

body {
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    transition: background 0.3s, color 0.3s;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 600px;
}

h1 {
    font-size: 2rem;
    color: var(--accent);
    letter-spacing: 2px;
}

#themeBtn {
    background: transparent !important;
    border: 2px solid var(--border) !important;
    color: var(--text) !important;
    padding: 6px 14px !important;
    border-radius: 20px !important;
    font-size: 0.85rem !important;
    font-weight: normal !important;
    cursor: pointer;
    transition: all 0.2s;
}

#themeBtn:hover {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

select, button {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
}

select {
    background: var(--bg-cell);
    color: var(--text);
    border: 1px solid var(--accent);
}

button {
    background: var(--btn-bg);
    color: var(--btn-text);
    font-weight: bold;
    transition: background 0.2s;
}

button:hover {
    background: #c73652;
}

.board {
    display: grid;
    grid-template-columns: repeat(9, 56px);
    grid-template-rows: repeat(9, 56px);
    border: 3px solid var(--accent);
    gap: 0;
}

.cell {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: bold;
    border: 1px solid var(--border);
    background: var(--bg-cell);
    color: var(--text);
    cursor: default;
    transition: background 0.3s, color 0.3s;
    position: relative;
    overflow: hidden;
}

.cell.given {
    color: var(--accent);
}

.cell.solution {
    color: var(--correct);
}

.cell:nth-child(3n) {
    border-right: 3px solid var(--accent);
}

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

.cell-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--correct);
    outline: none;
    cursor: text;
    caret-color: transparent;
    padding: 0;
    transition: background 0.3s, color 0.3s;
}

.cell-input.correct {
    color: var(--correct);
    background: rgba(78, 204, 163, 0.15);
}

.cell-input.wrong {
    color: var(--accent);
    background: rgba(233, 69, 96, 0.15);
}

.cell-input.selected {
    background: rgba(78, 204, 163, 0.1);
}

.numpad {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: center;
    width: 100%;
    max-width: 504px;
}

.num-btn {
    flex: 1;
    height: 48px;
    min-width: 0;
    font-size: 1.1rem;
    font-weight: bold;
    background: var(--bg-cell);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.num-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.num-btn.active-num {
    border-color: var(--correct);
    color: var(--correct);
}

.delete-btn {
    flex: 1.5;
    font-size: 0.85rem;
    color: var(--accent) !important;
    border-color: var(--accent) !important;
    background: transparent !important;
}

.delete-btn:hover {
    background: rgba(233, 69, 96, 0.15) !important;
}
.game-info {
    display: flex;
    gap: 24px;
    align-items: center;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-dim);
}

.timer {
    font-size: 1.1rem;
    color: var(--correct);
    min-width: 80px;
}

.mistakes {
    color: var(--accent);
}

.hints {
    color: #f0a500;
}
.celebration {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--correct);
    color: #fff;
    padding: 16px 32px;
    border-radius: 16px;
    font-size: 1.3rem;
    font-weight: bold;
    z-index: 999;
    animation: popIn 0.4s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

@keyframes popIn {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}
.score-table {
    width: 100%;
    max-width: 504px;
    background: var(--bg-cell);
    border-radius: 12px;
    padding: 16px 24px;
    border: 1px solid var(--border);
}

.score-table h3 {
    color: var(--accent);
    margin-bottom: 12px;
    font-size: 1rem;
    text-align: center;
}

.score-table table {
    width: 100%;
    border-collapse: collapse;
}

.score-table td {
    padding: 6px 12px;
    font-size: 0.95rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.score-table td:last-child {
    text-align: right;
    color: var(--correct);
    font-weight: bold;
    font-family: monospace;
    font-size: 1rem;
}
.cell.highlighted {
    background: rgba(78, 204, 163, 0.25);
}
.resume-bar {
    width: 100%;
    max-width: 504px;
    background: #f0a500;
    color: #1a1a2e;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.resume-bar button {
    background: #1a1a2e;
    color: #f0a500;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: bold;
    z-index: 999;
    animation: popIn 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.cell.same-number {
    background: rgba(233, 69, 96, 0.35);
    color: #fff;
}

.cell.same-number.highlighted {
    background: rgba(233, 69, 96, 0.5);
}
:root.light .cell.highlighted {
    background: rgba(78, 204, 163, 0.3);
}

:root.light .cell.same-number {
    background: rgba(233, 69, 96, 0.25);
}

:root.light .cell.same-number.highlighted {
    background: rgba(233, 69, 96, 0.4);
}