@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&display=swap');

/* Loot Page Specific Styles */
body.loot-page {
    background-color: #0f0f12;
    /* Fallback dark */
    color: #e0e0e0;
    /* Font inherits from body in styles.css */
}

/* --- Header Stats Bar --- */
.loot-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 1rem;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.5));
    border-bottom: 1px solid #333;
}

/* Loot stats bar styles moved to styles.css for global access */

/* --- Hero / Profile Section --- */
.dungeon-hero {
    text-align: center;
    margin-top: 140px;
    /* Space for fixed header/nav if needed, or just flow */
    padding: 2rem;
}

.auth-container {
    margin-bottom: 2rem;
}

.dungeon-btn {
    background: #3a2e22;
    border: 2px solid #8b7355;
    color: #ffd700;
    padding: 10px 20px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    /* Ensure children are positioned relative to button */
    overflow: visible;
    /* Allow particles to spill out */
}

.dungeon-btn:hover {
    background: #5a4a32;
    box-shadow: 0 0 10px #ffd700;
}

.dungeon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* --- Quest Board --- */
.quest-board {
    max-width: 1000px;
    margin: 0 auto 4rem;
    padding: 0 1rem;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    color: #bfa58a;
    margin-bottom: 2rem;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px #000;
}

.quest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.dungeon-card {
    background: rgba(30, 30, 35, 0.85);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 1.5rem;
    position: relative;
    overflow: visible;
    transition: transform 0.3s;
    backdrop-filter: blur(5px);
}

.dungeon-card:hover {
    transform: translateY(-5px);
    border-color: #ffd700;
}

.dungeon-card h3 {
    margin-top: 0;
    color: #fff;
    border-bottom: 1px solid #555;
    padding-bottom: 0.5rem;
}

.quest-rewards {
    margin: 1rem 0;
    font-size: 0.9rem;
    color: #aaa;
}

.reward-tag {
    background: #222;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 5px;
    color: #ffd700;
    border: 1px solid #555;
}

/* --- Animations --- */
@keyframes coin-float {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}

.coin-anim {
    position: absolute;
    pointer-events: none;
    animation: coin-float 1s ease-out forwards;
    font-size: 1.5rem;
    color: #ffd700;
    z-index: 9999;
}

/* --- Development Warning --- */
.dev-warning {
    background: rgba(184, 134, 11, 0.2);
    border: 2px solid #b8860b;
    color: #ffd700;
    padding: 1rem;
    margin: 2rem auto;
    max-width: 800px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: 0 0 15px rgba(184, 134, 11, 0.3);
    position: relative;
    overflow: hidden;

    /* STRICT ISOLATION */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
    text-shadow: none !important;
}

.dev-warning::before {
    content: '⚠️ WARNING';
    display: block;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: #ff4500;
    text-shadow: 0 0 5px rgba(255, 69, 0, 0.5);
}

/* --- Animated Characters --- */
.rpg-character {
    position: absolute;
    width: 60px;
    height: 60px;
    z-index: 10;
    /* Bring to front for the "pop" effect */
    pointer-events: none;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    opacity: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.character-pop {
    animation: character-pop-anim 4s ease-in-out forwards;
}

@keyframes character-pop-anim {
    0% {
        transform: translateY(20px) scale(0);
        opacity: 0;
    }

    10% {
        transform: translateY(-40px) scale(1.1);
        opacity: 1;
    }

    90% {
        transform: translateY(-45px) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-20px) scale(0);
        opacity: 0;
    }
}

/* --- Character Profile Styles --- */
.character-card {
    background: linear-gradient(135deg, rgba(40, 40, 50, 0.95), rgba(20, 20, 25, 0.95));
    border: 2px solid #8b7355;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.character-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b7355, #ffd700, #8b7355);
}

.character-display {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.character-portrait-container {
    position: relative;
    width: 150px;
    height: 150px;
    flex-shrink: 0;
    /* Prevent squashing on desktop/flex layouts */
    border-radius: 12px;
    border: 3px solid #ffd700;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    aspect-ratio: 1 / 1;
    /* Force square ratio */
}

.character-portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.portrait-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 5px;
    text-align: center;
    font-size: 0.8rem;
    color: #ffd700;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.3s;
    cursor: pointer;
    pointer-events: none;
    /* Ignore clicks when hidden */
    font-weight: bold;
    letter-spacing: 1px;
}

