/* ═══════════════════════════════════════════════════════════
   TOXIC MARK — Premium Dark Theme
   Dark mode with holographic accents, glassmorphism, modern UI
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
    --bg: #08080f;
    --bg-alt: #0e0e1a;
    --bg-elevated: #141428;
    --card: #1a1a30;
    --card-hover: #222244;
    --card-glass: rgba(26, 26, 48, 0.7);
    --border: #2a2a4a;
    --border-glow: rgba(100, 100, 255, 0.15);
    --text: #e8e8f8;
    --text-muted: #7878a8;
    --text-dim: #4a4a6a;
    --accent: #00ff88;
    --accent-dim: #00cc6a;
    --accent-glow: rgba(0, 255, 136, 0.15);
    --bitcoin: #f7931a;
    --bitcoin-dim: #cc7a12;
    --danger: #ff4455;
    --holo-gradient: linear-gradient(135deg, #ff6b9d, #c44dff, #6bcfff, #ff6b9d);
    --purple: #8b5cf6;
    --purple-glow: rgba(139, 92, 246, 0.2);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 48px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Prevent any content from breaking layout */
body, html { overflow-x: hidden; word-wrap: break-word; overflow-wrap: break-word; }
* { min-width: 0; } /* Flex children can shrink below content size */

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Background gradient effect */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(0, 255, 136, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-dim); text-decoration: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.hidden { display: none !important; }

/* ─── Toast notifications (externalized from inline JS styles) ─── */
#toast-container {
    position: fixed; bottom: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column-reverse; gap: 8px; max-width: 360px;
}
.toast {
    color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3); display: flex; gap: 8px; align-items: center;
    animation: toast-in 0.3s ease; cursor: pointer; font-family: inherit;
}
.toast-success { background: rgba(0,255,136,0.95); }
.toast-error   { background: rgba(255,68,85,0.95); }
.toast-info    { background: rgba(59,130,246,0.95); }
.toast-warning { background: rgba(247,147,26,0.95); }
.toast-fade    { opacity: 0; transition: opacity 0.3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ─── Notification badge dot (externalized from inline JS styles) ─── */
.notif-badge-parent { position: relative; }
.notif-badge-dot {
    position: absolute; top: -4px; right: -4px; width: 8px; height: 8px;
    background: var(--danger); border-radius: 50%;
}

/* ─── Urgency colors for auction timers (externalized from inline JS styles) ─── */
.countdown-danger { color: var(--danger) !important; }
.countdown-warning { color: var(--bitcoin) !important; }

/* ─── Price bump animation for auction page ─── */
.price-bump { transform: scale(1.1) !important; }

/* ─── Deposit modal success state ─── */
.deposit-success {
    background: rgba(0,255,136,0.1); border: 1px solid rgba(0,255,136,0.3);
}

/* Legacy utility class used by JS after removing inline style.display toggles */
.inline-flex { display: inline-flex !important; }

#user-menu { display: none; }
#user-menu.user-menu-open { display: flex; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: var(--transition); position: relative; overflow: hidden;
}
.btn-primary {
    background: var(--accent); color: #000;
    box-shadow: 0 0 20px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-dim); transform: translateY(-1px); box-shadow: 0 4px 24px var(--accent-glow); }
.btn-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: var(--accent); color: #000; }
.btn-bitcoin { background: var(--bitcoin); color: #000; font-weight: 700; }
.btn-bitcoin:hover { background: var(--bitcoin-dim); transform: translateY(-1px); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; }

/* ─── Navigation ─── */
nav {
    position: sticky; top: 0; z-index: 100;
    background: rgba(8, 8, 15, 0.85);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-bottom: 1px solid var(--border);
}
.nav-inner {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1200px; margin: 0 auto; padding: 14px 24px;
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.logo:hover { text-decoration: none; }
.logo-icon { font-size: 26px; filter: drop-shadow(0 0 8px rgba(0,255,136,0.3)); }
.logo-text {
    background: var(--holo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% 200%;
    animation: shimmer 3s ease infinite;
}
@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { color: var(--text-muted); font-size: 14px; font-weight: 500; transition: var(--transition); }
.nav-links a:hover { color: var(--text); }

/* ─── Hero ─── */
#hero {
    padding: 80px 0 50px; text-align: center;
    position: relative;
}
#hero::after {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--purple-glow) 0%, transparent 60%);
    pointer-events: none;
}
#hero h1 {
    font-size: 3.5rem; font-weight: 900; letter-spacing: -1px;
    background: var(--holo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 300% 300%;
    animation: shimmer 4s ease infinite;
    margin-bottom: 8px;
}
.subtitle { font-size: 1.15rem; color: var(--text-muted); margin-bottom: 40px; font-weight: 300; }
.subtitle strong { color: var(--text); font-weight: 600; }

.hero-stats {
    display: flex; justify-content: center; gap: 48px; margin-bottom: 56px;
    position: relative; z-index: 1;
}
.stat { text-align: center; }
.stat-num { display: block; font-size: 2.2rem; font-weight: 800; color: var(--accent); font-family: 'JetBrains Mono', monospace; }
.stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; margin-top: 4px; }

