/* ============================================
   MOBILE LEADERBOARD - SPIRIT DESIRE
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-dark: #0a0a0f;
    --bg-secondary: #151520;
    --bg-card: rgba(20, 20, 40, 0.9);
    --primary-blue: #4a5aff;
    --primary-purple: #8b5cf6;
    --accent-cyan: #00d9ff;
    --accent-pink: #ff00ff;
    --gold: #ffd700;
    --silver: #c0c0c0;
    --bronze: #cd7f32;
    --text-primary: #e0e0ff;
    --text-secondary: #8888aa;
    --border-glow: rgba(74, 90, 255, 0.5);
    --error-red: #ff3366;
    --success-green: #00ff88;
}

body {
    font-family: 'VT323', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    touch-action: pan-y;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   SCANLINES & NOISE EFFECTS
   ============================================ */

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0.1),
            rgba(0, 0, 0, 0.1) 1px,
            transparent 1px,
            transparent 2px);
    z-index: 9999;
    animation: scanline-move 8s linear infinite;
}

@keyframes scanline-move {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(10px);
    }
}

.noise {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    z-index: 9998;
    animation: noise-move 0.2s steps(10) infinite;
}

@keyframes noise-move {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(-5%, 5%);
    }
}

/* ============================================
   TOP BAR
   ============================================ */

.top-bar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(180deg, var(--primary-blue), var(--primary-purple));
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(74, 90, 255, 0.3);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success-green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.status-text {
    font-size: 0.9rem;
    font-weight: bold;
    color: white;
}

.app-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.9rem;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.refresh-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    color: white;
}

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

.refresh-btn.spinning svg {
    animation: spin 1s linear;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   STATS BAR
   ============================================ */

.stats-bar {
    background: var(--bg-secondary);
    padding: 1rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-bottom: 2px solid var(--primary-blue);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--accent-cyan);
    text-shadow: 0 0 10px var(--accent-cyan);
}

.stat-divider {
    width: 2px;
    height: 30px;
    background: linear-gradient(180deg, transparent, var(--primary-blue), transparent);
}

/* ============================================
   PODIUM SECTION
   ============================================ */

.podium-section {
    padding: 2rem 1rem;
    background: linear-gradient(180deg, var(--bg-secondary), var(--bg-dark));
}

.podium-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    text-align: center;
    color: var(--gold);
    margin-bottom: 1.5rem;
    text-shadow: 0 0 10px var(--gold);
    animation: glow-pulse 2s infinite;
}

@keyframes glow-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0 0.5rem;
}

.podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 120px;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes podium-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.podium-item.rank-1 {
    order: 2;
    transform: scale(1.1);
}

.podium-item.rank-2 {
    order: 1;
}

.podium-item.rank-3 {
    order: 3;
}

.crown {
    font-size: 1.5rem;
    animation: float-crown 3s ease-in-out infinite;
}

@keyframes float-crown {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.podium-avatar-wrapper {
    position: relative;
    width: 70px;
    height: 70px;
}

.rank-1 .podium-avatar-wrapper {
    width: 90px;
    height: 90px;
}

.podium-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid var(--primary-blue);
    object-fit: cover;
    box-shadow: 0 0 20px rgba(74, 90, 255, 0.5);
}

.rank-1 .podium-avatar {
    border-color: var(--gold);
    box-shadow: 0 0 30px var(--gold);
}

.rank-2 .podium-avatar {
    border-color: var(--silver);
    box-shadow: 0 0 20px var(--silver);
}

.rank-3 .podium-avatar {
    border-color: var(--bronze);
    box-shadow: 0 0 20px var(--bronze);
}

.podium-rank-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: var(--primary-blue);
    border: 2px solid var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: white;
}

.podium-rank-badge.gold {
    background: var(--gold);
    color: var(--bg-dark);
    box-shadow: 0 0 15px var(--gold);
}

