/* Global Styles & Variables */
:root {
    --background-color: #0f0f1e; /* Navy blue */
    --text-color: #ffffff;
    --primary-accent: #ff1493; /* Neon Pink */
    --secondary-accent: #00bfff; /* Bright Blue */
    --card-background: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 20, 147, 0.5); /* Pinkish border */
    --button-gradient: linear-gradient(45deg, var(--primary-accent), var(--secondary-accent));
    --disabled-color: #333333;
    --success-color: #69f0ae;
    --success-background: rgba(56, 142, 60, 0.3);
    --error-color: #ff6b6b;
    --error-background: rgba(211, 47, 47, 0.3);
    --info-color: #40c4ff;
    --info-background: rgba(25, 118, 210, 0.3);
    --warning-color: #ffa726; /* Added for warnings */
    --warning-background: rgba(255, 167, 38, 0.3);
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color); /* Default background color */
    /* Add a default background image if you have one, e.g.: */
    /* background-image: url('images/default-bg.webp'); */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.body-bg-chapters {
    background-image: url('images/8.webp');
}

.body-bg-collection {
    background-image: url('images/11.webp');
}

.body-bg-diaries {
    background-image: url('images/9.webp');
}

/* Add other .body-bg-SECTIONNAME classes here if needed */

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3); /* Halved the darkness */
    z-index: -1;
    pointer-events: none; /* Allows clicks to pass through to elements behind it */
}

#app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header and Navigation */
.app-header {
    background-color: rgba(15, 15, 30, 0.8);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(5px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease-in-out;
}

/* Class for header hidden on scroll - used by JavaScript */
.app-header.scroll-hidden {
    transform: translateY(-100%);
}

.logo-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    margin-right: 30px;
}

.logo img {
    height: 38px;
    width: auto;
    max-width: 240px;
    min-width: 200px;
}

.tab-nav {
    display: flex;
    gap: 20px;
    flex-grow: 1;
    justify-content: center;
}

.tab-link {
    color: var(--text-color);
    text-decoration: none;
    font-size: 16px;
    padding: 8px 15px;
    border-radius: 8px;
    transition: background-color 0.3s, color 0.3s;
    border: 1px solid transparent; /* Placeholder for active state */
}

.tab-link:hover {
    background-color: var(--card-background);
    color: var(--primary-accent);
}

.tab-link.active {
    font-weight: bold;
    color: var(--primary-accent);
    border: 1px solid var(--border-color);
    box-shadow: 0 0 10px rgba(255, 20, 147, 0.3);
}

/* Wallet Info Area */
.wallet-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wallet-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    background-color: var(--card-background);
    padding: 5px 10px;
    border-radius: 8px;
}

.wallet-status #walletAddress {
    font-family: monospace;
}

.wallet-status #walletNetwork {
    font-style: italic;
    opacity: 0.8;
}

.connect-button, .coinbase-button {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(45deg, var(--primary-accent), var(--secondary-accent));
    color: white;
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.connect-button:hover, .coinbase-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 191, 255, 0.3);
}

