/* 2025 Modern SpeedTest - Bento Grid Style */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #09090b;
    --surface: #18181b;
    --surface-2: #27272a;
    --border: #3f3f46;
    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --primary: #3b82f6;
    --primary-2: #60a5fa;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --download: #3b82f6;
    --upload: #8b5cf6;
    --ping: #22c55e;
    --radius: 16px;
    --radius-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* Background Effects */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 20% -20%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 0%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 50% 30% at 50% 100%, rgba(34, 197, 94, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Grid Pattern */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.app {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    padding: 16px 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
}

.lang-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    color: var(--text);
    border-color: var(--text-3);
}

.logo-icon {
    font-size: 24px;
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Start Section */
.start-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    position: relative;
}

/* Floating orbs animation */
.start-section::before,
.start-section::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.start-section::before {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.start-section::after {
    width: 250px;
    height: 250px;
    background: var(--upload);
    bottom: 20%;
    right: 10%;
    animation-delay: 5s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(20px, -20px) scale(1.05);
    }
    50% {
        transform: translate(-10px, 10px) scale(0.95);
    }
    75% {
        transform: translate(15px, 15px) scale(1.02);
    }
}

.start-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.start-content h1 {
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.start-content p {
    color: var(--text-2);
    font-size: 15px;
    margin-bottom: 32px;
}

.start-btn {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--upload) 100%);
    border: none;
    color: white;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 24px rgba(59, 130, 246, 0.4);
    position: relative;
    overflow: hidden;
}

.start-btn::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--upload) 100%);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.5);
}

.start-btn:active {
    transform: scale(0.98);
}

.start-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Status Bar */
.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-2);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* Bento Grid */
.results-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.bento-card {
    background: rgba(24, 24, 27, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.bento-card.large {
    grid-column: span 2;
    min-height: 200px;
}

.bento-card:not(.large) {
    min-height: 160px;
}

.bento-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    opacity: 0;
    transition: opacity 0.2s;
}

.bento-card:hover {
    border-color: var(--surface-2);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.bento-card:hover::before {
    opacity: 1;
}

/* Card Types */
.bento-card.large {
    grid-column: span 2;
}

.bento-card.download::before { background: var(--download); }
.bento-card.upload::before { background: var(--upload); }
.bento-card.ping::before { background: var(--ping); }
.bento-card.jitter::before { background: var(--warning); }
.bento-card.bufferbloat::before { background: var(--danger); }
.bento-card.dns::before { background: var(--text-3); }

.card-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.card-icon {
    font-size: 16px;
}

.card-value {
    font-size: clamp(36px, 6vw, 48px);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
    min-height: 48px;
    display: flex;
    align-items: center;
}

.bento-card.large .card-value {
    font-size: clamp(48px, 8vw, 64px);
    min-height: 64px;
}

.bento-card.download .card-value { color: var(--download); }
.bento-card.upload .card-value { color: var(--upload); }
.bento-card.ping .card-value { color: var(--ping); }
.bento-card.jitter .card-value { color: var(--warning); }
.bento-card.bufferbloat .card-value { color: var(--danger); }
.bento-card.dns .card-value { color: var(--text-2); }

.card-value.loading {
    gap: 6px;
}

.card-value.loading .dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: currentColor;
    animation: dotWave 1.4s ease-in-out infinite;
}

.bento-card.large .card-value.loading {
    min-height: 1.2em;
}

.bento-card.large .card-value.loading .dot {
    width: 16px;
    height: 16px;
}

.card-value.loading .dot:nth-child(1) { animation-delay: 0s; }
.card-value.loading .dot:nth-child(2) { animation-delay: 0.15s; }
.card-value.loading .dot:nth-child(3) { animation-delay: 0.3s; }

.bento-card.download .card-value.loading { color: var(--download); }
.bento-card.upload .card-value.loading { color: var(--upload); }
.bento-card.ping .card-value.loading { color: var(--ping); }
.bento-card.jitter .card-value.loading { color: var(--warning); }
.bento-card.bufferbloat .card-value.loading { color: var(--danger); }
.bento-card.dns .card-value.loading { color: var(--text-2); }

@keyframes dotWave {
    0%, 80%, 100% { 
        transform: translateY(0) scale(0.8);
        opacity: 0.5;
    }
    40% { 
        transform: translateY(-12px) scale(1);
        opacity: 1;
    }
}

.card-unit {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
}

.card-sub {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-3);
}

