/* ========================================
   Кото-Математика 3000 - Styles
   Mobile-first, kid-friendly design
   ======================================== */

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

:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --accent-color: #FFE66D;
    --success-color: #95E1A3;
    --error-color: #FF8B8B;
    --text-color: #2C3E50;
    --bg-color: #F7F9FC;
    --card-bg: #FFFFFF;
    --font-main: 'Nunito', 'Comic Sans MS', cursive, sans-serif;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Header
   ======================================== */
.header {
    text-align: center;
    padding: 20px 0;
    color: white;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 900;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 5px;
}

.header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 400;
}

/* ========================================
   Statistics Panel
   ======================================== */
.stats-panel {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 700;
}

.stat-correct {
    background: var(--success-color);
    color: #1e5c3a;
}

.stat-wrong {
    background: var(--error-color);
    color: #8b2a2a;
}

.stat-icon {
    font-size: 1.2rem;
}

.stat-label {
    font-size: 0.85rem;
}

.stat-value {
    font-size: 1.3rem;
    min-width: 25px;
    text-align: center;
}

.btn-reset {
    background: var(--accent-color);
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-family: var(--font-main);
    font-weight: 700;
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 0.9rem;
}

.btn-reset:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.btn-reset:active {
    transform: scale(0.98);
}

/* ========================================
   Main Problem Area
   ======================================== */
.problem-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.problem-card {
    background: var(--card-bg);
    border-radius: 25px;
    padding: 25px 20px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
}

/* ========================================
   Cat Helper
   ======================================== */
.cat-helper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: linear-gradient(135deg, #fff5e6 0%, #ffe0b2 100%);
    border-radius: 20px;
}

.cat-avatar {
    font-size: 3rem;
    animation: catBounce 2s ease-in-out infinite;
}

@keyframes catBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.cat-message {
    font-size: 1rem;
    font-weight: 700;
    color: #8b5a2b;
    line-height: 1.4;
}

/* ========================================
   Problem Display
   ======================================== */
.problem-display {
    margin-bottom: 25px;
}

.problem-text {
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: 3px;
}

/* ========================================
   Input Area
   ======================================== */
.input-area {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#answer-input {
    width: 150px;
    padding: 15px 20px;
    font-size: 2rem;
    font-family: var(--font-main);
    font-weight: 700;
    text-align: center;
    border: 3px solid #ddd;
    border-radius: 15px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#answer-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.4);
}

#answer-input.correct {
    border-color: var(--success-color);
    background: #e8f5e9;
    animation: pulse 0.5s ease-in-out;
}

#answer-input.wrong {
    border-color: var(--error-color);
    background: #ffebee;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    50% { transform: translateX(10px); }
    75% { transform: translateX(-10px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.btn-check {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 15px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-check:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
}

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

.btn-icon {
    font-size: 1.3rem;
}

/* ========================================
   Hint Button & Area
   ======================================== */
.btn-hint {
    background: transparent;
    border: 2px dashed var(--secondary-color);
    color: var(--secondary-color);
    padding: 12px 20px;
    border-radius: 15px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn-hint:hover {
    background: var(--secondary-color);
    color: white;
}

.hint-area {
    margin-top: 20px;
    display: none;
}

.hint-area.visible {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hint-card {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 15px;
    padding: 15px;
    margin-top: 10px;
    text-align: left;
    border-left: 4px solid var(--secondary-color);
}

.hint-card-title {
    font-weight: 900;
    color: #2e7d32;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.hint-card-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #1b5e20;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    text-align: center;
    padding: 20px 0;
    color: white;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (min-width: 480px) {
    .header h1 {
        font-size: 2.2rem;
    }

    .problem-text {
        font-size: 3.5rem;
    }

    .cat-message {
        font-size: 1.1rem;
    }
}

@media (min-width: 600px) {
    .app-container {
        padding: 30px 20px;
    }

    .problem-card {
        padding: 35px 30px;
    }
}

/* ========================================
   Confetti Animation (for correct answers)
   ======================================== */
.confetti {
    position: fixed;
    font-size: 20px;
    animation: confettiFall 3s ease-out forwards;
    pointer-events: none;
    z-index: 1000;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

/* ========================================
   Additional Polish Effects
   ======================================== */
.problem-card {
    animation: cardEnter 0.5s ease-out;
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-check:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Smooth transitions for all interactive elements */
.stat-item,
.btn-reset,
.btn-check,
.btn-hint {
    transition: all 0.3s ease;
}

/* Focus visible for accessibility */
.btn-check:focus-visible,
.btn-hint:focus-visible,
.btn-reset:focus-visible,
.btn-settings:focus-visible,
#answer-input:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* ========================================
   Settings Screen
   ======================================== */
.settings-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-card {
    background: var(--card-bg);
    border-radius: 25px;
    padding: 30px 25px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.problem-types-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 25px 0;
    text-align: left;
}

.type-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.type-checkbox:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.type-checkbox input[type="checkbox"] {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.type-checkbox input:checked + .type-label {
    font-weight: 700;
    color: var(--primary-color);
}

.type-label {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
}

.type-example {
    font-size: 0.85rem;
    color: #7f8c8d;
    font-style: italic;
}

.settings-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-select-all {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 15px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-select-all:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.btn-start {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 35px;
    border-radius: 15px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-start:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
}

.btn-start:active {
    transform: scale(0.98);
}

.btn-settings {
    background: var(--accent-color);
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    border-radius: 15px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-settings:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Training screen full height */
.training-screen {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ========================================
   Cat Reward Modal
   ======================================== */
.cat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-in-out;
}

.cat-modal.visible {
    display: flex;
}

.cat-modal-content {
    background: white;
    border-radius: 25px;
    padding: 30px;
    width: min(90vw, 460px);
    max-width: 90%;
    max-height: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: catPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes catPop {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-50px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.cat-modal-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 300px;
    max-height: 60vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    overflow: hidden;
}

.cat-modal-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    object-fit: cover;
    border-radius: 15px;
}

.cat-modal-image img.loaded {
    display: block;
}

.cat-modal-image img.loaded + .cat-loading {
    display: none;
}

.cat-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-main);
    animation: pulse 1s ease-in-out infinite;
}

.cat-modal-praise {
    margin-top: 20px;
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-color);
    font-family: var(--font-main);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.cat-modal-hint {
    margin-top: 10px;
    font-size: 1rem;
    color: #7f8c8d;
    font-family: var(--font-main);
}

.cat-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.cat-modal-close:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.cat-modal-content {
    position: relative;
    cursor: pointer;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