/* ─── Generation Cards ─── */
.generations {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px;
    max-width: 920px; margin: 0 auto; position: relative; z-index: 1;
}
.gen-card {
    display: flex; flex-direction: column; align-items: center;
    background: var(--card-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 28px 24px; text-align: center;
    transition: var(--transition); text-decoration: none; position: relative; overflow: hidden;
}
.gen-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px; background: var(--holo-gradient); opacity: 0;
    transition: var(--transition);
}
.gen-card:hover {
    background: var(--card-hover); transform: translateY(-4px);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.15);
}
.gen-card:hover::before { opacity: 1; }
.gen-card:hover h3 { color: var(--text); }

.gen-badge {
    display: inline-block;
    background: var(--holo-gradient); color: #000;
    font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
    padding: 3px 14px; border-radius: 20px; margin-bottom: 12px;
}
.gen-card h3 { color: var(--text); font-size: 1.1rem; margin: 6px 0 6px; transition: var(--transition); }
.gen-card p { color: var(--text-muted); font-size: 0.85rem; font-weight: 300; }

/* ─── Sections ─── */
.section { padding: 64px 0; position: relative; }
.section-alt { background: var(--bg-alt); }
.section h2 {
    font-size: 1.8rem; font-weight: 800; margin-bottom: 28px; letter-spacing: -0.5px;
}
.section h2 .emoji { margin-right: 8px; }

/* ─── Filter Bar ─── */
.filter-bar {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 28px; align-items: center;
}
.filter-btn {
    background: var(--card); color: var(--text-muted); border: 1px solid var(--border);
    padding: 8px 18px; border-radius: 24px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: var(--transition);
}
.filter-btn:hover, .filter-btn.active {
    background: var(--accent); color: #000; border-color: var(--accent);
    box-shadow: 0 0 16px var(--accent-glow);
}
.search-input {
    background: var(--card); color: var(--text); border: 1px solid var(--border);
    padding: 8px 18px; border-radius: 24px; font-size: 13px; outline: none;
    transition: var(--transition); margin-left: auto; min-width: 200px;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }

