:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #e2e8f0;
    --error: #ef4444;
    --success: #22c55e;
    --selected-bg: #dbeafe;
    --highlighted-bg: #f1f5f9;
    --border-color: #cbd5e1;
    --thick-border: #64748b;
    --cell-size: clamp(35px, 9vw, 55px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
}

.controls-top {
    display: flex;
    gap: 10px;
}

select, button {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

#new-game {
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
}

#new-game:hover {
    background: var(--primary-hover);
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #64748b;
}

.board {
    display: grid;
    grid-template-columns: repeat(9, var(--cell-size));
    grid-template-rows: repeat(9, var(--cell-size));
    border: 3px solid var(--thick-border);
    margin: 0 auto 1.5rem;
    width: max-content;
    background: white;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    cursor: pointer;
    position: relative;
    user-select: none;
}

/* Bordes gruesos para los bloques 3x3 */
.cell:nth-child(3n) { border-right: 2px solid var(--thick-border); }
.cell:nth-child(9n) { border-right: 3px solid var(--thick-border); }
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--thick-border);
}
.cell:nth-child(n+73) { border-bottom: 3px solid var(--thick-border); }

.cell.initial {
    font-weight: 800;
    color: #0f172a;
    background-color: #f8fafc;
}

.cell.selected { background-color: var(--selected-bg) !important; }
.cell.highlighted { background-color: var(--highlighted-bg); }
.cell.error { color: var(--error); background-color: #fee2e2; }
.cell.user-input { color: var(--primary); }

.notes-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    font-size: 0.6rem;
    line-height: 1;
    color: #94a3b8;
}

.note {
    display: flex;
    justify-content: center;
    align-items: center;
}

.tools {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 1.5rem;
}

.tools button {
    width: 50px;
    height: 50px;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

.tools .status {
    font-size: 0.6rem;
    font-weight: bold;
    margin-top: 2px;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 8px;
}

.num-btn {
    padding: 12px 0;
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--highlighted-bg);
}

.num-btn:hover {
    background: var(--accent);
}

footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: #94a3b8;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 1rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

#modal-close {
    margin-top: 1.5rem;
    background: var(--primary);
    color: white;
    width: 100%;
    font-weight: 600;
}

@media (max-width: 500px) {
    .container { padding: 1rem; }
    h1 { font-size: 1.4rem; }
    .numpad { grid-template-columns: repeat(5, 1fr); }
    .tools button { width: 45px; height: 45px; }
}
