:root {
    --bg-dark: #0a2d46;
    --bg-panel: #10374e;
    --bg-panel-hover: #174b6a;
    --accent: #add8f5;
    --accent-hover: #277fa3;
    --text-main: #f0f8ff;
    --text-muted: #8ab6d6;
    --glass-bg: rgba(16, 55, 78, 0.6);
    --glass-border: rgba(173, 216, 245, 0.2);
    
    /* Spacing & Radius Tokens */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

body.app-active {
    overflow: hidden;
    height: 100vh;
}

/* Glassmorphism utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* View Containers */
.view-container {
    display: none;
    height: 100vh;
    width: 100vw;
}

.view-container.active {
    display: flex;
}

/* --- Auth View --- */
#landing-view {
    display: none;
    flex-direction: column;
    background: var(--bg-dark);
    min-height: 100vh;
    overflow-y: auto;
}

#landing-view.active {
    display: block;
}

#auth-view {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, var(--bg-panel), var(--bg-dark));
    height: 100vh;
    width: 100vw;
}

#auth-view.active {
    display: flex;
}

.auth-page {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.auth-page-header {
    text-align: center;
}

.auth-site-logo {
    height: 76px;
    width: auto;
    display: block;
    object-fit: contain;
    cursor: pointer;
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
    font-size: 1rem;
}

.back-btn:hover {
    color: var(--accent);
}

.landing-page {
    width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* --- Landing Header --- */
.landing-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 1rem 0;
}

.landing-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-logo {
    height: 42px;
    width: auto;
    display: block;
    object-fit: contain;
}

.landing-header nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.landing-header nav a {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.landing-header nav a:hover {
    color: var(--accent);
}

.nav-auth-btn {
    background: var(--accent-hover);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.nav-auth-btn:hover {
    background: #206a8a;
    transform: translateY(-2px);
}

/* --- Hero Section --- */
.hero {
    padding: 10rem 2rem 6rem;
    display: flex;
    align-items: center;
    gap: 4rem;
    min-height: 90vh;
    background: radial-gradient(circle at 70% 30%, rgba(173, 216, 245, 0.1), transparent);
}

.hero-content {
    flex: 1;
}

.hero-content h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, #fff, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    max-width: 600px;
}

.hero-btns {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.hero-visual {
    flex: 1;
    position: relative;
}

.hero-img {
    width: 100%;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--glass-border);
    transform: perspective(1000px) rotateY(-10deg) rotateX(5deg);
    transition: transform 0.5s;
}

.hero-img:hover {
    transform: perspective(1000px) rotateY(0deg) rotateX(0deg);
}

/* --- Features Section --- */
.features {
    padding: 8rem 0;
    background: rgba(0, 0, 0, 0.2);
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 4rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.feature-card {
    padding: 3rem 2rem;
    border-radius: 24px;
    text-align: center;
    transition: transform 0.3s;
}

.feature-card:hover {
    transform: translateY(-10px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
}

.feature-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.feature-card p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* --- Preview Section --- */
.previews {
    padding: 8rem 0;
}

.preview-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-top: 2rem;
}

.preview-img {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    transition: transform 0.3s;
}

.preview-img:hover {
    transform: scale(1.02);
    z-index: 10;
}

/* --- Auth Section --- */
.auth-section {
    padding: 6rem 0 10rem;
    display: flex;
    justify-content: center;
    background: radial-gradient(circle at center, var(--bg-panel), var(--bg-dark));
}

.auth-box {
    width: 100%;
    max-width: 450px;
    padding: 3rem;
    border-radius: 24px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-tabs {
    display: flex;
    margin-top: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 4px;
}

.auth-tabs button {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.auth-tabs button.active {
    background: var(--accent-hover);
    color: var(--text-main);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.auth-form.active {
    display: flex;
}

.auth-form input, .auth-form select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input:focus, .auth-form select:focus {
    border-color: var(--accent);
}

.auth-form select option {
    background: var(--bg-panel);
    color: var(--text-main);
}

.primary-btn {
    background: var(--accent-hover);
    color: var(--text-main);
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: var(--accent);
    color: var(--bg-dark);
}

.primary-btn.large {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--accent-hover);
    color: var(--text-main);
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(39, 127, 163, 0.1);
    border-color: var(--accent);
}

.secondary-btn.large {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
}

.error-msg {
    color: #ff6b6b;
    font-size: 0.9rem;
    text-align: center;
    min-height: 1.2em;
}

/* --- Main App View --- */
.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-box {
    padding: 1rem;
}

.search-box input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    outline: none;
}

.series-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 1rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.series-item {
    margin-bottom: 0.5rem;
}

.series-title {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--accent);
    padding: 0.6rem 0.5rem;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.series-title:hover {
    background: rgba(255, 255, 255, 0.05);
}

.series-chevron {
    font-size: 0.6rem;
    transition: transform 0.25s ease;
    display: inline-block;
}

.series-item:not(.collapsed) .series-chevron {
    transform: rotate(90deg);
}

.sets-container {
    max-height: 3000px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 1;
}

.series-item.collapsed .sets-container {
    max-height: 0;
    opacity: 0;
}

.set-link {
    display: block;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.set-link:hover, .set-link.active {
    background: var(--bg-panel-hover);
    color: var(--accent);
    transform: translateX(4px);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.set-header {
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.set-progress-container {
    display: flex;
    gap: 2rem;
    align-items: flex-end;
    margin-top: 12px;
}

.progress-box {
    display: flex;
    flex-direction: column;
    width: 220px;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: var(--text-main);
}

.bold-label {
    font-weight: 700;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #3498db;
    width: 0%;
    transition: width 0.4s ease;
}

.set-value {
    color: #2ecc71;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 2px;
}

#set-logo {
    max-height: 50px;
    object-fit: contain;
}

.filter-dropdown {
    background: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 10px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.filter-dropdown:hover, .filter-dropdown:focus {
    border-color: var(--accent-hover);
    background: var(--bg-panel-hover);
}

.filter-dropdown option {
    background: var(--bg-dark);
    color: var(--text-main);
    font-weight: 500;
}

.cards-grid {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

/* --- Browse Series Landing --- */
.cards-grid.browse-mode {
    display: block;
    padding: 2rem;
}

.browse-heading {
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    letter-spacing: 0.5px;
}

.series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.series-card {
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 110px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.series-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
    pointer-events: none;
}

.series-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

.series-card-logo {
    max-height: 45px;
    max-width: 80%;
    object-fit: contain;
    filter: brightness(1.1);
    flex: 1;
    align-self: center;
    object-position: center;
}

.series-card-logo.large-logo {
    max-height: 80px;
    max-width: 95%;
}

img.series-card-logo[alt*="Black" i],
img.series-card-logo[alt*="Diamond" i],
img.series-card-logo[alt*="Mega" i] {
    transform: scale(1.3);
}

img.series-card-logo[alt="Base" i],
img.series-card-logo[alt="EX" i],
img.series-card-logo[alt="NP" i],
img.series-card-logo[alt="Promo" i],
img.series-card-logo[alt="XY" i],
img.series-card-logo[alt*="Scarlet" i] {
    transform: translateY(10px);
}

.series-card-name {
    font-weight: 800;
    font-size: 1.3rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    flex: 1;
    display: flex;
    align-items: center;
}

.series-owned-count {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    background: transparent;
    padding: 2px 0;
    border-radius: 0;
    z-index: 2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.series-card-count {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 10px;
    border-radius: 10px;
    z-index: 2;
    margin-top: auto;
}

.placeholder-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
    font-size: 1.1rem;
}

/* --- Back Button --- */
.back-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--glass-border);
    color: var(--accent);
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    transition: background 0.2s;
}

.back-btn:hover {
    background: rgba(255,255,255,0.12);
}

/* --- Series Sets Header --- */
.series-sets-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-panel);
    border-radius: 12px;
    border-left: 4px solid;
}

.series-sets-logo {
    max-height: 40px;
    object-fit: contain;
}

.series-sets-name {
    font-weight: 800;
    font-size: 1.5rem;
    text-transform: uppercase;
}

.series-sets-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Sets Grid --- */
.sets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.set-card {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    min-height: 120px;
}

.set-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-hover);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    background: var(--bg-panel-hover);
}

.set-card-logo {
    max-height: 50px;
    max-width: 90%;
    object-fit: contain;
}

.set-card-fallback {
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    color: var(--accent);
}

.set-card-info {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.set-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.set-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-item {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid transparent;
}

.card-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
    border-color: var(--accent-hover);
}

.card-image {
    width: 100%;
    aspect-ratio: 2.5 / 3.5;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 12px;
    background: rgba(0, 0, 0, 0.2);
}

.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.card-name {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-variant {
    font-size: 0.8rem;
    color: var(--accent);
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.variant-border-1st { border-color: #ef4444 !important; }
.variant-border-reverse { border-color: #ec4899 !important; }
.variant-border-holo { border-color: #eab308 !important; }

/* Unowned cards are greyscale */
.card-item.unowned .card-image {
    filter: grayscale(100%);
    opacity: 0.5;
    transition: filter 0.3s, opacity 0.3s;
}

.card-item.unowned:hover .card-image {
    filter: grayscale(60%);
    opacity: 0.7;
}

/* --- Variant Controls in Modal --- */
.variants-title {
    font-size: 1.4rem;
    margin: 1.5rem 0 0.5rem;
    color: var(--accent);
}

.save-btn {
    background: #2d8f4e;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: background 0.2s;
}

.save-btn:hover {
    background: #3aaf62;
}

.action-btn {
    background: var(--bg-panel-hover);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent);
}

.variants-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.variant-row {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px;
    transition: border-color 0.2s;
}

.variant-row.dirty {
    border-color: #f0ad4e;
}

.variant-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.variant-badge {
    background: var(--accent-hover);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
}

.variant-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.qty-btn {
    width: 30px;
    height: 30px;
    background: var(--bg-panel-hover);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.qty-btn:hover {
    background: var(--accent-hover);
}

.qty-input {
    width: 50px;
    text-align: center;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 6px;
    border-radius: 6px;
    font-family: inherit;
}

.cond-select {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 6px 8px;
    border-radius: 6px;
    font-family: inherit;
    min-width: 100px;
}

.notes-input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 6px 8px;
    border-radius: 6px;
    font-family: inherit;
    flex: 1;
    min-width: 80px;
}

.save-status {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    min-height: 1.2em;
}

.save-status.saving { color: var(--accent); }
.save-status.success { color: #3aaf62; }
.save-status.error { color: #ff6b6b; }

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    display: flex;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.active .modal-content {
    transform: scale(1);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 2;
}

.close-btn:hover {
    background: #ff6b6b;
}

.modal-body {
    display: flex;
    width: 100%;
    padding: 2rem;
    gap: 2rem;
}

.modal-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 50%;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 80vh;
}

.modal-info h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: -webkit-linear-gradient(var(--accent), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badges {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.badge {
    background: var(--bg-panel-hover);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--accent-hover);
}

.flavor-text {
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    border-left: 3px solid var(--accent-hover);
    padding-left: 1rem;
}

.artist {
    font-size: 0.9rem;
    color: var(--text-muted);
    opacity: 0.8;
}

.price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.price-table th, .price-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.price-table th {
    font-weight: 600;
    color: var(--accent);
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.price-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
    #app-view {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 300px;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }
    .modal-body {
        flex-direction: column;
        overflow-y: auto;
    }
    .modal-image-container {
        max-width: 100%;
    }
}

/* --- Sidebar Friends Button --- */
.sidebar-actions {
    padding: 0 1rem 1rem;
}

.sidebar-action-btn {
    width: 100%;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s, transform 0.2s;
}

.sidebar-action-btn:hover {
    background: var(--bg-panel-hover);
    transform: translateX(4px);
}

/* --- Friends / Chat Full Page --- */
#friends-chat-view {
    background: #182536;
    color: #dbe8f5;
}

#friends-chat-view.active {
    display: flex;
}

.friends-chat-page {
    display: flex;
    width: 100%;
    height: 100vh;
    background: linear-gradient(180deg, #1b2a3d, #101722);
}

.friends-chat-sidebar {
    width: 320px;
    height: 100vh;
    background: #1a2430;
    border-right: 1px solid #2d3a4a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.friends-chat-user {
    position: relative;
    padding: 14px;
    background: linear-gradient(180deg, #223246, #1b2735);
    border-bottom: 1px solid #2d3a4a;
}

.friends-back-btn {
    background: transparent;
    color: #9fb4c9;
    border: none;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 12px;
}

.friends-back-btn:hover {
    color: #ffffff;
}

.friends-user-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.friends-avatar,
.web-friend-avatar {
    width: 42px;
    height: 42px;
    border: 2px solid #3b82f6;
    background: #304256;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.friends-user-info {
    min-width: 0;
}

.friends-current-name {
    color: #67c5f5;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friends-status-button {
    background: transparent;
    border: none;
    color: #22c58b;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 0;
}

.friends-status-button.status-away {
    color: #facc15;
}

.friends-status-button.status-dnd {
    color: #f87171;
}

.friends-status-button.status-offline {
    color: #94a3b8;
}

.friends-status-menu {
    display: none;
    position: absolute;
    left: 58px;
    top: 86px;
    z-index: 30;
    background: #263342;
    border: 1px solid #405166;
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
    min-width: 190px;
    padding: 6px;
}

.friends-status-menu.active {
    display: block;
}

.friends-status-menu button {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    color: #dbe8f5;
    padding: 9px 10px;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
}

.friends-status-menu button:hover {
    background: #34465a;
}

.friends-panel-band {
    height: 34px;
    background: #4b5563;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #dbe8f5;
    font-weight: 800;
    padding: 0 12px;
}

.friends-panel-band button {
    width: 26px;
    height: 26px;
    border: 1px solid #94a3b8;
    background: #5b6674;
    color: white;
    cursor: pointer;
    font-weight: 900;
}

.friends-search-wrap {
    padding: 10px 12px;
}

.friends-search-wrap input {
    width: 100%;
    background: #eef4f8;
    color: #111827;
    border: none;
    padding: 9px 10px;
    outline: none;
}

.friends-section {
    padding: 4px 12px 10px;
}

.friends-section h3 {
    font-size: 0.95rem;
    color: #e5edf6;
    margin: 10px 0 8px;
}

.web-friend-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.web-friend-row,
.web-request-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 4px;
    cursor: pointer;
    border-radius: 4px;
    position: relative;
}

.web-friend-row:hover,
.web-request-row:hover,
.web-friend-row.active {
    background: rgba(255,255,255,0.06);
}

.web-friend-text {
    min-width: 0;
    flex: 1;
}

.web-friend-name {
    font-weight: 800;
    color: #76c8f5;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.web-friend-status {
    font-size: 0.82rem;
    line-height: 1.15;
}

.status-online {
    color: #8ee35d;
}

.status-away {
    color: #facc15;
}

.status-dnd {
    color: #f87171;
}

.status-offline {
    color: #64748b;
}

.web-friend-status.invite {
    color: #facc15;
}

.web-friend-actions {
    opacity: 0;
    transition: opacity 0.2s;
}

.web-friend-row:hover .web-friend-actions {
    opacity: 1;
}

.friend-menu-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
}

.web-request-actions {
    display: flex;
    gap: 4px;
}

.web-request-actions button {
    width: 26px;
    height: 26px;
    border: none;
    color: white;
    font-weight: 800;
    cursor: pointer;
}

.web-request-actions .accept {
    background: #10b981;
}

.web-request-actions .decline {
    background: #ef4444;
}

.web-empty-row {
    color: #64748b;
    font-size: 0.95rem;
    padding: 4px 0 10px;
}

.friends-chat-main {
    flex: 1;
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #161b22;
}

.chat-empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #94a3b8;
    text-align: center;
}

.chat-empty-state h2 {
    color: white;
    margin-bottom: 8px;
}

.web-chat-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

.web-chat-header {
    min-height: 70px;
    background: #202b3a;
    border-bottom: 1px solid #2d3a4a;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.web-chat-header h2 {
    color: white;
    font-size: 1.15rem;
    margin-bottom: 2px;
}

.web-chat-status {
    font-size: 0.9rem;
    font-weight: 700;
}

.web-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 38px;
    background: linear-gradient(180deg, #171b21, #15191f);
}

.web-chat-messages::-webkit-scrollbar {
    width: 10px;
}
.web-chat-messages::-webkit-scrollbar-track {
    background: #111827;
}
.web-chat-messages::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 5px;
}

.web-chat-sender {
    font-weight: 800;
    margin-bottom: 4px;
}

.web-chat-sender.mine {
    color: #8cc9ff;
}

.web-chat-sender.friend {
    color: #c5f59b;
}

.web-chat-line {
    color: #d4d7dd;
    font-size: 1rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.web-chat-gap {
    height: 18px;
}

.web-chat-input-row {
    height: 76px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #202b3a;
    border-top: 1px solid #2d3a4a;
    padding: 12px;
    position: relative;
}

.web-chat-input-row input {
    flex: 1;
    height: 46px;
    background: #101720;
    border: 1px solid #2d3a4a;
    color: white;
    padding: 0 12px;
    outline: none;
    font-size: 1rem;
}

.web-chat-input-row button {
    height: 46px;
    background: #33465c;
    color: white;
    border: 1px solid #718096;
    padding: 0 18px;
    cursor: pointer;
    font-weight: 800;
}

.web-chat-input-row button:hover {
    background: #3b5774;
}

.web-sound-menu {
    display: none;
    position: absolute;
    right: 92px;
    bottom: 64px;
    background: #263342;
    border: 1px solid #405166;
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
    width: 180px;
    padding: 6px;
    z-index: 40;
}

.web-sound-menu.active {
    display: block;
}

.web-sound-menu button {
    width: 100%;
    height: auto;
    display: block;
    padding: 8px 10px;
    background: transparent;
    border: none;
    color: #dbe8f5;
    text-align: left;
    cursor: pointer;
    font-weight: 600;
}

.web-sound-menu button:hover {
    background: #34465a;
}

.web-friend-action-menu {
    position: fixed;
    z-index: 9999;
    background: #263342;
    border: 1px solid #405166;
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
    width: 150px;
    padding: 6px;
}

.web-friend-action-menu button {
    width: 100%;
    background: transparent;
    border: none;
    color: #dbe8f5;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
}

.web-friend-action-menu button:hover {
    background: #34465a;
}

/* --- Add Friend Modal --- */
.web-friends-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.web-friends-modal.active {
    display: flex;
}

.web-friends-modal-card {
    width: 360px;
    background: #192433;
    border: 1px solid #405166;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    padding: 20px;
    border-radius: 10px;
}

.web-friends-modal-card h3 {
    margin-bottom: 12px;
}

.web-friends-modal-card input {
    width: 100%;
    background: #101720;
    border: 1px solid #405166;
    color: white;
    padding: 11px 12px;
    outline: none;
}

.web-friends-error {
    color: #ff6b6b;
    font-size: 0.9rem;
    min-height: 22px;
    margin-top: 8px;
}

.web-friends-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.web-friends-modal-actions button {
    background: #33465c;
    color: white;
    border: 1px solid #718096;
    padding: 9px 16px;
    cursor: pointer;
    font-weight: 800;
}

.web-friends-modal-actions button:hover {
    background: #3b5774;
}

@media (max-width: 900px) {
    .friends-chat-page {
        flex-direction: column;
    }

    .friends-chat-sidebar {
        width: 100%;
        height: 45vh;
    }

    .friends-chat-main {
        height: 55vh;
    }
}

/* --- Friends unread badge --- */
.friends-chat-nav-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.friends-unread-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}

.friends-unread-badge.hidden {
    display: none;
}

/* --- Legal Notice Section --- */
.legal-notice-section {
    padding: 4rem 0 2rem;
    background: rgba(0, 0, 0, 0.18);
}

.legal-notice-card {
    max-width: 980px;
    margin: 0 auto;
    padding: 2rem;
    border-radius: 18px;
    color: var(--text-muted);
    line-height: 1.65;
    font-size: 0.95rem;
}

.legal-notice-card h2 {
    color: var(--accent);
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.legal-notice-card p {
    margin-bottom: 1rem;
}

.legal-notice-card p:last-child {
    margin-bottom: 0;
}

.sidebar-logo {
    height: 38px;
    width: auto;
    max-width: 180px;
    display: block;
    object-fit: contain;
}

/* --- Friend collection read-only mode --- */
.friend-view-banner {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.35), rgba(15, 23, 42, 0.9));
    border-bottom: 1px solid rgba(173, 216, 245, 0.25);
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.friend-view-banner strong {
    display: block;
    color: #ffffff;
    font-size: 1rem;
}

.friend-view-banner span {
    display: block;
    color: var(--text-muted);
    font-size: 0.86rem;
    margin-top: 2px;
}

.friend-view-banner button {
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent);
    border: 1px solid var(--glass-border);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    white-space: nowrap;
}

.friend-view-banner button:hover {
    background: rgba(255, 255, 255, 0.14);
}

.friend-readonly-notice {
    background: rgba(250, 204, 21, 0.12);
    border: 1px solid rgba(250, 204, 21, 0.35);
    color: #fde68a;
    padding: 10px 12px;
    border-radius: 8px;
    margin: 0 0 12px;
    font-size: 0.92rem;
    font-weight: 700;
}

.variant-row input:disabled,
.variant-row select:disabled,
.variant-row button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* --- Donation System --- */
.donation-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    margin: 1.5rem 2rem 1.5rem;
    border-radius: 14px;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.18), rgba(15, 23, 42, 0.85));
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.donation-strip-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.donation-strip-copy strong {
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.1;
}

.donation-strip-copy span {
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.9);
    line-height: 1.2;
}

