/* ===== CSS Variables ===== */
:root {
    --primary: #4A7CFF;
    --primary-light: #6B9AFF;
    --primary-dark: #3660D9;
    --secondary: #FF6B8A;
    --accent: #FFD93D;
    --accent-green: #4ECDC4;
    --accent-purple: #A78BFA;
    --accent-orange: #FB923C;
    --bg: #F0F4FF;
    --bg-alt: #FFFFFF;
    --card: #FFFFFF;
    --text: #1E293B;
    --text-light: #64748B;
    --text-lighter: #94A3B8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Navigation ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(74, 124, 255, 0.1);
    transition: var(--transition);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 8px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-links a:hover {
    background: rgba(74, 124, 255, 0.1);
    color: var(--primary);
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-xl);
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary);
    transition: var(--transition);
}

.lang-toggle:hover {
    background: var(--primary);
    color: white;
}

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: var(--transition);
}

/* ===== Hero ===== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 100px 24px 60px;
}

.hero-bg-shapes {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    top: -100px;
    right: -100px;
    animation: float 8s ease-in-out infinite;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary);
    bottom: -50px;
    left: -50px;
    animation: float 6s ease-in-out infinite reverse;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: var(--accent-green);
    top: 50%;
    left: 50%;
    animation: float 10s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(5deg); }
}

.hero-content {
    text-align: center;
    z-index: 1;
    max-width: 600px;
}

.hero-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px 20px;
    border-radius: var(--radius-xl);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.hero-title {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 800;
    color: white;
    line-height: 1.1;
    margin-bottom: 16px;
}

.hero-class {
    display: block;
    font-size: clamp(4rem, 12vw, 7rem);
    background: linear-gradient(135deg, #FFD93D, #FF6B8A);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.hero-subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.hero-desc {
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.1rem;
    margin-bottom: 32px;
}

.hero-btn {
    display: inline-block;
    padding: 14px 36px;
    background: white;
    color: var(--primary-dark);
    text-decoration: none;
    border-radius: var(--radius-xl);
    font-weight: 700;
    font-size: 1rem;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.hero-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.hero-illustration {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hero-illustration > div {
    position: absolute;
    font-size: 2.5rem;
    animation: floatEmoji 6s ease-in-out infinite;
    opacity: 0.6;
}

.hero-book { top: 20%; left: 10%; animation-delay: 0s; }
.hero-star { top: 15%; right: 15%; animation-delay: 1s; }
.hero-pencil { bottom: 25%; left: 15%; animation-delay: 2s; }
.hero-globe { bottom: 20%; right: 10%; animation-delay: 3s; }
.hero-music { top: 40%; right: 25%; animation-delay: 4s; }

@keyframes floatEmoji {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(5deg); }
    75% { transform: translateY(10px) rotate(-5deg); }
}

/* ===== Sections ===== */
.section {
    padding: 80px 0;
}

.section-alt {
    background: white;
}

.section-title {
    text-align: center;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 48px;
}

/* ===== Student Cards ===== */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
}

.student-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.student-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.student-card.highlight {
    border-color: var(--accent);
    background: linear-gradient(135deg, #FFF9E6, #FFFFFF);
}

.student-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    position: relative;
    box-shadow: var(--shadow-md);
}

.student-avatar::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

.student-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.student-desc {
    font-size: 0.75rem;
    color: var(--text-light);
    line-height: 1.4;
    margin-bottom: 2px;
}

.student-emoji {
    font-size: 1.2rem;
    margin-top: 4px;
    display: block;
}

/* ===== Teacher Cards ===== */
.teachers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.teacher-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    border: 2px solid transparent;
}

.teacher-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.teacher-card.main-teacher {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #EEF2FF, #FDF2F8);
    border-color: var(--primary-light);
    padding: 36px;
}

.teacher-avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.teacher-card.main-teacher .teacher-avatar {
    width: 80px;
    height: 80px;
    font-size: 2.2rem;
}