.coinbase-button {
    background: linear-gradient(45deg, #0052FF, #00BFFF);
}

.coinbase-button:hover {
    background: linear-gradient(45deg, #0047E1, #00A3E0);
}

/* Main Content Area */
#app-content {
    flex-grow: 1;
    padding: 30px;
    max-width: 1200px; /* Limit content width */
    margin: 0 auto; /* Center content */
    width: 100%;
    box-sizing: border-box;
}

.app-section {
    display: none; /* Sections hidden by default */
    animation: fadeIn 0.5s ease-in-out;
}

.app-section.active {
    display: block; /* Active section shown */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Common Elements (Buttons, Cards, Status Messages) */
.card {
    background-color: var(--card-background);
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    padding: 30px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

h1, h2, h3 {
    background: var(--button-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: 0;
    margin-bottom: 20px;
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }

.button {
    background: var(--button-gradient);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s;
    display: inline-block; /* Allow side-by-side buttons */
    margin: 5px;
}

.button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 20, 147, 0.5);
}

.button:disabled {
    background: var(--disabled-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

.disconnect-button {
    background: var(--disabled-color);
    font-size: 12px;
    padding: 5px 10px;
}

.disconnect-button:hover {
    background: #555;
    transform: scale(1.05);
    box-shadow: none;
}

/* Status Messages */
#status-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    width: 90%;
    max-width: 600px;
}

.status {
    padding: 15px;
    border-radius: 10px;
    font-weight: bold;
    margin-top: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    animation: slideInUp 0.3s ease-out;
}

.status.error {
    background-color: var(--error-background);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.status.success {
    background-color: var(--success-background);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.status.info {
    background-color: var(--info-background);
    color: var(--info-color);
    border: 1px solid var(--info-color);
}

.status.warning {
    background-color: var(--warning-background);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

.hidden {
    display: none !important;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Mobile Wallet Display (from spinandmint) */
.mobile-wallet-display {
    display: none !important;
}

/* Mobile Debug Area (from spinandmint) */
.mobile-debug-area {
    position: fixed;
    bottom: 60px; /* Above debug toggle/panel */
    left: 20px;
    width: calc(100% - 40px);
    max-width: 400px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 999;
}

.mobile-debug-area h4 {
    margin-top: 0;
    margin-bottom: 5px;
    color: var(--secondary-accent);
    font-size: 14px;
    text-align: left;
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
    background-clip: initial;
}

.mobile-debug-log {
    width: 100%;
    height: 100px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #00ff00;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    padding: 8px;
    font-family: monospace;
    font-size: 10px;
    resize: vertical;
    box-sizing: border-box;
}

.debug-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
}

.small-button {
    background: #333;
    color: white;
    border: 1px solid #666;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}

.small-button:hover {
    background: #444;
}

/* Mobile Navigation Fixes */
/* Updated Media Query for Mobile */
@media (max-width: 768px) {
    .app-header {
        padding: 15px;
        position: fixed;
        width: 100%;
        box-sizing: border-box;
        display: flex;
        flex-direction: row; /* Change to row */
        align-items: center;
        justify-content: space-between;
        z-index: 1000;
    }
    
    /* Fix logo size */
    .logo img {
        height: 32px;
        width: auto !important;
        max-width: 180px !important;
        min-width: 140px !important;
    }
    
    /* Right side content */
    .header-right {
        display: flex;
        align-items: center;
    }
    
    /* Hamburger button */
    .hamburger-button {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        width: 24px !important;
        height: 20px !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
        z-index: 2000 !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
    }
    
    .hamburger-button span {
        width: 100% !important;
        height: 3px !important;
        background: var(--primary-accent, #ff1493) !important;
        border-radius: 3px !important;
        display: block !important;
        transition: all 0.3s ease;
    }
    
    /* Navigation menu - initially hidden */
    .tab-nav {
        position: fixed;
        top: 0;
        right: -100%; /* Initially off-screen */
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: var(--background-color);
        padding: 60px 20px 20px; /* Changed top padding from 80px to 60px */
        flex-direction: column;
        align-items: flex-start;
        transition: right 0.3s ease; /* Use right instead of transform */
        z-index: 1000; /* Ensure it's above general content but below hamburger button if necessary */
        box-shadow: -2px 0 10px rgba(0,0,0,0.2);
        display: flex; /* Make sure it's flex */
        overflow-y: auto;
        /* Explicitly remove any transform that might be inherited or misapplied from old rules */
        transform: none !important; 
    }
    
    .tab-nav.active {
        right: 0; /* Slide in from right */
        /* Explicitly remove any transform that might be inherited or misapplied */
        transform: none !important; 
    }
    
    .tab-nav a,
    .tab-nav button {
        width: 100%;
        padding: 15px 0;
        text-align: left;
        border-bottom: 1px solid var(--border-color);
        color: var(--text-color);
        background: none;
        font-size: 16px;
        font-weight: 500;
        display: block;
        margin: 5px 0;
    }
    
    /* Add some space below the fixed header */
    #app-content {
        padding-top: 70px;
    }
    
    /* Adjust wallet connection button */
    #connectWalletBtn {
        padding: 8px 12px !important;
        font-size: 14px !important;
    }
    
    /* Add overlay when menu is active */
    .menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }
    
    .menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Mobile wallet display */
    .wallet-status {
        display: none; /* Hide on mobile by default */
    }
    
    .mobile-wallet-display {
        display: block;
    }

    /* Adjust main content padding to account for NO mobile wallet container bar */
    #app-content {
        padding-top: 70px; /* Assuming header is approx 70px. Adjust if necessary. */
    }

    /* Styles for wallet info now inside the .tab-nav (hamburger menu) */
    .tab-nav #walletInfoMobileNavContainer { /* Target the cloned container by its new ID */
        display: flex; /* Already set by JS, but good for clarity */
        flex-direction: column; /* Already set by JS */
        align-items: stretch; /* Already set by JS */
        padding: 15px 0; /* Vertical padding, no horizontal as items will stretch */
        margin-top: 15px; /* Space from other nav links */
        border-top: 1px solid var(--border-color); /* Separator line */
    }

    .tab-nav #walletInfoMobileNavContainer .button,
    .tab-nav #walletInfoMobileNavContainer .connect-button, /* Includes #connectWalletBtnMobileNav */
    .tab-nav #walletInfoMobileNavContainer .disconnect-button { /* Includes #disconnectWalletBtnMobileNav */
        width: 100%; 
        margin: 8px 0; /* Vertical margin for spacing between buttons/status */
        padding: 12px 15px; 
        font-size: 15px; 
        text-align: center;
        box-sizing: border-box; /* Ensure padding doesn't make it overflow */
    }

    .tab-nav #walletInfoMobileNavContainer .wallet-status { /* This is #walletStatusMobileNav */
        display: flex; 
        flex-direction: column; 
        align-items: center; 
        padding: 10px 0; /* Vertical padding */
        margin: 8px 0; /* Consistent vertical margin */
        background-color: transparent;
        border: none;
        font-size: 13px;
        color: var(--text-color); /* Ensure text is visible */
        text-align: center;
        width: 100%;
        box-sizing: border-box;
    }

    .tab-nav #walletInfoMobileNavContainer .wallet-status span { /* For #walletAddressMobileNav & #walletNetworkMobileNav */
        margin-bottom: 5px;
        word-break: break-all; /* Ensure long addresses don't break layout */
    }
    
    /* Hide wallet info in the main header on mobile, as it's now in the nav */
    .app-header .wallet-info {
        display: none !important; 
    }
}