.donation-strip-btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    white-space: nowrap;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.donation-strip-btn:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

.donation-page {
    margin: 1.5rem 2rem 1.5rem;
    padding: 22px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.22);
}

.donation-page.hidden {
    display: none;
}

.donation-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.donation-page-header h2 {
    margin: 0 0 6px;
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 800;
}

.donation-page-header p {
    margin: 0;
    color: rgba(226, 232, 240, 0.82);
}

.donation-back-btn {
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.donation-back-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.donation-goal-card {
    margin-bottom: 20px;
    padding: 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(30, 41, 59, 0.95));
    border: 1px solid rgba(59, 130, 246, 0.28);
}

.donation-goal-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: rgba(191, 219, 254, 0.9);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.donation-goal-amount {
    font-size: 2rem;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.05;
    margin-bottom: 6px;
}

.donation-goal-note {
    color: rgba(226, 232, 240, 0.84);
    font-size: 0.95rem;
}

.donation-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.donation-body p {
    margin: 0;
    color: #e2e8f0;
    line-height: 1.65;
    font-size: 0.98rem;
}

.donation-actions {
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.donation-primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-width: 170px;
    padding: 12px 18px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 800;
    color: #ffffff;
    background: linear-gradient(135deg, #16a34a, #15803d);
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.donation-primary-btn:hover {
    transform: translateY(-1px);
    opacity: 0.96;
}

.donation-helper-text {
    font-size: 0.88rem;
    color: rgba(148, 163, 184, 0.92);
}

.donation-helper-text code {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 6px;
}

@media (max-width: 700px) {
    .donation-strip {
        flex-direction: column;
        align-items: flex-start;
        margin: 1rem;
    }

    .donation-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .donation-back-btn,
    .donation-strip-btn,
    .donation-primary-btn {
        width: 100%;
        justify-content: center;
    }
}

.donation-primary-btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(35%);
}

.hidden {
    display: none !important;
}

/* --- Mobile App Layout --- */
.mobile-menu-btn,
.mobile-sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    body.app-active {
        overflow: hidden;
        height: 100vh;
    }

    #app-view {
        position: relative;
        flex-direction: row;
        overflow: hidden;
    }

    .mobile-menu-btn {
        display: flex;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 3000;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        border: 1px solid var(--glass-border);
        background: rgba(16, 55, 78, 0.92);
        color: var(--text-main);
        align-items: center;
        justify-content: center;
        font-size: 1.45rem;
        font-weight: 900;
        cursor: pointer;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    }

    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 2500;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(2px);
    }

    #app-view.mobile-sidebar-open .mobile-sidebar-overlay {
        display: block;
    }

    .sidebar {
        position: fixed;
        z-index: 2600;
        inset: 0;
        width: 100vw;
        max-width: none;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        border-right: none;
        border-radius: 0;
        box-shadow: none;
        overflow-y: auto;
    }

    #app-view.mobile-sidebar-open .sidebar {
        transform: translateX(0);
    }

    .mobile-sidebar-overlay {
        display: none !important;
    }

    #app-view.mobile-sidebar-open .mobile-menu-btn {
        left: auto;
        right: 12px;
    }

    .main-content {
        width: 100%;
        min-width: 0;
        padding-top: 58px;
    }

    .set-header {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .set-header > div:first-child {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    #set-logo {
        max-height: 42px;
        max-width: 180px;
    }

    #set-title {
        font-size: 1.45rem;
        line-height: 1.15;
    }

    #set-stats {
        font-size: 0.88rem;
    }

    .set-progress-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .progress-box {
        width: 100%;
    }

    #filter-container {
        width: 100%;
        align-items: stretch !important;
    }


    .cards-grid {
        padding: 1rem;
        gap: 0.8rem;
        grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    }

    .card-item {
        padding: 8px;
        border-radius: 10px;
    }

    .card-image {
        margin-bottom: 8px;
        border-radius: 7px;
    }

    .card-meta {
        font-size: 0.72rem;
        gap: 4px;
    }

    .card-name {
        font-size: 0.82rem;
    }

    .card-variant {
        font-size: 0.72rem;
    }

    .cards-grid.browse-mode {
        padding: 1rem;
    }

    .browse-heading {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .series-grid {
        grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
        gap: 0.8rem;
    }

    .series-card {
        min-height: 90px;
        padding: 1rem;
        border-radius: 10px;
    }

    .series-card-logo {
        max-height: 34px;
        max-width: 90%;
    }

    .series-card-logo.large-logo {
        max-height: 54px;
    }

    .series-card-count {
        font-size: 0.74rem;
        padding: 2px 8px;
    }

    .sets-grid {
        grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
        gap: 0.8rem;
    }

    .set-card {
        min-height: 105px;
        padding: 0.9rem;
    }

    .set-card-logo {
        max-height: 38px;
    }

    .set-card-name {
        font-size: 0.82rem;
    }

    .set-card-meta {
        font-size: 0.72rem;
    }

    .series-sets-header {
        flex-wrap: wrap;
        gap: 0.6rem;
        padding: 0.85rem 1rem;
    }

    .series-sets-logo {
        max-height: 34px;
        max-width: 160px;
    }

    .series-owned-count,
    .series-sets-count {
        font-size: 0.78rem;
    }

    .friend-view-banner {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
    }

    .friend-view-banner button {
        width: 100%;
    }

    .donation-strip {
        margin: 0 0 14px;
    }
}

