:root {
    --bg-dark: #080315;
    --accent-purple: #b030f0;
    --accent-pink: #ff00cc;
    --accent-blue: #33ccff;
    --accent-gold: #ffcc00;
    --glass-white: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    /* 120Hz optimized easing */
    --ease-out-premium: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back-premium: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out-premium: cubic-bezier(0.76, 0, 0.24, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 430px;
    height: 100%;
    position: relative;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbar for Safari/Chrome handle below */
}

.app-container::-webkit-scrollbar {
    display: none;
}

/* COSMOS BACKGROUND */
.cosmos {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: radial-gradient(circle at 50% 10%, #200b3b 0%, #080315 100%);
    overflow: hidden;
}

.stars {
    position: absolute;
    width: 200%;
    height: 200%;
    background: url('https://www.transparenttextures.com/patterns/stardust.png');
    opacity: 0.3;
    animation: rotateStars 120s linear infinite;
}

.nebula {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    transition: all 5s ease-in-out;
}

.nebula-1 {
    width: 300px;
    height: 300px;
    background: var(--accent-purple);
    top: -50px;
    left: -50px;
}

.nebula-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-pink);
    bottom: -100px;
    right: -100px;
}

@keyframes rotateStars {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* PROFILE HEADER */
.profile-section {
    position: relative;
    z-index: 10;
    margin-top: 10px;
}

.profile-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.avatar-glow {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--accent-blue), var(--accent-pink));
    animation: pulseGlow 2s infinite ease-in-out;
    filter: blur(8px);
}

