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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#game {
    display: block;
    width: 100%;
    height: 100%;
}

#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    font-family: monospace;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#speed {
    font-size: 24px;
    font-weight: bold;
}

#beacon-info {
    margin-top: 8px;
    font-size: 16px;
    color: #00ffff;
    min-height: 20px;
}

#controls {
    margin-top: 8px;
    font-size: 12px;
    opacity: 0.7;
}

/* News Cards */
#cards-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.news-card {
    position: absolute;
    width: 220px;
    background: rgba(10, 20, 30, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    padding: 16px;
    min-height: 80px;
    color: white;
    font-family: 'Segoe UI', system-ui, sans-serif;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 255, 255, 0.1);
}

.news-card:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 255, 255, 0.2);
    border-color: rgba(0, 255, 255, 0.5);
}

.news-card.entering {
    animation: cardSlideIn 0.25s ease-out forwards;
}

.news-card.exiting {
    animation: cardFadeOut 0.3s ease-in forwards;
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes cardFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.news-card-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 10px;
    background: rgba(0, 255, 255, 0.1);
}

.news-card-headline {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: rgba(0, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.news-card-city {
    position: absolute;
    top: -8px;
    left: 12px;
    background: rgba(0, 255, 255, 0.9);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Expanded card overlay */
#card-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#card-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.news-card-expanded {
    width: 400px;
    max-width: 90vw;
    background: rgba(10, 20, 30, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 255, 255, 0.4);
    border-radius: 12px;
    padding: 20px;
    color: white;
    font-family: 'Segoe UI', system-ui, sans-serif;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 255, 255, 0.15);
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

#card-overlay.active .news-card-expanded {
    transform: scale(1);
}

.news-card-expanded .news-card-image {
    height: 180px;
    margin-bottom: 15px;
}

.news-card-expanded .news-card-headline {
    font-size: 18px;
    -webkit-line-clamp: unset;
    margin-bottom: 12px;
}

.news-card-expanded .news-card-body {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 255, 255, 0.3) transparent;
}

.news-card-expanded .news-card-body::-webkit-scrollbar {
    width: 4px;
}

.news-card-expanded .news-card-body::-webkit-scrollbar-track {
    background: transparent;
}

.news-card-expanded .news-card-body::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.3);
    border-radius: 2px;
}

.news-card-expanded .news-card-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 255, 0.5);
}

.news-card-expanded .news-card-meta {
    font-size: 11px;
}

.news-card-link {
    display: block;
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 4px;
    color: #00ffff;
    text-decoration: none;
    font-size: 12px;
    text-align: center;
    transition: background 0.2s, border-color 0.2s;
}

.news-card-link:hover {
    background: rgba(0, 255, 255, 0.2);
    border-color: rgba(0, 255, 255, 0.5);
}

.news-card-expanded .news-card-city {
    top: -10px;
    font-size: 10px;
    padding: 3px 8px;
}

/* Online count */
#online-count {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(10, 20, 30, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 6px;
    padding: 8px 14px;
    color: #00ffff;
    font-family: monospace;
    font-size: 14px;
    z-index: 50;
}

#online-count::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #00ff00;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Mobile Controls */
#mobile-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    pointer-events: none;
    z-index: 150;
}

@media (pointer: coarse), (max-width: 768px) {
    #mobile-controls {
        display: block;
    }

    #controls {
        display: none;
    }

    #ui {
        top: 10px;
        left: 10px;
    }

    #speed {
        font-size: 20px;
    }

    #online-count {
        top: 10px;
        right: 10px;
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Virtual Joystick */
#joystick-zone {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 140px;
    height: 140px;
    pointer-events: auto;
}

#joystick-base {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.1);
}

#joystick-stick {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.3);
    border: 2px solid rgba(0, 255, 255, 0.6);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: background 0.1s;
}

#joystick-stick.active {
    background: rgba(0, 255, 255, 0.5);
}

/* Action Buttons */
#action-buttons {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}

.action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid rgba(0, 255, 255, 0.3);
    color: rgba(0, 255, 255, 0.8);
    font-family: monospace;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.1);
    transition: background 0.1s, transform 0.1s;
}

.action-btn.active {
    background: rgba(0, 255, 255, 0.3);
    transform: scale(0.95);
}

.action-btn.brake {
    background: rgba(255, 100, 100, 0.1);
    border-color: rgba(255, 100, 100, 0.3);
    color: rgba(255, 100, 100, 0.8);
}

.action-btn.brake.active {
    background: rgba(255, 100, 100, 0.3);
}

/* Top controls bar for mobile */
#mobile-top-controls {
    position: fixed;
    top: 60px;
    right: 20px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.top-btn {
    padding: 10px 14px;
    border-radius: 6px;
    background: rgba(10, 20, 30, 0.8);
    border: 1px solid rgba(0, 255, 255, 0.3);
    color: rgba(0, 255, 255, 0.9);
    font-family: monospace;
    font-size: 12px;
    font-weight: bold;
    backdrop-filter: blur(10px);
    transition: background 0.1s, transform 0.1s;
}

.top-btn:active {
    background: rgba(0, 255, 255, 0.2);
    transform: scale(0.95);
}