/* --- Mobile Modals --- */
@media (max-width: 768px) {
    .modal {
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
    }

    .modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        overflow-y: auto;
    }

    .modal-body {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
        overflow-y: auto;
    }

    .modal-image-container {
        max-width: 100%;
        flex: none;
        max-height: 42vh;
    }

    .modal-image-container img {
        max-height: 40vh;
    }

    .modal-info {
        max-height: none;
        overflow: visible;
    }

    .modal-info h2 {
        font-size: 1.5rem;
    }

    .variant-controls {
        align-items: stretch;
    }

    .qty-btn {
        width: 34px;
        height: 34px;
    }

    .qty-input {
        width: 55px;
    }

    .cond-select,
    .notes-input {
        flex: 1 1 100%;
        min-width: 100%;
    }

    .price-actions {
        flex-direction: column;
    }

    .price-actions .action-btn {
        width: 100%;
    }
}

/* --- Mobile Friends/Chat --- */
@media (max-width: 768px) {
    .friends-chat-page {
        flex-direction: column;
    }

    .friends-chat-sidebar {
        width: 100%;
        height: 42vh;
        min-height: 300px;
    }

    .friends-chat-main {
        height: 58vh;
    }

    .web-chat-header {
        min-height: 54px;
        padding: 0 14px;
    }

    .web-chat-messages {
        padding: 16px;
    }

    .web-chat-input-row {
        height: auto;
        padding: 10px;
        gap: 6px;
    }

    .web-chat-input-row input {
        height: 42px;
        min-width: 0;
    }

    .web-chat-input-row button {
        height: 42px;
        padding: 0 12px;
    }

    .web-sound-menu {
        right: 64px;
    }
}

