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

:root {
    --accent-gold: #FFC300;
    --accent-orange: #FF5733;
    --dark-bg: rgba(0, 0, 0, 0.85);
    --fab-blue: #1a1a2e;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    transition: background 0.4s ease;
    position: relative;
    background-size: cover;
    background-position: center;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    z-index: 10;
}

.title {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 700;
    color: #1a1a2e;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.5);
    letter-spacing: -1px;
}

.subtitle {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    color: #2d2d2d;
    margin-top: 8px;
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    display: inline-block;
}

.upload-badge {
    display: block;
    margin-top: 10px;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 12px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
}

.character-container {
    position: relative;
    margin: 20px 0;
}

.character-display {
    width: min(300px, 80vw);
    height: min(300px, 80vw);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 4px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    overflow: hidden;
    padding: 20px;
    position: relative;
}

.character-display:hover {
    transform: scale(1.02);
}

.character-display:active {
    transform: scale(0.98);
}

.character-display.pixelated {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.character-display.pixelated svg,
.character-display.pixelated img {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.overlay-image {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    object-fit: contain;
    pointer-events: none;
    opacity: 0.9;
}

.overlay-image.animated {
    animation: bobble 1.5s ease-in-out infinite;
    transform-origin: center bottom;
}

.character-svg-container {
    width: 100%;
    height: 100%;
}

.character-svg-container.animated {
    animation: bobble 1.5s ease-in-out infinite;
    transform-origin: center bottom;
}

.character-svg {
    width: 100%;
    height: 100%;
}

.character-svg.animated {
    animation: bobble 1.5s ease-in-out infinite;
    transform-origin: center bottom;
}

@keyframes bobble {
    0%, 100% { transform: rotate(-1deg) translateY(0); }
    25% { transform: rotate(1deg) translateY(-3px); }
    50% { transform: rotate(-1deg) translateY(0); }
    75% { transform: rotate(1deg) translateY(-2px); }
}

.fuse-glow {
    animation: fuseGlow 0.5s ease-in-out infinite alternate;
}

@keyframes fuseGlow {
    from { opacity: 0.6; }
    to { opacity: 1; fill: #ff9500; }
}

.sparkle-effect {
    animation: sparkle 1s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.explosion {
    animation: shake 0.3s ease-in-out 3;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px) rotate(-5deg); }
    75% { transform: translateX(10px) rotate(5deg); }
}

.explosion-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: explode 1.5s ease-out forwards;
    pointer-events: none;
}

.explosion-emoji {
    font-size: 120px;
    display: block;
}

@keyframes explode {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}

/* Success Toast */
.success-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 14px 28px;
    border-radius: 30px;
    font-weight: 600;
    z-index: 1000;
    animation: slideDown 0.3s ease, fadeOut 0.3s ease 1.7s forwards;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
}

@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* Upload Modal */
.upload-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
    padding: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.upload-modal {
    background: linear-gradient(145deg, #1a1a2e, #2d2d4a);
    border-radius: 24px;
    padding: 28px;
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.upload-modal-header h2 {
    color: white;
    font-size: 1.4rem;
    font-weight: 600;
}

.upload-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.upload-dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
}

.upload-dropzone:hover {
    border-color: var(--accent-gold);
    background: rgba(255, 195, 0, 0.05);
}

.upload-dropzone.dragging {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.2);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-icon {
    font-size: 48px;
}

.dropzone-content p {
    color: white;
    font-size: 1rem;
}

.upload-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
}

.bounce-berry {
    font-size: 60px;
    animation: bounce 0.5s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.upload-error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 12px 16px;
    border-radius: 10px;
    margin-top: 12px;
    font-size: 0.9rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.upload-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.upload-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid var(--accent-gold);
}

.upload-preview span {
    color: white;
    font-size: 0.9rem;
    word-break: break-all;
}

.upload-mode-selector {
    margin-top: 20px;
}

.upload-mode-selector label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    display: block;
    margin-bottom: 10px;
}

.mode-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mode-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid transparent;
    border-radius: 12px;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.mode-btn.active {
    background: var(--accent-gold);
    color: #1a1a2e;
    border-color: var(--accent-gold);
    font-weight: 600;
}

.recent-uploads {
    margin-top: 20px;
}

.recent-uploads label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    display: block;
    margin-bottom: 10px;
}