.teacher-info h3 {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.teacher-subject {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
}

.teacher-desc {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ===== Gallery ===== */
.gallery-filters {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 20px;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-xl);
    background: white;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.gallery-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--card);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.gallery-image {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    position: relative;
    overflow: hidden;
}

.gallery-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.05) 100%);
}

.gallery-image .placeholder-text {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.2);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    z-index: 1;
}

.gallery-info {
    padding: 16px 20px;
}

.gallery-info h3 {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.gallery-info p {
    font-size: 0.85rem;
    color: var(--text-light);
}

.gallery-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: var(--radius-xl);
    margin-top: 8px;
}

.gallery-card.hidden {
    display: none;
}

/* ===== Fun Section ===== */
.fun-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

/* Кнопка «Добавить юмор» — только для админа */
#funGrid .add-item-card { display: none; }
.admin-mode #funGrid .add-item-card { display: flex; }

.fun-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: var(--transition);
    position: relative;
}

.fun-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.fun-card-emoji {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.fun-card h3 {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.fun-card p {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.7;
}

.fun-card .joke-answer {
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(74, 124, 255, 0.08);
    border-radius: var(--radius-md);
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.fun-card .joke-answer.hidden-answer {
    color: rgba(74, 124, 255, 0.08);
    background: repeating-linear-gradient(
        45deg,
        rgba(74, 124, 255, 0.05),
        rgba(74, 124, 255, 0.05) 10px,
        rgba(74, 124, 255, 0.1) 10px,
        rgba(74, 124, 255, 0.1) 20px
    );
}

.fun-card .joke-answer.hidden-answer::after {
    content: '👆';
    display: block;
    text-align: center;
    font-size: 0.8rem;
    margin-top: 4px;
    color: var(--text-light);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    padding: 24px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
    box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: #F1F5F9;
}

.modal-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-lg);
}

.modal-name {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.modal-desc {
    color: var(--primary);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.modal-hobby {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 16px;
}

.modal-quote {
    font-style: italic;
    color: var(--text);
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    position: relative;
}

.modal-quote::before {
    content: '\201C';
    font-size: 2rem;
    color: var(--primary-light);
    position: absolute;
    top: 4px;
    left: 12px;
    line-height: 1;
}

/* ===== Footer ===== */
.footer {
    background: linear-gradient(135deg, #1E293B, #334155);
    color: white;
    padding: 48px 0;
    text-align: center;
}

.footer-logo {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.footer-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.footer-heart {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 16px;
        box-shadow: var(--shadow-lg);
        border-radius: 0 0 var(--radius-md) var(--radius-md);
    }

    .nav-links.open {
        display: flex;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .students-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 12px;
    }

    .student-card {
        padding: 16px 12px;
    }

    .student-avatar {
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
    }

    .teachers-grid {
        grid-template-columns: 1fr;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .fun-grid {
        grid-template-columns: 1fr;
    }

    .section {
        padding: 60px 0;
    }

    .hero {
        padding: 80px 16px 40px;
    }

    .hero-illustration > div {
        font-size: 1.5rem;
        opacity: 0.4;
    }
}

@media (max-width: 480px) {
    .students-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .student-name {
        font-size: 0.8rem;
    }

    .student-desc {
        display: none;
    }
}

/* ===== Animations ===== */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

/* ===== Avatar / Teacher Photos ===== */
.student-avatar {
    overflow: hidden;
}

.avatar-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    z-index: 1;
}

.avatar-photo.broken { display: none; }

.teacher-avatar {
    overflow: hidden;
    position: relative;
}

.teacher-avatar-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
    z-index: 1;
}

.teacher-avatar-photo.broken { display: none; }

.gallery-image { position: relative; }

.gallery-real-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
}

.gallery-real-photo.broken { display: none; }

.gallery-card { position: relative; }
.teacher-card { position: relative; }

/* ===== Drag Handle Button ===== */
.drag-handle-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: rgba(100, 116, 139, 0.18);
    color: #64748b;
    font-size: 1.1rem;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 20;
    touch-action: none;
    transition: background 0.15s, color 0.15s;
}

.drag-handle-btn:hover {
    background: rgba(74, 124, 255, 0.18);
    color: var(--primary);
}

.drag-handle-btn:active { cursor: grabbing; }

body.admin-mode .drag-handle-btn { display: flex; }

/* ===== Edit Photo Button ===== */
.edit-photo-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(74, 124, 255, 0.92);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    z-index: 20;
}

