/* =========================================
   DESIGN TOKENS
   ========================================= */
:root {
    --bg-1: #0d0d1a;
    --bg-2: #1a0d2e;
    --bg-3: #0d1a2e;
    --glass: rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-hover: rgba(255, 255, 255, 0.13);
    --accent: #a78bfa;
    --accent-2: #f472b6;
    --accent-glow: rgba(167, 139, 250, 0.4);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --green: #4ade80;
    --yellow: #fbbf24;
    --red: #f43f5e;
    --nav-h: 72px;
    --bar-h: 44px;
    --r: 16px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(ellipse at 20% 20%, #1e0a3c 0%, var(--bg-1) 50%),
                radial-gradient(ellipse at 80% 80%, #0a1e3c 0%, var(--bg-1) 50%);
    background-blend-mode: screen;
    background-color: var(--bg-1);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
    user-select: none;
}

/* =========================================
   STARS BACKGROUND
   ========================================= */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 50% 10%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 15% 75%, rgba(255,255,255,0.2) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 15%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 55% 50%, rgba(255,255,255,0.2) 0%, transparent 100%),
        radial-gradient(1px 1px at 25% 90%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 75% 25%, rgba(255,255,255,0.3) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

/* =========================================
   NAVBAR
   ========================================= */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: var(--nav-h);
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    position: relative;
    z-index: 50;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    background: rgba(0,0,0,0.3);
    padding: 5px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    position: relative;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.5rem 1.2rem;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tab-btn:hover {
    color: var(--text);
    background: var(--glass-hover);
}

.tab-btn.active {
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: white;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

.badge {
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 22px;
    text-align: center;
    transition: all 0.3s;
}

.tab-btn.active .badge {
    background: rgba(255,255,255,0.3);
}

.score-block {
    text-align: right;
}

.score-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f472b6, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: inline-block;
}

.score-value.pop {
    transform: scale(1.4);
}

/* =========================================
   CONTENT & VIEWS
   ========================================= */
.content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.view {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    display: flex;
    flex-direction: column;
}

.view.active {
    opacity: 1;
    pointer-events: all;
    z-index: 10;
}

/* =========================================
   GAME AREA
   ========================================= */
#view-game {
    overflow: hidden;
}

.game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: crosshair;
}

.hint-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: 700;
    color: rgba(255,255,255,0.08);
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
}

/* =========================================
   DIFFICULTY BAR
   ========================================= */
.difficulty-bar {
    height: var(--bar-h);
    background: rgba(0,0,0,0.4);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.diff-segments {
    display: flex;
    gap: 4px;
}

.seg {
    width: 28px;
    height: 10px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
    transition: background 0.4s ease;
}

.seg.on-1 { background: var(--green); box-shadow: 0 0 6px var(--green); }
.seg.on-2 { background: #86efac; box-shadow: 0 0 6px #86efac; }
.seg.on-3 { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.seg.on-4 { background: #fb923c; box-shadow: 0 0 6px #fb923c; }
.seg.on-5 { background: var(--red); box-shadow: 0 0 6px var(--red); }

#diff-label {
    color: var(--text);
    font-weight: 600;
    transition: color 0.4s;
}

/* =========================================
   CAT ELEMENT
   ========================================= */
.cat {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 0 3px rgba(255,255,255,0.2);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    z-index: 20;
    will-change: left, top;
}

.cat:hover {
    transform: scale(1.15);
    box-shadow: 0 0 14px rgba(167, 139, 250, 0.7), 0 0 0 4px rgba(255,255,255,0.5);
}

.cat.popping {
    animation: cat-pop 0.4s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
    pointer-events: none;
}

@keyframes cat-pop {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.9; filter: brightness(1.5) drop-shadow(0 0 20px gold); }
    100% { transform: scale(0); opacity: 0; }
}

/* =========================================
   PARTICLES
   ========================================= */
#particles-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
}

.particle {
    position: absolute;
    font-size: 1.2rem;
    animation: particle-fly 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes particle-fly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.score-popup {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fbbf24;
    animation: score-up 0.8s ease-out forwards;
    pointer-events: none;
    z-index: 200;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
}

@keyframes score-up {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-80px) scale(0.8); opacity: 0; }
}

/* =========================================
   COLLECTION VIEW
   ========================================= */
.collection-wrapper {
    padding: 2rem;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.collection-title h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.3rem;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1.2rem;
    padding-bottom: 2rem;
}

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.empty-icon {
    font-size: 5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.empty-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
}

.empty-sub {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* Collection cards */
.cat-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--r);
    padding: 1.5rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: default;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    animation: card-in 0.4s cubic-bezier(0.34, 1.2, 0.64, 1) both;
    backdrop-filter: blur(10px);
}

@keyframes card-in {
    from { opacity: 0; transform: scale(0.7) rotate(-5deg); }
    to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.cat-card:hover {
    transform: translateY(-6px) rotate(1deg);
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}

.cat-card.rarity-common { border-color: rgba(255,255,255,0.15); }
.cat-card.rarity-uncommon { border-color: rgba(74, 222, 128, 0.5); box-shadow: 0 0 10px rgba(74, 222, 128, 0.1); }
.cat-card.rarity-rare { border-color: rgba(96, 165, 250, 0.6); box-shadow: 0 0 12px rgba(96, 165, 250, 0.2); }
.cat-card.rarity-epic { border-color: rgba(167, 139, 250, 0.7); box-shadow: 0 0 15px rgba(167, 139, 250, 0.3); background: rgba(124,58,237,0.1); }
.cat-card.rarity-legendary { border-color: rgba(251, 191, 36, 0.8); box-shadow: 0 0 20px rgba(251, 191, 36, 0.35), inset 0 0 20px rgba(251, 191, 36, 0.05); background: rgba(251,191,36,0.07); }

.card-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 0.5rem;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border: 3px solid rgba(255,255,255,0.1);
    transition: transform 0.3s ease;
}

.cat-card:hover .card-img {
    transform: scale(1.1) rotate(-3deg);
    border-color: rgba(255,255,255,0.4);
}

.card-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}

.card-rarity {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 20px;
}

.rarity-common .card-rarity { background: rgba(255,255,255,0.1); color: var(--text-muted); }
.rarity-uncommon .card-rarity { background: rgba(74,222,128,0.15); color: #4ade80; }
.rarity-rare .card-rarity { background: rgba(96,165,250,0.15); color: #60a5fa; }
.rarity-epic .card-rarity { background: rgba(167,139,250,0.2); color: #a78bfa; }
.rarity-legendary .card-rarity { background: rgba(251,191,36,0.2); color: #fbbf24; }

.card-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* =========================================
   SCROLLBAR
   ========================================= */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
