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

body {
    font-family: 'Courier New', monospace;
    background: #000;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Particles background */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.particle {
    position: fixed;
    background: #fff;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 10px #fff;
}

.particle::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    background: linear-gradient(to top, transparent, rgba(255,255,255,0.8));
    animation: stretch linear infinite;
    transform-origin: bottom;
}

@keyframes stretch {
    from {
        height: 0;
        opacity: 0;
    }
    to {
        height: 100px;
        opacity: 0;
    }
}

.container {
    width: 100%;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* Sections */
.section {
    display: none;
    min-height: 100vh;
    padding: 40px 20px;
    position: relative;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.section.active {
    display: flex;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: normal;
    letter-spacing: 0.2em;
    margin-bottom: 10px;
    text-align: center;
}

h2 {
    font-size: 1.2rem;
    font-weight: normal;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.6;
    margin-bottom: 40px;
    letter-spacing: 0.05em;
    text-align: center;
}

.subtitle a {
    color: inherit;
}

/* Instance Selection */
.instances-container {
    width: 100%;
    max-width: 800px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #fff;
    padding: 30px;
    margin-bottom: 30px;
}

.hint {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-bottom: 20px;
}

.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.instance-checkbox {
    display: flex;
    align-items: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.instance-checkbox:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05);
}

.instance-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    margin-right: 15px;
    flex-shrink: 0;
    position: relative;
}

.instance-checkbox input:checked ~ .checkmark {
    background: #fff;
}

.instance-checkbox input:checked ~ .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    font-size: 14px;
}

.instance-info {
    flex: 1;
}

.instance-name {
    font-size: 0.95rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.instance-url {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Custom Instance */
.custom-instance {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.custom-instance input {
    flex: 1;
    padding: 12px 15px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    outline: none;
}

.custom-instance input:focus {
    border-color: rgba(255, 255, 255, 0.5);
}

.custom-instance input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Buttons */
.btn {
    padding: 15px 40px;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    background: transparent;
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.btn:hover:not(:disabled) {
    background: #fff;
    color: #000;
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn.primary {
    background: #fff;
    color: #000;
}

.btn.primary:hover:not(:disabled) {
    background: transparent;
    color: #fff;
}

.btn.secondary {
    background: transparent;
    color: #fff;
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    background: transparent;
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: #fff;
    color: #000;
}

/* Error Message */
.error-message {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin: 20px 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    text-align: center;
}

.error-message.show {
    opacity: 1;
}

/* Test Mode Selector */
.test-mode-selector {
    display: flex;
    gap: 15px;
    margin: 30px 0 20px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.test-mode-option {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.test-mode-option:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.08);
}

.test-mode-option input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: #fff;
}

.test-mode-option:has(input:checked) {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.mode-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.mode-title {
    font-size: 0.95rem;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.mode-desc {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Info Text */
.info-text {
    max-width: 600px;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.6;
    margin-top: 30px;
    line-height: 1.6;
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.footer a {
    color: #fff;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.footer a:hover {
    opacity: 0.6;
}

.footer .separator {
    margin: 0 10px;
    opacity: 0.4;
}

/* Testing Section */
.testing-status {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
    width: 100%;
    max-width: 800px;
}

.status-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    text-align: center;
}

.status-label {
    font-size: 0.8rem;
    opacity: 0.6;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.status-value {
    font-size: 1.1rem;
    font-weight: bold;
    word-break: break-all;
}

/* Progress Container */
.progress-container {
    width: 100%;
    max-width: 800px;
    margin-bottom: 30px;
}

.progress-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 15px;
    margin-bottom: 15px;
}

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

.progress-name {
    font-size: 0.9rem;
    font-weight: bold;
    flex: 1;
}

.progress-status {
    font-size: 0.85rem;
    opacity: 0.7;
    min-width: 140px;
    text-align: right;
    white-space: nowrap;
}

.progress-status.received {
    color: #4ade80;
    opacity: 1;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #4ade80;
    width: 0;
    transition: width 0.3s ease;
}

.progress-bar.loading .progress-bar-fill {
    width: 100%;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.1) 0%,
        rgba(255,255,255,0.3) 50%,
        rgba(255,255,255,0.1) 100%);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Results Section */
.results-container {
    width: 100%;
    max-width: 800px;
    margin-bottom: 40px;
}

.result-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    margin-bottom: 15px;
    position: relative;
}

.result-item.fastest {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.result-name {
    font-size: 0.95rem;
    font-weight: bold;
    flex: 1;
}

.fastest-tag {
    font-size: 0.7rem;
    font-weight: bold;
    padding: 4px 10px;
    background: #4ade80;
    color: #000;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.result-latency {
    font-size: 0.9rem;
    color: #4ade80;
    font-weight: bold;
    white-space: nowrap;
}

.result-latency.timeout {
    color: #ff6b6b;
}

.result-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    margin-bottom: 12px;
}

.result-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    width: 0;
    transition: width 0.5s ease;
}

.result-bar-fill.timeout {
    background: #ff6b6b;
}

.result-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
}

.stat-item {
    opacity: 0.8;
}

.stat-separator {
    opacity: 0.3;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* Share Message */
.share-message {
    margin-top: 20px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.share-message.show {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #000;
    border: 2px solid #fff;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 30px;
}

.turnstile-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    min-height: 65px;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    flex-direction: column;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
        letter-spacing: 0.1em;
    }

    .instances-container {
        padding: 20px;
    }

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

    .custom-instance {
        flex-direction: column;
    }

    .testing-status {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .button-group .btn {
        width: 100%;
    }

    .footer-content {
        flex-direction: column;
        gap: 10px;
    }

    .footer .separator {
        display: none;
    }
}
