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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    min-height: 100vh;
    color: #fff;
}

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.screen.hidden { display: none !important; }

/* Settings */
.settings-container {
    max-width: 560px; margin: auto; padding: 40px;
    background: rgba(0,0,0,0.3); border-radius: 20px; text-align: center;
}
.settings-container h1 { font-size: 3.5rem; margin-bottom: 10px; text-shadow: 2px 2px 4px rgba(0,0,0,0.5); }
.settings-container h2 { font-size: 2rem; margin-bottom: 35px; font-weight: normal; opacity: 0.9; }
.setting-group { margin-bottom: 28px; }
.setting-group > label { display: block; font-size: 1.4rem; margin-bottom: 15px; }
.button-group { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.setting-btn {
    padding: 16px 24px; font-size: 1.2rem;
    border: 3px solid #fff; background: transparent; color: #fff;
    border-radius: 12px; cursor: pointer; transition: all 0.2s;
    min-width: 140px; min-height: 78px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.setting-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.05); }
.setting-btn:focus { outline: 4px solid #f39c12; outline-offset: 2px; }
.setting-btn.active { background: #fff; color: #2c3e50; font-weight: bold; }
.diff-hint { font-size: 0.82rem; opacity: 0.7; font-weight: normal; }
.setting-btn.active .diff-hint { opacity: 0.6; }
.primary-btn {
    margin-top: 20px; padding: 20px 50px; font-size: 1.8rem;
    background: #e74c3c; color: #fff; border: none; border-radius: 15px;
    cursor: pointer; font-weight: bold; transition: all 0.2s;
    min-height: 70px; display: block; width: 100%;
}
.primary-btn:hover { background: #c0392b; transform: scale(1.03); box-shadow: 0 5px 20px rgba(231,76,60,0.5); }
.primary-btn:focus { outline: 4px solid #f39c12; outline-offset: 3px; }
.secondary-btn { margin-top: 15px; background: rgba(255,255,255,0.2); border: 3px solid #fff; }
.secondary-btn:hover { background: rgba(255,255,255,0.35); transform: scale(1.03); box-shadow: none; }

.rules-summary {
    background: rgba(255,255,255,0.1); border-radius: 12px;
    padding: 18px 22px; margin: 20px 0; text-align: left;
}
.rules-summary h3 { font-size: 1.3rem; margin-bottom: 10px; }
.rules-summary ul { list-style: none; }
.rules-summary li { font-size: 1.05rem; padding: 5px 0; opacity: 0.9; }
.rules-summary li::before { content: '• '; color: #f39c12; font-weight: bold; }

/* Header */
.game-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px; background: rgba(0,0,0,0.3);
    flex-wrap: wrap; gap: 8px; min-height: 75px;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.game-header h1 { font-size: 1.8rem; }
.difficulty-badge {
    background: rgba(255,255,255,0.2); border-radius: 8px;
    padding: 5px 14px; font-size: 1rem; font-weight: bold;
}
.header-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.timer-wrap { display: flex; align-items: center; gap: 8px; font-size: 1.4rem; font-weight: bold; }
.timer { font-variant-numeric: tabular-nums; min-width: 56px; }
.error-counter {
    font-size: 1.1rem; display: flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,0.1); padding: 4px 14px; border-radius: 8px;
}
.error-icon { color: #e74c3c; font-weight: bold; }
.header-right { display: flex; gap: 8px; flex-wrap: wrap; }
.action-btn {
    padding: 11px 16px; font-size: 1rem;
    background: rgba(255,255,255,0.9); color: #2c3e50;
    border: none; border-radius: 10px; cursor: pointer;
    font-weight: bold; transition: all 0.2s; min-height: 48px;
    white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.action-btn:hover { background: #fff; transform: scale(1.05); }
.action-btn:focus { outline: 4px solid #f39c12; outline-offset: 2px; }
a.action-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.notes-btn { background: rgba(255,255,255,0.2); color: #fff; border: 2px solid rgba(255,255,255,0.5); }
.notes-btn:hover { background: rgba(255,255,255,0.35); }
.notes-btn.active { background: #f39c12; color: #fff; border-color: #f39c12; }
.hint-btn { background: #f39c12; color: #fff; }
.hint-btn:hover { background: #d68910; }

/* Game Area */
.game-area {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 15px; gap: 18px; overflow: auto;
}

/* Sudoku Grid */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    border: 3px solid #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    background: #fff;
}

.sudoku-cell {
    width: clamp(46px, 8.5vw, 64px);
    height: clamp(46px, 8.5vw, 64px);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    position: relative;
    border: 1px solid #ccc;
    background: #fff;
    transition: background 0.1s;
    /* Box borders — right thick */
}
/* Thick box borders */
.sudoku-cell[data-col="2"], .sudoku-cell[data-col="5"] { border-right: 3px solid #333; }
.sudoku-cell[data-row="2"], .sudoku-cell[data-row="5"] { border-bottom: 3px solid #333; }

/* States */
.sudoku-cell.given { cursor: default; background: #f0f0f0; }
.sudoku-cell.selected { background: #bde0ff !important; }
.sudoku-cell.highlighted { background: #ddf0ff; }
.sudoku-cell.same-number { background: #c5e4ff; }
.sudoku-cell.error { background: #ffd4d4 !important; }
.sudoku-cell.solved-hint { background: #d4f8e8 !important; }
.sudoku-cell:not(.given):hover { background: #e8f4ff; }
.sudoku-cell:focus { outline: 3px solid #3498db; outline-offset: -3px; z-index: 2; }

/* Number inside cell */
.cell-value {
    font-size: clamp(20px, 3.5vw, 30px);
    font-weight: bold;
    color: #2c3e50;
    line-height: 1;
    user-select: none;
}
.given .cell-value { color: #1a252f; }
.user-value { color: #2980b9; }
.error .cell-value { color: #c0392b; }

/* Notes grid (3×3 inside cell) */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%; height: 100%;
    padding: 2px;
    gap: 0;
}
.note-num {
    font-size: clamp(7px, 1.3vw, 11px);
    color: #555;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    font-weight: 600;
}
.note-num.active { color: #2980b9; }

/* Number Pad */
.numpad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 8px;
    width: 100%;
    max-width: calc(9 * clamp(46px, 8.5vw, 64px) + 8*8px);
}
.num-btn {
    height: clamp(52px, 8vw, 68px);
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: bold;
    background: rgba(255,255,255,0.9);
    color: #2c3e50;
    border: none; border-radius: 10px;
    cursor: pointer; transition: all 0.15s;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}
.num-btn:hover { background: #fff; transform: scale(1.08); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.num-btn:focus { outline: 4px solid #f39c12; outline-offset: 2px; }
.num-btn.completed { opacity: 0.4; cursor: default; }

/* End Screens */
.result-container {
    max-width: 500px; margin: auto; padding: 60px 40px;
    background: rgba(0,0,0,0.4); border-radius: 20px; text-align: center;
}
.win-container  { border: 3px solid #27ae60; }
.lose-container { border: 3px solid #e74c3c; }
.result-container h1 { font-size: 3rem; margin-bottom: 20px; }
.result-container p  { font-size: 1.5rem; margin-bottom: 12px; opacity: 0.9; }

/* Responsive */
@media (max-width: 768px) {
    .game-header { justify-content: center; }
    .header-left { width: 100%; justify-content: center; }
    .header-center, .header-right { width: 100%; justify-content: center; }
    .numpad { gap: 5px; }
}
@media (max-width: 520px) {
    .numpad { grid-template-columns: repeat(5, 1fr); }
}