/* --- Mobile Friends / Chat: list-only then chat-only --- */
.mobile-chat-back-btn {
    display: none;
}

@media (max-width: 768px) {
    #friends-chat-view.active {
        display: block;
        width: 100vw;
        height: 100dvh;
        overflow: hidden;
    }

    .friends-chat-page {
        display: block;
        width: 100vw;
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
        background: linear-gradient(180deg, #1b2a3d, #101722);
    }

    .friends-chat-sidebar {
        width: 100vw;
        height: 100dvh;
        min-height: 100dvh;
        border-right: none;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    .friends-chat-main {
        display: none;
        width: 100vw;
        height: 100dvh;
        min-height: 100dvh;
    }

    .friends-chat-page.mobile-chat-open .friends-chat-sidebar {
        display: none;
    }

    .friends-chat-page.mobile-chat-open .friends-chat-main {
        display: flex;
        width: 100vw;
        height: 100dvh;
        min-height: 100dvh;
    }

    .friends-chat-page.mobile-chat-open .chat-empty-state {
        display: none !important;
    }

    .friends-chat-page.mobile-chat-open .web-chat-panel {
        display: flex !important;
        height: 100dvh;
        min-height: 100dvh;
        width: 100vw;
    }

    .web-chat-header {
        min-height: 64px;
        padding: 10px 12px;
        gap: 10px;
        align-items: center;
    }

    .mobile-chat-back-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        height: 38px;
        padding: 0 12px;
        border-radius: 8px;
        border: 1px solid rgba(148, 163, 184, 0.35);
        background: rgba(255, 255, 255, 0.06);
        color: #dbe8f5;
        font-weight: 800;
        cursor: pointer;
    }

    .web-chat-header > div {
        min-width: 0;
    }

    .web-chat-header h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .web-chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 16px;
    }

    .web-chat-input-row {
        flex: 0 0 auto;
        height: auto;
        padding: 10px;
        gap: 6px;
    }

    .web-chat-input-row input {
        min-width: 0;
        height: 42px;
    }

    .web-chat-input-row button {
        height: 42px;
        padding: 0 12px;
    }

    .web-sound-menu {
        right: 64px;
        bottom: 58px;
    }

    .friends-section {
        padding-bottom: 14px;
    }

    .web-friend-list {
        padding-bottom: 6px;
    }
}