.avatar-circle {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #1a0a2e;
    border: 3px solid rgba(255, 255, 255, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

.avatar-icon { font-size: 48px; }

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-label {
    font-size: 18px;
    font-weight: 500;
}

.pts-capsule {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.pts-icon { font-size: 20px; }

.pts-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.pts-label {
    font-size: 14px;
    color: var(--text-muted);
}

.add-pts-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    margin-left: 4px;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

/* STATUS CARDS SECTION */
.status-cards-section {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.status-cards-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 12px;
    padding: 10px 0;
}

.status-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.6s var(--ease-out-back-premium);
    will-change: transform, opacity, width, height;
}

.status-card.primary {
    width: 120px;
    height: 140px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    z-index: 10;
    transform: scale(1);
    opacity: 1;
}

.status-card.secondary {
    width: 100px;
    height: 110px;
    opacity: 0.6;
    transform: scale(0.9);
}

/* RANK-SPECIFIC THEMES */

/* Silver */
.status-card.rank-silver {
    background: linear-gradient(135deg, #4a4e69, #22223b);
}
.status-card.rank-silver.primary {
    box-shadow: 0 0 30px rgba(154, 160, 185, 0.4);
}

/* Gold */
.status-card.rank-gold {
    background: linear-gradient(135deg, #d4af37, #9c7e1a);
}
.status-card.rank-gold.primary {
    box-shadow: 0 0 30px rgba(255, 223, 0, 0.4);
}

/* Platinum */
.status-card.rank-platinum {
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
}
.status-card.rank-platinum.primary {
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.4);
}

/* Diamond */
.status-card.rank-diamond {
    background: linear-gradient(135deg, #b300ff, #302b63);
}
.status-card.rank-diamond.primary {
    box-shadow: 0 0 40px rgba(179, 0, 255, 0.5);
}

.card-glass {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    pointer-events: none;
}

.card-inner-glow {
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    height: 60px;
    filter: blur(25px);
    opacity: 0.6;
}

.rank-silver .card-inner-glow { background: #9aa0b9; }
.rank-gold .card-inner-glow { background: #ffdf00; }
.rank-platinum .card-inner-glow { background: #00f2ff; }
.rank-diamond .card-inner-glow { background: #b300ff; }

.card-star { font-size: 32px; margin-bottom: 4px; color: #fff; text-shadow: 0 0 10px rgba(255,255,255,0.5); }
.card-rank { font-size: 24px; font-weight: 800; color: #fff; }
.card-title { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255,255,255,0.9); }

/* STATUS BADGE */
.status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-gold);
    color: #000;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.6);
    z-index: 20;
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    0%, 100% { opacity: 0.9; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* Progress Bar */
.progress-bar-container {
    padding: 0 10px;
}

.progress-bar-bg {
    background: rgba(0, 0, 0, 0.4);
    height: 12px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 10px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-gold));
    box-shadow: 0 0 10px var(--accent-blue);
    border-radius: 10px;
    transition: width 1s var(--ease-out-premium);
    will-change: width;
}

.progress-info {
    font-size: 14px;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    width: 100%;
}

.view-route-link {
    color: var(--accent-blue);
    text-decoration: underline;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
    white-space: nowrap;
}

.view-route-link:hover {
    color: var(--text-primary);
}

/* ACTIONS BLOCK */
.actions-block {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-card {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    color: white;
    transition: all 0.3s var(--ease-out-back-premium);
    will-change: transform, background;
}

.action-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.action-card:active { transform: scale(0.97); }

/* MATCH-3 THEME (Royal Gold & Purple) */
.action-card.match3 {
    background: linear-gradient(135deg, rgba(48, 43, 99, 0.4), rgba(15, 12, 41, 0.6));
    border-color: rgba(255, 223, 0, 0.25);
}

.action-card.match3:hover {
    border-color: rgba(255, 223, 0, 0.5);
    box-shadow: 0 10px 40px rgba(255, 223, 0, 0.1);
}

.action-card.match3 .action-icon {
    font-size: 28px;
    width: 54px;
    height: 54px;
    background: linear-gradient(180deg, #ffdf00, #d4af37);
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(255, 223, 0, 0.2);
}

.action-card.match3 .action-title {
    background: linear-gradient(to right, #ffffff, #ffdf00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

/* RHYTHM DASH THEME (Neon Cyan & Speed) */
.action-card.rhythm-dash {
    background: linear-gradient(135deg, rgba(5, 5, 16, 0.6), rgba(0, 242, 255, 0.05));
    border-color: rgba(0, 242, 255, 0.25);
}

.action-card.rhythm-dash:hover {
    border-color: rgba(0, 242, 255, 0.5);
    box-shadow: 0 10px 40px rgba(0, 242, 255, 0.15);
}

.action-card.rhythm-dash .action-icon {
    font-size: 28px;
    width: 54px;
    height: 54px;
    background: linear-gradient(135deg, #00f2ff, #0077ff);
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
}

.action-card.rhythm-dash .action-title {
    background: linear-gradient(to right, #ffffff, #00f2ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

/* UPGRADE THEME (Rocket Blast) */
.action-card.upgrade {
    background: linear-gradient(135deg, rgba(20, 10, 40, 0.6), rgba(255, 0, 204, 0.05));
    border-color: rgba(255, 0, 204, 0.2);
}

.action-card.upgrade:hover {
    border-color: rgba(255, 0, 204, 0.4);
    box-shadow: 0 10px 40px rgba(255, 0, 204, 0.1);
}

.action-card.upgrade .action-icon {
    font-size: 28px;
    width: 54px;
    height: 54px;
    background: linear-gradient(135deg, #ff00cc, #3333ff);
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(255, 0, 204, 0.2);
}

.action-card.upgrade .action-title {
    background: linear-gradient(to right, #ffffff, #ff00cc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.action-icon {
    flex-shrink: 0;
}

.action-title { font-size: 19px; font-weight: 700; margin-bottom: 2px; }
.action-stats { display: flex; gap: 10px; font-size: 14px; }
.reward { color: var(--accent-blue); font-weight: 700; }
.duration { color: var(--text-muted); }

/* MINI RANKING */
.ranking-block {
    position: relative;
    z-index: 10;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    transition: all 0.5s var(--ease-out-back-premium);
    will-change: transform, background, border-color;
}

.ranking-item.current-user {
    background: rgba(176, 48, 240, 0.15);
    border: 1px solid rgba(176, 48, 240, 0.4);
}

.item-pos { width: 40px; font-weight: 700; color: var(--text-muted); }
.mini-avatar { margin-right: 12px; font-size: 20px; }
.item-name { flex-grow: 1; font-weight: 500; }
.item-score { font-weight: 700; }

/* --- PREMIUM FULL-SCREEN MAP --- */
.map-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #080315;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s var(--ease-out-premium);
    will-change: opacity;
}

.map-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.map-content.full-screen-map {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    background: #000;
}

/* FIXED ASPECT RATIO CONTAINER FOR MAP ALIGNMENT */
.map-viewport {
    position: relative;
    height: 100%;
    aspect-ratio: 10 / 16;
    overflow: hidden;
    background: #080315;
    box-shadow: 0 0 100px rgba(0,0,0,1);
}

.map-bg-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: brightness(0.5) saturate(1.1);
}

.map-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.map-path-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.03);
    stroke-width: 15;
    stroke-linecap: round;
}

.map-path-glow {
    fill: none;
    stroke: #00f2ff;
    stroke-width: 6;
    stroke-linecap: round;
    filter: drop-shadow(0 0 10px #00f2ff);
    stroke-dasharray: 4000;
    stroke-dashoffset: 4000;
    transition: stroke-dashoffset 3s ease-in-out;
}

.map-overlay.visible .map-path-glow {
    stroke-dashoffset: 0;
}

.map-points-container {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

.map-point {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    transition: all 0.5s var(--ease-out-back-premium);
    will-change: transform;
}

.point-core {
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    position: relative;
    z-index: 2;
}

.map-point.active .point-core {
    background: #00f2ff;
    border-color: #fff;
    box-shadow: 0 0 20px #00f2ff;
    transform: scale(1.4);
}

.map-point.next .point-core {
    background: #ff00cc;
    border-color: #fff;
    box-shadow: 0 0 15px #ff00cc;
    animation: p-pulse 1.5s infinite;
}

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

.point-core.treasure {
    width: 60px; height: 60px;
    background: radial-gradient(circle, #ffd700, #ff8c00);
    border: 4px solid #fff;
    display: flex; justify-content: center; align-items: center;
    font-size: 32px;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
}

.point-label {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    background: rgba(0,0,0,0.4);
    padding: 2px 10px;
    border-radius: 10px;
    backdrop-filter: blur(4px);
}

.point-reward {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-gold);
}

.user-marker {
    position: absolute;
    width: 32px; height: 32px;
    z-index: 30;
    pointer-events: none;
    offset-rotate: none;
    transform: translate(-50%, -50%);
    transition: left 0.8s var(--ease-in-out-premium), top 0.8s var(--ease-in-out-premium);
    will-change: left, top;
}

.marker-core {
    width: 100%; height: 100%;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255,255,255,0.8);
}

.marker-glow {
    position: absolute;
    inset: -15px;
    background: radial-gradient(circle, rgba(0, 242, 255, 0.4) 0%, transparent 70%);
}

.close-map-btn {
    position: absolute;
    top: 40px; right: 40px;
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    z-index: 2500;
    cursor: pointer;
    backdrop-filter: blur(5px);
}

.close-map-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: rotate(90deg);
}

.map-path {
    fill: none;
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 8 8;
}

.map-point {
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.4s ease;
}

.map-point.active {
    background: var(--accent-blue);
    box-shadow: 0 0 15px var(--accent-blue);
    border-color: white;
}

.map-point.next {
    animation: pulsePoint 1.5s infinite ease-in-out;
}

.point-label {
    position: absolute;
    top: 22px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.point-reward {
    position: absolute;
    top: 36px;
    white-space: nowrap;
    font-size: 10px;
    color: var(--accent-blue);
    font-weight: 800;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.4s ease;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.map-point.active .point-reward {
    opacity: 1;
    transform: translateY(0);
}

.point-crown {
    font-size: 32px;
    position: absolute;
    top: -45px;
}

.map-point.final {
    width: 30px;
    height: 30px;
    background: rgba(255, 204, 0, 0.2);
    border-color: var(--accent-gold);
}

.map-point.final.active {
    background: var(--accent-gold);
    box-shadow: 0 0 30px var(--accent-gold);
    transform: translate(-50%, -50%) scale(1.5);
}

/* USER MARKER */
.user-marker {
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 20px 5px var(--accent-cyan);
    z-index: 1005;
    transform: translate(-50%, -50%);
    /* Movement set via offset-path in JS */
}

/* EXPLOSION EFFECT */
.light-explosion {
    position: absolute;
    width: 0;
    height: 0;
    background: radial-gradient(circle, white 0%, var(--accent-gold) 50%, transparent 100%);
    border-radius: 50%;
    top: 50px;
    left: 50px;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    z-index: 1020;
}

.light-explosion.active {
    animation: explode 0.8s ease-out forwards;
}

@keyframes explode {
    0% { width: 0; height: 0; opacity: 1; }
    50% { width: 400px; height: 400px; opacity: 0.8; }
    100% { width: 600px; height: 600px; opacity: 0; }
}

@keyframes pulsePoint {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
}
