/* Импорт рукописного шрифта */
@import url('https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap');

/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Kalam', cursive;
    line-height: 1.6;
    color: #1e3a8a; /* Синий цвет ручки */
    background: #f8fafc;
    min-height: 100vh;
    position: relative;
}

/* Фон тетради в клетку */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(to right, #e5e7eb 1px, transparent 1px),
        linear-gradient(to bottom, #e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: -1;
    opacity: 0.3;
}

/* Красная линия полей */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 60px;
    width: 2px;
    height: 100%;
    background: #ef4444;
    z-index: -1;
    opacity: 0.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 80px 40px 100px; /* Отступ от красной линии */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Заголовок */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    border-bottom: 2px solid #1e3a8a;
    position: relative;
}

header h1 {
    font-size: 3em;
    margin-bottom: 15px;
    color: #1e3a8a;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(30, 58, 138, 0.1);
    -webkit-transform: rotate(-1deg);
    -moz-transform: rotate(-1deg);
    -ms-transform: rotate(-1deg);
    transform: rotate(-1deg);
}

header p {
    font-size: 1.4em;
    color: #3730a3;
    font-weight: 400;
    transform: rotate(0.5deg);
}

.grade-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    transform: rotate(-0.3deg);
}

.current-grade {
    background: #1e3a8a;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 1.2em;
    transform: rotate(1deg);
}

.back-link {
    color: #1e3a8a;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1em;
    border-bottom: 2px dotted #1e3a8a;
}

.back-link:hover {
    color: #3730a3;
    transform: scale(1.05);
}

/* Основной контент */
main {
    flex: 1;
    padding: 20px 0;
}

/* Выбор класса */
.grade-selection {
    text-align: center;
}

.grade-selection h2 {
    margin-bottom: 40px;
    color: #1e3a8a;
    font-size: 2.2em;
    font-weight: 700;
    transform: rotate(-0.5deg);
}

.grade-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.grade-btn {
    display: block;
    text-decoration: none;
    background: #ffffff;
    color: #1e3a8a;
    padding: 30px 20px;
    border: 3px solid #1e3a8a;
    border-radius: 15px;
    transition: all 0.3s ease;
    box-shadow: 3px 3px 0px #1e3a8a;
    transform: rotate(-1deg);
}

.grade-btn:hover {
    transform: rotate(0deg) translateY(-3px);
    box-shadow: 5px 5px 0px #1e3a8a;
    background: #f0f4ff;
}

.grade-btn:nth-child(even) {
    transform: rotate(1deg);
}

.grade-btn:nth-child(even):hover {
    transform: rotate(0deg) translateY(-3px);
}

.grade-number {
    display: block;
    font-size: 3.5em;
    font-weight: 700;
    margin-bottom: 8px;
}

.grade-desc {
    display: block;
    font-size: 1.3em;
    margin-bottom: 12px;
    font-weight: 600;
}

.grade-btn small {
    display: block;
    font-size: 1em;
    color: #3730a3;
    font-weight: 400;
}

/* Упражнения */
.exercise-container h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #1e3a8a;
    font-size: 2.2em;
    font-weight: 700;
    transform: rotate(-0.8deg);
}

.instruction {
    text-align: center;
    margin-bottom: 35px;
    font-size: 1.3em;
    color: #3730a3;
    background: rgba(30, 58, 138, 0.1);
    padding: 20px;
    border-radius: 15px;
    border: 2px dashed #1e3a8a;
    transform: rotate(0.3deg);
    font-weight: 600;
}

.problems-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.problem-item {
    background: #ffffff;
    border: 2px solid #1e3a8a;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    transform: rotate(-0.5deg);
    box-shadow: 2px 2px 0px #1e3a8a;
}

.problem-item:nth-child(even) {
    transform: rotate(0.5deg);
}

.problem-item:hover {
    transform: rotate(0deg) translateY(-2px);
    box-shadow: 4px 4px 0px #1e3a8a;
    background: #f0f4ff;
}

.problem-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #1e3a8a;
    font-size: 1.2em;
}

.problem-number {
    color: #ef4444; /* Красная ручка для номеров */
    font-weight: 700;
    font-size: 1.2em;
}

.problem-expression {
    font-size: 1.3em;
    margin-left: 10px;
    font-weight: 600;
}

.answer-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #1e3a8a;
    border-radius: 8px;
    font-size: 1.3em;
    text-align: center;
    font-family: 'Kalam', cursive;
    font-weight: 600;
    color: #1e3a8a;
    background: #ffffff;
    transition: all 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: #3730a3;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.2);
    background: #f0f4ff;
}

.answer-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* Кнопки действий */
.form-actions {
    text-align: center;
}

.check-btn {
    background: #1e3a8a;
    color: white;
    border: 3px solid #1e3a8a;
    padding: 18px 45px;
    border-radius: 25px;
    font-size: 1.4em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Kalam', cursive;
    box-shadow: 3px 3px 0px #0f172a;
    transform: rotate(-1deg);
}

