* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 600px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 300;
    color: #333;
    letter-spacing: 2px;
}

/* User Bar */
.user-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
}

.user-name {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.user-btn {
    padding: 4px 12px;
    border: 1px solid #ccc;
    background: white;
    color: #555;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-btn:hover {
    background: #333;
    color: white;
    border-color: #333;
}

/* Auth Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: white;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.modal h2 {
    font-weight: 300;
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 25px;
    letter-spacing: 1px;
}

.auth-btn {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #333;
    background: white;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-btn:hover {
    background: #333;
    color: white;
}

.google-btn {
    margin-bottom: 0;
}

.google-btn:hover svg path {
    fill: white;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #ddd;
}

.auth-divider span {
    padding: 0 15px;
    color: #999;
    font-size: 13px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input {
    padding: 12px 15px;
    border: 2px solid #ddd;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
}

.auth-form input:focus {
    border-color: #333;
}

.email-btn {
    background: #333;
    color: white;
}

.email-btn:hover {
    background: white;
    color: #333;
}

.auth-toggle {
    margin: 20px 0;
    font-size: 13px;
    color: #666;
}

.auth-toggle a {
    color: #333;
    font-weight: 600;
    text-decoration: none;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.anonymous-btn {
    border-style: dashed;
    color: #999;
    border-color: #ccc;
}

.anonymous-btn:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #333;
}

.auth-error {
    color: #c00;
    font-size: 13px;
    margin-top: 15px;
    min-height: 18px;
}

/* Stats Modal */
.stats-modal {
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.stats-header h2 {
    margin-bottom: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: #f9f9f9;
    padding: 15px;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.stat-label {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-modal h3 {
    font-weight: 400;
    font-size: 1rem;
    color: #666;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-empty {
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #f9f9f9;
    font-size: 13px;
}

.history-difficulty {
    font-weight: 600;
    text-transform: capitalize;
    color: #333;
    min-width: 60px;
}

.history-time {
    color: #06c;
    font-weight: 500;
}

.history-mistakes {
    color: #999;
}

.history-date {
    color: #bbb;
    font-size: 12px;
}

/* Controls */
.controls {
    margin-bottom: 20px;
}

.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.difficulty-btn {
    padding: 8px 20px;
    border: 2px solid #333;
    background: white;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.difficulty-btn:hover {
    background: #f0f0f0;
}

.difficulty-btn.active {
    background: #333;
    color: white;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: 2px solid #333;
    background: white;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: #333;
    color: white;
}

/* Game Info */
.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 10px;
}

.timer, .mistakes {
    font-size: 16px;
    font-weight: 500;
    color: #666;
}

/* Sudoku Grid */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    width: 100%;
    aspect-ratio: 1;
    border: 3px solid #333;
    background: #333;
    margin-bottom: 20px;
}

.cell {
    aspect-ratio: 1;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 400;
    color: #333;
    background: white;
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
    box-sizing: border-box;
}

.cell:hover:not(.fixed):not(.correct) {
    background: #f9f9f9;
}

.cell.selected {
    background: #d0d0d0;
    border: 3px solid #333 !important;
    z-index: 10;
}

.cell.fixed {
    font-weight: 600;
    background: #fafafa;
    cursor: default;
}

.cell.wrong {
    background: #fee;
    color: #c00;
}

.cell.correct {
    color: #080;
}

/* Thick borders for 3x3 boxes */
.cell:nth-child(3n) {
    border-right: 2px solid #333;
}

.cell:nth-child(n+19):nth-child(-n+27) {
    border-bottom: 2px solid #333;
}

.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #333;
}

/* Remove borders on edges */
.cell:nth-child(9n) {
    border-right: none;
}

.cell:nth-child(n+73) {
    border-bottom: none;
}

/* Number Pad */
.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 20px;
    max-width: 100%;
}

.number-btn {
    padding: 15px;
    border: 2px solid #333;
    background: white;
    color: #333;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.number-btn:hover {
    background: #333;
    color: white;
}

.number-btn:active {
    transform: scale(0.95);
}

.erase-btn {
    grid-column: span 2;
    background: #f8f8f8;
}

.erase-btn:hover {
    background: #e55;
    color: white;
    border-color: #e55;
}

/* Message */
.message {
    text-align: center;
    padding: 15px;
    font-size: 18px;
    font-weight: 500;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message.success {
    color: #080;
}

.message.error {
    color: #c00;
}

.message.info {
    color: #06c;
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 2rem;
    }

    .cell {
        font-size: 1.2rem;
    }

    .number-btn {
        padding: 12px;
        font-size: 16px;
    }

    .btn {
        padding: 8px 15px;
        font-size: 13px;
    }

    .difficulty-btn {
        padding: 6px 15px;
        font-size: 13px;
    }

    .modal {
        padding: 25px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .history-item {
        flex-wrap: wrap;
        gap: 4px;
    }
}

@media (max-width: 400px) {
    .cell {
        font-size: 1rem;
    }

    .number-pad {
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
    }

    .number-btn {
        padding: 10px;
        font-size: 14px;
    }
}