/* ─── Cards Grid ─── */
.cards-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px;
}
.card-item {
    background: var(--card-glass); backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    overflow: hidden; transition: var(--transition); cursor: pointer; position: relative;
}
.card-item:hover {
    background: var(--card-hover); transform: translateY(-4px);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-md), 0 0 24px var(--purple-glow);
}
img.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-img {
    width: 100%; aspect-ratio: 3/4; background: linear-gradient(145deg, #1a1a3a, #0e0e20);
    display: flex; align-items: center; justify-content: center; font-size: 56px;
    position: relative; overflow: hidden;
}
.card-img::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(8,8,15,0.8));
}
.card-info { padding: 12px 14px 16px; position: relative; z-index: 1; }
.card-name { font-size: 13px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.card-gen {
    display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 10px;
    border-radius: 10px; margin-top: 6px; letter-spacing: 0.5px;
}
.card-gen.gen-1 { background: rgba(0, 255, 136, 0.15); color: #00ff88; }
.card-gen.gen-2 { background: rgba(196, 77, 255, 0.15); color: #c44dff; }
.card-gen.gen-3 { background: rgba(107, 207, 255, 0.15); color: #6bcfff; }
.card-price { font-size: 14px; color: var(--bitcoin); font-weight: 700; margin-top: 6px; font-family: 'JetBrains Mono', monospace; }
.card-holo {
    background: var(--holo-gradient); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; font-weight: 700; font-size: 11px; margin-top: 4px;
    animation: shimmer 3s ease infinite; background-size: 200% 200%;
}

/* ─── Listings Grid ─── */
.listings-grid, .auctions-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
}
.listing-item {
    background: var(--card-glass); backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 20px; transition: var(--transition);
}
.listing-item:hover { border-color: var(--border-glow); box-shadow: var(--shadow-sm); }
.listing-title { font-weight: 600; font-size: 15px; color: var(--text); }
.listing-price {
    font-size: 1.4rem; color: var(--bitcoin); font-weight: 800; margin: 8px 0;
    font-family: 'JetBrains Mono', monospace;
}
.listing-price::before { content: '₿ '; font-size: 0.8em; opacity: 0.7; }
.listing-meta { font-size: 12px; color: var(--text-muted); }
.auction-timer { font-size: 14px; color: var(--danger); font-weight: 600; }

/* ─── Proof of Ownership ─── */
.proof-box {
    background: rgba(0, 255, 136, 0.04); border: 1px solid rgba(0, 255, 136, 0.15);
    border-radius: var(--radius-md); padding: 24px; margin: 20px 0;
}
.proof-box h3 { color: var(--accent); margin-bottom: 14px; font-size: 1rem; }
.proof-steps { list-style: none; padding: 0; }
.proof-steps li {
    padding: 10px 0 10px 36px; position: relative;
    color: var(--text-muted); font-size: 14px; border-left: 2px solid var(--border);
    margin-left: 12px;
}
.proof-steps li::before {
    content: attr(data-step); position: absolute; left: -16px; top: 8px;
    font-weight: 700; color: var(--accent); font-size: 13px;
    background: var(--bg); padding: 0 4px;
}
.proof-steps li:last-child { border-left-color: transparent; }
.proof-hash-box {
    background: rgba(139, 92, 246, 0.08); border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-sm); padding: 14px; margin: 14px 0;
    font-family: 'JetBrains Mono', monospace; font-size: 12px; word-break: break-all;
    line-height: 1.6;
}
.proof-verified { color: var(--accent); font-weight: 600; }
.proof-unverified { color: var(--text-dim); }

/* ─── Modal ─── */
.modal {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
}
.modal-content {
    position: relative; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius-xl);
    padding: 36px; max-width: 420px; width: 92%;
    box-shadow: var(--shadow-lg);
}
.modal-close {
    position: absolute; top: 16px; right: 20px;
    background: none; border: none; color: var(--text-dim); font-size: 22px;
    cursor: pointer; transition: var(--transition);
}
.modal-close:hover { color: var(--text); }

.auth-tabs { display: flex; gap: 0; margin-bottom: 28px; }
.auth-tabs .tab {
    flex: 1; padding: 14px; background: var(--bg); color: var(--text-muted);
    border: 1px solid var(--border); cursor: pointer; font-size: 14px;
    font-weight: 500; text-align: center; transition: var(--transition);
}
.auth-tabs .tab:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.auth-tabs .tab:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.auth-tabs .tab.active { background: var(--accent); color: #000; font-weight: 700; }

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 12px; color: var(--text-muted);
    font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px 16px;
    background: var(--bg); color: var(--text);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); outline: none;
}
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.auth-divider {
    display: flex; align-items: center; margin: 24px 0; color: var(--text-dim);
}
.auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.auth-divider span { padding: 0 14px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

/* ─── Disclaimer Banner ─── */
.disclaimer-banner {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(30, 20, 0, 0.95);
    backdrop-filter: blur(10px);
    border-top: 2px solid var(--bitcoin);
    padding: 14px 0; z-index: 150; font-size: 13px;
}
.disclaimer-banner p { margin: 0 0 10px; line-height: 1.5; }
.disclaimer-banner .btn {
    background: rgba(247, 147, 26, 0.1); color: var(--bitcoin);
    border: 1px solid var(--bitcoin);
}
.disclaimer-banner .btn:hover { background: var(--bitcoin); color: #000; }

/* ─── Footer ─── */
footer {
    padding: 40px 0; text-align: center; color: var(--text-dim); font-size: 13px;
    border-top: 1px solid var(--border); margin-top: 60px;
}
footer p { margin: 4px 0; }
footer a { color: var(--text-muted); }
footer a:hover { color: var(--accent); }
footer strong { color: var(--bitcoin); }

/* ─── Empty State ─── */
.empty { color: var(--text-dim); text-align: center; padding: 40px 0; font-size: 15px; }
.empty a { color: var(--accent); }
.empty a:hover { text-decoration: underline; }

/* ─── Checkbox ─── */
.checkbox-label {
    display: flex; gap: 10px; align-items: flex-start;
    font-size: 12px; color: var(--text-muted); cursor: pointer; line-height: 1.5;
}
.checkbox-label input { margin-top: 3px; accent-color: var(--accent); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Hamburger Nav ─── */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.hamburger:hover, .hamburger:active { background: var(--card); }
.mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}
.mobile-nav.open {
    max-height: 500px;
    opacity: 1;
}
.mobile-nav a {
    padding: 14px 24px;
    color: var(--text-muted);
    font-size: 15px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    min-height: 44px;
    display: flex;
    align-items: center;
}
.mobile-nav a:hover { background: var(--card); color: var(--text); }
.mobile-nav a:active { background: var(--card-hover); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    /* Sticky header with safe-area */
    nav {
        top: env(safe-area-inset-top, 0);
    }
    .nav-inner {
        padding-top: max(14px, env(safe-area-inset-top, 0px));
        padding-left: max(24px, env(safe-area-inset-left, 0px));
        padding-right: max(24px, env(safe-area-inset-right, 0px));
    }
    /* Touch targets min 44px */
    .btn { min-height: 44px; padding: 10px 20px; }
    .filter-btn { min-height: 44px; display: flex; align-items: center; justify-content: center; }
    .nav-links a { min-height: 44px; display: flex; align-items: center; }
    /* Form inputs: font-size >= 16px to prevent iOS zoom */
    .form-group input, .form-group select, .form-group textarea {
        font-size: 16px;
        padding: 14px 16px;
    }
    .search-input { font-size: 16px; min-height: 44px; }
    /* Bid input */
    .bid-input { font-size: 16px; min-height: 44px; }
    /* Cards grid: 2 columns on mobile */
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    /* Buttons full-width on mobile */
    .btn:not(.btn-sm):not(.filter-btn):not(.modal-close):not(.hamburger):not(.auth-tabs .tab) {
        width: 100%;
    }
    /* Modal: bottom-sheet style on mobile */
    .modal {
        align-items: flex-end;
    }
    .modal-content {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-width: 100%;
        width: 100%;
        max-height: 85vh;
        overflow-y: auto;
        padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    }
    .modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 0 auto 16px;
    }
    /* Auction timer: bigger and readable */
    .auction-timer {
        font-size: 18px !important;
        font-weight: 700;
        padding: 6px 0;
    }
    /* QR code: responsive */
    .qr-container, #payment-qr, canvas[class*="qr"] {
        max-width: 260px !important;
        width: 100% !important;
        height: auto !important;
    }
    /* Bid section: stack layout */
    .bid-input-group {
        flex-direction: column;
    }
    .bid-input-group .bid-input {
        width: 100%;
    }
    /* Payment modal: scrollable, QR large enough */
    #payment-modal .modal-content {
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Dashboard: single column */
    .dashboard-grid, .auction-info-grid {
        grid-template-columns: 1fr;
    }
    /* Generation hero */
    #hero h1 { font-size: 2.2rem; }
    .hero-stats { gap: 24px; flex-wrap: wrap; }
    .stat-num { font-size: 1.6rem; }
    .generations { grid-template-columns: 1fr; }
    .listings-grid, .auctions-grid { grid-template-columns: 1fr; }
    .nav-links .desktop-link { display: none; }
    #hero { padding: 50px 0 30px; }
    .filter-bar { gap: 6px; }
    .hamburger { display: flex; }
    /* Safe-area body padding */
    .disclaimer-banner {
        padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
    }
    /* Card info touch targets */
    .card-item { cursor: pointer; }
    .card-info { min-height: 44px; }
    /* Gen card touch */
    .gen-card { min-height: 44px; }
}