.edit-photo-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

body.admin-mode .edit-photo-btn {
    display: flex;
}

.edit-text-btn {
    position: absolute;
    top: 8px;
    right: 46px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(16, 185, 129, 0.92);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    z-index: 20;
}

.edit-text-btn:hover {
    background: #059669;
    transform: scale(1.1);
}

body.admin-mode .edit-text-btn {
    display: flex;
}

/* ===== Text Edit Modal ===== */
.edit-text-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    padding: 24px;
}

.edit-text-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.edit-text-modal {
    background: white;
    border-radius: var(--radius-xl);
    padding: 36px;
    max-width: 500px;
    width: 100%;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
    box-shadow: var(--shadow-xl);
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
}

.edit-text-modal-overlay.active .edit-text-modal {
    transform: scale(1) translateY(0);
}

.edit-text-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.edit-text-modal-close:hover { background: #F1F5F9; }

.edit-text-modal h3 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 20px;
    padding-right: 40px;
}

.edit-field-group {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-md);
    padding: 14px 14px 2px;
    margin-bottom: 14px;
}

.edit-field-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.edit-field-group-header span {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.translate-btn {
    font-size: 0.78rem;
    padding: 4px 10px;
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, #4A7CFF, #7C5CBF);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}

.translate-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.translate-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.translate-status {
    font-size: 0.85rem;
    font-weight: 700;
    color: #10B981;
    min-width: 16px;
    text-align: right;
}

.edit-text-field {
    margin-bottom: 16px;
}

.edit-text-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.edit-text-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    resize: vertical;
    min-height: 60px;
    outline: none;
    transition: var(--transition);
    line-height: 1.5;
}

.edit-text-field textarea:focus { border-color: var(--primary); }

.edit-text-status {
    font-size: 0.9rem;
    min-height: 20px;
    margin-bottom: 12px;
    text-align: center;
}

.edit-text-save-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.edit-text-save-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.edit-text-save-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

/* ===== Add Item Card ===== */
.add-item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px dashed #CBD5E1;
    border-radius: var(--radius-xl);
    background: #F8FAFC;
    cursor: pointer;
    min-height: 140px;
    transition: var(--transition);
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.9rem;
}

.add-item-card:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #EEF2FF;
}

.add-item-icon {
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
}

/* ===== Delete Item Button ===== */
.delete-item-btn {
    position: absolute;
    top: 8px;
    right: 84px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #EF4444;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: var(--transition);
}

.delete-item-btn:hover { background: #DC2626; transform: scale(1.1); }
body.admin-mode .delete-item-btn { display: flex; }

/* ===== Add Modal Extra Fields ===== */
.add-extra-row {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.add-simple-field {
    flex: 1;
}

.add-simple-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.add-simple-field input,
.add-simple-field select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    background: white;
}

.add-simple-field input:focus,
.add-simple-field select:focus { border-color: var(--primary); }

.edit-photo-btn.uploading {
    animation: spin 1s linear infinite;
    pointer-events: none;
    background: #F59E0B;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Admin Badge ===== */
.admin-badge {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-xl);
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-badge button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-xl);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
}

.admin-badge button:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ===== Admin Login Modal ===== */
.admin-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    padding: 24px;
}

.admin-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.admin-modal {
    background: white;
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
    box-shadow: var(--shadow-xl);
    position: relative;
}

.admin-modal-overlay.active .admin-modal {
    transform: scale(1) translateY(0);
}

