/* ==================== ОБЩИЙ СБРОС ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    background: #eef2f7;
    font-family: 'Segoe UI', Arial, sans-serif;
    text-align: center;
    color: #1e293b;
    overflow-x: hidden;
    min-height: 100vh;
}

html {
    overflow-x: hidden;
}

/* ==================== ШАПКА ==================== */
.header {
    font-size: 32px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #1e3a8a;
    color: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 15px 20px;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.level-switcher {
    display: flex;
    border: 3px solid #ffffff;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.level-tab {
    padding: 8px 24px;
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border-right: 2px solid rgba(255, 255, 255, 0.4);
}

.level-tab:last-child {
    border-right: none;
}

.level-tab:hover {
    background: rgba(255, 255, 255, 0.15);
}

.level-tab.active {
    background: #ffffff;
    color: #1e3a8a;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.15);
}

.progress-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

#progressText {
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
    margin-right: 15px;
}

.progress-bar-bg {
    width: 170px;
    height: 14px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #facc15;
    border-radius: 10px;
    position: relative;
    transition: width 0.3s ease-out;
}

.progress-ball {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 10px #ffffff, 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* ==================== МЕНЮ ==================== */
.menu {
    margin-top: 170px;
    padding: 20px;
}

.menu h1 {
    font-size: 56px;
    color: #1e3a8a;
    margin-bottom: 25px;
}

.menu-sub-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 5px;
    margin-bottom: 30px;
}

.sub-btn {
    font-size: 24px;
    padding: 14px 35px;
    margin: 0;
    background: #334155 !important;
}

.sub-btn:hover {
    background: #1e293b !important;
}

.level-info-box {
    font-size: 24px;
    color: #475569;
    line-height: 1.6;
}

/* ==================== ИГРОВОЙ ЭКРАН ==================== */
.game {
    margin-top: 190px;
    padding: 20px;
}

.question {
    font-size: 145px;
    font-weight: 900;
    margin: 15px 0;
    color: #0f172a;
    line-height: 1.1;
    transition: all 0.4s ease;
}

.question.new {
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    0% {
        transform: scale(0.6) rotate(-8deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.1) rotate(4deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

#timerBox {
    font-size: 38px;
    font-weight: bold;
    color: #475569;
    transition: color 0.3s;
}

#timerBox.low {
    color: #dc2626;
    animation: pulse 0.8s infinite;
}

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

/* ==================== КНОПКИ ==================== */
button {
    font-size: 32px;
    font-weight: bold;
    padding: 20px 45px;
    margin: 15px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:active {
    transform: scale(0.96);
}

.blue {
    background: #2563eb;
    color: white;
}

.green {
    background: #16a34a;
    color: white;
}

.red {
    background: #dc2626;
    color: white;
}

.yellow {
    background: #facc15;
    color: black;
}

.start-btn {
    font-size: 40px;
    padding: 24px 80px;
    margin-bottom: 15px;
}

.answer-trigger-btn {
    font-size: 38px;
    padding: 22px 80px;
    width: 100%;
    max-width: 420px;
}

.reset-btn-fixed {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: #2563eb;
    color: white;
    font-size: 18px;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
    z-index: 1000;
    border: none;
    font-weight: bold;
}

/* ==================== ПОПАПЫ ==================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.popup {
    background: white;
    border-radius: 28px;
    text-align: center;
    width: 90%;
    max-width: 620px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
}

.info-popup {
    max-width: 550px;
    padding: 30px;
}

.info-popup h2 {
    font-size: 34px;
    color: #1e3a8a;
    margin-bottom: 20px;
}

.close-modal-btn {
    width: 100%;
    margin: 20px 0 0 0;
    padding: 14px;
    font-size: 26px;
}

.answer {
    font-size: 165px;
    font-weight: 900;
    color: #1e3a8a;
    margin-bottom: 25px;
    line-height: 1;
}

.popup-buttons-row {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.popup-btn {
    flex: 1;
    margin: 0;
    padding: 24px 10px;
    font-size: 34px;
}

.modal-scroll-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px;
    background: #f8fafc;
}

/* ==================== ИСТОРИЯ И РЕКОРДЫ ==================== */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 18px;
}

.history-item:last-child {
    border-bottom: none;
}

.hist-meta {
    text-align: left;
}

.hist-date {
    font-size: 13px;
    color: #64748b;
}

.hist-lvl {
    font-weight: bold;
    color: #1e3a8a;
}

.hist-score {
    font-weight: bold;
    color: #0f172a;
}

.hist-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    font-weight: 900;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.records-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.rec-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 16px;
    border-radius: 14px;
}

