/* DESIGN SYSTEM */
:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #eef0f4;

    --primary: #111827;
    --primary-2: #1f2937;

    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.15);
}

body {
    margin: 0;
    font-family: system-ui, Arial;
    background: var(--bg);
    color: var(--text);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

.top-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;

    margin-bottom: 35px;
}

.top-bar h1 {
    font-size: 40px;
    font-weight: 700;
    margin: 20px 0;
    letter-spacing: 0.5px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 40px;
}

.timer-block {
    background: white;
    padding: 12px 30px;
    border-radius: 14px;

    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.clock i {
    font-size: 3rem;
    margin-top: 10px;
    border: 8px solid var(--primary);
    border-radius: 50%;
    background-color: black;
    color: white;
}

.select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.select-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

select {
    appearance: none;
    padding: 10px 40px 10px 14px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: white;

    font-weight: 500;
    cursor: pointer;
    background-repeat: no-repeat;
    background-position: right 10px center;
}

select:hover {
    border-color: var(--primary);
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(56, 58, 133, 0.2);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#timer {
    font-size: 48px;
    font-weight: 800;
    margin: 10px 0;
    letter-spacing: 1px;
    color: var(--text);
}

.progress {
    height: 4px;
    background: #e5e7eb;
    border-radius: 10px;
    margin: 10px 0 20px;
}

#progressBar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#textDisplay {
    font-size: 20px;
    line-height: 1.8;

    padding: 20px;
    margin-top: 10px;

    min-height: 120px;

    background: white;
    border-radius: 16px;

    border: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

#textDisplay span {
    transition: all 0.1s ease;
}

#textDisplay span.correct {
    color: #16a34a;
    transform: scale(1.02);
}

#textDisplay span.incorrect {
    color: #dc2626;
    text-decoration: underline;
}

#textDisplay span.active {
    background: rgba(99, 102, 241, 0.15);
    border-radius: 4px;
}

.type-here-div {
    position: relative;
    text-align: left;
    width: 100%;
    margin: 20px auto;
    animation: jump 1.4s ease-in-out infinite;
    display: flex;
    align-items: center;
    gap: 8px;
}

.type-here-anim {
    background-color: #333333ca;
    color: white;
    padding: 6px;
    letter-spacing: 1px;
    border-radius: 2px;
}

.triangle-down {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 10px solid #555;
    position: absolute;
    bottom: -15px;
    left: 45px;
}

.type-here-hidden {
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

textarea {
    width: 100%;
    display: block;
    margin: 20px auto;
    min-height: 150px;
    padding: 12px;
    font-size: 16px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    outline: none;
    background: white;
    resize: none;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
}

textarea:hover {
    border-color: #9ca3af;
}

textarea:focus {
    transform: scale(1.01);
    border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(17, 24, 39, 0.12);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-top: 25px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 18px 10px;
    text-align: center;

    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);

    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    transition: transform 0.2s ease;
}

.stat-card:hover .stat-value {
    transform: scale(1.1);
}

.stat-label {
    font-size: 12px;
    margin-top: 6px;
    color: var(--muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#resetBtn {
    display: block;
    margin: 35px auto 10px;

    padding: 14px 26px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;

    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;

    border-radius: 14px;
    border: none;

    cursor: pointer;
    transition: all 0.2s ease;

    box-shadow: var(--shadow-sm);
}

#resetBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.2);
}

#resetBtn:active {
    transform: translateY(0);
}

/*  MODAL */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);

    display: none;
    align-items: center;
    justify-content: center;

    opacity: 0;
    animation: modalFade 0.25s ease forwards;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
    display: flex;
}

.modal-content {
    opacity: 0;
    transition: all 0.25s ease;
    background: var(--card);
    padding: 32px;
    border-radius: 20px;
    text-align: center;

    width: min(420px, 90%);
    box-shadow: var(--shadow-lg);

    transform: translateY(20px) scale(0.95);
    animation: modalPop 0.3s ease forwards;
}

.modal.show .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.result-card h2 {
    font-size: 22px;
    margin-bottom: 18px;
    font-weight: 700;
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}

.result-item {
    background: #f9fafb;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    transition: 0.2s ease;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.result-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}

.result-label {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* BUTTON INSIDE MODAL */
.modal-content button {
    margin-top: 15px;
    padding: 12px 18px;
    border: none;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: 0.2s ease;
}

.modal-content button:hover {
    background: var(--primary-2);
    transform: translateY(-2px);
}

/* CARD */
@keyframes modalPop {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Animations */
@keyframes jump {
    0% {
        top: 5px;
    }

    50% {
        top: -10px;
    }

    100% {
        top: 5px;
    }
}

@media (max-width: 768px) {

    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .controls-row {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        gap: 10px;
    }

    .select-wrapper {
        flex: 1;
    }

    select {
        width: 100%;
    }

    .timer-block {
        flex-shrink: 0;
        padding: 10px 16px;
    }

    #timer {
        font-size: 36px;
    }

    #textDisplay {
        font-size: 16px;
        padding: 14px;
        line-height: 1.6;
    }

    textarea {
        width: 100%;
        min-height: 90px;
        font-size: 14px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px 8px;
    }

    .stat-value {
        font-size: 20px;
    }

    #resetBtn {
        width: 100%;
    }
}

@media (max-width: 480px) {

    .top-bar h1 {
        font-size: 22px;
    }

    #timer {
        font-size: 28px;
    }

    .stat-value {
        font-size: 22px;
    }

    #textDisplay {
        font-size: 15px;
    }
}