.admin-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.admin-modal-close:hover { background: #F1F5F9; }

.admin-modal-icon { font-size: 3rem; margin-bottom: 16px; }

.admin-modal h3 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.admin-modal p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.admin-modal input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    margin-bottom: 12px;
}

.admin-modal input:focus { border-color: var(--primary); }

.admin-login-status {
    font-size: 0.85rem;
    color: #EF4444;
    min-height: 20px;
    margin-bottom: 8px;
}

.admin-login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.admin-login-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.admin-login-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Student Drag & Drop ===== */
.student-card.dnd-source {
    opacity: 0.28;
    transform: scale(0.96);
    transition: opacity 0.2s, transform 0.2s;
}

.student-card.drop-left {
    box-shadow: -4px 0 0 0 var(--primary), var(--shadow-sm);
}

.student-card.drop-right {
    box-shadow: 4px 0 0 0 var(--primary), var(--shadow-sm);
}

#trashZone {
    position: fixed;
    bottom: -110px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: #fff;
    border-radius: 999px;
    padding: 16px 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    z-index: 9998;
    transition: bottom 0.35s cubic-bezier(0.34,1.56,0.64,1),
                background 0.2s, transform 0.2s;
    box-shadow: 0 8px 32px rgba(239,68,68,0.45);
    pointer-events: none;
    user-select: none;
}

#trashZone span:first-child {
    font-size: 1.4rem;
}

#trashZone.visible {
    bottom: 36px;
    pointer-events: all;
}

#trashZone.over {
    background: linear-gradient(135deg, #DC2626, #991B1B);
    transform: translateX(-50%) scale(1.12);
    box-shadow: 0 14px 48px rgba(239,68,68,0.65);
}

/* Delete confirm dialog */
#deleteConfirmOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.18s ease;
}

#deleteConfirmBox {
    background: #fff;
    border-radius: 24px;
    padding: 36px 32px 28px;
    max-width: 340px;
    width: 90%;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,0.22);
    animation: popIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

#deleteConfirmBox .confirm-emoji {
    font-size: 3rem;
    margin-bottom: 12px;
}

#deleteConfirmBox .confirm-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 8px;
}

#deleteConfirmBox .confirm-sub {
    font-size: 0.92rem;
    color: #64748b;
    margin-bottom: 28px;
}

#deleteConfirmBox .confirm-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
}

#deleteConfirmBox .confirm-btns button {
    flex: 1;
    padding: 12px 0;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

#deleteConfirmBox .btn-cancel {
    background: #f1f5f9;
    color: #475569;
}

#deleteConfirmBox .btn-cancel:hover {
    background: #e2e8f0;
    transform: scale(1.03);
}

#deleteConfirmBox .btn-delete {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: #fff;
    box-shadow: 0 4px 16px rgba(239,68,68,0.35);
}

#deleteConfirmBox .btn-delete:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(239,68,68,0.5);
}

/* ===== MASKS SECTION ===== */
.masks-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 0;
}
.masks-section-header .section-title,
.masks-section-header .section-subtitle {
    text-align: left;
    margin-left: 0;
}

.masks-edit-btn {
    display: none;
    background: var(--card);
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    margin-top: 16px;
    box-shadow: var(--shadow-sm);
    align-items: center;
    justify-content: center;
}
.masks-edit-btn:hover { border-color: #667eea; background: #f0f0ff; }
.masks-edit-btn.active { background: #667eea; border-color: #667eea; }
.admin-mode .masks-edit-btn { display: flex; }


.masks-list {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-top: 32px;
}

/* Маска: название + прямоугольник */
.mask-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mask-item-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    padding-left: 4px;
}

.mask-rect {
    width: 100%;
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.28);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}
.mask-rect:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(102, 126, 234, 0.45);
}
.mask-rect-icon { font-size: 4rem; }
.mask-rect-desc {
    font-size: 1.05rem;
    opacity: 0.88;
    max-width: 480px;
    line-height: 1.55;
}
.mask-rect-btn {
    margin-top: 8px;
    background: rgba(255,255,255,0.22);
    border: 2px solid rgba(255,255,255,0.55);
    padding: 13px 36px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    transition: var(--transition);
}
.mask-rect:hover .mask-rect-btn { background: rgba(255,255,255,0.38); }

