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

body {
    font-family: 'Courier New', monospace;
    background-color: #1d2530;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    text-align: center;
}

h1 {
    margin-bottom: 20px;
    font-size: 24px;
    color: #e0e6ed;
}

.sudoku-grid {
    display: inline-grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 0;
    border: 3px solid #4a5568;
    margin-bottom: 20px;
    width: min(90vw, 450px);
    height: min(90vw, 450px);
    max-width: 450px;
    max-height: 450px;
}

.cell {
    border: 1px solid #4a5568;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 4vw, 24px);
    font-weight: bold;
    cursor: pointer;
    background-color: #2a3441;
    transition: background-color 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* 3×3ブロックの太線 */
.cell:nth-child(3n) {
    border-right: 3px solid #4a5568;
}

/* 9列目（右端）は1pxに戻す */
.cell:nth-child(9n) {
    border-right: 1px solid #4a5568;
}

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

/* 9行目（下端）は1pxに戻す */
.cell:nth-child(n+73) {
    border-bottom: 1px solid #4a5568;
}

/* セルの状態による色分け */
.cell.user {
    color: #e0e6ed;
}

.cell.inferred {
    color: #90caf9;
}

.cell.conflict {
    background-color: #dc2626;
    color: #fff;
}

/* ハイライト */
.cell.selected {
    background-color: #3d4a5c;
}

.cell.related {
    background-color: #313d4f;
}

.cell.same-number {
    background-color: #2d5573;
}

/* conflictが最優先 */
.cell.conflict.selected,
.cell.conflict.related,
.cell.conflict.same-number {
    background-color: #dc2626;
}

.controls {
    margin-top: 20px;
}

button {
    font-size: 16px;
    padding: 10px 20px;
    margin: 0 5px;
    cursor: pointer;
    border: 2px solid #4a5568;
    background-color: #2a3441;
    color: #e0e6ed;
    border-radius: 4px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #3d4a5c;
}

button:active {
    background-color: #313d4f;
}

button:focus-visible {
    outline: 3px solid #64b5f6;
    outline-offset: 2px;
}

.message {
    margin-top: 15px;
    font-size: 18px;
    min-height: 30px;
    color: #e0e6ed;
}

.message.error {
    color: #f87171;
}

.message.success {
    color: #64b5f6;
}

/* セル内のinput要素 */
.cell input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
    color: inherit;
    outline: none;
    padding: 0;
    margin: 0;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    caret-color: #64b5f6;
}

/* キーボードフォーカス時のアウトライン */
.cell input:focus-visible {
    outline: 3px solid #64b5f6;
    outline-offset: -3px;
}

/* 数値入力のスピンボタンを非表示 */
.cell input::-webkit-outer-spin-button,
.cell input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
