html {
    height: 100%;
    /* Prevents layout shift when scrollbar appears/disappears */
    overflow-y: scroll; 
}

body {
    min-height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    /* These two lines vertically center the content */
    flex-grow: 1;
    justify-content: center;
    width: 100%;
}

.test-container {
    background-color: var(--light-container-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .1);
    width: 100%;
    max-width: 900px;
    text-align: center;
    transition: background-color .3s, color .3s;
    box-sizing: border-box;
    margin: 0 auto;
}

.test-container h1 {
    color: var(--light-primary);
    margin-bottom: 20px;
    transition: color .3s;
}

.config-bar {
    justify-content: center;
    display: flex;
    margin-bottom: 25px;
    align-items: center;
    /* Increased gap for better spacing */
    gap: 30px;
    font-size: 1.2rem;
    flex-wrap: wrap; /* Allows items to wrap on very small screens */
}

.config-bar,
.stat p {
    color: var(--light-secondary);
    font-weight: 700;
}

.config-bar p,
.stat p {
    margin: 0;
}

.time-selector {
    position: relative;
    background-color: #f0f2f5;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color .3s;
    font-size: 1.1rem;
    color: var(--light-text);
    z-index: 10;
}

.time-selector:hover {
    background-color: #e4e6eb;
}

.test-area {
    position: relative;
    margin-bottom: 10px;
}

.overlay-message {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, .65);
    color: #333;
    font-size: 2.5rem;
    font-weight: 700;
    justify-content: center;
    display: flex;
    align-items: center;
    border-radius: 8px;
    z-index: 20; /* Increased z-index to appear above dropdown */
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease-in-out;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    flex-direction: column;
    line-height: 1.2;
    cursor: pointer;
}

#times-up-overlay,
body.dark-mode #times-up-overlay {
    color: #e74c3c;
    cursor: default;
}

.overlay-message.show {
    opacity: 1;
    pointer-events: auto;
}

.text-display {
    color: #606770;
    padding: 20px;
    border: 1px solid #dddfe2;
    border-radius: 8px;
    height: 15vh;
    min-height: 70px;
    max-height: 120px;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    pointer-events: none;
    transition: border-color .3s, color .3s, height .3s;
}

#typed-text-display,
.text-display {
    font-size: 1.9rem; 
    line-height: 1.7;
    text-align: left;
}

.text-display::-webkit-scrollbar {
    display: none;
}

.text-display span {
    display: inline;
    padding: 2px 0;
    border-radius: 3px;
}

span.space {
    padding: 2px .25em;
}

#typed-text-display {
    width: 100%;
    margin-top: 10px;
    padding: 7px;
    border-radius: 8px;
    border: 2px solid #e4e6eb;
    box-sizing: border-box;
    font-family: inherit;
    background-color: #f7f7f7;
    color: #333;
    transition: background-color .3s, color .3s, border-color .3s;
    font-size: 1.6rem;
}

.input-field {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    z-index: -1;
}

.stats {
    display: flex;
    justify-content: center;
    align-items: center; 
    gap: 15px;
    margin: 25px 0;
    flex-wrap: wrap;
    min-height: 58px; 
}

.stat {
    font-size: 1.2rem;
    padding: 10px 20px;
    border-radius: 8px;
    min-width: 130px;
    position: relative;
    transition: background-color .3s, opacity .3s, transform .3s;
    flex: 1;
    background-color: #f0f2f5;
    box-sizing: border-box;
    border: 2px solid rgba(44, 62, 80, 0.080);
}

.stat.hidden {
    display: none; 
}

.stat span {
    font-size: 2rem;
    font-weight: 700;
    color: #1877f2;
}

.stat span.timer-value {
    color: #640d5f;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--light-container-bg);
    border: 1px solid #dddfe2;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
    min-width: 100%;
    z-index: 10;
    margin-top: 5px;
    padding: 5px 0;
}

.dropdown-item {
    padding: 10px 20px;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    color: var(--light-text);
}

.dropdown-item:hover {
    background-color: #f0f2f5;
}

.dropdown-menu.show {
    display: block;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

#pause-resume-button,
#reset-button {
    border: none;
    padding: 12px 25px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, .1);
    transition: .2s ease-in-out;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}