@media (max-width: 480px) {
    html, body { overflow-x: hidden !important; max-width: 100vw !important; }
    .container { padding: 0 max(16px, env(safe-area-inset-left, 0px)) 0 max(16px, env(safe-area-inset-right, 0px)); max-width: 100vw; overflow-x: hidden; }
    #hero h1 { font-size: 1.8rem; }
    .card-detail-grid { grid-template-columns: 1fr !important; }
    .nav-inner { padding: 12px 16px; }
    .nav-links a { font-size: 11px; }
    .nav-links .btn { padding: 4px 10px; font-size: 11px; }
    .nav-links .desktop-link { display: none; }
    .hamburger { display: flex; }
    .generations { grid-template-columns: 1fr; }
    /* Set-Builder: 3 columns on small mobile */
    .set-grid, .collection-grid-mini { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .cards-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .filter-bar { flex-direction: column; }
    .filter-btn { width: 100%; text-align: center; }
    .search-input { width: 100%; min-width: unset; }
    .hero-stats { flex-direction: column; gap: 16px; }
    .stat-num { font-size: 1.4rem; }
    .modal-content { width: 100%; padding: 24px 16px; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
    .disclaimer-banner { font-size: 11px; }
    .proof-steps li { padding: 8px 0 8px 24px; font-size: 12px; }
    img.card-img, .card-img { width: 100% !important; max-width: 100% !important; height: auto !important; aspect-ratio: 3/4; object-fit: cover; }
    .card-detail-image { font-size: 48px !important; }
    .listing-price { font-size: 1.2rem !important; }
    #auction-price-display { font-size: 1.8rem !important; }
    /* Auction timer extra large on small mobile */
    .auction-timer { font-size: 20px !important; }
    /* QR code fills available width on small mobile */
    .qr-container, #payment-qr, canvas[class*="qr"] {
        max-width: 240px !important;
    }
    /* Ensure listing cards stack well */
    .listing-item { padding: 14px; }
}

@media (max-width: 640px) {
    .card-detail-grid { grid-template-columns: 1fr !important; }
}

/* Prevent horizontal scroll on any device */
img, svg, video, iframe, table, pre { max-width: 100%; height: auto; overflow-wrap: break-word; word-break: break-word; }
* { box-sizing: border-box; }

/* Prevent long text from overflowing */
.proof-hash-box, .modal-content, .listing-title, .card-name, .card-info, .form-group input, .form-group textarea, .listing-item, .auction-item, p, h1, h2, h3, h4, h5, h6, span, a, td, th, li, div { overflow-wrap: break-word; word-break: break-word; }

/* Specific overflow fixes */
.card-item { max-width: 100%; }
.listing-item { max-width: 100%; overflow: hidden; }
.auction-item { max-width: 100%; overflow: hidden; }
.auth-divider span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-inner { max-width: 100%; overflow: hidden; }
.hero-stats { overflow: hidden; }
/* Card detail listings & auctions */
.card-listings, .card-auctions { margin-top: 16px; }
.card-listings h4, .card-auctions h4 { color: var(--accent); margin-bottom: 8px; font-size: 0.9rem; }
.listing-item, .auction-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--bg2); border-radius: var(--radius-sm); margin-bottom: 6px; cursor: pointer; transition: background 0.2s; }
.listing-item:hover, .auction-item:hover { background: var(--bg3); }
.listing-title, .auction-title { font-size: 0.85rem; flex: 1; }
.listing-price, .auction-price { color: var(--accent); font-family: monospace; font-size: 0.85rem; margin-right: 8px; }
.card-img-main { width: 100%; height: auto; border-radius: var(--radius-sm); }
.badge-success { background: var(--accent); color: var(--bg); }