/* Telegram Button Styles */
.telegram-button {
    background-color: #0088cc; /* Telegram blue */
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
    margin-left: 15px;
}

.telegram-button:hover {
    background-color: #0077b5; /* Darker blue on hover */
}

/* Video Overlay Styles */
.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.video-container {
    position: relative;
    width: 90%;
    max-width: 1000px;
}

.close-video-btn {
    position: absolute;
    top: -40px;
    right: 0;
    background-color: transparent;
    color: white;
    border: none;
    font-size: 30px;
    cursor: pointer;
    z-index: 1001;
}

.video-overlay video {
    width: 100%;
    display: block;
}

/* Animation for highlighting text changes */
@keyframes highlight-text {
    0% {
        color: var(--text-color);
        transform: scale(1);
    }
    50% {
        color: var(--secondary-accent);
        transform: scale(1.1);
    }
    100% {
        color: var(--text-color);
        transform: scale(1);
    }
}

/* Connect button base styles */
.connect-button {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(45deg, var(--primary-accent), var(--secondary-accent));
    color: white;
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.connect-button span {
    display: inline;
}

/* Marketplace Styles */
.marketplace-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.marketplace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.marketplace-tabs {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.tab-button {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 16px;
    position: relative;
    z-index: 1;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.tab-button:active {
    transform: translateY(0);
}

.tab-button.active {
    background: var(--primary-accent);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 20, 147, 0.3);
}

.marketplace-tab-content {
    display: none;
    padding: 20px 0;
}

.marketplace-tab-content:first-child {
    display: block;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.loading-screen.visible {
    opacity: 1;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-accent);
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Status Message */
.status-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 8px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--primary-accent);
    backdrop-filter: blur(5px);
}

.status-message.visible {
    opacity: 1;
}

/* Card Grid Styles */
.marketplace-listings-grid,
.my-listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    padding: 25px 0;
}

.marketplace-listing-card,
.my-listing-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
}