.card-grade {
    margin-top: 12px;
}

/* Retest Button Small */
.retest-btn-small {
    margin-left: auto;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.retest-btn-small:hover {
    color: white;
    border-color: var(--text);
}

/* Share Section */
.share-section {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.share-btn {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.share-btn:hover {
    color: white;
    border-color: var(--text);
}

.share-btn.copied {
    color: var(--primary);
    border-color: var(--primary);
}

.share-id {
    font-size: 12px;
    font-family: monospace;
    color: var(--text-3);
}

.shared-info {
    font-size: 13px;
    color: var(--text-3);
}

.new-test-link {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: var(--primary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.new-test-link:hover {
    background: var(--primary-2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* Grade Badge */
.grade-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: white;
}

.grade-A { background: var(--success); }
.grade-B { background: var(--primary); }
.grade-C { background: var(--warning); }
.grade-D { background: var(--danger); }
.grade-F { background: #7f1d1d; }

/* Scenarios */
.scenarios-section {
    animation: fadeIn 0.3s ease 0.1s both;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.scenario-card {
    background: rgba(24, 24, 27, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
}

.scenario-card:hover {
    border-color: var(--surface-2);
    transform: translateY(-2px);
}

.scenario-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 12px;
}

.status-badge.suitable {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.status-badge.not-suitable {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.issues-list {
    list-style: none;
    margin-top: 12px;
}

.issues-list li {
    padding: 8px 0;
    color: var(--text-2);
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.issues-list li:last-child {
    border-bottom: none;
}

.issues-list li::before {
    content: "•";
    color: var(--warning);
    font-weight: bold;
}

.success-message {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 12px;
    color: var(--success);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.success-message::before {
    content: "✓";
    font-weight: bold;
}

.help-button {
    margin-top: 12px;
    padding: 10px 16px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.help-button:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 720px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-head {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--surface);
}

.modal-head h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-x {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-x:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.modal-content {
    padding: 20px;
}

.solution-section {
    margin-bottom: 24px;
}

.solution-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.solution-list {
    list-style: none;
}

.solution-list li {
    padding: 14px;
    margin-bottom: 10px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.solution-list li:hover {
    transform: translateX(4px);
}

.solution-list li strong {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text);
}

.solution-list li div {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.6;
}

.video-container {
    margin-top: 16px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
}

.video-container iframe {
    width: 100%;
    height: 320px;
    border: none;
}

/* Responsive */
@media (max-width: 768px) {
    .app {
        padding: 16px;
    }
    
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .bento-card.large {
        grid-column: span 2;
    }
    
    .start-btn {
        width: 120px;
        height: 120px;
        font-size: 16px;
    }
    
    .bento-card {
        padding: 20px;
    }
    
    .card-value {
        font-size: 32px;
    }
    
    .bento-card.large .card-value {
        font-size: 40px;
    }
}

@media (max-width: 480px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }
    
    .bento-card.large {
        grid-column: span 1;
    }
    
    .scenarios-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}

/* IP Info Bar */
.ip-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 16px;
    background: rgba(24, 24, 27, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.ip-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ip-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
}

.ip-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    font-family: monospace;
}

.ip-value.hidden {
    color: var(--text-3);
}

.ip-toggle {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-2);
    background: transparent;
    border: 1px solid var(--primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.ip-toggle:hover {
    background: var(--primary);
    color: white;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 40px 0;
    border-top: 1px solid var(--border);
}

.footer-main {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-github {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0;
}

.footer-github:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.footer-info h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.footer-info p {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.6;
}

/* Marquee Footer */
.marquee-footer {
    background: transparent;
    padding: 24px 0;
    overflow: hidden;
    position: relative;
}

.marquee-track {
    display: flex;
    width: max-content;
    animation: marquee 40s linear infinite;
}

.marquee-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

.marquee-footer:hover .marquee-track {
    animation-play-state: paused;
}

/* Responsive Footer */
@media (max-width: 768px) {
    .ip-bar {
        gap: 16px;
    }
    
    .ip-item {
        flex: 1;
        min-width: calc(50% - 8px);
    }
    
    .footer-main {
        flex-direction: column;
        gap: 16px;
    }
    
    .marquee-text {
        font-size: 12px;
    }
}
