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

:root {
    --color-add: #D1E7DD;
    --color-sub: #ECB3CD;
    --color-mul: #F8E967;
    --color-div: #A3EE87;
    --color-correct: #28a745;
    --color-incorrect: #dc3545;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: 70px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#app {
    min-height: calc(100vh - 70px);
    position: relative;
}

.screen {
    display: none;
    min-height: calc(100vh - 70px);
    padding: 20px;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Home Screen */
#home-screen {
    background-color: #ffffff;
}

.home-content {
    text-align: center;
}

.home-logo {
    max-width: 300px;
    width: 80%;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s;
}

.home-logo:active {
    transform: scale(0.95);
}

/* Statistics Display */
.statistics {
    margin-top: 32px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 400px;
    width: 90%;
}

.statistics h3 {
    font-size: 1.3rem;
    margin-bottom: 16px;
    color: #333;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: white;
    border-radius: 6px;
    border-left: 4px solid #007bff;
}

.stat-item:nth-child(2) {
    border-left-color: #D1E7DD;
}

.stat-item:nth-child(3) {
    border-left-color: #ECB3CD;
}

.stat-item:nth-child(4) {
    border-left-color: #F8E967;
}

.stat-item:nth-child(5) {
    border-left-color: #A3EE87;
}

.stat-label {
    font-weight: 500;
    color: #555;
}

.stat-value {
    font-weight: 700;
    font-size: 1.2rem;
    color: #007bff;
}

/* Exercise Screens */
.exercise-screen {
    padding: 40px 20px;
}

#add-screen {
    background-color: var(--color-add);
}

#sub-screen {
    background-color: var(--color-sub);
}

#mul-screen {
    background-color: var(--color-mul);
}

#div-screen {
    background-color: var(--color-div);
}

.exercise-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.exercise-container h1 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    text-align: center;
}

.task-counter {
    font-size: 1.2rem;
    margin-bottom: 16px;
    text-align: center;
}

.exercise-text {
    font-size: 1.5rem;
    margin-bottom: 24px;
    text-align: center;
    font-weight: 500;
}

.answer-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.2rem;
    border: 2px solid var(--color-incorrect);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.answer-input.correct {
    border-color: var(--color-correct);
}

.answer-input:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

.answer-input.correct:focus {
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.2);
}

.check-button {
    width: 100%;
    padding: 14px;
    margin-top: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background-color: #007bff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.check-button:hover {
    background-color: #0056b3;
}

.check-button:active {
    transform: scale(0.98);
}

.result-message {
    margin-top: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    min-height: 28px;
}

.result-message.correct {
    color: var(--color-correct);
}

.result-message.incorrect {
    color: var(--color-incorrect);
}

/* Results Table */
.results-table {
    margin-top: 32px;
    overflow-x: auto;
}

.results-table.hidden {
    display: none;
}

.results-table table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.results-table th {
    background-color: #f8f9fa;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid #dee2e6;
}

.results-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.9rem;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.summary {
    margin-top: 24px;
    padding: 16px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.summary p {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

/* Settings Screen */
#settings-screen {
    background-color: #ffffff;
}

.settings-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.settings-container h1 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    text-align: center;
}

.settings-container h2 {
    font-size: 1.3rem;
    margin-bottom: 24px;
    text-align: center;
    color: #333;
}

.settings-info {
    font-size: 1.1rem;
    margin-bottom: 16px;
    text-align: center;
}

.operation-select {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.operation-button {
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 500;
    background-color: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.operation-button:hover {
    background-color: #e9ecef;
    border-color: #007bff;
}

.operation-button:active {
    transform: scale(0.98);
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-form.hidden {
    display: none;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 1rem;
    font-weight: 500;
    color: #333;
}

.settings-input {
    padding: 12px 16px;
    font-size: 1.1rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.settings-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 12px;
    margin-top: 16px;
}

.settings-back-button,
.settings-save-button {
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.settings-back-button {
    background-color: #6c757d;
    color: white;
}

.settings-back-button:hover {
    background-color: #5a6268;
}

.settings-save-button {
    background-color: #007bff;
    color: white;
}

.settings-save-button:hover {
    background-color: #0056b3;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background-color: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.nav-button {
    flex: 1;
    padding: 12px 4px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    background-color: white;
    color: #007bff;
    cursor: pointer;
    transition: all 0.3s;
    border-top: 3px solid transparent;
}

.nav-button:hover {
    background-color: #f8f9fa;
}

.nav-button.active {
    background-color: #fff3cd;
    color: black;
    border-top-color: #ffc107;
}

/* Dialog */
.dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.dialog.hidden {
    display: none;
}

.dialog-content {
    background-color: white;
    padding: 24px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.dialog-content h3 {
    font-size: 1.4rem;
    margin-bottom: 16px;
}

.dialog-content p {
    font-size: 1rem;
    margin-bottom: 24px;
    color: #555;
}

.dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.dialog-button {
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.dialog-button {
    background-color: #6c757d;
    color: white;
}

.dialog-button:hover {
    background-color: #5a6268;
}

.dialog-confirm {
    background-color: #007bff;
}

.dialog-confirm:hover {
    background-color: #0056b3;
}

/* Name Input */
.name-input {
    width: 100%;
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.3s;
}

.name-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

/* Name Button States */
.nav-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #e9ecef;
    color: #6c757d;
}

.nav-button.quit-button {
    background-color: #dc3545;
    color: white;
    font-weight: 600;
}

.nav-button.quit-button:hover:not(:disabled) {
    background-color: #c82333;
}

.nav-button.quit-button.active {
    background-color: #bd2130;
    border-top-color: #dc3545;
}

/* Responsive Design */
@media (max-width: 480px) {
    .exercise-container h1 {
        font-size: 1.5rem;
    }

    .exercise-text {
        font-size: 1.3rem;
    }

    .results-table th,
    .results-table td {
        font-size: 0.8rem;
        padding: 8px 4px;
    }

    .nav-button {
        font-size: 0.75rem;
        padding: 10px 2px;
    }
}

@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    #app {
        min-height: 100vh;
    }

    .screen {
        min-height: 100vh;
    }

    .bottom-nav {
        position: relative;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }

    .nav-button {
        font-size: 1rem;
        padding: 16px 8px;
    }

    .home-logo {
        max-width: 400px;
    }
}

/* Install Prompt (Optional) */
.install-prompt {
    position: fixed;
    bottom: 80px;
    left: 10px;
    right: 10px;
    background-color: #007bff;
    color: white;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: none;
    z-index: 1500;
}

.install-prompt.show {
    display: block;
}

.install-prompt button {
    margin-top: 12px;
    padding: 10px 20px;
    background-color: white;
    color: #007bff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}