/* --- Mobile set page space saver --- */
.donation-strip {
    position: relative;
}

.donation-strip-dismiss-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.donation-strip-dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.progress-mobile-label {
    display: none;
}

@media (max-width: 768px) {
    .set-header {
        padding: 14px 18px;
        gap: 10px;
        align-items: flex-start;
    }

    #set-logo {
        max-height: 46px;
        max-width: 190px;
        margin-bottom: 4px;
    }

    #set-title {
        display: none;
    }

    #set-stats {
        font-size: 0.9rem;
        line-height: 1.25;
        margin-top: 2px;
        color: rgba(240, 248, 255, 0.92);
    }

    .set-progress-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        align-items: start;
        width: 100%;
        margin-top: 8px;
    }

    .progress-box {
        width: 100%;
        min-width: 0;
    }

    .progress-labels {
        font-size: 0.78rem;
        line-height: 1.15;
        margin-bottom: 3px;
        gap: 4px;
    }

    .bold-label {
        font-weight: 800;
        white-space: nowrap;
    }

    .progress-full-label {
        display: none;
    }

    .progress-mobile-label {
        display: inline;
    }

    .progress-bar-bg {
        height: 5px;
        border-radius: 999px;
    }

    .donation-strip {
        margin: 10px 12px 12px;
        padding: 12px 42px 12px 14px;
        border-radius: 14px;
        gap: 10px;
    }

    .donation-strip-copy strong {
        font-size: 0.95rem;
        line-height: 1.15;
    }

    .donation-strip-copy span {
        font-size: 0.8rem;
        line-height: 1.2;
    }

    .donation-strip-btn {
        padding: 8px 12px;
        min-height: 38px;
        border-radius: 10px;
        font-size: 0.9rem;
    }

    .donation-strip-dismiss-btn {
        top: 8px;
        right: 8px;
        width: 26px;
        height: 26px;
        font-size: 20px;
    }

    .cards-grid {
        padding-top: 14px;
    }
}

