:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5f7fa;
    --text-color: #2c3e50;
    --border-color: #cbd5e0;
    --thick-border: #4a5568;
    --selected-bg: #e2e8f0;
    --error-color: #e53e3e;
    --success-color: #38a169;
    --note-color: #718096;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #edf2f7;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 500px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 24px;
    color: var(--primary-color);
}

.stats {
    display: flex;
    gap: 15px;
    align-items: center;
}

#timer {
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr); /* 세로 크기도 동일하게 고정 */
    border: 3px solid var(--thick-border);
    margin-bottom: 20px;
    aspect-ratio: 1 / 1; /* 보드 전체를 정사각형으로 유지 */
    background-color: white;
}

.cell {
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    position: relative;
    width: 100%;
    height: 100%; /* 부모 그리드 칸을 꽉 채움 */
    overflow: hidden; /* 내용물이 삐져나가지 않게 */
}

/* 3x3 subgrid borders */
.cell:nth-child(3n) { border-right: 2px solid var(--thick-border); }
.cell:nth-child(9n) { border-right: none; }
.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.selected { background-color: var(--selected-bg); }
.cell.hint { background-color: #fff0f0; } /* 힌트용 연한 빨간색 */
.cell.same-num { background-color: #fed7d7; } /* 동일 숫자 강조 (조금 더 진한 빨간색 계열) */
.cell.error { color: var(--error-color); }
.cell.initial { color: #000; }
.cell.user-input { color: var(--primary-color); }

.notes-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    font-size: 0.6rem;
    color: var(--note-color);
    padding: 2px;
}

.note { display: none; justify-content: center; align-items: center; }
.note.active { display: flex; }

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 8px; /* 간격을 조금 더 넓힘 */
    margin-top: 10px;
}

.num-btn {
    padding: 15px 0; /* 높이를 키움 */
    border: 2px solid transparent;
    background: var(--secondary-color);
    border-radius: 8px;
    font-size: 1.2rem; /* 글자 크기를 키움 */
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.num-btn:hover {
    background: var(--selected-bg);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.num-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
    border: none;
}

.action-btn.active {
    background: #cbd5e0;
    border-color: #718096;
}

@media (max-width: 400px) {
    .cell { font-size: 1.2rem; }
    .container { padding: 10px; }
}