.podium-name {
    font-size: 0.95rem;
    color: var(--text-primary);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-points {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
    padding: 0.5rem 1rem;
    border-radius: 12px;
    min-width: 60px;
}

.rank-1 .podium-points {
    background: linear-gradient(135deg, var(--gold), #ffed4e);
}

.podium-points-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.rank-1 .podium-points-value {
    font-size: 1.8rem;
    color: var(--bg-dark);
}

.podium-points-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
}

.rank-1 .podium-points-label {
    color: rgba(0, 0, 0, 0.6);
}

/* ============================================
   RANKINGS SECTION
   ============================================ */

.rankings-section {
    padding: 1rem;
    min-height: 400px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--primary-blue);
    margin-bottom: 1rem;
    box-shadow: 0 0 20px rgba(74, 90, 255, 0.2);
}

.section-title {
    font-size: 1rem;
    color: var(--accent-cyan);
    font-weight: bold;
}

.section-count {
    font-size: 1.2rem;
    color: var(--text-primary);
    background: var(--primary-blue);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

/* ============================================
   RANKING ITEMS
   ============================================ */

.rankings-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ranking-item {
    background: var(--bg-card);
    border: 1px solid rgba(74, 90, 255, 0.3);
    border-radius: 12px;
    padding: 1rem;
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 1rem;
    align-items: center;
    transition: all 0.3s;
    animation: slide-in 0.5s ease forwards;
    opacity: 0;
    transform: translateX(-20px);
}

@keyframes slide-in {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.ranking-item:active {
    transform: scale(0.98);
    background: linear-gradient(135deg, rgba(74, 90, 255, 0.2), rgba(139, 92, 246, 0.1));
    border-color: var(--primary-blue);
    box-shadow: 0 0 20px rgba(74, 90, 255, 0.3);
}

.ranking-rank {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

.ranking-rank.rank-gold {
    font-size: 1.5rem;
}

.ranking-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--primary-blue);
}

.ranking-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ranking-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.ranking-name {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.ranking-points {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    min-width: 60px;
}

.ranking-points-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: white;
}

.ranking-points-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================
   LOADING & ERROR STATES
   ============================================ */

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(74, 90, 255, 0.2);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spinner 1s linear infinite;
}

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

.loading-text {
    font-size: 1rem;
    color: var(--text-secondary);
    animation: pulse-text 1.5s infinite;
}

@keyframes pulse-text {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.error-message {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
    text-align: center;
}

.error-icon {
    font-size: 3rem;
    color: var(--error-red);
    animation: error-shake 1s infinite;
}

@keyframes error-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.error-text {
    color: var(--error-red);
}

.error-text div:first-child {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.error-subtext {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.error-retry {
    background: var(--error-red);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-family: 'VT323', monospace;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 1rem;
}

.error-retry:active {
    transform: scale(0.95);
    background: #ff1a4d;
}

/* ============================================
   PULL TO REFRESH
   ============================================ */

.pull-refresh {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--primary-blue);
    border-radius: 12px;
    z-index: 999;
    opacity: 0;
    transition: all 0.3s;
}

.pull-refresh-icon {
    font-size: 2rem;
    color: var(--accent-cyan);
    animation: bounce 1s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.pull-refresh-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pull-refresh.refreshing .pull-refresh-icon {
    animation: spin 1s linear infinite;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 360px) {
    .podium-item {
        max-width: 100px;
    }

    .podium-avatar-wrapper {
        width: 60px;
        height: 60px;
    }

    .rank-1 .podium-avatar-wrapper {
        width: 75px;
        height: 75px;
    }

    .ranking-item {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .ranking-avatar {
        width: 45px;
        height: 45px;
    }

    .ranking-name {
        font-size: 1rem;
    }
}

@media (min-width: 768px) {
    .podium {
        gap: 1rem;
    }

    .podium-item {
        max-width: 150px;
    }

    .rankings-section {
        max-width: 600px;
        margin: 0 auto;
    }
}

/* ============================================
   SAFE AREA HANDLING (for notched devices)
   ============================================ */

@supports (padding: max(0px)) {
    .top-bar {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .rankings-section {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ============================================
   DARK MODE OPTIMIZATION
   ============================================ */

@media (prefers-color-scheme: dark) {
    body {
        background: #000;
    }
}
