/* main.css - WonderArcade Design System & Mobile Touch Utilities */
:root {
    --bg-dark: #0f051d;
    --bg-mid: #240d47;
    --bg-light: #3d1b7a;
    --text-primary: #ffffff;
    --text-secondary: #c9bbf2;
    --accent-pink: #ff4791;
    --accent-cyan: #00f2fe;
    --accent-yellow: #ffb800;
    --accent-green: #00e676;
    --accent-purple: #9f55ff;
    
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-bg-hover: rgba(255, 255, 255, 0.14);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35);
    
    --font-heading: 'Fredoka', sans-serif;
    --font-body: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-mid) 50%, var(--bg-light) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

html {
    height: -webkit-fill-available;
}

/* Cosmic Background Animations */
.cosmic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    animation: floatOrb 20s infinite alternate ease-in-out;
}

.orb-1 {
    width: 350px;
    height: 350px;
    background: var(--accent-pink);
    top: -50px;
    left: -50px;
}

.orb-2 {
    width: 450px;
    height: 450px;
    background: var(--accent-cyan);
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: var(--accent-yellow);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, -60px) scale(1.15); }
    100% { transform: translate(-30px, 40px) scale(0.9); }
}

.stars-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(rgba(255, 255, 255, 0.4) 1px, transparent 0);
    background-size: 30px 30px;
    opacity: 0.2;
}

/* Glassmorphism System */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 24px;
}

.glass-pill {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* View Transition Utilities */
.view {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.view.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.view.active {
    display: block;
    opacity: 1;
}

/* Header Styles */
.arcade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin-bottom: 20px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    font-size: 2.4rem;
    animation: pulseIcon 2s infinite;
}

@keyframes pulseIcon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.gradient-text {
    background: linear-gradient(90deg, var(--accent-pink), var(--accent-yellow), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wallet-badge {
    background: linear-gradient(135deg, rgba(255, 184, 0, 0.25), rgba(255, 71, 145, 0.25));
    border-color: var(--accent-yellow);
    font-size: 1.1rem;
}

.star-icon {
    font-size: 1.3rem;
    filter: drop-shadow(0 0 6px var(--accent-yellow));
}

.icon-btn {
    cursor: pointer;
    border: none;
    outline: none;
    font-size: 1.2rem;
    padding: 10px 14px;
}

.icon-btn:active {
    transform: scale(0.9);
}

.icon-btn.active {
    background: rgba(0, 230, 118, 0.2);
    border-color: var(--accent-green);
}

/* Search and Filters */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.search-bar {
    width: 100%;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.06);
}

.search-bar input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    width: 100%;
}

.search-bar input::placeholder {
    color: rgba(201, 187, 242, 0.6);
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
}

.category-filters {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.category-filters::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    cursor: pointer;
    white-space: nowrap;
    border: none;
    font-size: 0.95rem;
    padding: 10px 18px;
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(255, 71, 145, 0.4);
    transform: translateY(-2px);
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.game-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: var(--card-gradient, linear-gradient(90deg, var(--accent-cyan), var(--accent-pink)));
}

.game-card:hover, .game-card:active {
    transform: translateY(-6px) scale(1.02);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.game-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.game-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    background: var(--icon-bg, rgba(255, 255, 255, 0.15));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.game-badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 700;
}

.game-card-body h3 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    margin-bottom: 6px;
    color: #fff;
}

.game-card-body p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 18px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.difficulty-stars {
    color: var(--accent-yellow);
    font-size: 0.9rem;
    letter-spacing: 2px;
}

.play-btn {
    background: var(--card-gradient, linear-gradient(135deg, var(--accent-pink), var(--accent-purple)));
    border: none;
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 20px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.play-btn:active {
    transform: scale(0.92);
}

/* Footer Extensibility Banner */
.arcade-footer {
    padding: 20px 24px;
    margin-top: 20px;
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.footer-icon {
    font-size: 2.2rem;
}

.footer-content h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--accent-cyan);
    margin-bottom: 4px;
}

.footer-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.footer-content code {
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--accent-yellow);
}

/* =========================================================
   Fullscreen Game Overlay & Touch Lock
   ========================================================= */
#game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    padding: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.game-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin: 10px;
    border-radius: 18px;
    z-index: 10;
    flex-shrink: 0;
}

.back-btn {
    border: none;
    cursor: pointer;
    background: rgba(255, 71, 145, 0.2);
    border-color: var(--accent-pink);
    font-size: 0.95rem;
}

.game-title-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-title-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.game-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-badge, .high-score-badge {
    padding: 6px 12px;
    font-size: 0.9rem;
    gap: 4px;
}

.score-badge {
    background: rgba(0, 242, 254, 0.15);
    border-color: var(--accent-cyan);
}

.high-score-badge {
    background: rgba(255, 184, 0, 0.15);
    border-color: var(--accent-yellow);
}

.score-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
}

/* Touch-Locked Game Container */
.game-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none; /* CRITICAL FOR MOBILE TOUCH GAMES */
    user-select: none;
    -webkit-user-select: none;
}

/* Ensure canvas takes up appropriate space without overflow */
.game-container canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Touch Hint Toast */
.touch-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 50px;
    background: rgba(15, 5, 29, 0.9);
    border: 2px solid var(--accent-cyan);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    pointer-events: none;
    z-index: 50;
    animation: bounceHint 1.5s infinite;
    transition: opacity 0.5s ease;
}

@keyframes bounceHint {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, -10px); }
}

/* Confetti Celebration */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Responsive Mobile Tweaks */
@media (max-width: 600px) {
    .arcade-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 14px 18px;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .game-topbar {
        padding: 8px 12px;
        margin: 6px;
    }
    
    .game-title-header h2 {
        font-size: 1rem;
        max-width: 120px;
    }
    
    .score-badge, .high-score-badge {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}