@media (max-width: 480px) {
    .set-progress-container {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .progress-labels {
        font-size: 0.72rem;
    }

    .donation-strip {
        flex-direction: column;
        align-items: stretch;
    }

    .donation-strip-btn {
        width: 100%;
    }
}

/* --- Mobile: put set search + filter on same row --- */
@media (max-width: 768px) {
    #filter-container {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 118px;
        gap: 8px;
        width: 100%;
        align-items: stretch !important;
    }

    #set-card-search {
        display: block !important;
        width: 100% !important;
        min-width: 0;
        height: 46px;
        margin: 0 !important;
        padding: 0 14px;
        font-size: 1rem;
        border-radius: 12px;
    }

    #card-filter {
        width: 100% !important;
        min-width: 0;
        height: 46px;
        margin: 0 !important;
        padding: 0 10px;
        font-size: 0.95rem;
        border-radius: 12px;
    }
}

@media (max-width: 420px) {
    #filter-container {
        grid-template-columns: minmax(0, 1fr) 96px;
        gap: 7px;
    }

    #set-card-search {
        font-size: 0.95rem;
        padding: 0 12px;
    }

    #card-filter {
        font-size: 0.9rem;
        padding: 0 8px;
    }
}




/* --- Mobile: move the real set logo into the top bar --- */
.mobile-top-bar {
    display: none;
}

.desktop-set-logo-slot {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .mobile-top-bar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 66px;
        z-index: 3000;
        align-items: center;
        gap: 12px;
        padding: 8px 16px;
        background: rgba(10, 45, 70, 0.96);
        border-bottom: 1px solid var(--glass-border);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .mobile-top-bar .mobile-menu-btn {
        position: static !important;
        display: flex !important;
        width: 50px;
        height: 50px;
        flex: 0 0 50px;
        border-radius: 14px;
        border: 1px solid var(--glass-border);
        background: rgba(16, 55, 78, 0.92);
        color: var(--text-main);
        align-items: center;
        justify-content: center;
        font-size: 1.45rem;
        font-weight: 900;
        cursor: pointer;
        box-shadow: none;
    }

    .mobile-set-logo-slot {
        flex: 1;
        min-width: 0;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        overflow: hidden;
    }

    .mobile-set-logo-slot #set-logo {
        display: block;
        max-height: 40px !important;
        max-width: 190px !important;
        width: auto;
        object-fit: contain;
        margin: 0 !important;
    }

    .desktop-set-logo-slot {
        display: none !important;
    }

    #app-view.mobile-sidebar-open .mobile-set-logo-slot {
        display: none;
    }

    #app-view.mobile-sidebar-open .mobile-top-bar .mobile-menu-btn {
        margin-left: 0;
    }

    .main-content {
        padding-top: 66px !important;
    }

    .set-header {
        padding-top: 12px !important;
    }

    #set-title {
        display: none !important;
    }
}