.marketplace-listing-card:hover,
.my-listing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-accent);
}

.listing-card-image,
.my-listing-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.listing-card-content,
.my-listing-content {
    padding: 20px;
}

.token-title,
.card-title {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: white;
}

.listing-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.eth-price {
    font-size: 1.3em;
    color: #00ff00;
    font-weight: 600;
}

.usd-price {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
}

/* Create Listing Button */
.create-listing-button {
    padding: 12px 24px;
    background: var(--primary-accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(255, 20, 147, 0.3);
    position: relative;
    z-index: 1;
}

.create-listing-button:hover {
    background: #e0127d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 20, 147, 0.4);
}

.create-listing-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(255, 20, 147, 0.3);
}

/* No Items Message */
.no-items-message {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.7);
}

/* Rarity Badge */
.rarity-badge {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    margin-left: 10px;
}

.rarity-badge.common { background: #808080; }
.rarity-badge.uncommon { background: #00ff00; }
.rarity-badge.rare { background: #0000ff; }
.rarity-badge.epic { background: #800080; }
.rarity-badge.legendary { background: #ffd700; }

/* Marketplace Button Styles */
.marketplace-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Listing Action Buttons */
.listing-action-button {
    padding: 10px 20px;
    background: var(--primary-accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 14px;
    width: 100%;
    margin-top: 10px;
    position: relative;
    z-index: 1;
}

.listing-action-button:hover {
    background: #e0127d;
    transform: translateY(-2px);
}

.listing-action-button:active {
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.listing-action-button:disabled {
    background: var(--disabled-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Hamburger Menu Styles */
.hamburger-button {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 105;
}

.hamburger-button span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}

/* Styles for when the menu is open (toggled by JS) */
.hamburger-button.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger-button.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-button.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Animation for menu toggle */
@keyframes hamburgerTop {
    0% { transform: rotate(0); }
    50% { transform: translateY(8px); }
    100% { transform: translateY(8px) rotate(45deg); }
}

@keyframes hamburgerMiddle {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes hamburgerBottom {
    0% { transform: rotate(0); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(-8px) rotate(-45deg); }
}

.hamburger-button.active span:nth-child(1) {
    animation: hamburgerTop 0.3s ease forwards;
}

.hamburger-button.active span:nth-child(2) {
    animation: hamburgerMiddle 0.3s ease forwards;
}

.hamburger-button.active span:nth-child(3) {
    animation: hamburgerBottom 0.3s ease forwards;
}

/* END OF HAMBURGER STYLES TO KEEP. REMOVING THE SUBSEQUENT REDUNDANT MEDIA QUERY. */ 

/* Chapters Debug Box Styles */
.chapters-debug-container {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 350px;
    max-height: 250px;
    background-color: rgba(30, 30, 40, 0.9);
    border: 1px solid var(--secondary-accent);
    border-radius: 8px;
    z-index: 2000;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-color);
    display: none; /* Hiding the debug box */
    flex-direction: column;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

.chapters-debug-header {
    background-color: rgba(40, 40, 50, 0.95);
    padding: 8px;
    font-weight: bold;
    border-bottom: 1px solid var(--secondary-accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapters-debug-clear-btn {
    background: var(--primary-accent);
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
}
.chapters-debug-clear-btn:hover {
    background: var(--secondary-accent);
}

.chapters-debug-console {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column-reverse; /* New messages at bottom, scroll to view */
}

.chapters-debug-message {
    padding: 3px 0;
    border-bottom: 1px dotted rgba(255,255,255,0.2);
    line-height: 1.4;
}
.chapters-debug-message:last-child {
    border-bottom: none;
}

.chapters-debug-error {
    color: var(--error-color);
}
.chapters-debug-warn {
    color: var(--warning-color);
}
.chapters-debug-info {
    color: var(--text-color);
}
.chapters-debug-system {
    color: var(--success-color);
    font-style: italic;
}

.chapters-debug-detail {
    color: #aaa; /* Grey for detailed logs */
    font-style: italic;
    font-size: 0.9em;
}

/* END OF DEBUG BOX STYLES */ 

/* Update connect button text styling */
.connect-button,
.mobile-wallet-container .connect-button {
    min-width: 80px; /* Ensure consistent button width */
    text-align: center;
}

/* Ensure wallet buttons in mobile container have consistent styling */
.mobile-wallet-container .connect-button,
.mobile-wallet-container .disconnect-button {
    padding: 10px 20px;
    font-size: 14px;
    margin: 0 5px;
    min-width: 90px; /* Ensure buttons are wide enough for "Disconnect" */
    text-align: center;
}

/* Wallet Connection Popup Overlay */
.wallet-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wallet-popup-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Wallet Connection Popup */
.wallet-popup {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 2px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.wallet-popup h2 {
    margin-bottom: 20px;
    background: var(--button-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 24px;
}

.wallet-popup p {
    margin-bottom: 30px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    font-size: 16px;
}

.wallet-popup-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.wallet-popup .connect-button {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 25px;
    background: var(--button-gradient);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.wallet-popup .connect-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 20, 147, 0.4);
}

.wallet-popup-skip {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 25px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.wallet-popup-skip:hover {
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

/* Hide wallet elements on mobile when connected */
@media (max-width: 768px) {
    .mobile-wallet-container.hidden-after-connect {
        display: none !important;
    }
    
    .app-header .wallet-info.hidden-after-connect {
        display: none !important;
    }
    
    /* Adjust content padding when wallet container is hidden */
    .mobile-wallet-container.hidden-after-connect + #app-content {
        padding-top: 70px !important; /* Back to just header height */
    }
}

/* Desktop wallet elements can also be hidden if desired */
.desktop-wallet-hidden .wallet-info {
    display: none !important;
}

/* Loading state for popup */
.wallet-popup.connecting {
    pointer-events: none;
}

.wallet-popup.connecting .connect-button {
    background: var(--disabled-color);
    position: relative;
    overflow: hidden;
}

.wallet-popup.connecting .connect-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Mobile-specific styles for chapters carousel */
@media (max-width: 768px) {
    /* Make the chapters section take full width */
    #chapters {
        padding: 10px 2mm; /* ~2mm margins on sides */
        min-height: 100vh;
        box-sizing: border-box;
    }
    
    /* Story content container - nearly full width */
    #story-content {
        max-width: none; /* Remove the 900px max-width restriction */
        width: 100%;
        margin: 0;
    }
    
    /* Story carousel - almost full width with 2mm margins */
    #chapters .story-carousel {
        width: calc(100vw - 4mm); /* Full viewport width minus 2mm on each side */
        max-width: none; /* Remove max-width constraint */
        margin: 0;
        height: 70vh; /* Slightly smaller height for mobile */
        border-radius: 12px; /* Slightly smaller border radius for mobile */
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
    }
    
    /* Carousel inner container */
    #chapters .carousel-inner {
        width: 100%;
        height: 100%;
    }
    
    /* Individual carousel items */
    #chapters .carousel-item {
        min-width: 100%;
        height: 100%;
    }
    
    /* Chapter content areas */
    #chapters .chapter-content, 
    #chapters .locked-content, 
    #chapters .coming-soon {
        padding: 15px; /* Reduce padding for more content space */
        width: 100%;
        height: 100%;
        box-sizing: border-box;
    }
    
    /* Canva embed - make it take more of the available space */
    #chapters .canva-embed {
        height: 90%; /* Increased from 85% to make player taller */
        width: 100%;
        border-radius: 6px;
        box-shadow: 0 0 15px rgba(255, 20, 147, 0.4);
    }
    
    /* Navigation buttons - adjust for mobile */
    #chapters .nav-button {
        width: 35px;
        height: 35px;
        font-size: 20px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    #chapters .prev {
        left: 8px;
    }
    
    #chapters .next {
        right: 8px;
    }
    
    /* Carousel dots - adjust spacing for mobile */
    #chapters .carousel-dots {
        bottom: 15px;
        gap: 8px;
    }
    
    #chapters .dot {
        width: 10px;
        height: 10px;
    }
    
    /* Locked content styling adjustments */
    #chapters .price-display {
        padding: 8px 16px;
        margin: 12px 0;
    }
    
    #chapters .price-amount {
        font-size: 20px;
    }
    
    #chapters .unlock-button {
        padding: 10px 20px;
        font-size: 14px;
        margin-top: 15px;
    }
    
    /* Coming soon text adjustments */
    #chapters .coming-soon h3 {
        font-size: 22px;
        margin-bottom: 15px;
    }
    
    #chapters .coming-soon p {
        font-size: 16px;
        color: #FF1493;
        font-weight: bold;
    }
    
    /* Make sure the main app content doesn't interfere */
    body.body-bg-chapters #app-content {
        padding: 0; /* Remove default padding on chapters page for mobile */
    }
}

