/* Add styles for the ad container */
.ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    width: 100%;
    padding: 10px;
    overflow: hidden;
    background: transparent;
}

/* Rest of the existing CSS content */
:root {
    /* Dark Theme (Default) */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --pause-color: #4f46e5;
    --restart-color: #7c3aed;
    --border-color: #475569;
    --input-bg: #1e293b;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --keyboard-key-bg: #1e293b;
    --keyboard-key-text: #f1f5f9;
    --keyboard-key-border: #475569;
    --keyboard-key-shadow: rgba(0, 0, 0, 0.5);
    --keyboard-key-active: #3b82f6;
    --keyboard-key-wrong: #ef4444;
    --gradient-start: #1e3a8a;
    --gradient-mid: #2563eb;
    --gradient-end: #3b82f6;
}

.light-theme {
    --bg-primary: #f0f9ff;  /* Lighter blue background */
    --bg-secondary: #e0f2fe;  /* Lighter secondary background */
    --bg-tertiary: #bae6fd;  /* Lighter tertiary background */
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --error-color: #dc2626;
    --warning-color: #d97706;
    --success-color: #059669;
    --pause-color: #4338ca;  /* Indigo for light theme */
    --restart-color: #6d28d9; /* Purple for light theme */
    --border-color: #93c5fd;  /* Lighter border color */
    --input-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --keyboard-key-bg: #ffffff;
    --keyboard-key-text: #0f172a;
    --keyboard-key-border: #3b82f6;  /* Changed to blue for better visibility */
    --keyboard-key-shadow: rgba(0, 0, 0, 0.1);
    --keyboard-key-active: #3b82f6;
    --keyboard-key-wrong: #ef4444;
    --gradient-start: #bfdbfe;
    --gradient-mid: #60a5fa;  /* Added mid gradient color */
    --gradient-end: #3b82f6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(30, 58, 138, 0.4) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.3) 0%, transparent 40%),
        linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-mid) 50%, var(--bg-primary) 100%);
    background-attachment: fixed;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%233b82f6' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

/* ===== Layout Components ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-secondary);
    box-shadow: 0 4px 12px var(--shadow-color);
    position: relative;
    z-index: 10;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.logo i {
    margin-right: 0.5rem;
    color: var(--accent-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

nav ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s;
    padding: 0.5rem;
    border-radius: 4px;
}

nav a:hover {
    color: var(--accent-color);
}

nav a.active {
    background-color: var(--accent-color);
    color: white;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    min-height: calc(100vh - 140px);
}

.container {
    width: 90%;
    max-width: 1000px;
    margin: 0 auto;
}

footer {
    text-align: center;
    padding: 1rem;
    background-color: var(--bg-secondary);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ===== Test Options ===== */
.test-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.option-group {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 5px;
    min-width: 150px;
}

.option-group h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.option-buttons {
    display: flex;
    gap: 0.5rem;
}

.option-btn {
    padding: 0.5rem;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    flex: 1;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.option-btn:hover {
    background-color: var(--accent-color);
    color: white;
}

.option-btn.active {
    background-color: var(--accent-color);
    color: white;
}

/* ===== Test Container ===== */
.test-container {
    width: 100%;
    max-width: 800px;
    text-align: center;
    margin-bottom: 2rem;
    background-color: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease-in-out;
}

h1 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

h1.gradient-heading {
    font-size: 2.8rem;
    margin-bottom: 1rem;
}

.test-container p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

#text-display {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    white-space: pre-wrap;
    background-color: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: left;
    line-height: 1.8;
    min-height: 150px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

#text-display:focus-within {
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 0 2px var(--accent-color);
}

.text-content {
    position: relative;
}

#user-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

#user-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.test-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

#timer {
    font-size: 2rem;
    color: var(--accent-color);
    font-weight: bold;
    min-width: 100px;
}

#progress-bar-container {
    width: 100%;
    background-color: var(--bg-tertiary);
    height: 10px;
    margin: 1rem 0;
    border-radius: 5px;
    overflow: hidden;
}

#progress-bar {
    width: 100%;
    height: 100%;
    background-color: var(--accent-color);
    transition: width 0.5s;
    border-radius: 5px;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-weight: 500;
    letter-spacing: 0.5px;
}

button i {
    margin-right: 0.5rem;
}