@media (max-width: 420px) {
    .mobile-top-bar {
        height: 62px;
        padding: 7px 14px;
    }

    .mobile-top-bar .mobile-menu-btn {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
    }

    .mobile-set-logo-slot {
        height: 48px;
    }

    .mobile-set-logo-slot #set-logo {
        max-height: 36px !important;
        max-width: 165px !important;
    }

    .main-content {
        padding-top: 62px !important;
    }
}

/* --- Mobile top bar: site logo + set logo behavior --- */
.mobile-site-logo {
    display: none;
}

@media (max-width: 768px) {
    .mobile-site-logo {
        display: block;
        height: 34px;
        width: auto;
        max-width: 190px;
        object-fit: contain;
        flex: 1;
        min-width: 0;
    }

    .mobile-set-logo-slot {
        display: none;
    }

    #app-view.mobile-set-logo-active .mobile-site-logo {
        display: none;
    }

    #app-view.mobile-set-logo-active .mobile-set-logo-slot {
        display: flex;
    }

    #app-view.mobile-sidebar-open .mobile-site-logo {
        display: block;
    }

    #app-view.mobile-sidebar-open .mobile-set-logo-slot {
        display: none !important;
    }
}

@media (max-width: 420px) {
    .mobile-site-logo {
        height: 30px;
        max-width: 160px;
    }
}

/* --- Mobile menu open: keep hamburger + logo on left --- */
@media (max-width: 768px) {
    #app-view.mobile-sidebar-open .mobile-top-bar {
        justify-content: flex-start;
    }

    #app-view.mobile-sidebar-open .mobile-top-bar .mobile-menu-btn {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    #app-view.mobile-sidebar-open .mobile-site-logo {
        flex: 0 1 auto;
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .mobile-site-logo {
        cursor: pointer;
    }
}

@media (max-width: 768px) {
    .mobile-site-logo,
    .mobile-set-logo-slot,
    .mobile-set-logo-slot #set-logo {
        cursor: pointer;
    }
}

/* =========================================================
   Mobile responsive layout for logged-out landing/auth pages
   Desktop stays unchanged
========================================================= */

@media (max-width: 768px) {
    body:not(.app-active) {
        overflow-x: hidden;
    }

    #landing-view.active {
        display: block;
        width: 100%;
        min-height: 100dvh;
        overflow-y: auto;
    }

    .container {
        width: 100%;
        max-width: 100%;
        padding: 0 18px;
    }

    /* Landing top nav */
    .landing-header {
        position: sticky;
        top: 0;
        padding: 12px 0;
        z-index: 1000;
    }

    .landing-header .container {
        gap: 12px;
    }

    .site-logo {
        height: 34px;
        max-width: 170px;
    }

    .landing-header nav {
        gap: 10px;
        flex-shrink: 0;
    }

    .landing-header nav a {
        display: none;
    }

    .nav-auth-btn {
        padding: 9px 12px;
        border-radius: 9px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Hero section */
    .hero {
        min-height: auto;
        padding: 42px 0 38px;
        display: block;
    }

    .hero-content {
        display: flex;
        flex-direction: column;
        gap: 24px;
        padding: 0 18px;
    }

    .hero-content h1 {
        font-size: clamp(2rem, 9vw, 3rem);
        line-height: 1.08;
        margin-bottom: 16px;
        text-align: left;
    }

    .hero-content p {
        font-size: 1rem;
        line-height: 1.55;
        margin-bottom: 22px;
        max-width: 100%;
    }

    .hero-btns {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 0;
    }

    .primary-btn.large,
    .secondary-btn.large {
        width: 100%;
        padding: 14px 18px;
        font-size: 1rem;
        border-radius: 12px;
    }

    .hero-visual {
        width: 100%;
    }

    .hero-img {
        width: 100%;
        border-radius: 14px;
        transform: none;
        box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45);
    }

    .hero-img:hover {
        transform: none;
    }

    /* Feature section */
    .features {
        padding: 48px 0;
    }

    .section-title {
        font-size: 1.8rem;
        line-height: 1.15;
        margin-bottom: 24px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .feature-card {
        padding: 24px 18px;
        border-radius: 18px;
    }

    .feature-card:hover {
        transform: none;
    }

    .feature-icon {
        font-size: 2.4rem;
        margin-bottom: 12px;
    }

    .feature-card h3 {
        font-size: 1.25rem;
    }

    .feature-card p {
        font-size: 0.95rem;
    }

    /* Preview section */
    .previews {
        padding: 48px 0;
    }

    .preview-gallery {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .preview-img {
        border-radius: 12px;
    }

    .preview-img:hover {
        transform: none;
    }

    /* Legal notice */
    .legal-notice-section {
        padding: 36px 0 24px;
    }

    .legal-notice-card {
        padding: 18px;
        border-radius: 16px;
        font-size: 0.88rem;
        line-height: 1.55;
    }

    .legal-notice-card h2 {
        font-size: 1.2rem;
    }

    .landing-footer {
        padding: 18px 0;
        text-align: center;
        font-size: 0.85rem;
    }

    /* Auth login/register page */
    #auth-view.active {
        display: flex;
        min-height: 100dvh;
        height: auto;
        overflow-y: auto;
        padding: 24px 18px;
        justify-content: flex-start;
    }

    .auth-page {
        min-height: calc(100dvh - 48px);
        justify-content: center;
        gap: 18px;
    }

    .auth-page-header {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .auth-site-logo {
        height: 54px;
        max-width: 240px;
    }

    .auth-box {
        width: 100%;
        max-width: 430px;
        padding: 22px 18px;
        border-radius: 18px;
    }

    .auth-header {
        margin-bottom: 18px;
    }

    .auth-header h2 {
        font-size: 1.35rem;
        line-height: 1.2;
    }

    .auth-tabs {
        margin-top: 14px;
    }

    .auth-tabs button {
        padding: 10px 8px;
        font-size: 0.95rem;
    }

    .auth-form {
        gap: 12px;
    }

    .auth-form input,
    .auth-form select {
        min-height: 46px;
        font-size: 1rem;
        padding: 11px 12px;
        border-radius: 10px;
    }

    .auth-form .primary-btn {
        min-height: 46px;
        font-size: 1rem;
        border-radius: 10px;
    }

    .auth-page > .back-btn {
        margin-bottom: 0;
        font-size: 0.95rem;
    }
}

@media (max-width: 430px) {
    .container {
        padding: 0 14px;
    }

    .landing-header .container {
        padding: 0 12px;
    }

    .site-logo {
        height: 30px;
        max-width: 150px;
    }

    .nav-auth-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .hero-content {
        padding: 0 14px;
    }

    .hero-content h1 {
        font-size: 2.15rem;
    }

    .hero-content p {
        font-size: 0.95rem;
    }

    .auth-box {
        padding: 20px 16px;
    }

    .auth-site-logo {
        height: 48px;
        max-width: 220px;
    }
}

/* --- Mobile logout button --- */
.mobile-logout-btn {
    display: none;
}

@media (max-width: 768px) {
    .mobile-logout-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        margin-left: auto;
        border-radius: 12px;
        border: 1px solid var(--glass-border);
        background: rgba(16, 55, 78, 0.92);
        color: var(--text-main);
        font-size: 1.15rem;
        cursor: pointer;
    }

    .mobile-logout-btn:hover {
        background: var(--bg-panel-hover);
    }

    .mobile-site-logo {
        min-width: 0;
    }

    .mobile-set-logo-slot {
        min-width: 0;
    }
}