/* Auction detail & bidding */
.auction-detail { padding: 8px 0; }
.auction-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.auction-id { color: var(--text2); font-family: monospace; font-size: 0.8rem; }
.badge-active { background: var(--accent); color: var(--bg); padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; }
.badge-ended { background: var(--danger); color: white; padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; }
.auction-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.info-item { background: var(--bg2); padding: 10px; border-radius: var(--radius-sm); }
.info-label { display: block; color: var(--text2); font-size: 0.75rem; margin-bottom: 4px; }
.info-value { display: block; font-size: 1rem; font-weight: 600; }
.info-value.highlight { color: var(--accent); }
.info-value.ended { color: var(--danger); }
.auction-desc { color: var(--text2); font-size: 0.9rem; margin: 12px 0; line-height: 1.4; }

/* Bid section */
.bid-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.bid-section h4 { color: var(--accent); margin-bottom: 12px; }
.bid-input-group { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bid-input { background: var(--bg2); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 1rem; width: 100%; }
.bid-input:focus { border-color: var(--accent); outline: none; }
.bid-sats { color: var(--text2); font-family: monospace; font-size: 0.85rem; white-space: nowrap; }
.bid-hint { color: var(--text2); font-size: 0.8rem; margin-bottom: 12px; }
.btn-bid { width: 100%; padding: 12px; font-size: 1rem; margin-top: 4px; }
.auction-own-note { color: var(--accent); font-size: 0.85rem; text-align: center; padding: 12px; background: var(--bg2); border-radius: var(--radius-sm); }

/* Dashboard improvements */
.dashboard-section { margin-bottom: 24px; }
.dashboard-section h3 { color: var(--text); margin-bottom: 12px; font-size: 1rem; }
.auction-card-mini, .bid-item, .listing-mini { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--bg2); border-radius: var(--radius-sm); margin-bottom: 6px; cursor: pointer; transition: background 0.2s; }
.auction-card-mini:hover, .bid-item:hover, .listing-mini:hover { background: var(--bg3); }
.auction-mini-info, .bid-item-info { display: flex; flex-direction: column; gap: 2px; }
.auction-mini-title, .bid-item-title, .listing-mini-title { font-size: 0.85rem; }
.auction-mini-price, .bid-item-amount, .listing-mini-price { color: var(--accent); font-family: monospace; font-size: 0.85rem; }
.collection-grid-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; margin-top: 8px; }
.collection-mini-card { text-align: center; cursor: pointer; transition: transform 0.2s; }
.collection-mini-card:hover { transform: scale(1.05); }
.collection-mini-img { width: 100%; border-radius: 6px; aspect-ratio: 3/4; object-fit: cover; }
.collection-mini-name { display: block; font-size: 0.65rem; color: var(--text2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-mini-fallback { font-size: 2rem; display: block; }
.collection-more { display: flex; align-items: center; justify-content: center; background: var(--bg2); border-radius: 6px; padding: 10px; color: var(--accent); font-size: 0.85rem; cursor: pointer; }
.text-muted { color: var(--text2); }
.text-muted a { color: var(--accent); }

/* ─── Payment Modal ─── */
#payment-modal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
}
#payment-amount {
    animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 20px rgba(247,147,26,0.3); }
    50% { text-shadow: 0 0 40px rgba(247,147,26,0.6); }
}
.payment-success {
    background: rgba(0,255,136,0.1) !important;
    border: 1px solid rgba(0,255,136,0.3) !important;
}
.payment-pending {
    animation: pending-pulse 1.5s ease-in-out infinite;
}
@keyframes pending-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ─── Notification Bell ─── */
.notif-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.notif-badge .badge-count {
    position: absolute;
    top: -6px; right: -8px;
    background: var(--danger);
    color: white;
    font-size: 10px; font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}