/* Updated styles for better diary visibility on mobile */

/* Mobile-specific styles for diaries */
@media (max-width: 768px) {
    /* Move the entire diaries container down to make more room */
    .diaries-container {
        margin-top: 20px;
        padding-top: 20px;
    }

    /* Increase the carousel height significantly */
    .diaries-container .carousel {
        height: 85vh !important; /* Increased from 80vh to accommodate larger player */
        margin-bottom: 40px; /* Add space below carousel */
    }

    /* Push the card game container down */
    .card-game-container {
        margin-top: 40px;
        margin-bottom: 60px; /* Add bottom margin to prevent cutoff */
        padding-top: 20px;
    }

    /* Adjustments for diary content when wallet notice is present */
    .diaries-container .carousel-content.wallet-view {
        padding-top: 40px; /* Was effectively 40px */
        padding-bottom: 100px; /* Was effectively 100px */
        padding-left: 0; /* Was 10px, now 0 */
        padding-right: 0; /* Was 10px, now 0 */
        justify-content: flex-start;
        height: 100%;
        box-sizing: border-box;
    }

    /* Regular carousel content also needs adjustment */
    .diaries-container .carousel-content {
        padding-top: 10px; /* Was 10px */
        padding-bottom: 10px; /* Was 10px */
        padding-left: 0; /* Was 10px, now 0 */
        padding-right: 0; /* Was 10px, now 0 */
        height: 100%;
        box-sizing: border-box;
    }

    /* Landscape rotation for wallet apps on mobile - LARGER SIZE */
    .diaries-container .canva-embed.landscape-rotated,
    .diaries-container .diary-iframe.landscape-rotated {
        transform: rotate(90deg);
        transform-origin: center center;
        width: 160vh !important; /* Increased from 140vh - about 14% larger */
        height: 160vw !important; /* Increased from 140vw - about 14% larger */
        margin-top: 80px; /* Increased margin to accommodate top buttons and larger size */
        margin-bottom: 20px;
        border-radius: 8px;
        box-shadow: 0 0 20px rgba(255, 20, 147, 0.3);
    }

    /* Regular (non-rotated) diary iframes should also be larger */
    .diaries-container .canva-embed,
    .diaries-container .diary-iframe {
        width: 100%;
        height: 90% !important; /* Increased height */
        border-radius: 8px;
        box-shadow: 0 0 20px rgba(255, 20, 147, 0.3);
    }

    /* Ensure the carousel content centers the rotated iframe properly */
    .diaries-container .carousel-content.wallet-view {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start; /* Changed from center to flex-start */
        overflow: hidden; /* Prevent content from overflowing */
    }

    /* Adjust titles for wallet view - account for top navigation */
    .diaries-container .carousel-content.wallet-view h3 {
        margin-top: 60px; /* Increased to account for top navigation buttons */
        margin-bottom: 15px;
        position: relative;
        z-index: 10; /* Ensure title is below navigation buttons */
        text-align: center;
        font-size: 18px; /* Slightly smaller font */
    }

    /* Adjust the wallet app notice to be more compact */
    .diaries-container .wallet-app-notice {
        background: rgba(255, 20, 147, 0.1);
        border: 1px solid rgba(255, 20, 147, 0.3);
        border-radius: 8px;
        padding: 8px; /* Reduced padding */
        margin-bottom: 15px; /* Reduced margin */
        text-align: center;
        width: 80%; /* Make it narrower */
        max-width: 200px;
    }

    /* Make the open in browser button more compact */
    .diaries-container .open-in-browser-button {
        background: linear-gradient(45deg, #00bfff, #ff1493);
        color: white;
        border: none;
        padding: 8px 12px; /* Reduced padding */
        border-radius: 5px;
        font-size: 13px; /* Slightly smaller font */
        font-weight: 600;
        cursor: pointer;
        transition: transform 0.2s, box-shadow 0.2s;
    }

    /* Navigation buttons positioned at the top like in chapters */
    .diaries-container .carousel .nav-button {
        position: absolute;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.9);
        border: none;
        border-radius: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        font-weight: bold;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        z-index: 20;
        color: #00214d;
        transition: all 0.2s ease;
        
        /* Position at top instead of center */
        top: 15px;
        transform: none; /* Remove the translateY transform */
    }

    .diaries-container .carousel .nav-button:hover,
    .diaries-container .carousel .nav-button:active {
        background: rgba(255, 255, 255, 1);
        transform: scale(0.95);
    }

    .diaries-container .carousel .prev {
        left: 15px; /* Position from left */
    }

    .diaries-container .carousel .next {
        right: 15px; /* Position from right */
    }

    /* Move dots lower to avoid interference with rotated content */
    .carousel .dots {
        bottom: 10px;
        z-index: 20;
    }

    /* Hide dots in diaries section */
    .diaries-container .carousel .dots {
        display: none !important;
    }

    /* Adjust locked content and coming soon content too */
    .diaries-container .locked-content,
    .diaries-container .coming-soon {
        padding: 20px;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    /* Ensure proper spacing for the entire diaries section */
    #diaries {
        padding-bottom: 100px; /* Add extra bottom padding */
        min-height: calc(100vh + 100px); /* Ensure enough height */
    }

    /* Card slots and collection should be moved further down */
    .card-slots, .card-collection {
        margin-top: 20px;
    }

    /* Make sure card collection doesn't get cut off at bottom */
    .card-collection-container {
        max-height: 250px; /* Reduced height to prevent cutoff */
        margin-bottom: 40px;
    }
}