@media (max-width: 420px) {
    .mobile-logout-btn {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
        font-size: 1rem;
    }
}

/* --- Fix desktop donation close button overlap --- */
@media (min-width: 701px) {
    .donation-strip {
        padding-right: 58px;
    }

    .donation-strip-dismiss-btn {
        top: 50%;
        right: 14px;
        transform: translateY(-50%);
    }

    .donation-strip-btn {
        margin-right: 0;
    }
}

/* --- Mobile: make expanded donation page scrollable --- */
@media (max-width: 768px) {
    .main-content {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: 100dvh;
        -webkit-overflow-scrolling: touch;
    }

    .donation-page {
        max-height: none;
        overflow: visible;
        margin: 12px;
        padding: 18px;
        padding-bottom: 120px;
    }

    .donation-body {
        overflow: visible;
    }

    .donation-body p {
        font-size: 0.98rem;
        line-height: 1.55;
    }

    .donation-actions {
        padding-bottom: 40px;
    }
}

@media (max-width: 768px) {
    #app-view.active {
        overflow: hidden;
    }

    .cards-grid {
        min-height: 0;
    }
}

/* =========================================================
   Mobile fix: card detail modal should fit under top bar
   and scroll normally on phones.
   Desktop is unchanged.
========================================================= */
@media (max-width: 768px) {
    /* Keep the mobile top bar visible, but do not let it cover the modal */
    #card-modal.modal {
        top: 66px;
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(100dvh - 66px);
        max-height: calc(100dvh - 66px);
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
        overflow: hidden;
        z-index: 2500;
    }

    /* Use the real mobile viewport instead of old 100vh */
    #card-modal .modal-content {
        width: 100%;
        height: calc(100dvh - 66px);
        max-height: calc(100dvh - 66px);
        min-height: 0;
        border-radius: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Do not create a second trapped scroll area */
    #card-modal .modal-body {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-height: auto;
        padding: 14px 16px calc(34px + env(safe-area-inset-bottom));
        gap: 16px;
        overflow: visible;
    }

    /* Keep image visible but not so tall that it steals the whole screen */
    #card-modal .modal-image-container {
        width: 100%;
        max-width: 100%;
        max-height: none;
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #card-modal .modal-image-container img {
        width: auto;
        max-width: min(82vw, 300px);
        max-height: 44dvh;
        object-fit: contain;
        border-radius: 12px;
    }

    /* Let all card text and variants be part of the main modal scroll */
    #card-modal .modal-info {
        width: 100%;
        max-height: none;
        min-height: 0;
        overflow: visible;
        display: flex;
        flex-direction: column;
    }

    #card-modal .modal-info h2 {
        font-size: 1.55rem;
        line-height: 1.15;
        margin-bottom: 12px;
    }

    #card-modal .badges {
        margin-bottom: 18px;
        flex-wrap: wrap;
    }

    #card-modal .flavor-text {
        font-size: 1rem;
        line-height: 1.55;
        margin-bottom: 20px;
    }

    #card-modal .variants-title {
        margin-top: 18px;
        margin-bottom: 10px;
    }

    /* Remove the small internal variant scroll limit on mobile */
    #card-modal .variants-list {
        max-height: none;
        overflow: visible;
        padding-bottom: 14px;
    }

    #card-modal .variant-row {
        width: 100%;
    }

    #card-modal .variant-controls {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr) 42px;
        gap: 8px;
        align-items: stretch;
    }

    #card-modal .qty-btn {
        width: 42px;
        height: 42px;
    }

    #card-modal .qty-input {
        width: 100%;
        height: 42px;
    }

    #card-modal .cond-select,
    #card-modal .notes-input {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 100%;
        height: 42px;
    }

    #card-modal .close-btn {
        top: 10px;
        right: 10px;
        z-index: 5;
    }
}