#reset-button {
    background-image: linear-gradient(to right, #4caf50, #81c784);
}

#pause-resume-button {
    background-image: linear-gradient(to right, #3498db, #5dade2);
}

#pause-resume-button:hover:not(:disabled),
#reset-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, .15);
}

#pause-resume-button:active:not(:disabled),
#reset-button:active {
    transform: translateY(0) scale(.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
}

#pause-resume-button:disabled {
    background-image: none;
    background-color: #bdc3c7;
    cursor: not-allowed;
    opacity: .7;
    box-shadow: none;
    text-shadow: none;
}

.correct {
    color: #42b72a;
}

.incorrect {
    color: #fa3e3e;
    text-decoration: underline;
    text-decoration-color: #fa3e3e;
}

.current,
span.space.current {
    background-color: rgba(52, 152, 219, .3);
}

body.dark-mode .seo-content-block,
body.dark-mode .test-container {
    background-color: var(--dark-container-bg);
}

body.dark-mode .seo-content-block h2,
body.dark-mode .test-container h1 {
    color: var(--dark-primary);
}

body.dark-mode .config-bar,
body.dark-mode .stat p {
    color: var(--dark-secondary);
}

body.dark-mode .time-selector {
    background-color: var(--dark-bg);
    color: var(--dark-text);
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .time-selector:hover {
    background-color: #5a626f;
}

body.dark-mode .overlay-message {
    background-color: rgba(34, 40, 49, .75);
    color: var(--dark-text);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

body.dark-mode .text-display {
    color: var(--dark-secondary);
    border-color: #4a5a8a;
}

body.dark-mode #typed-text-display {
    background-color: var(--dark-bg);
    color: var(--dark-text);
    border-color: #4a5a8a;
}

body.dark-mode .stat {
    background-color: var(--dark-bg);
    border-color:#4d6da2;;
}

body.dark-mode .dropdown-menu {
    background-color: var(--dark-container-bg);
    border-color: #4a5a8a;
}

body.dark-mode .dropdown-item,
body.dark-mode .seo-content-block p {
    color: var(--dark-text);
}

body.dark-mode #pause-resume-button:disabled {
    background-image: none;
    background-color: #5a626f;
}

body.dark-mode .current,
body.dark-mode span.space.current {
    background-color: rgba(52, 152, 219, .4);
}

/* === FIXED SEO CONTENT STYLES === */
.seo-content-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
    box-sizing: border-box;
}

.seo-content-block {
    margin-bottom: 0;
    width: 100%;
    background-color: var(--light-container-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .1);
    transition: background-color .3s, transform .3s ease-out, box-shadow .3s ease-out;
}

.seo-content-block:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, .2);
}

.seo-content-block h2 {
    color: var(--light-primary);
    border-bottom: 2px solid var(--light-highlight);
    padding-bottom: 10px;
    margin-top: 0;
    transition: color .3s;
    font-size: 1.8rem;
}

.seo-content-block p {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--light-text);
    text-align: justify;
    transition: color .3s;
}

body.dark-mode .seo-content-block:hover {
    box-shadow: 0 8px 25px rgba(52, 152, 219, .25);
}

/* === VOLUME CONTROL STYLES === */
.volume-control-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-slider {
    width: 100px;
    cursor: pointer;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

body.dark-mode .icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* === RESULTS SUMMARY STYLES === */
.hidden {
    display: none !important;
}

.results-summary-container {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #dddfe2;
    animation: fadeInResult 0.5s ease-out;
}

@keyframes fadeInResult {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.results-summary-container h2 {
    color: var(--light-primary);
    margin-bottom: 20px;
}

.results-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.profile-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.profile-pic-label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--light-text);
}