.recent-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.recent-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.recent-thumb:hover {
    border-color: var(--accent-gold);
    transform: scale(1.1);
}

.upload-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.upload-btn {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
    border: none;
}

.upload-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.upload-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.upload-btn.primary {
    background: linear-gradient(135deg, var(--accent-orange), #ff8c42);
    color: white;
}

.upload-btn.primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 87, 51, 0.4);
}

.upload-btn.primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Traits Panel */
.traits-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: 320px;
    max-width: 100vw;
    height: 100vh;
    background: var(--dark-bg);
    backdrop-filter: blur(10px);
    transform: translateX(-100%);
    transition: transform 0.3s ease-out;
    z-index: 100;
    overflow-y: auto;
    padding: 24px;
    border-radius: 0 20px 20px 0;
}

.traits-panel.open {
    transform: translateX(0);
}

.traits-title {
    color: var(--accent-gold);
    font-size: 1.5rem;
    margin-bottom: 24px;
    font-weight: 600;
}

.traits-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.trait-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trait-item.custom-trait {
    background: rgba(255, 195, 0, 0.1);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 195, 0, 0.2);
}

.trait-value {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.trait-value span {
    color: white;
    font-size: 0.85rem;
    word-break: break-all;
}

.clear-custom-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.2);
    border: none;
    color: #ef4444;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.clear-custom-btn:hover {
    background: rgba(239, 68, 68, 0.4);
}

.trait-category {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'JetBrains Mono', monospace;
}

.trait-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.trait-option {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
}

.trait-option:hover {
    background: rgba(255, 255, 255, 0.2);
}

.trait-option.active {
    background: var(--accent-gold);
    color: #1a1a2e;
    border-color: var(--accent-gold);
    font-weight: 600;
}

.close-traits-btn {
    width: 100%;
    padding: 16px;
    margin-top: 30px;
    background: linear-gradient(135deg, var(--accent-orange), #ff8c42);
    border: none;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
}

.close-traits-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 87, 51, 0.4);
}

/* FAB Menu */
.fab-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 90;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 12px;
}

.fab-main {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a2e, #2d2d4a);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-main:hover {
    transform: scale(1.1);
}

.fab-main.open {
    transform: rotate(180deg);
    background: linear-gradient(135deg, var(--accent-orange), #ff8c42);
}

.fab-menu {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.fab-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.fab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transform: translateX(60px);
    opacity: 0;
    transition: all 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
}

.fab-menu.open .fab-item {
    transform: translateX(0);
    opacity: 1;
}

.fab-item:hover {
    transform: translateX(-5px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.fab-item.active {
    background: var(--accent-gold);
}

.fab-item.pulse {
    animation: fabPulse 2s ease-in-out infinite;
}

@keyframes fabPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); }
    50% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 20px rgba(255, 195, 0, 0.5); }
}

.fab-icon {
    font-size: 18px;
}

.fab-label {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 20px;
    text-align: center;
}

.footer a {
    color: rgba(0, 0, 0, 0.5);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    transition: all 0.2s ease;
}

.footer a:hover {
    color: #1a1a2e;
    background: rgba(255, 255, 255, 0.8);
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .traits-panel {
        width: 100%;
        border-radius: 0;
    }
    
    .character-display {
        width: 85vw;
        height: 85vw;
    }
    
    .fab-container {
        bottom: 16px;
        right: 16px;
    }
    
    .fab-main {
        width: 54px;
        height: 54px;
    }
    
    .upload-modal {
        max-height: 95vh;
        border-radius: 20px 20px 0 0;
        margin-top: auto;
    }
    
    .upload-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    
    .mode-options {
        flex-direction: column;
    }
    
    .mode-btn {
        width: 100%;
    }
}

/* Dark background text adjustment */
.app-container[style*="#1a1a2e"] .title,
.app-container[style*="#2c3e50"] .title,
.app-container[style*="#3357FF"] .title {
    color: white;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.app-container[style*="#1a1a2e"] .subtitle,
.app-container[style*="#2c3e50"] .subtitle,
.app-container[style*="#3357FF"] .subtitle {
    background: rgba(0, 0, 0, 0.4);
    color: white;
}

.app-container[style*="#1a1a2e"] .footer a,
.app-container[style*="#2c3e50"] .footer a,
.app-container[style*="#3357FF"] .footer a {
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
}