button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:disabled {
    background-color: var(--bg-tertiary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

.secondary-btn {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: none;
}

.secondary-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* ===== Character Styling ===== */
.char {
    transition: color 0.2s, background-color 0.2s;
    border-radius: 2px;
    position: relative;
}

.char.correct {
    color: var(--success-color);
    text-shadow: 0 0 5px rgba(16, 185, 129, 0.3);
}

.char.incorrect {
    color: var(--error-color);
    text-decoration: underline;
    text-shadow: 0 0 5px rgba(239, 68, 68, 0.3);
}

.char.current {
    background-color: rgba(59, 130, 246, 0.2);
    border-radius: 2px;
    animation: blink 1s infinite;
    position: relative;
}

.char.current::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
    animation: cursor-blink 1s infinite;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.current-word {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== Results Section ===== */
#results {
    background-color: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    box-shadow: 0 8px 24px var(--shadow-color);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#results h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-primary);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-card {
    background-color: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.result-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.result-card .value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: linear-gradient(45deg, var(--accent-color), var(--success-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-card .unit {
    font-size: 1rem;
    color: var(--text-secondary);
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    background-color: var(--bg-tertiary);
    padding: 1.5rem 1.5rem 2.5rem 1.5rem; /* Increased bottom padding for x-axis labels */
    border-radius: 8px;
    overflow: visible; /* Allow chart to overflow for axis labels */
    max-width: 100%; /* Ensure chart respects container width */
    height: 320px; /* Increased height to accommodate x-axis labels */
    position: relative; /* Ensure proper positioning of chart elements */
    margin-bottom: 1rem; /* Add margin to prevent overlap with elements below */
}

.chart-container h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

canvas {
    width: 100%;
    max-height: 300px;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* ===== Keyboard Layout ===== */
.keyboard-container {
    width: 100%;
    max-width: 850px;
    margin: 2rem auto;
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-color);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.key {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--keyboard-key-bg);
    color: var(--keyboard-key-text);
    border: 2px solid var(--keyboard-key-border); /* Increased border width for better visibility */
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 800; /* Increased from bold to 800 for better visibility */
    box-shadow: 0 3px 6px var(--keyboard-key-shadow);
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
    margin: 2px;
    /*text-shadow: 0 0 3px rgba(255, 255, 255, 0.7);  Changed to white shadow for better visibility */
    /*-webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.3);  Added text outline for better contrast */
    letter-spacing: 0.5px; /* Slightly increased letter spacing */
    z-index: 2; /* Ensure text is above the heatmap */
}

/* Different text shadow for light theme */
.light-theme .key {
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.3); /* Dark shadow for light theme */
}

.key:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--keyboard-key-shadow);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.key.active {
    background-color: var(--keyboard-key-active);
    color: white;
    transform: translateY(2px);
    box-shadow: 0 1px 2px var(--keyboard-key-shadow);
    animation: keyPress 0.2s ease;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
    border: 1px solid #ffffff;
}

.key.wrong {
    background-color: var(--keyboard-key-wrong);
    color: white;
    animation: keyError 0.3s ease;
    border: 2px solid #ffffff; /* Add white border to make keys more visible */
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8); /* Add glow effect for better visibility */
    font-weight: bold; /* Make text bolder */
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8), 0 0 5px rgba(0, 0, 0, 0.5); /* Enhanced text shadow for better contrast */
}

@keyframes keyPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes keyError {
    0% { transform: scale(1); }
    25% { transform: scale(0.95) rotate(-2deg); }
    50% { transform: scale(0.95) rotate(2deg); }
    75% { transform: scale(0.95) rotate(-2deg); }
    100% { transform: scale(1) rotate(0); }
}

.key.space {
    width: 200px;
}

.key.wide {
    width: 65px;
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Special class for Backspace key */
.key.backspace {
    width: 90px; /* Wider than standard wide keys */
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.key.extra-wide {
    width: 80px;
}

.key .heatmap {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: transparent;
    border-radius: 0 0 5px 5px;
    z-index: 1; /* Ensure heatmap is below the text */
    opacity: 0.7; /* Make heatmap semi-transparent */
}

/* ===== History Section ===== */
.history-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 2rem;
    /* Show scroll hints */
    background-image: linear-gradient(to right, var(--bg-secondary) 30%, rgba(255, 255, 255, 0)),
                      linear-gradient(to left, var(--bg-secondary) 30%, rgba(255, 255, 255, 0));
    background-position: 0 0, 100% 0;
    background-repeat: no-repeat;
    background-size: 20px 100%;
    border-radius: 8px;
}

.history-container {
    width: 100%;
    max-width: 800px;
    margin: 2rem auto;
    background-color: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-color);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Gradient Heading Style */
.gradient-heading {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(45deg, var(--accent-color), var(--success-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 0.5rem;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideInLeft 0.5s ease-in-out;
}

.gradient-heading::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), transparent);
    border-radius: 3px;
}

.gradient-heading i {
    color: var(--accent-color);
    font-size: 1.8rem;
}

.history-header h2 {
    color: var(--text-primary);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.6s ease-in-out, slideUp 0.6s ease-in-out;
    border: 1px solid var(--border-color);
}

.history-table th, .history-table td {
    padding: 1.2rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.history-table td {
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

/* Highlight important values in the history table */
.history-table td:nth-child(2), 
.history-table td:nth-child(3) {
    font-weight: 600;
    color: var(--accent-color);
}

.history-table th {
    background-color: var(--accent-color);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1.2px;
    padding: 1.2rem 1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    border-bottom: 2px solid var(--accent-hover);
}

.history-table tr:hover {
    background: linear-gradient(to right, rgba(59, 130, 246, 0.2), rgba(16, 185, 129, 0.1));
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.history-table tr {
    transition: all 0.2s ease;
    position: relative;
    animation: fadeIn 0.5s ease-in-out forwards;
    opacity: 0;
    animation-delay: calc(var(--row-index, 0) * 0.1s);
}

.history-table tr:hover td {
    color: var(--accent-color);
}

.history-table tr:last-child td {
    border-bottom: none;
}

/* ===== About Section ===== */
#about {
    width: 100%;
    max-width: 800px;
    margin: 2rem auto;
    background-color: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-color);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#about h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

#about h3 {
    font-size: 1.4rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

#about p {
    margin-bottom: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

#about a {
    color: #60a5fa;
    text-decoration: underline;
    font-weight: bold;
    transition: color 0.2s;
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.3);
}

#about a:hover {
    color: #93c5fd;
    text-decoration: none;
}