.check-btn:hover {
    transform: rotate(0deg) translateY(-3px);
    box-shadow: 5px 5px 0px #0f172a;
    background: #3730a3;
}

/* Результаты */
.results-container {
    text-align: center;
}

.score-summary {
    margin-bottom: 50px;
    padding: 30px;
    background: rgba(220, 38, 38, 0.05);
    border: 3px dashed #dc2626;
    border-radius: 20px;
    transform: rotate(-0.5deg);
    position: relative;
}

.score-summary::before {
    content: '👨‍🏫';
    position: absolute;
    top: -15px;
    right: 20px;
    font-size: 2em;
    background: #ffffff;
    padding: 5px;
    border-radius: 50%;
    border: 2px solid #dc2626;
}

.score-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 25px;
    box-shadow: 5px 5px 0px #dc2626;
    border: 4px solid #dc2626;
    position: relative;
    transform: rotate(-3deg);
}

.score-circle::before {
    content: '';
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #dc2626;
    border-radius: 50%;
    opacity: 0.3;
}

.score-number {
    color: #dc2626;
    font-size: 3em;
    font-weight: 700;
    text-shadow: 1px 1px 0px rgba(220, 38, 38, 0.3);
}

.grade-text {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #dc2626;
    font-weight: 700;
    transform: rotate(0.8deg);
    text-shadow: 1px 1px 0px rgba(220, 38, 38, 0.2);
    position: relative;
}

.grade-text::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%) rotate(-1deg);
    width: 90%;
    height: 4px;
    background: #dc2626;
    border-radius: 2px;
    opacity: 0.6;
}

.score-details {
    font-size: 1.4em;
    color: #dc2626;
    background: #ffffff;
    padding: 18px 25px;
    border-radius: 15px;
    display: inline-block;
    border: 2px solid #dc2626;
    font-weight: 600;
    transform: rotate(-0.3deg);
    position: relative;
}

.score-details::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    color: #dc2626;
    font-size: 1.5em;
    font-weight: 700;
    background: #ffffff;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #dc2626;
}

.teacher-signature {
    margin-top: 25px;
    text-align: right;
    color: #dc2626;
    font-weight: 600;
    transform: rotate(1deg);
    font-style: italic;
}

.signature-text {
    display: block;
    font-size: 1.1em;
    margin-bottom: 5px;
    text-decoration: underline;
    text-decoration-color: #dc2626;
    text-decoration-thickness: 2px;
}

.signature-date {
    display: block;
    font-size: 0.9em;
    opacity: 0.8;
}

/* Разбор заданий */
.problems-review {
    margin-bottom: 50px;
    text-align: left;
}

.problems-review h3 {
    text-align: center;
    margin-bottom: 30px;
    color: #1e3a8a;
    font-size: 2em;
    font-weight: 700;
    transform: rotate(-0.6deg);
}

.problem-result {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #1e3a8a;
    margin-bottom: 18px;
    transform: rotate(-0.2deg);
    box-shadow: 2px 2px 0px #1e3a8a;
}

.problem-result:nth-child(even) {
    transform: rotate(0.2deg);
}

.problem-result:hover {
    transform: rotate(0deg) translateY(-2px);
    box-shadow: 4px 4px 0px #1e3a8a;
    background: #f0f4ff;
}

.problem-result.correct {
    border-color: #16a34a; /* Зелёная ручка для правильных */
    background: #f0fdf4;
}

.problem-result.incorrect {
    border-color: #dc2626; /* Красная ручка для неправильных */
    background: #fef2f2;
}

.problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #9ca3af;
}

.problem-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.problem-expression {
    font-weight: 600;
    color: #1e3a8a;
    font-size: 1.3em;
    flex: 1;
    text-align: left;
}

.answer-comparison {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    justify-content: flex-end;
}

.user-answer.wrong-answer {
    text-decoration: line-through;
    text-decoration-color: #dc2626;
    text-decoration-thickness: 3px;
    color: #dc2626;
    font-weight: 700;
    font-size: 1.2em;
    text-align: center;
}

.user-answer.correct-answer {
    color: #16a34a;
    font-weight: 700;
    font-size: 1.2em;
    text-align: center;
}

.correct-answer-display {
    color: #16a34a;
    font-weight: 700;
    background: #f0fdf4;
    padding: 6px 12px;
    border-radius: 8px;
    border: 2px solid #16a34a;
    font-size: 1.2em;
    text-align: center;
    white-space: nowrap;
}

.status-icon {
    font-size: 1.5em;
    font-weight: 700;
}

.problem-result.correct .status-icon {
    color: #16a34a;
}

.problem-result.incorrect .status-icon {
    color: #dc2626;
}

