
        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
            min-height: 100vh;
            color: #e0e0e0;
        }
        .card-container {
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        #actualCardContent {
            background: linear-gradient(145deg, #2a2a4e, #1a1a2e);
            border: 2px solid #4a4a7e;
            box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 10px 20px rgba(127,90,240,0.1);
            width: 320px;
            height: 480px;
            position: relative;
            overflow: hidden;
            border-radius: 1rem;
            backdrop-filter: blur(10px);
            transition: border-color 0.5s ease;
        }
        .card-art-area {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
            overflow: hidden;
        }
        .card-image-display {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: all 0.3s ease;
        }
        #imagePlaceholderText, #imageLoader {
            color: #ccc;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 1;
            text-align: center;
            font-size: 0.9rem;
        }
        .loader {
            border: 4px solid #4a4a7e;
            border-top: 4px solid #7f5af0;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }
        .small-loader {
            width: 20px;
            height: 20px;
            border-width: 2px;
            display: inline-block;
            margin-left: 8px;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .card-overlay-layer {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background: linear-gradient(180deg,
                rgba(0,0,0,0.1) 0%,
                rgba(0,0,0,0.3) 30%,
                rgba(0,0,0,0.4) 70%,
                rgba(0,0,0,0.8) 100%);
            z-index: 10;
            pointer-events: none;
        }

        .card-name-area {
            position: absolute;
            top: 25px;
            left: 65px;
            right: 20px; /* Keep for width calculation */
            height: 40px;
            display: flex; /* Use flexbox for centering */
            align-items: center;
            justify-content: center;
            z-index: 11;
            background: rgba(0,0,0,0.3);
            border-radius: 8px;
            padding: 0 15px; /* Padding on the container */
            backdrop-filter: blur(5px);
            transition: background-color 0.5s ease;
        }
        #cardNameDisplay {
            font-size: 1.4rem;
            font-weight: bold;
            color: #fff;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            letter-spacing: 0.5px;
            text-align: center; /* More reliable for html2canvas */
        }

        .card-lore-area {
            flex: 1;
            height: 100%;
            display: flex;
            flex-direction: column;
            font-size: 0.7rem;
            line-height: 1.4;
            color: #f0f0f0;
            padding: 8px 12px;
            background: rgba(0,0,0,0.6);
            border-radius: 8px;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255,255,255,0.1);
        }
        .card-lore-text {
             overflow-y: hidden; /* We will manage overflow with JS */
             text-align: center; /* More reliable for html2canvas */
        }

        .card-lore-text .triggered-ability-text {
            font-style: italic;
            color: #c7d2fe;
        }

        .card-body-wrapper {
            position: absolute;
            top: 270px;
            bottom: 35px;
            left: 20px;
            right: 20px;
            display: flex;
            gap: 15px;
            z-index: 11;
        }

        .card-stats-container {
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            width: 60px;
        }

        .stat-box {
            width: 60px;
            height: 60px;
            clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            border: 2px solid rgba(255, 255, 255, 0.4);
            box-shadow: 0 2px 8px rgba(0,0,0,0.7);
            backdrop-filter: blur(5px);
        }
        /* Flexbox-based centering for stat text (more stable for html2canvas) */
        .stat-box .stat-label { font-size: 0.7rem; opacity: 0.9; margin: 0; line-height: 1; }
        .stat-box .stat-value { font-size: 1.5rem; line-height: 1.2; text-shadow: 2px 2px 4px rgba(0,0,0,0.9); }

        .stat-attack { background: rgba(220,38,38,0.5); } /* Red */
        .stat-defense { background: rgba(59,130,246,0.5); } /* Blue */
        .stat-special { background: rgba(34,197,94,0.5); } /* Green */

        .stat-special-ability-area {
            position: absolute;
            bottom: 5px;
            left: 20px;
            right: 20px;
            height: 24px;
            display: flex; /* Use flexbox for centering */
            align-items: center;
            justify-content: center;
            z-index: 11;            
            color: #fff;
            background: rgba(127,90,240,0.6);
            border-radius: 8px;
            overflow: hidden;
            padding: 2px 10px; /* Padding on the container */
            text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
            backdrop-filter: blur(5px);
            border: 1px solid rgba(255,255,255,0.1);
        }
        /* This is more reliable for html2canvas than centering the parent flex container */
        .stat-special-ability-area p {
            width: 100%;
            text-align: center;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }

        .card-dice-roll {
            position: absolute;
            top: 18px;
            left: 18px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(145deg, #0ea5e9, #0284c7);
            color: white;
            font-size: 1.5rem;
            font-weight: bold;            
            display: flex; /* Use flexbox for centering */
            align-items: center;
            justify-content: center;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
            border: 2px solid rgba(255, 255, 255, 0.4);
            box-shadow: 0 2px 8px rgba(0,0,0,0.7);
            z-index: 12;
            transition: background 0.5s ease;
        }

        .glass-card {
            background: rgba(36, 36, 64, 0.7);
            backdrop-filter: blur(20px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        }

        .button-primary, .button-secondary, .button-export, .button-save, .button-regenerate {
            padding: 0.75rem 1.25rem;
            border-radius: 0.5rem;
            font-weight: 600;
            transition: all 0.3s ease;
            text-align: center;
            border: none;
            cursor: pointer;
        }
        .button-primary {
            background: linear-gradient(135deg, #7f5af0, #9333ea);
            color: white;
            box-shadow: 0 4px 15px rgba(127,90,240,0.3);
        }
        .button-primary:hover {
            background: linear-gradient(135deg, #6a48d0, #7c3aed);
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(127,90,240,0.4);
        }
        .button-secondary {
            background: rgba(74, 74, 126, 0.8);
            color: #e0e0e0;
            backdrop-filter: blur(10px);
        }
        .button-secondary:hover {
            background: rgba(90, 90, 142, 0.9);
            transform: translateY(-1px);
        }
        .button-export {
            background: linear-gradient(135deg, #22c55e, #16a34a);
            color: white;
            box-shadow: 0 4px 15px rgba(34,197,94,0.3);
        }
        .button-export:hover {
            background: linear-gradient(135deg, #16a34a, #15803d);
            transform: translateY(-2px);
        }
        .button-save {
            background: linear-gradient(135deg, #0ea5e9, #0284c7);
            color: white;
            font-size: 0.75rem;
            padding: 0.5rem 0.75rem;
            margin-top: 0.5rem;
            display: inline-block;
        }
        .button-save:hover {
            background: linear-gradient(135deg, #0284c7, #0369a1);
            transform: translateY(-1px);
        }
        .button-regenerate {
            position: relative;
            background: rgba(0,0,0,0.7);
            color: white;
            border: 1px solid rgba(255,255,255,0.3);
            border-radius: 50%;
            width: 28px;
            height: 28px;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0.8;
            transition: all 0.2s ease;
            backdrop-filter: blur(5px);
            flex-shrink: 0;
            margin-left: auto;
        }
        .button-regenerate:hover {
            opacity: 1;
            background: rgba(127,90,240,0.8);
            transform: scale(1.1);
        }

        .input-field {
            background: rgba(20, 20, 35, 0.6);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: #e0e0e0;
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
            border-radius: 0.75rem;
        }
        .input-field:focus {
            border-color: #a78bfa;
            box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.2);
            background: rgba(20, 20, 35, 0.8);
        }
        .input-field::placeholder { color: #999; }

        .radio-label input[type="radio"] { opacity: 0; width: 0; height: 0; }
        .radio-label span {
            display: inline-block;
            padding: 0.6rem 1.2rem;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 0.5rem;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-right: 0.5rem;
            backdrop-filter: blur(10px);
        }
        .radio-label input[type="radio"]:checked + span {
            background: linear-gradient(135deg, #7f5af0, #9333ea);
            border-color: #7f5af0;
            color: white;
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(127,90,240,0.3);
        }
        .radio-label:hover span {
            background: rgba(58, 58, 94, 0.9);
            transform: translateY(-1px);
        }

        .message-box {
            padding: 1rem 1.5rem;
            border-radius: 0.75rem;
            margin-bottom: 1rem;
            font-size: 0.9rem;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255,255,255,0.1);
        }
        .message-box-success {
            background: rgba(16, 185, 129, 0.2);
            color: #6ee7b7;
            border-color: rgba(16, 185, 129, 0.3);
        }
        .message-box-error {
            background: rgba(239, 68, 68, 0.2);
            color: #fca5a5;
            border-color: rgba(239, 68, 68, 0.3);
        }

        .section-title {
            color: #a78bfa;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }
        .card-actions-container {
            width: 100%;
            max-width: 320px;
            margin-top: 1.5rem;
        }
        .feature-display-area {
            margin-top: 1rem;
            padding: 1rem;
            background: rgba(42, 42, 78, 0.6);
            border-radius: 0.75rem;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255,255,255,0.1);
        }
        .card-instance {
            background: linear-gradient(145deg, #2a2a4e, #1a1a2e);
            border: 2px solid #4a4a7e;
            box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 10px 20px rgba(127,90,240,0.1);
            width: 320px;
            height: 480px;
            position: relative;
            overflow: hidden;
            border-radius: 1rem;
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
            cursor: pointer;
        }
        .card-instance:hover {
            transform: translateY(-5px) scale(1.02);
            box-shadow: 0 25px 50px rgba(0,0,0,0.6), 0 15px 30px rgba(127,90,240,0.2);
            z-index: 20;
        }
        .selected-card {
            transform: translateY(-5px) scale(1.05) !important;
            border-color: #facc15; /* Legendary yellow for selection */
            box-shadow: 0 30px 60px rgba(0,0,0,0.7), 0 0 30px rgba(250, 204, 21, 0.5) !important;
            z-index: 25;
        }

        .api-config {
            background: rgba(20, 20, 40, 0.8);
            border: 1px solid rgba(74, 74, 126, 0.6);
            border-radius: 0.75rem;
            padding: 1.5rem;
            margin-bottom: 2rem;
            backdrop-filter: blur(10px);
        }

        .config-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1rem;
        }

        @media (max-width: 640px) {
            .config-grid { grid-template-columns: 1fr; }
        }

        /* Full Art View Feature */
        .card-instance .card-overlay-layer,
        .card-instance .card-name-area,
        .card-instance .card-lore-area,
        .card-instance .card-stats-container,
        .card-instance .stat-special-ability-area {
            opacity: 0;
            transition: opacity 0.4s ease-in-out;
        }

        .card-instance:hover .card-overlay-layer,
        .card-instance.selected-card .card-overlay-layer,
        .card-instance:hover .card-name-area,
        .card-instance.selected-card .card-name-area,
        .card-instance:hover .card-lore-area,
        .card-instance.selected-card .card-lore-area,
        .card-instance:hover .card-stats-container,
        .card-instance.selected-card .card-stats-container,
        .card-instance:hover .stat-special-ability-area,
        .card-instance.selected-card .stat-special-ability-area {
            opacity: 1;
        }

        .card-instance:hover .card-image-display,
        .card-instance.selected-card .card-image-display {
            filter: brightness(0.8) contrast(1.1);
        }

        #subTypeContainer > div {
            transition: opacity 0.4s ease-in-out, max-height 0.4s ease-in-out;
            overflow: hidden;
        }

        /* Class for PNG export to ensure all elements are visible */
        .exporting-card {
            /* Reset transforms and shadows to a base state for stable canvas capture */
            transform: none !important;
            box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 10px 20px rgba(127,90,240,0.1) !important;
        }

        .exporting-card .card-overlay-layer,
        .exporting-card .card-name-area,
        .exporting-card .card-lore-area,
        .exporting-card .card-stats-container,
        .exporting-card .stat-special-ability-area {
            opacity: 1 !important;
            transition: none !important;
        }
        .exporting-card .card-image-display {
            filter: brightness(0.8) contrast(1.1) !important;
        }
        .exporting-card .button-regenerate {
            display: none !important;
        }

        /*
         * The export CSS is being removed. The new centering method above works for both
         * on-screen display and html2canvas, making special export styles for text unnecessary.
         * This ensures a 1-to-1 match between the screen and the exported PNG.
        */
        .view-art-button {
            position: absolute;
            top: 12px;
            right: 12px;
            z-index: 12;
            background: rgba(0,0,0,0.6);
            color: white;
            border: 1px solid rgba(255,255,255,0.3);
            border-radius: 50%;
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            transform: scale(0.8);
            transition: all 0.3s ease;
            backdrop-filter: blur(5px);
        }

        .selected-card .view-art-button {
            opacity: 0.8;
            transform: scale(1);
        }

        .view-art-button:hover {
            opacity: 1;
            background: rgba(127,90,240,0.8);
            transform: scale(1.1) !important;
        }

        #searchModal.visible,
        #historyModal.visible {
            opacity: 1;
            pointer-events: auto;
        }
        #imageModal.visible {
            opacity: 1;
            pointer-events: auto;
        }

        /* Dropdown Menu Styles */
        .dropdown {
            position: relative;
            display: inline-block;
        }

        .dropdown-content {
            display: none;
            position: absolute;
            right: 0;
            background-color: #1a1a2e;
            min-width: 200px;
            box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.5);
            z-index: 100;
            border-radius: 0.5rem;
            border: 1px solid #4a4a7e;
            padding: 0.5rem 0;
            margin-top: 0.5rem;
        }

        .dropdown-content a, .dropdown-content button {
            color: #e0e0e0;
            padding: 0.75rem 1.25rem;
            text-decoration: none;
            display: block;
            width: 100%;
            text-align: left;
            background: none;
        }
        .dropdown-content a:hover, .dropdown-content button:hover { background-color: #7f5af0; }
        /* Changed from hover to a class-based toggle for better UX */
        .dropdown-content.show {
            display: block;
        }

        /* Sponsorship Section Styles */
        .sponsorship-section {
            background: rgba(15, 15, 35, 0.6);
            border: 1px solid rgba(74, 74, 126, 0.5);
            backdrop-filter: blur(10px);
        }
        .affiliate-link {
            background: rgba(42, 42, 78, 0.8);
            border: 1px solid rgba(74, 74, 126, 0.8);
            transition: all 0.3s ease;
        }
        .affiliate-link:hover {
            background: rgba(58, 58, 94, 0.9);
            border-color: #7f5af0;
        }
        /* PayPal Modal Styles */
        #buyCreditsModal.visible {
            opacity: 1;
            pointer-events: auto;
        }
        .credit-pack {
            border: 2px solid #4a4a7e;
            transition: all 0.3s ease;
        }
        .credit-pack:hover {
            border-color: #7f5af0;
            transform: translateY(-4px);
            cursor: pointer;
        }
    