:root {
    --bg-color: #0d1117;
    --card-bg: #161b22;
    --accent: #58a6ff;
    --accent-glow: rgba(88, 166, 255, 0.2);
    --success: #3fb950;
    --error: #f85149;
    --text-main: #c9d1d9;
    --text-muted: #8b949e;
    --text-bright: #ffffff;
    --border: #30363d;
    --gold: #d29922;
    --silver: #8b949e;
    --bronze: #7e4c1f;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

.background-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
}

.glow-1 {
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    top: -200px;
    right: -200px;
}

.glow-2 {
    background: radial-gradient(circle, rgba(63, 185, 80, 0.05) 0%, transparent 70%);
    bottom: -200px;
    left: -200px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.5rem;
    font-weight: 800;
}

.logo-text span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.3s;
}

.brand-tag {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-login {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-login:hover {
    background: var(--accent);
    color: var(--bg-color);
}

/* Ad Strip */
.ad-strip {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.ad-tag {
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
}

.ad-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.btn-ad {
    background: var(--text-bright);
    color: var(--bg-color);
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
}

/* Hero Typing Section */
.hero {
    margin-bottom: 4rem;
}

.test-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.stat-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 16px;
    min-width: 150px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent);
}

.typing-container {
    position: relative;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    min-height: 200px;
    cursor: text;
    transition: border-color 0.3s;
}

.typing-container:focus-within {
    border-color: var(--accent);
}

.text-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    color: var(--text-muted);
    line-height: 1.8;
    user-select: none;
    word-break: break-word;
}

.text-display span {
    position: relative;
}

.text-display .correct {
    color: var(--text-bright);
}

.text-display .incorrect {
    color: var(--error);
    background: rgba(248, 81, 73, 0.1);
    text-decoration: underline;
}

.text-display .current {
    color: var(--accent);
}

.text-display .current::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent);
    animation: blink 1s infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.text-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.focus-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    z-index: 10;
    cursor: pointer;
}

.focus-overlay p {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
}

.test-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-secondary {
    background: var(--border);
    color: var(--text-main);
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #3c444d;
}

.time-options {
    display: flex;
    gap: 0.5rem;
}

.time-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.time-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 4rem;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 3rem;
    text-align: center;
}

.final-stats {
    display: flex;
    justify-content: center;
    gap: 4rem;
    margin: 2rem 0 3rem;
}

.final-stat {
    display: flex;
    flex-direction: column;
}

.final-stat .label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.final-stat .value {
    font-size: 4rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.final-stat .unit {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
}

.btn-primary-lg {
    background: var(--accent);
    color: var(--bg-color);
    border: none;
    padding: 1.2rem 2.5rem;
    border-radius: 16px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
}

.btn-primary-lg:hover {
    background: #79c0ff;
    transform: scale(1.02);
}

.ad-placeholder-sq {
    width: 100%;
    aspect-ratio: 1;
    background: var(--border);
    border-radius: 12px;
    margin-top: 1rem;
}

/* Info Section */
.info-section {
    margin-bottom: 6rem;
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.section-title p {
    color: var(--text-muted);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.info-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 2.5rem;
    border-radius: 24px;
    transition: transform 0.3s;
}

.info-card:hover {
    transform: translateY(-10px);
}

.info-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
}

.info-card h3 {
    margin-bottom: 1rem;
}

.info-card p {
    color: var(--text-muted);
}

/* Leaderboard */
.leaderboard-section {
    margin-bottom: 4rem;
}

.leaderboard-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    overflow: hidden;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th {
    text-align: left;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
}

.leaderboard-table td {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: 800;
}

.rank-badge.gold { background: var(--gold); color: #000; }
.rank-badge.silver { background: var(--silver); color: #000; }
.rank-badge.bronze { background: var(--bronze); color: #fff; }

/* Modal & Certificate */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem;
}

.certificate-wrap {
    max-width: 800px;
    margin: 2rem auto;
    position: relative;
}

.close-modal {
    position: absolute;
    right: -20px;
    top: -40px;
    font-size: 2rem;
    color: #fff;
    cursor: pointer;
}

.certificate {
    background: #fff;
    color: #333;
    padding: 4rem;
    position: relative;
    border: 20px solid #eee;
    text-align: center;
    font-family: 'Outfit', serif;
}

.cert-border {
    position: absolute;
    top: 10px; left: 10px; right: 10px; bottom: 10px;
    border: 2px solid #555;
    pointer-events: none;
}

.cert-logo {
    font-size: 1.2rem;
    font-weight: 800;
    color: #555;
    margin-bottom: 2rem;
}

.certificate h1 {
    font-size: 2.5rem;
    text-transform: uppercase;
    color: #222;
    margin-bottom: 1rem;
}

.cert-name h2 {
    font-size: 3rem;
    font-style: italic;
    color: var(--accent);
    border-bottom: 2px solid #ddd;
    display: inline-block;
    padding: 0 2rem;
    margin: 1.5rem 0;
}

.cert-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 3rem;
}

.cert-stat {
    display: flex;
    flex-direction: column;
}

.cert-stat .stat-val {
    font-size: 2.5rem;
    font-weight: 800;
    color: #222;
}

.cert-stat .stat-lab {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
}

.cert-footer {
    margin-top: 4rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.sig-line {
    width: 200px;
    border-top: 1px solid #333;
    margin-bottom: 0.5rem;
}

.cert-actions {
    margin-top: 2rem;
    text-align: center;
}

.hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #8b949e;
}

/* Footer */
.footer {
    border-top: 1px solid var(--border);
    padding: 4rem 0;
    margin-top: 4rem;
}

.footer-content {
    text-align: center;
    color: var(--text-muted);
}

.footer-logo {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
}

@media (max-width: 768px) {
    .info-grid { grid-template-columns: 1fr; }
    .final-stats { gap: 2rem; }
    .final-stat .value { font-size: 3rem; }
    .results-grid { grid-template-columns: 1fr; }
    .stat-box { min-width: 100px; padding: 1rem; }
    .stat-value { font-size: 1.5rem; }
}

@media print {
    body * { visibility: hidden; }
    #certModal, #certModal *, #certificate, #certificate * { visibility: visible; }
    #certModal { position: absolute; left: 0; top: 0; width: 100%; height: auto; background: none; }
    .cert-actions, .close-modal { display: none; }
}
