/* ============================================================
   ⌨️ TYPING TEST MODAL — WHITE THEME + GREEN TEXT
   BOSC Tech & Edu · Hoṛ Katha Suite v3.7.4
   ============================================================ */
/* ✅ v3.7.4.70 — PERFECT TYPING TEST:
      • White theme with green accents
      • Responsive grid (3-col → 2-col → 1-col)
      • Timer states (warn/danger)
      • Live stats cards
      • Character highlighting (correct/wrong/current)
      • Result hero with animated grade badge
      • Mobile-optimized (400px+)
      • Reduced motion support
      • Print styles
      • Null-safe CSS variables
   ============================================================ */

/* ============================================================
   📐 MODAL WINDOW — WHITE
   ============================================================ */
.tt-modal-window {
    max-width: 950px !important;
    width: 96vw !important;
    max-height: 95vh !important;
    max-height: 95dvh !important;
    background: #ffffff !important;
    color: #0f172a !important;
}

.tt-modal-window .modal-header {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
    border-bottom: 2px solid #16a34a !important;
    color: #14532d !important;
}

.tt-modal-window .modal-title {
    color: #14532d !important;
    font-weight: 900;
}

.tt-modal-window .modal-close {
    color: #166534 !important;
    background: #ffffff !important;
    border: 1.5px solid #16a34a !important;
}

.tt-modal-window .modal-close:hover {
    background: #16a34a !important;
    color: #ffffff !important;
}

.tt-modal-window .modal-close:focus-visible {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}

.tt-modal-window .modal-body {
    background: #ffffff !important;
    color: #0f172a !important;
}

/* ============================================================
   ═══ SETUP VIEW ═══
   ============================================================ */
.tt-section-title {
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #16a34a;
    margin-bottom: 6px;
    margin-top: 12px;
}

.tt-lessons-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 8px;
}

.tt-lesson-col {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
}

.tt-lesson-heading {
    font-size: 0.75rem;
    font-weight: 900;
    color: #16a34a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px 0;
    padding-bottom: 6px;
    border-bottom: 1.5px solid #d1fae5;
    line-height: 1.3;
}

.tt-lesson-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: #ffffff;
    border: 1.5px solid #e5e7eb;
    color: #0f172a;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 6px;
    transition: all 0.15s;
    line-height: 1.3;
}

.tt-lesson-btn:hover {
    border-color: #16a34a;
    background: #f0fdf4;
    color: #14532d;
}

.tt-lesson-btn.active {
    background: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.tt-lesson-btn:focus-visible {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}

.tt-lesson-btn:last-child {
    margin-bottom: 0;
}

.tt-time-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.tt-time-btn {
    flex: 1;
    min-width: 80px;
    background: #ffffff;
    border: 1.5px solid #e5e7eb;
    color: #0f172a;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}

.tt-time-btn:hover {
    border-color: #16a34a;
    background: #f0fdf4;
}

.tt-time-btn.active {
    background: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
}

.tt-time-btn:focus-visible {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}

.tt-selected-info {
    background: #f0fdf4;
    border: 1.5px dashed #16a34a;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.75rem;
    color: #166534;
    font-weight: 700;
    margin: 10px 0;
    text-align: center;
}

.tt-selected-info b {
    color: #16a34a;
    font-weight: 900;
}

/* ============================================================
   ═══ ARENA VIEW ═══
   ============================================================ */
.tt-arena-header {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.tt-stat-box {
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
    transition: all 0.2s;
}

.tt-stat-box b {
    display: block;
    font-size: 1.3rem;
    font-weight: 900;
    color: #16a34a;
    line-height: 1.1;
}

.tt-stat-box span {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #15803d;
    font-weight: 700;
}

.tt-stat-box.timer-box b {
    font-family: 'Courier New', monospace;
    color: #16a34a;
    transition: color 0.3s ease;
}

.tt-stat-box.timer-box b.warn {
    color: #d97706;
}

.tt-stat-box.timer-box b.danger {
    color: #dc2626;
    animation: ttBlink 0.8s infinite;
}

@keyframes ttBlink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ═══ TARGET TEXT — WHITE BG + GREEN TEXT ═══ */
.tt-target-text {
    background: #ffffff;
    border: 2px solid #16a34a;
    border-radius: 10px;
    padding: 18px 20px;
    font-size: 1.1rem;
    line-height: 2;
    font-family: 'Inter', 'Noto Sans Devanagari', 'Noto Sans Ol Chiki', monospace;
    letter-spacing: 0.4px;
    color: #16a34a;
    margin-bottom: 10px;
    max-height: 240px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: none;
    -webkit-user-select: none;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #16a34a #f0fdf4;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.08);
}

.tt-target-text::-webkit-scrollbar {
    width: 6px;
}

.tt-target-text::-webkit-scrollbar-track {
    background: #f0fdf4;
    border-radius: 3px;
}

.tt-target-text::-webkit-scrollbar-thumb {
    background: #16a34a;
    border-radius: 3px;
}

.tt-char {
    transition: color 0.1s, background 0.1s;
    padding: 0 1px;
    border-radius: 2px;
    color: #15803d;
    font-weight: 700;
}

.tt-char.correct {
    color: #16a34a;
    background: #dcfce7;
    font-weight: 900;
}

.tt-char.wrong {
    color: #dc2626;
    background: #fee2e2;
    text-decoration: underline wavy #dc2626;
    font-weight: 900;
}

.tt-char.current {
    background: #16a34a;
    color: #ffffff;
    border-bottom: 3px solid #14532d;
    font-weight: 900;
    animation: ttCursor 0.8s infinite;
    padding: 2px 3px;
    border-radius: 4px;
}

@keyframes ttCursor {
    0%, 100% { background: #16a34a; }
    50%      { background: #15803d; }
}

/* ═══ INPUT TEXTAREA ═══ */
#ttInput {
    width: 100%;
    min-height: 110px;
    background: #ffffff;
    border: 2px solid #16a34a;
    border-radius: 10px;
    color: #16a34a;
    padding: 14px 16px;
    font-size: 1.05rem;
    line-height: 1.7;
    font-weight: 700;
    font-family: 'Inter', 'Noto Sans Devanagari', 'Noto Sans Ol Chiki', sans-serif;
    outline: none;
    resize: vertical;
    margin-bottom: 10px;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #16a34a #f0fdf4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.05);
}

#ttInput:focus {
    border-color: #15803d;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15);
}

#ttInput::placeholder {
    color: #86efac;
    font-weight: 600;
}

#ttInput:disabled {
    opacity: 0.6;
    border-color: #d1fae5;
    color: #15803d;
}

#ttInput::-webkit-scrollbar {
    width: 6px;
}

