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

:root {
    --bg-primary: #667eea;
    --bg-secondary: #764ba2;
    --bg-surface: white;
    --text-primary: #333;
    --text-secondary: #999;
    --glass-bg: rgba(255,255,255,0.25);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.dark-theme {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-surface: #0f0f23;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --glass-bg: rgba(255,255,255,0.1);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-primary);
    transition: background 0.3s ease;
}

.container {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-bg);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 40px;
    max-width: 600px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5em;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1em;
}

.main-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
}

.speed-box {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    border-radius: 24px;
    padding: 40px 60px;
    color: white;
    text-align: center;
    margin-bottom: 30px;
    min-width: 280px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.speed-value {
    font-size: 4em;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 10px;
}

.speed-unit {
    font-size: 1.5em;
    opacity: 0.9;
    margin-bottom: 15px;
}

.speed-label {
    font-size: 1em;
    opacity: 0.8;
    letter-spacing: 1px;
}

.start-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 50px;
    font-size: 1.1em;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.start-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.6);
}

.start-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.2);
}

.metric-item {
    display: flex;
    flex-direction: column;
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.metric-item {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.9em;
    color: #999;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
}

.metric-value {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--bg-primary);
}

.metric-item.skeleton .metric-value {
    height: 1.5em;
    width: 80%;
}

.progress-container {
    margin-bottom: 30px;
}

.progress-bar {
    width: 0%;
    height: 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
    transition: width 0.3s ease;
}

.progress-bar.active {
    background: var(--glass-bg);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes progress {
    0% {
        width: 0%;
    }
    50% {
        width: 100%;
    }
    100% {
        width: 100%;
    }
}

.progress-text {
    text-align: center;
    font-size: 0.9em;
    color: #999;
    height: 20px;
}

.history-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #f0f0f0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-header h2 {
    font-size: 1.3em;
    color: #333;
}

.clear-btn, .share-button {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.clear-btn:hover, .share-button:hover {
    background: #ff5252;
    transform: translateY(-1px);
}

.dark-toggle {
    float: right;
    margin-top: 10px;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.dark-toggle input {
    margin-right: 8px;
    transform: scale(1.2);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-item-speed {
    font-weight: bold;
    font-size: 1.1em;
    color: #667eea;
}

.history-item-time {
    font-size: 0.85em;
    color: #999;
}

.no-history {
    text-align: center;
    color: #ccc;
    padding: 20px;
    font-style: italic;
}

.server-info {
    margin-top: 30px;
    padding: 15px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    font-size: 0.9em;
    color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.1);
}

.server-info p {
    margin: 5px 0;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    .header h1 {
        font-size: 2em;
    }

    .speed-box {
        padding: 30px 40px;
    }

    .speed-value {
        font-size: 3em;
    }

    .metrics {
        grid-template-columns: 1fr;
    }

    .start-button {
        width: 100%;
    }
}