/* Кнопка удалить (в строке с названием) */
.mask-no-delete-hint {
    font-size: 0.75rem;
    color: var(--text-lighter);
    background: #f1f5f9;
    padding: 3px 10px;
    border-radius: 20px;
}

.mask-delete-btn {
    background: #fee2e2;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.mask-delete-btn:hover { background: #ef4444; }

.mask-add-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 2.5px dashed #c7d2fe;
    border-radius: var(--radius-lg);
    padding: 28px;
    cursor: pointer;
    color: #667eea;
    font-weight: 700;
    font-size: 1rem;
    transition: var(--transition);
    background: rgba(102,126,234,0.04);
}
.mask-add-card:hover { background: rgba(102,126,234,0.1); border-color: #667eea; }
.mask-add-icon { font-size: 1.5rem; font-weight: 900; }

@media (max-width: 600px) {
    .mask-rect { padding: 36px 20px; }
    .masks-section-header .section-title,
    .masks-section-header .section-subtitle { text-align: center; }
}

/* ===== TOURNAMENT ===== */
.tournament-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.tournament-overlay.active { display: flex; }

.tournament-container {
    background: var(--bg);
    border-radius: 24px;
    width: 100%;
    max-width: 680px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.tournament-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 24px 16px;
    color: #fff;
}
.tournament-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.tournament-trophy { font-size: 1.5rem; }
.tournament-title { font-size: 1.1rem; font-weight: 700; flex: 1; }
.tournament-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 32px; height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.tournament-close:hover { background: rgba(255,255,255,0.35); }

.tournament-progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.tournament-progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.25);
    border-radius: 4px;
    overflow: hidden;
}
.tournament-progress-fill {
    height: 100%;
    background: #fff;
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
}
.tournament-progress-text {
    font-size: 0.8rem;
    opacity: 0.85;
    white-space: nowrap;
}

.tournament-vs-screen {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 32px 24px;
    gap: 16px;
}
.tournament-card {
    flex: 1;
    background: var(--bg-card, #f8f9ff);
    border: 3px solid transparent;
    border-radius: 20px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.tournament-card:hover {
    border-color: #667eea;
    transform: scale(1.03);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.2);
}
.tournament-card.chosen {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
    transform: scale(1.05);
}
.tournament-card.rejected {
    opacity: 0.3;
    transform: scale(0.95);
}
.tournament-card-emoji { font-size: 4rem; }
.tournament-card-name { font-size: 1.3rem; font-weight: 800; color: var(--text); }
.tournament-card-hint { font-size: 0.8rem; color: var(--text-light); }

.tournament-vs-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text-light);
    flex-shrink: 0;
    width: 40px;
}

.tournament-winner-screen {
    text-align: center;
    padding: 48px 32px;
    position: relative;
    overflow: hidden;
}
.tournament-winner-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.tournament-winner-emoji { font-size: 5rem; margin-bottom: 8px; }
.tournament-winner-crown { font-size: 3rem; margin-bottom: 4px; }
.tournament-winner-name {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}
.tournament-winner-label {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 28px;
}
.tournament-restart-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    padding: 14px 32px;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 6px 24px rgba(102,126,234,0.4);
}
.tournament-restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(102,126,234,0.55);
}

/* confetti particles */
.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confetti-fall 2s ease-in forwards;
}
@keyframes confetti-fall {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(300px) rotate(720deg); opacity: 0; }
}

@media (max-width: 600px) {
    .tournament-banner { flex-direction: column; text-align: center; }
    .tournament-vs-screen { flex-direction: column; }
    .tournament-vs-badge { transform: rotate(90deg); }
    .tournament-card-emoji { font-size: 3rem; }
}