.profile-pic-preview {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    border: 3px solid #1877f2;
    background-color: #f0f2f5;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}

.profile-pic-preview i {
    font-size: 50px;
    color: #1877f2;
    transition: opacity 0.3s ease;
}

.profile-pic-preview.has-image i {
    opacity: 0;
}

.profile-pic-label:hover .profile-pic-preview {
    transform: scale(1.05);
    box-shadow: 0 0 15px #1877f2;
    background-color: #e4e6eb;
}

.result-card {
    background-color: transparent;
    border: none;
    padding: 0;
    width: 100%;
    max-width: 380px;
}

.result-card h3 {
    font-size: 1.5rem;
    margin: 0 0 15px 0;
    color: var(--light-text);
}

.final-wpm-container {
    text-align: center;
    margin-bottom: 10px;
}

.final-wpm-container span {
    font-size: 4rem;
    font-weight: bold;
    color: #42b72a;
    line-height: 1;
}

.final-wpm-container p {
    font-size: 1.2rem;
    margin: 0;
    color: #42b72a;
    font-weight: 700;
}

.share-name-input {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    background-color: #f0f2f5;
    border: 1px solid #dddfe2;
    color: var(--light-text);
    border-radius: 5px;
    text-align: center;
}

.result-card p {
    color: var(--light-text);
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 5px;
    transition: opacity 0.2s;
    border: none;
    font-size: 22px;
}

.share-btn:hover {
    opacity: 0.8;
}

.facebook { background-color: #3b5998; }
.twitter { background-color: #000000; }
.whatsapp { background-color: #25d366; }
.linkedin { background-color: #0a66c2; }
.copy-link { background-color: #606770; }

#copy-feedback {
    font-size: 0.9rem;
    color: #42b72a;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 1s, opacity 1s;
}

#copy-feedback.visible {
    visibility: visible;
    opacity: 1;
    transition: opacity 1s;
}

.results-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.download-result-btn {
    border: none;
    padding: 12px 25px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, .1);
    transition: .2s ease-in-out;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    background-image: linear-gradient(to right, #3498db, #5dade2);
}

.download-result-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, .15);
}

/* Dark Mode for Results */
body.dark-mode .results-summary-container {
    border-top-color: #4a5a8a;
}
body.dark-mode .results-summary-container h2 {
    color: var(--dark-primary);
}
body.dark-mode .profile-pic-label,
body.dark-mode .result-card h3,
body.dark-mode .result-card p {
    color: var(--dark-text);
}
body.dark-mode .profile-pic-preview {
    border-color: var(--dark-primary);
    background-color: var(--dark-bg);
}
body.dark-mode .profile-pic-preview i {
    color: var(--dark-primary);
}
body.dark-mode .profile-pic-label:hover .profile-pic-preview {
    box-shadow: 0 0 15px var(--dark-primary);
    background-color: #5a626f;
}
body.dark-mode .share-name-input {
    background-color: var(--dark-bg);
    border-color: #4a5a8a;
    color: var(--dark-text);
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .config-bar {
        flex-direction: column;
        gap: 15px;
    }
    
    .seo-content-container {
        width: 90%;
        padding: 10px;
        gap: 20px;
    }
    
    .test-container {
        width: 90%;
        padding: 20px;
    }
    
    .seo-content-block {
        padding: 20px;
    }
    
    .seo-content-block h2 {
        font-size: 1.5rem;
    }
    
    .seo-content-block p {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .results-content {
        flex-direction: column;
        gap: 20px;
    }
    
    .stats {
        gap: 10px;
    }
    
    .stat {
        min-width: 120px;
        padding: 8px 15px;
    }
}

@media (min-width: 992px) {
    .stats {
        flex-wrap: nowrap;
    }
}

@media (max-height: 750px) and (max-width: 992px) {
    .main-content {
        padding-top: 20px;
        padding-bottom: 20px; 
    }

    .test-container {
        padding: 20px;
    }

    .text-display {
        font-size: 1.3rem;
        line-height: 1.6;
    }

    #typed-text-display {
        font-size: 1.5rem;
    }
    
    .stats {
        margin: 15px 0;
        gap: 10px;
    }

    .stat {
        min-width: 120px;
        padding: 8px 15px;
    }

    .button-container {
        margin-top: 15px;
    }
}

.overlay-message .resume-prompt {
    font-size: 1.25rem;
    font-weight: 500;
    margin-top: 15px;
    color: #606770;
}

body.dark-mode .overlay-message .resume-prompt {
    color: var(--dark-secondary);
}