:root {
    --bg-color: #000000;
    --surface: #0a0a0a;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.06);
    --text-primary: #e8e8e8;
    --text-secondary: #6b6b6b;
    --accent: #00d4ff;
    --accent-dim: rgba(0, 212, 255, 0.15);
    --accent-glow: rgba(0, 212, 255, 0.25);
    --success: #34d399;
    --danger: #f87171;
    --font-main: 'Outfit', sans-serif;
    --font-mono: 'Space Grotesk', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Subtle background glow — very minimal */
.background-decor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(150px);
    opacity: 0.08;
}

.orb-1 {
    top: -20%;
    right: -15%;
    width: 50vw;
    height: 50vw;
    background: var(--accent);
}

.orb-2 {
    bottom: -25%;
    left: -15%;
    width: 45vw;
    height: 45vw;
    background: var(--accent);
}

/* Top-right navigation */
.global-nav {
    position: absolute;
    top: 1.5rem;
    right: 4%;
    z-index: 100;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-link {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    letter-spacing: 0.3px;
}

.nav-link:hover {
    color: var(--text-primary);
    border-color: var(--card-border);
    background: var(--card-bg);
}

/* App container */
.app-container {
    width: 90%;
    max-width: 1100px;
    z-index: 1;
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2.5rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1.25rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

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

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.pulse-dot.idle {
    background-color: var(--text-secondary);
}

.pulse-dot.running {
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    animation: pulse 1.5s infinite;
}

.pulse-dot.success {
    background-color: var(--success);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.5; }
}

/* Main layout */
.main-layout {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 3rem;
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
}

/* Gauge section */
.gauge-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.unit-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border: 1px solid var(--card-border);
    padding: 0.2rem 0.4rem 0.2rem 0.9rem;
    border-radius: 50px;
}

.unit-toggle-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 1.5px;
}

.unit-toggle-container {
    display: flex;
    gap: 0.2rem;
}

.unit-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.unit-btn:hover {
    color: var(--text-primary);
}

.unit-btn.active {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 12px var(--accent-dim);
}

.gauge-container {
    position: relative;
    width: 300px;
    height: 300px;
}

.speedometer {
    width: 100%;
    height: 100%;
}

.gauge-track {
    stroke-linecap: round;
}

.gauge-fill {
    stroke-linecap: round;
    transition: stroke-dashoffset 0.15s cubic-bezier(0.1, 0.8, 0.25, 1);
    filter: drop-shadow(0 0 6px var(--accent-dim));
}

.gauge-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%);
    text-align: center;
    width: 180px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.speed-label {
    font-size: 0.75rem;
    letter-spacing: 2.5px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.speed-value {
    font-family: var(--font-mono);
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.speed-unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* GO button */
.go-button {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #000;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}

.go-button:hover {
    transform: translateX(-50%) scale(1.08);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.go-button:active {
    transform: translateX(-50%) scale(0.95);
}

.go-button:disabled {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) scale(0.8);
}

/* Stats section */
.stats-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.stat-card.active-test {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-dim);
}

.stat-icon {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    width: 42px;
    height: 42px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

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

.stat-title {
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    font-weight: 600;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value .unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 0.2rem;
    font-weight: 400;
}

/* Info container */
.info-container {
    display: flex;
    justify-content: space-between;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.9rem 1.25rem;
}

.info-block {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.info-val {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* History */
.history-container h3 {
    font-size: 1rem;
    margin-bottom: 0.6rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-table-wrapper {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    max-height: 180px;
    overflow-y: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: left;
}

.history-table th {
    padding: 0.65rem 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.7rem;
    letter-spacing: 1px;
}

.history-table td {
    padding: 0.65rem 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.history-table tr:last-child td {
    border-bottom: none;
}

.empty-row td {
    text-align: center;
    color: var(--text-secondary);
    padding: 1.5rem 0;
}

/* Ad banner */
.ad-banner-section {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    width: 100%;
}

.ad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    max-width: 728px;
}

.ad-tag {
    font-size: 0.55rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
    font-weight: 700;
}

.ad-placeholder {
    width: 100%;
    min-height: 80px;
    background: var(--card-bg);
    border: 1px dashed var(--card-border);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.mock-ad-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 1rem 1.5rem;
    gap: 1.5rem;
    text-align: left;
}

.mock-ad-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.mock-ad-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mock-ad-subtitle {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.mock-ad-btn {
    background: var(--accent);
    border: none;
    color: #000;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.mock-ad-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(16px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #0a0a0a;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2.5rem;
    width: 90%;
    max-width: 580px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    transform: translateY(16px);
    transition: transform 0.3s ease;
    color: var(--text-primary);
}

.modal.open .modal-content {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
    font-weight: 800;
    color: var(--accent);
}

.modal-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.modal-features {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1.25rem 0;
}

.feature-item {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    border: 1px solid var(--card-border);
    padding: 0.9rem;
    border-radius: 10px;
}

.feature-icon {
    font-size: 1.3rem;
}

.feature-item h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.feature-item p {
    font-size: 0.8rem;
    margin-bottom: 0;
    line-height: 1.4;
}

.modal-footer-note {
    text-align: center;
    font-size: 0.75rem !important;
    color: var(--text-secondary) !important;
    opacity: 0.5;
    margin-bottom: 0 !important;
    margin-top: 1.25rem;
}

/* ========== Responsive ========== */

/* Tablet */
@media (max-width: 768px) {
    body {
        padding: 1rem 0;
        flex-direction: column;
    }

    .global-nav {
        position: static;
        display: flex;
        justify-content: center;
        margin: 0 auto 1rem;
        gap: 0.5rem;
    }

    .app-container {
        padding: 1.5rem;
        width: 95%;
        border-radius: 14px;
    }

    .app-header {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 2rem;
        padding-bottom: 1rem;
        text-align: center;
    }

    .gauge-container {
        width: 250px;
        height: 250px;
    }

    .go-button {
        width: 64px;
        height: 64px;
        font-size: 0.95rem;
    }

    .speed-value {
        font-size: 2.2rem;
    }

    .mock-ad-content {
        flex-direction: column;
        text-align: center;
        padding: 0.9rem;
        gap: 0.8rem;
    }

    .mock-ad-btn {
        width: 100%;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .modal-content h2 {
        font-size: 1.3rem;
    }
}

/* Phone */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .info-container {
        flex-direction: column;
        gap: 0.8rem;
        text-align: center;
    }

    .app-container {
        padding: 1.25rem;
        width: 97%;
    }

    .gauge-container {
        width: 220px;
        height: 220px;
    }

    .speed-value {
        font-size: 2rem;
    }

    .logo-area h1 {
        font-size: 1.2rem;
    }
}