/* Действия */
.actions {
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.action-btn {
    display: inline-block;
    padding: 15px 30px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.3s ease;
    border: 3px solid #1e3a8a;
    cursor: pointer;
    font-size: 1.2em;
    font-family: 'Kalam', cursive;
    transform: rotate(-1deg);
    box-shadow: 3px 3px 0px #1e3a8a;
}

.retry-btn {
    background: #ffffff;
    color: #1e3a8a;
}

.retry-btn:hover {
    transform: rotate(0deg) translateY(-3px);
    box-shadow: 5px 5px 0px #1e3a8a;
    background: #f0f4ff;
}

/* Поделиться */
.share-section {
    display: block;
    margin-top: 30px;
    text-align: left;
    background: #ffffff;
    padding: 25px;
    border: 3px dashed #1e3a8a;
    border-radius: 15px;
    transform: rotate(0.3deg);
}

.share-section h4 {
    display: block;
    margin-bottom: 18px;
    color: #1e3a8a;
    font-size: 1.4em;
    font-weight: 700;
}

.messenger-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.messenger-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1em;
    transition: all 0.3s ease;
    border: 3px solid;
    transform: rotate(-1deg);
    box-shadow: 3px 3px 0px;
    cursor: pointer;
    background: none;
    font-family: 'Kalam', cursive;
}

.whatsapp-btn {
    display: flex;
    background: #25d366;
    color: white;
    border-color: #128c7e;
    box-shadow: 3px 3px 0px #128c7e;
}

.whatsapp-btn:hover {
    transform: rotate(0deg) translateY(-3px);
    box-shadow: 5px 5px 0px #128c7e;
    background: #22c55e;
}

.telegram-btn {
    display: flex;
    background: #0088cc;
    color: white;
    border-color: #006bb3;
    box-shadow: 3px 3px 0px #006bb3;
    transform: rotate(1deg);
}

.telegram-btn:hover {
    transform: rotate(0deg) translateY(-3px);
    box-shadow: 5px 5px 0px #006bb3;
    background: #0ea5e9;
}

.messenger-icon {
    font-size: 1.3em;
}

.print-link {
    text-align: center;
}

.print-btn {
    display: inline-block;
    padding: 12px 20px;
    background: #ffffff;
    color: #1e3a8a;
    border: 2px solid #1e3a8a;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    transform: rotate(-0.5deg);
}

.print-btn:hover {
    transform: rotate(0deg) translateY(-2px);
    background: #f0f4ff;
    box-shadow: 2px 2px 0px #1e3a8a;
}

/* Подвал */
footer {
    text-align: center;
    margin-top: 40px;
    color: #1e3a8a;
    font-size: 1.3em;
    font-weight: 600;
    padding: 20px;
    border-top: 2px dashed #1e3a8a;
    transform: rotate(0.2deg);
}

/* Специальные эффекты для "рукописности" */
.problem-number {
    color: #ef4444; /* Красная ручка для номеров */
    font-weight: 700;
    font-size: 1.2em;
}

.problem-expression {
    font-size: 1.4em;
    margin-left: 12px;
    font-weight: 600;
}

/* Имитация чернильных клякс */
.grade-btn::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 15px;
    width: 8px;
    height: 8px;
    background: #1e3a8a;
    border-radius: 50%;
    opacity: 0.3;
}

/* Адаптивность */
@media (max-width: 768px) {
    body::after {
        left: 30px;
    }
    
    .container {
        padding: 20px 40px 20px 50px;
    }
    
    header h1 {
        font-size: 2.2em;
    }
    
    .grade-buttons {
        grid-template-columns: 1fr;
    }
    
    .problems-grid {
        grid-template-columns: 1fr;
    }
    
    .actions {
        flex-direction: column;
        align-items: center;
    }
    
    .grade-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .problem-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .answer-comparison {
        align-self: flex-end;
        margin-top: 8px;
        justify-content: flex-start;
        width: 100%;
    }
    
    .problem-expression {
        font-size: 1.2em;
        word-break: break-all;
        hyphens: auto;
    }
    
    .user-answer.wrong-answer,
    .user-answer.correct-answer,
    .correct-answer-display {
        font-size: 1.1em;
    }
    
    .problem-result {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .problem-line {
        gap: 8px;
    }
    
    .problem-expression {
        font-size: 1.1em;
        line-height: 1.4;
    }
    
    .answer-comparison {
        gap: 8px;
    }
    
    .user-answer.wrong-answer,
    .user-answer.correct-answer,
    .correct-answer-display {
        font-size: 1em;
        padding: 4px 8px;
    }
}

/* Дополнительные рукописные эффекты */
h1, h2, h3, .grade-text {
    position: relative;
}

/* Имитация подчёркивания ручкой */
.grade-text::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(-0.5deg);
    width: 80%;
    height: 3px;
    background: #1e3a8a;
    border-radius: 2px;
    opacity: 0.7;
} 