/* Show overlay only when editing */
.character-card.is-editing .portrait-overlay {
    opacity: 1;
    pointer-events: auto;
}

.character-portrait-container:hover .character-portrait {
    transform: scale(1.05);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.character-info {
    flex: 1;
    min-width: 250px;
    text-align: left;
}

.character-info h2 {
    font-size: 2.2rem;
    margin: 0 0 0.5rem 0;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-family: 'Outfit', sans-serif;
}

.char-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.char-rank {
    font-size: 1rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.char-gender-tag {
    background: rgba(139, 115, 85, 0.3);
    padding: 2px 10px;
    border-radius: 20px;
    border: 1px solid #8b7355;
    font-size: 0.8rem;
    color: #bfa58a;
    text-transform: capitalize;
}

.char-address-preview {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    border: 1px dashed #444;
    font-style: italic;
    color: #888;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.9rem;
}

/* Edit Form */
.edit-form-container {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #444;
    animation: fadeIn 0.5s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.edit-form-container h3 {
    color: #bfa58a;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #ffd700;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: #111;
    border: 1px solid #444;
    color: #fff;
    padding: 10px;
    border-radius: 4px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #ffd700;
}

.form-actions {
    display: flex;
    gap: 1rem;
}

.btn-secondary {
    background: #444;
    border-color: #666;
    color: #ccc;
}

.btn-secondary:hover {
    background: #555;
    box-shadow: none;
    color: #fff;
}

@media (max-width: 600px) {
    .character-display {
        flex-direction: column;
        text-align: center;
    }

    .character-info {
        text-align: center;
    }

    .char-meta {
        justify-content: center;
    }
}

/* --- Refinement Styles --- */
.hero-cta {
    text-align: center;
    margin: 2rem 0;
}

.hero-main-btn {
    font-size: 1.5rem;
    padding: 1.2rem 3rem;
    background: linear-gradient(135deg, #ffd700, #b8860b);
    color: #000;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
    border-radius: 50px;
    font-weight: 800;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    cursor: pointer;
}

.hero-main-btn:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.6);
}

.char-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.char-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.2rem;
    color: #ffd700;
    font-weight: bold;
}

/* Avatar Selection Gallery */
.avatar-selection-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    /* 5 columns for a clean 5x2 grid */
    gap: 15px;
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #333;
    max-width: 500px;
    /* Prevent it from getting too large on desktop */
}

.avatar-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    border: 2px solid #444;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    object-fit: cover;
}

.avatar-option:hover {
    border-color: #ffd700;
    transform: translateY(-3px);
}

.avatar-option.selected {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    outline: 2px solid #ffd700;
}

/* Shipping Form Grid */
.shipping-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 10px;
}

.shipping-form-grid .full-width {
    grid-column: span 2;
}

.shipping-form-grid input {
    background: rgba(0, 0, 0, 0.6);
    padding: 12px;
}

@media (max-width: 600px) {
    .char-stats-grid {
        grid-template-columns: 1fr;
    }
}

.usa-only-badge {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: #ffd700;
    padding: 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.8rem;
    pointer-events: none;
    opacity: 0.8;
}

/* --- UNIMATRIX ONE: BORG HIVE AESTHETIC --- */
.btn-admin {
    background: #000 !important;
    color: #00ff41 !important;
    border: 2px solid #00ff41 !important;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.4);
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 900;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    position: relative;
    overflow: hidden;
}

.btn-admin::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 255, 65, 0.1) 0%, transparent 70%);
    animation: borgPulse 4s infinite linear;
}

@keyframes borgPulse {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.6;
    }

    100% {
        transform: scale(1);
        opacity: 0.3;
    }
}

.btn-admin:hover {
    background: #00ff41 !important;
    color: #000 !important;
    box-shadow: 0 0 25px rgba(0, 255, 65, 0.8), inset 0 0 15px rgba(0, 0, 0, 0.3);
}

#admin-hub-modal .modal-content {
    background: #050505;
    border: 3px solid #1a1a1a;
    border-left: 8px solid #00ff41;
    /* Asymmetric Borg design */
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 255, 65, 0.1);
    border-radius: 4px;
    position: relative;
    color: #00ff41;
}