.rec-lvl {
    font-size: 18px;
    font-weight: bold;
    color: #475569;
}

.rec-val {
    font-size: 32px;
    font-weight: 900;
    color: #eab308;
    margin-top: 4px;
}

/* ==================== ИТОГОВЫЙ ОТЧЁТ ==================== */
.report-container {
    max-width: 800px;
    margin: 40px auto;
    background: white;
    padding: 40px 30px;
    border-radius: 28px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.06);
    position: relative;
    text-align: center;
}

.grade-badge-container {
    margin-bottom: 35px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.grade-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    color: white;
    font-size: 64px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.grade-label {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.grade-percent {
    font-size: 20px;
    color: #64748b;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 35px;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 18px;
    padding: 22px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stat-val {
    font-size: 34px;
    font-weight: bold;
    margin-bottom: 6px;
}

.stat-lbl {
    font-size: 15px;
    color: #64748b;
    font-weight: 500;
}

.wrong-section {
    text-align: left;
    margin-bottom: 30px;
}

.wrong-section h2 {
    font-size: 26px;
    color: #1e293b;
    margin-bottom: 15px;
}

.wrong-questions-list {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px;
    background: #f8fafc;
}

.wrong-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    margin-bottom: 10px;
    border-radius: 12px;
    font-size: 22px;
    font-weight: bold;
}

.wrong-item:last-child {
    margin-bottom: 0;
}

.item-wrong {
    background: #fef2f2;
    border-left: 6px solid #ef4444;
    color: #991b1b;
}

.item-skipped {
    background: #fff7ed;
    border-left: 6px solid #f97316;
    color: #9a3412;
}

.item-tag {
    font-size: 15px;
    font-weight: normal;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.6);
}

.no-mistakes {
    text-align: center;
    color: #16a34a;
    font-size: 22px;
    font-weight: bold;
    padding: 25px;
}

.reset-btn {
    width: 100%;
    margin: 0;
    padding: 22px;
    font-size: 34px;
}

.no-data-msg {
    color: #64748b;
    font-size: 18px;
    padding: 30px 10px;
}

/* ==================== АНИМАЦИИ ==================== */
.scoreEffect {
    position: fixed;
    z-index: 99999;
    font-size: 46px;
    font-weight: bold;
    animation: scoreFly 1s forwards;
    pointer-events: none;
}

.plus { color: #16a34a; }
.minus { color: #dc2626; }

@keyframes scoreFly {
    0% { opacity: 0; transform: translateY(40px); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-60px); }
}

.countdownScreen {
    position: fixed;
    inset: 0;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
}

#countdownText {
    color: #2563eb;
    font-size: 280px;
    font-weight: 900;
}

.countAnim {
    animation: zoomCountdown 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes zoomCountdown {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ==================== АДАПТИВНОСТЬ ==================== */
@media (max-width: 768px) {
    .header {
        font-size: 24px;
        padding: 12px 10px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .level-switcher { font-size: 18px; }
    .level-tab { padding: 6px 16px; font-size: 18px; }
    .question { font-size: 92px; margin: 10px 0; }
    #timerBox { font-size: 32px; }
    .answer-trigger-btn { font-size: 32px; padding: 18px 60px; }
    .menu h1 { font-size: 42px; }
}