/* Additional styles for wallet app notice and button in diaries (non-mobile or fallback) */
.diaries-container .wallet-app-notice {
    background: rgba(255, 20, 147, 0.1);
    border: 1px solid rgba(255, 20, 147, 0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    text-align: center;
}

.diaries-container .wallet-app-notice p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #f0f0f0;
}

.diaries-container .open-in-browser-button {
    background: linear-gradient(45deg, #00bfff, #ff1493);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.diaries-container .open-in-browser-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

/* Hide the fullscreen button */
.diaries-container .open-in-browser-button {
    display: none !important;
}

/* Mobile fullscreen overlay styles */
.mobile-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-fullscreen-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-fullscreen-container {
    width: 150vh;  /* 50% wider in landscape (was 100vh) */
    height: 100vw; /* Keep original height */
    display: flex;
    flex-direction: column;
    transform: rotate(90deg);
    transform-origin: center center;
    position: relative;
}

.mobile-fullscreen-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    color: white;
}

.fullscreen-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-accent, #ff1493);
}

.fullscreen-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background 0.2s ease;
}

.fullscreen-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mobile-fullscreen-player {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    background: #000;
}

/* Lock body when fullscreen is active */
body.fullscreen-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Mobile chapter preview styles */
@media (max-width: 768px) {
    .mobile-chapter .mobile-preview-container {
        position: relative;
        width: 100%;
        height: 60vh;
        margin: 20px 0;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .mobile-chapter .mobile-preview {
        width: 100%;
        height: 100%;
        border: none;
    }
    
    .mobile-chapter .mobile-preview-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(2px);
    }
    
    .mobile-fullscreen-btn {
        background: linear-gradient(45deg, #ff1493, #00bfff);
        color: white;
        border: none;
        padding: 15px 25px;
        border-radius: 25px;
        font-size: 16px;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.3s, box-shadow 0.3s;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        box-shadow: 0 4px 15px rgba(255, 20, 147, 0.3);
    }
    
    .mobile-fullscreen-btn:hover,
    .mobile-fullscreen-btn:active {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(255, 20, 147, 0.5);
    }
    
    .mobile-hint {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.7);
        text-align: center;
        margin: 10px 0;
        font-style: italic;
    }
}

/* Diaries Container Styles */
.diaries-container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.diaries-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
    pointer-events: none;
}

.diaries-container .carousel {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.diaries-container .carousel-content {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
} 