#ttInput::-webkit-scrollbar-thumb {
    background: #16a34a;
    border-radius: 3px;
}

.tt-arena-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================
   ═══ RESULT VIEW ═══
   ============================================================ */
.tt-result-hero {
    text-align: center;
    padding: 24px 10px 16px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-radius: 12px;
    border: 2px solid #bbf7d0;
}

.tt-grade-badge {
    display: inline-block;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #ffffff;
    font-size: 2.8rem;
    font-weight: 900;
    line-height: 100px;
    margin-bottom: 10px;
    box-shadow: 0 10px 30px rgba(22, 163, 74, 0.4);
    font-family: 'Georgia', serif;
    animation: gradePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 4px solid #ffffff;
}

@keyframes gradePop {
    0%   { transform: scale(0.3); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.tt-result-hero h3 {
    font-size: 1.3rem;
    font-weight: 900;
    color: #14532d;
    margin-bottom: 4px;
}

.tt-result-hero p {
    font-size: 0.9rem;
    font-weight: 800;
    color: #16a34a;
}

.tt-result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.tt-result-box {
    background: #ffffff;
    border: 2px solid #bbf7d0;
    border-radius: 10px;
    padding: 16px 10px;
    text-align: center;
    transition: all 0.2s;
}

.tt-result-box:hover {
    transform: translateY(-2px);
    border-color: #16a34a;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.2);
}

.tt-result-box b {
    display: block;
    font-size: 1.7rem;
    font-weight: 900;
    color: #16a34a;
    line-height: 1.1;
    margin-bottom: 2px;
}

.tt-result-box span {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #15803d;
    font-weight: 700;
}

.tt-result-box.highlight {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    border-color: #16a34a;
}

.tt-result-box.highlight b,
.tt-result-box.highlight span {
    color: #ffffff;
}

.tt-result-meta {
    background: #f0fdf4;
    border: 1.5px dashed #16a34a;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.72rem;
    color: #166534;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.tt-result-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.tt-result-actions .modal-btn {
    min-height: 42px;
    padding: 10px 18px;
    font-weight: 900;
}

.tt-result-actions .modal-btn-primary {
    background: #16a34a;
    border-color: #16a34a;
    color: #ffffff;
}

.tt-result-actions .modal-btn-primary:hover {
    background: #15803d;
}

/* ============================================================
   📱 MOBILE — 768px
   ============================================================ */
@media (max-width: 768px) {
    .tt-modal-window {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .tt-lessons-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .tt-arena-header {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .tt-stat-box b {
        font-size: 1.1rem;
    }

    .tt-stat-box span {
        font-size: 0.55rem;
    }

    .tt-target-text {
        font-size: 1rem;
        line-height: 1.9;
        padding: 14px 16px;
        max-height: 200px;
    }

    #ttInput {
        font-size: 1rem;
        min-height: 90px;
        padding: 12px 14px;
    }

    .tt-result-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .tt-result-box {
        padding: 12px 8px;
    }

    .tt-result-box b {
        font-size: 1.4rem;
    }

    .tt-grade-badge {
        width: 80px;
        height: 80px;
        line-height: 80px;
        font-size: 2.2rem;
    }

    .tt-time-btn {
        padding: 8px 4px;
        font-size: 0.7rem;
        min-width: 60px;
    }

    .tt-result-actions {
        flex-direction: column;
    }

    .tt-result-actions .modal-btn {
        width: 100%;
    }

    .tt-arena-actions {
        flex-direction: column;
    }

    .tt-arena-actions .modal-btn {
        width: 100%;
    }
}

/* ============================================================
   📱 SMALL MOBILE — 400px
   ============================================================ */
@media (max-width: 400px) {
    .tt-arena-header {
        grid-template-columns: repeat(2, 1fr);
    }

    .tt-target-text {
        font-size: 0.92rem;
        padding: 12px;
        max-height: 170px;
    }

    #ttInput {
        font-size: 0.95rem;
        min-height: 80px;
    }

    .tt-result-box b {
        font-size: 1.2rem;
    }
}

/* ============================================================
   🖨️ PRINT
   ============================================================ */
@media print {
    #typingTestModal {
        display: none !important;
    }
}

/* ============================================================
   ♿ REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .tt-char.current,
    .tt-stat-box.timer-box b.danger,
    .tt-grade-badge {
        animation: none !important;
    }

    .tt-char.current {
        background: #16a34a;
        color: #ffffff;
    }

    .tt-result-box:hover {
        transform: none;
    }
}