/* Mechanical Underlay (Greeblies Effect) */
#admin-hub-modal .modal-content::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(90deg, rgba(0, 255, 65, 0.05) 1px, transparent 1px),
        linear-gradient(rgba(0, 255, 65, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.2;
}

.admin-hub-content h2 {
    font-family: 'Courier New', Courier, monospace;
    color: #00ff41;
    text-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
    background: rgba(0, 255, 65, 0.1);
    padding: 10px 20px;
    display: inline-block;
    border-right: 4px solid #00ff41;
}

.admin-tabs {
    border-bottom: 2px solid #1a1a1a;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
}

.admin-tab-btn {
    font-family: 'Courier New', Courier, monospace;
    color: #00ff41;
    background: #111 !important;
    border: 1px solid #333 !important;
    margin-right: 5px;
    opacity: 0.6;
    transition: all 0.2s;
}

.admin-tab-btn.active {
    background: #00ff41 !important;
    color: #000 !important;
    opacity: 1;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
}

.admin-section h3 {
    color: #00ff41;
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 2px solid #00ff41;
    padding-bottom: 5px;
}

.input-group-stack input,
.admin-list-container,
.sync-item {
    background: #000 !important;
    border: 1px solid #1a1a1a !important;
    border-left: 3px solid #00ff41 !important;
    color: #00ff41 !important;
    font-family: 'Courier New', Courier, monospace;
    box-shadow: inset 0 0 10px rgba(0, 255, 65, 0.05);
}

.input-group-stack input:focus {
    border-left-width: 6px !important;
    background: #080808 !important;
}

.admin-list-container::-webkit-scrollbar-thumb {
    background: #00ff41;
    box-shadow: 0 0 10px #00ff41;
}

.creator-item {
    background: rgba(0, 255, 65, 0.02);
    margin-bottom: 2px;
    border: none;
}

.sync-info strong {
    color: #00ff41;
    text-transform: uppercase;
}

.btn-sync,
#panel-feed .dungeon-btn,
#save-game-meta-btn {
    background: #111 !important;
    border: 2px solid #00ff41 !important;
    color: #00ff41 !important;
    font-weight: bold;
    text-shadow: 0 0 5px #00ff41;
}

.btn-sync:hover,
#panel-feed .dungeon-btn:hover,
#save-game-meta-btn:hover {
    background: #00ff41 !important;
    color: #000 !important;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.6);
}

#admin-hub-modal .close-modal {
    color: #00ff41;
    background: rgba(0, 255, 65, 0.1);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
}

.delete-btn {
    color: #ff0000;
    font-family: serif;
    font-weight: bold;
}

/* --- Base Modal Styles --- */
.dungeon-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    z-index: 1;
    background: #1a1a1f;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: #888;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.3s;
}

/* =========================================
   Magic The Gathering - High Fidelity Theme
   ========================================= */

/* =========================================
   Magic The Gathering - High Fidelity Theme
   ========================================= */

body.theme-mtg {
    /* Base background if video fails */
    background-color: #0c0e14 !important;
    font-family: "Goudy Old Style", "Garamond", serif;
    --card-p: 0.8rem;
    overflow-x: hidden;
}

/* Fullscreen Video Background */
body.theme-mtg .mtg-video-bg {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    transform: translate(-50%, -50%);
    z-index: -2;
    pointer-events: none;
}

/* Cinematic Video Overlay */
body.theme-mtg .mtg-video-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1;
    pointer-events: none;
}

/* 
   ------------------------------------------
   NEW CARD ARCHITECTURE (User Reference)
   !!! LOCKED STYLE - DO NOT MODIFY !!!
   User requires explicit confirmation before changing this layout.
   This matches the "Serra Angel" high-fidelity reference.
   ------------------------------------------
*/

body.theme-mtg .dungeon-card {
    /* Resets & Base Layout */
    all: initial;
    /* Reset inherited styles from .dungeon-card */
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;

    /* Dimensions & Scaling */
    width: 100%;
    max-width: 350px;
    /* Consistently match user reference max width */
    aspect-ratio: 0.714;
    /* Standard MTG Card Ratio (2.5 x 3.5) */
    margin: 0 auto;

    /* Theme Variables Definition (Defaults) */
    --frame-bg: #d1c8b3;
    --inner-border: #a9a9a9;
    --text-box-bg: rgba(255, 255, 255, 0.9);
    --border-color: #171314;

    font-family: "Goudy Old Style", "Garamond", serif;
    background: var(--border-color);
    /* Outer Black Border */
    border-radius: 14px;
    /* Slightly tighter radius for better look */
    padding: 10px;
    /* The black border thickness essentially */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    transition: transform 0.3s ease, z-index 0s;
}