.notif-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    display: none;
}
.notif-dropdown.open { display: block; }
.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.notif-item:hover { background: var(--card-hover); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item:last-child { border-bottom: none; }
.notif-type { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.notif-title { font-size: 13px; font-weight: 600; color: var(--text); margin: 2px 0; }
.notif-time { font-size: 11px; color: var(--text-dim); }

/* ─── Mobile Notification Fixes ─── */
@media (max-width: 480px) {
    .notif-dropdown { width: calc(100vw - 32px); right: -40px; }
    #bid-section input[type="number"] { width: 100%; font-size: 16px; }
    #bid-section { display: flex; flex-direction: column; gap: 8px; }
    #bid-section .btn { width: 100%; min-height: 44px; }
    .modal-content { max-height: 85vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
}

/* ─── Toast Improvements ─── */
#toast-container { z-index: 99999; }
.toast { min-width: 200px; max-width: 90vw; }

/* ═══════════════════════════════════════════════════════════
   MOBILE OPTIMIZATION — Comprehensive mobile-first improvements
   ═══════════════════════════════════════════════════════════ */

/* ─── Safe Area & iOS Support ─── */
@supports (padding: env(safe-area-inset-top)) {
    nav { padding-top: env(safe-area-inset-top); }
    .disclaimer-banner { padding-bottom: env(safe-area-inset-bottom); }
    body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* ─── Touch Targets (min 44px) ─── */
@media (pointer: coarse) {
    .btn { min-height: 44px; min-width: 44px; }
    .filter-btn { min-height: 44px; padding: 10px 18px; }
    .nav-links a, .nav-links .btn { min-height: 44px; display: inline-flex; align-items: center; }
    .mobile-nav a { min-height: 48px; display: flex; align-items: center; }
    .card-item { min-height: 44px; }
    .checkbox-label { min-height: 44px; padding: 8px 0; }
    .form-group input, .form-group select, .form-group textarea { min-height: 48px; font-size: 16px; }
    .modal-close { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
    .listing-item, .auction-item { min-height: 48px; }
}

/* ─── iOS Zoom Fix: inputs ≥ 16px ─── */
@media (max-width: 768px) {
    .form-group input, .form-group select, .form-group textarea,
    .search-input, .bid-input {
        font-size: 16px !important;
    }
}

/* ─── Mobile Bottom-Sheet Modals ─── */
@media (max-width: 640px) {
    .modal {
        align-items: flex-end;
    }
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        padding: 28px 20px 32px !important;
        max-height: 85vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 0 auto 20px;
    }
    .modal-close {
        top: 20px; right: 16px;
        width: 44px; height: 44px;
        display: flex; align-items: center; justify-content: center;
    }
    /* Payment modal: QR code bigger on mobile */
    #payment-modal .modal-content { max-height: 90vh; }
    #payment-qr { width: 220px !important; height: 220px !important; }
}

/* ─── Mobile Auction Detail ─── */
@media (max-width: 640px) {
    .auction-info-grid { grid-template-columns: 1fr; }
    .auction-header { flex-wrap: wrap; }
    .bid-input-group { flex-direction: column; }
    .bid-input-group .bid-input { width: 100%; }
    .bid-input-group .bid-sats { width: 100%; text-align: center; }
    #auction-price-display { font-size: 2rem !important; }
    .auction-timer { font-size: 1.1rem; }
}

/* ─── Mobile Dashboard ─── */
@media (max-width: 640px) {
    .auction-card-mini, .bid-item, .listing-mini { flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; }
    .auction-mini-price, .bid-item-amount, .listing-mini-price { align-self: flex-end; }
    .collection-grid-mini { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}

/* ─── Mobile Set-Builder ─── */
@media (max-width: 480px) {
    .set-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
}

/* ─── Mobile Cards Grid Refinement ─── */
@media (min-width: 481px) and (max-width: 768px) {
    .cards-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}

/* ─── Mobile Buttons Full-Width ─── */
@media (max-width: 640px) {
    .btn-bid, .btn-bitcoin { width: 100%; }
    .bid-section .btn { width: 100%; }
    /* Auth modal buttons */
    .modal-content .btn { width: 100%; }
}

/* ─── Mobile Hero Improvements ─── */
@media (max-width: 480px) {
    #hero { padding: 40px 0 20px; }
    #hero::after { width: 300px; height: 300px; }
    .subtitle { font-size: 0.95rem; }
    .gen-card { padding: 20px 16px; }
    .gen-card h3 { font-size: 1rem; }
    .gen-card p { font-size: 0.8rem; }
}

/* ─── Mobile Footer ─── */
@media (max-width: 640px) {
    footer { padding: 24px 0; font-size: 12px; }
    footer p { margin: 2px 0; }
}

/* ─── Touch feedback (no hover on touch) ─── */
@media (hover: none) {
    .card-item:hover { transform: none; }
    .card-item:active, .card-item.touch-active { transform: scale(0.98); background: var(--card-hover); }
    .gen-card:hover { transform: none; }
    .gen-card:active, .gen-card.touch-active { transform: scale(0.98); background: var(--card-hover); }
    .listing-item:hover { border-color: var(--border); box-shadow: none; }
    .listing-item:active, .listing-item.touch-active { border-color: var(--border-glow); }
    .btn-primary:hover { transform: none; }
    .btn-primary:active { transform: scale(0.98); }
}

/* ─── Landscape phone fixes ─── */
@media (max-height: 500px) and (orientation: landscape) {
    #hero { padding: 30px 0 15px; }
    #hero h1 { font-size: 1.6rem; }
    .hero-stats { gap: 16px; margin-bottom: 24px; }
    .section { padding: 32px 0; }
    .modal-content { max-height: 95vh; }
}