#about ul {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

#about li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background-color: var(--bg-secondary);
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal h2 {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.modal-content {
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ===== Custom Text Input ===== */
#custom-text {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 1rem;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 20px;
    padding: 0.3rem;
    position: relative;
    cursor: pointer;
}

.theme-option {
    padding: 0.3rem 0.6rem;
    border-radius: 15px;
    font-size: 0.8rem;
    z-index: 1;
}

.theme-option.active {
    color: var(--bg-primary);
}

.theme-slider {
    position: absolute;
    top: 0.3rem;
    left: 0.3rem;
    width: calc(50% - 0.3rem);
    height: calc(100% - 0.6rem);
    background-color: var(--accent-color);
    border-radius: 15px;
    transition: transform 0.3s;
}

.theme-toggle[data-theme="light"] .theme-slider {
    transform: translateX(100%);
}

/* ===== Sound Toggle ===== */
.sound-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
}

.sound-toggle:hover {
    color: var(--text-primary);
}

.sound-toggle i {
    transition: color 0.2s;
}

.sound-toggle.active i {
    color: var(--accent-color);
}

/* ===== Tooltip ===== */
.tooltip {
    position: relative;
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 5px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 2px 5px var(--shadow-color);
}

/* ===== Responsive Design ===== */
@media (max-width: 900px) {
    .test-options {
        flex-direction: column;
        align-items: center;
    }
    
    .option-group {
        width: 100%;
        max-width: 400px;
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    nav ul {
        gap: 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .test-container p {
        font-size: 1rem;
    }
    
    #text-display {
        font-size: 1.1rem;
        padding: 1rem;
    }
    
    .keyboard-container {
        padding: 1rem;
        margin: 1rem auto;
    }
    
    .key {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .history-table th,
    .history-table td {
        padding: 0.8rem 0.6rem;
        font-size: 0.9rem;
    }
    
    .history-table {
        min-width: 600px; /* Ensure minimum width for scrolling */
    }
}

@media (max-width: 480px) {
    main {
        padding: 1rem;
    }
    
    .container {
        width: 100%;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    #text-display {
        font-size: 1rem;
    }
    
    #user-input {
        font-size: 0.9rem;
    }
    
    #timer {
        font-size: 1.5rem;
    }
    
    button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal {
        padding: 1.5rem;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.slide-up {
    animation: slideUp 0.5s ease-in-out;
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-in-out;
}

.slide-in-right {
    animation: slideInRight 0.5s ease-in-out;
}

.scale-in {
    animation: scaleIn 0.5s ease-in-out;
}

/* ===== Button Styles ===== */
#pause-btn {
    background-color: var(--pause-color);
}

#pause-btn:hover {
    background-color: #3730a3; /* Darker indigo for hover */
}

#restart-btn {
    background-color: var(--restart-color);
    color: white;
}

#restart-btn:hover {
    background-color: #5b21b6; /* Darker purple for hover */
}

/* ===== Back to Top Button ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow-color);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    transform: translateY(20px);
    padding: 0; /* Remove padding to help with centering */
}

.back-to-top i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0; /* Remove any margin that might affect centering */
    font-size: 1.2rem; /* Slightly larger icon */
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: var(--accent-hover);
    transform: translateY(-5px);
    box-shadow: 0 6px 15px var(--shadow-color);
}

.back-to-top:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px var(--shadow-color);
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 2.5rem;
        height: 2.5rem;
    }
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