body.theme-mtg .dungeon-card:hover {
    transform: translateY(-10px) scale(1.05) rotateX(2deg);
    z-index: 100;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

/* Color Identity Overrides */
/* WHITE */
body.theme-mtg .dungeon-card.mtg-white {
    --frame-bg: linear-gradient(135deg, #e6e6e6 0%, #f9faf4 50%, #dcdcdc 100%);
    --inner-border: #fff;
    --text-box-bg: rgba(249, 250, 244, 0.92);
}

/* BLUE */
body.theme-mtg .dungeon-card.mtg-blue {
    --frame-bg: linear-gradient(135deg, #b0c4de 0%, #c1d7e9 50%, #aab7c4 100%);
    --inner-border: #0e68ab;
    --text-box-bg: rgba(193, 215, 233, 0.92);
}

/* BLACK */
body.theme-mtg .dungeon-card.mtg-black {
    --frame-bg: linear-gradient(135deg, #888 0%, #555 50%, #333 100%);
    /* Lighter for visibility texture? No, authentic swampy */
    --frame-bg: url('https://www.transparenttextures.com/patterns/black-scales.png'), linear-gradient(135deg, #595552 0%, #2f2f2f 100%);
    --inner-border: #150b00;
    --text-box-bg: rgba(200, 190, 190, 0.92);
    color: #000;
}

/* RED */
body.theme-mtg .dungeon-card.mtg-red {
    --frame-bg: linear-gradient(135deg, #f08080 0%, #e49977 50%, #cd5c5c 100%);
    --inner-border: #d3202a;
    --text-box-bg: rgba(245, 220, 210, 0.92);
}

/* GREEN */
body.theme-mtg .dungeon-card.mtg-green {
    --frame-bg: linear-gradient(135deg, #8fbc8f 0%, #c4d3ca 50%, #556b2f 100%);
    --inner-border: #00733e;
    --text-box-bg: rgba(210, 230, 215, 0.92);
}

/* MULTICOLOR / GOLD */
body.theme-mtg .dungeon-card.mtg-multicolor,
body.theme-mtg .dungeon-card.mtg-gold {
    --frame-bg: linear-gradient(135deg, #b8860b 0%, #ffdf00 40%, #dab522 60%, #b8860b 100%);
    --inner-border: #f0e68c;
    --text-box-bg: rgba(255, 245, 230, 0.95);
}

/* 2. Inner Frame */
.card-frame {
    flex: 1;
    background: var(--frame-bg);
    border: 3px solid var(--inner-border);
    /* Slightly thicker inner border */
    border-radius: 8px;
    /* Inner radius */
    padding: 6px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 60;
    /* Above Foil Overlay (50) */
    pointer-events: none;
    /* Let clicks pass to children */
}

.card-frame>* {
    pointer-events: auto;
    /* Re-enable clicks for children */
}

/* 3. Header (Name & Mana) */
.card-header {
    background: rgba(255, 255, 255, 0.85);
    /* Slightly more opaque */
    border: 2px solid #555;
    border-radius: 5px;
    /* Slightly squarer than pill */
    padding: 3px 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 900;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    margin-bottom: 4px;
    z-index: 2;
}

.card-name {
    font-size: 0.95rem;
    color: #000;
    font-family: 'Goudy Old Style', serif;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* 4. Mana Symbols (Updated to match existing icon system) */
.mana-cost {
    display: flex;
    gap: 2px;
}

/* Mana Font Integration overrides and Coloring */
body.theme-mtg .mana-cost i.ms {
    font-size: 0.9rem !important;
    width: 1.1rem;
    height: 1.1rem;
    line-height: 1.1rem;
    text-align: center;
    border-radius: 50%;
    margin-left: 2px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
    display: inline-block;
}

/* White */
body.theme-mtg .ms-w {
    background-color: #f8e7b9;
    color: #111 !important;
}

/* Blue */
body.theme-mtg .ms-u {
    background-color: #aae0fa;
    color: #111 !important;
}

/* Black */
body.theme-mtg .ms-b {
    background-color: #cbc2bf;
    color: #111 !important;
}

/* Authentic Black might be dark bg, white symbol, but user asked for "green for green" etc. 
   Usually sets use grey/swamp color bg. 
*/

/* Red */
body.theme-mtg .ms-r {
    background-color: #f9aa8f;
    color: #111 !important;
}

/* Green */
body.theme-mtg .ms-g {
    background-color: #9bd3ae;
    color: #111 !important;
}

/* Generic/Colorless */
body.theme-mtg .ms-c,
body.theme-mtg .ms-cost {
    background-color: #cbc2c0;
    color: #111 !important;
}

/* 5. Art Box */
.art-box {
    flex-grow: 1;
    /* Allow efficient fill */
    min-height: 140px;
    /* Ensure visibility */
    max-height: 45%;
    /* Don't dominate too much */
    border: 2px solid #222;
    background: #000;
    background-size: cover;
    background-position: center;
    margin-bottom: 4px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.8);
    z-index: 1;
}

/* 6. Type Line */
.type-line {
    background: rgba(255, 255, 255, 0.85);
    border: 2px solid #555;
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    z-index: 2;
    font-weight: bold;
    color: #000;
}

.set-symbol svg {
    filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.5));
}

/* 7. Text Box */
.card-text-box {
    flex: 1;
    /* Take remaining space */
    background: var(--text-box-bg);
    border: 2px solid #555;
    padding: 8px 8px 15px 8px;
    /* Added extra bottom padding to clear stamp */
    font-family: "Plantin", "Times New Roman", serif;
    font-size: 0.85rem;
    line-height: 1.25;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.1);
    color: #000 !important;
    /* Force black text for readability */
}

.rules-text {
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #000 !important;
}

.flavor-text {
    font-style: italic;
    margin-top: auto;
    /* Push to bottom */
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    font-size: 0.75rem;
    color: #111 !important;
    /* Nearly black for flavor */
    padding-bottom: 8px;
    /* Ensure space above stamp if needed */
}

/* 8. Power/Toughness */
.pt-box {
    position: absolute;
    bottom: -1px;
    right: -1px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #444;
    border-radius: 8px 0 4px 0;
    /* Corner radius */
    padding: 2px 8px;
    font-weight: bold;
    font-size: 1.0rem;
    font-family: "Goudy Old Style", serif;
    box-shadow: -1px -1px 2px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

/* 9. Foil Overlay */
body.theme-mtg .dungeon-card .foil-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    /* Above art and text */
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    background: linear-gradient(125deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.15) 30%,
            rgba(255, 0, 0, 0.15) 40%,
            rgba(0, 255, 0, 0.15) 50%,
            rgba(0, 0, 255, 0.15) 60%,
            rgba(255, 255, 255, 0.15) 70%,
            rgba(255, 255, 255, 0) 100%);
    background-size: 200% 200%;
    mix-blend-mode: color-dodge;
    border-radius: 14px;
}

body.theme-mtg .dungeon-card.mtg-foil:hover .foil-overlay,
body.theme-mtg .dungeon-card.mtg-foil-permanent .foil-overlay {
    opacity: 1;
    animation: foil-shimmer 2.5s infinite linear;
}

/* Permanent foil is stronger */
body.theme-mtg .dungeon-card.mtg-foil-permanent .foil-overlay {
    opacity: 0.8 !important;
}

@keyframes foil-shimmer {
    0% {
        background-position: 100% 100%;
    }

    100% {
        background-position: 0% 0%;
    }
}

/* Holofoil Stamp */
body.theme-mtg .dungeon-card .holofoil-stamp {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, #fff 0%, #d1d1d1 40%, #8a8a8a 100%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    border: 1px solid #666;
    z-index: 10;
    opacity: 0.9;
}

/* Action Button embedded in Rules Text */
body.theme-mtg .dungeon-card .dungeon-btn {
    display: block;
    width: 100%;
    margin: 4px 0;
    background: transparent;
    color: #000;
    border: 1px solid #888;
    border-radius: 4px;
    font-family: inherit;
    font-weight: bold;
    font-size: 0.85rem;
    padding: 4px;
    cursor: pointer;
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
    text-align: center;
    transition: all 0.2s;
}

body.theme-mtg .dungeon-card .dungeon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: #000;
    transform: translateY(-1px);
}

body.theme-mtg .dungeon-card .dungeon-btn:active {
    transform: translateY(1px);
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Rewards Tag Styling as Keywords */
body.theme-mtg .quest-rewards {
    font-weight: bold;
    font-size: 0.85rem;
    color: #000;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
    margin-bottom: 4px;
}

/* 
   Profile Section Overrides 
*/
body.theme-mtg .character-card {
    /* Make the profile look like a "Planeswalker" card or Command Zone */
    background: #1a1a1a;
    border: 4px solid #b8860b;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
}

body.theme-mtg .character-info h2 {
    color: #fff;
    font-family: 'Cinzel', serif;
    border-bottom: 2px solid #b8860b;
    padding-bottom: 5px;
}

/* Ensure global text visibility on background */
body.theme-mtg .section-title,
body.theme-mtg h2 {
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    color: #fff;
}

/* --- Claim Reward Animations --- */

/* --- Claim Reward Animations (Intense) --- */

@keyframes claim-glow-pulse {
    0% {
        box-shadow: 0 0 20px rgba(156, 39, 176, 0.5), inset 0 0 20px rgba(255, 215, 0, 0.2);
        border-color: #9c27b0;
    }

    50% {
        /* Massive Spread */
        box-shadow: 0 0 80px rgba(156, 39, 176, 1), inset 0 0 50px rgba(255, 215, 0, 0.8);
        border-color: #ffd700;
    }

    100% {
        box-shadow: 0 0 20px rgba(156, 39, 176, 0.5), inset 0 0 20px rgba(255, 215, 0, 0.2);
        border-color: #9c27b0;
    }
}

.card-claiming {
    animation: claim-glow-pulse 0.5s infinite alternate !important;
    z-index: 9999 !important;
    /* Highest priority */
    transform: scale(1.05);
    background: #000 !important;
    /* Ensure no transparent bleed */
}

/* Button Vibration (Retained but intense) */
@keyframes heavy-vibration {
    0% {
        transform: translate(0, 0);
    }

    10% {
        transform: translate(-3px, -3px);
    }

    20% {
        transform: translate(3px, 3px);
    }

    30% {
        transform: translate(-4px, 0);
    }

    40% {
        transform: translate(4px, 0);
    }

    50% {
        transform: translate(-3px, 3px);
    }

    60% {
        transform: translate(3px, -3px);
    }

    70% {
        transform: translate(0, 4px);
    }

    80% {
        transform: translate(-4px, -4px);
    }

    90% {
        transform: translate(4px, 4px);
    }

    100% {
        transform: translate(0, 0);
    }
}

.btn-vibrating {
    animation: heavy-vibration 0.1s infinite !important;
    background-color: #5a1e75 !important;
    color: #fff !important;
    border-color: #ffd700 !important;
    box-shadow: 0 0 30px #9c27b0;
}

/* --- Default Theme: Screen-filling Magic Charge (Now handled by Canvas) --- */
/* .magic-charging-particle removed */

/* --- MTG Theme: Solar Plasma Corona (Now handled by Canvas) --- */
/* .plasma-sun-burst and keyframes removed */

/* --- Screen Flash --- */
.screen-flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
}

@keyframes flash-bang {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.flashing {
    animation: flash-bang 0.8s ease-out forwards;
}

/* --- Explosive Particles (Success) --- */
.claim-particle {
    position: absolute;
    pointer-events: none;
    z-index: 10001;
    border-radius: 50%;
}

.magic-particle {
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, #fff, rgba(255, 215, 0, 0.8) 40%, transparent 80%);
    filter: blur(1px);
}

.plasma-particle {
    width: 25px;
    height: 25px;
    background: radial-gradient(circle, currentColor, transparent 70%);
    filter: blur(2px);
    mix-blend-mode: screen;
    opacity: 0.8;
}

canvas.fade-out {
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

/* NUCLEAR READABILITY FIX */
body.theme-mtg .dungeon-card .card-text-box p,
body.theme-mtg .dungeon-card .rules-text p,
body.theme-mtg .dungeon-card .flavor-text,
body.theme-mtg .dungeon-card .rules-text div {
    color: #000000 !important;
    opacity: 1 !important;
    text-shadow: none !important;
    background: transparent !important;
    -webkit-text-fill-color: #000000 !important;
    isolation: isolate;
    mix-blend-mode: normal !important;
    font-weight: 600 !important;
    /* Bold it up slightly for readability */
}