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

:root {
    --wii-blue: #00a0dc;
    --wii-light-blue: #7fcce8;
    --wii-gray: #e8e8e8;
    --wii-dark-gray: #888888;
    --wii-white: #ffffff;
    --wii-shadow: rgba(0, 0, 0, 0.1);
    --wii-text: #333333;
    --wii-channel-bg: linear-gradient(180deg, #f8f8f8 0%, #e0e0e0 100%);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(180deg, #7fcce8 0%, #a8dff0 50%, #d4eef7 100%);
    min-height: 100vh;
    color: var(--wii-text);
    font-size: 14px;
    line-height: 1.5;
    padding: 20px;
}

.site-header {
    text-align: center;
    padding: 30px 20px;
}

.title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.title-icon {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px var(--wii-shadow));
}

.title-text {
    text-align: left;
}

.site-title {
    font-size: 48px;
    font-weight: 600;
    color: var(--wii-white);
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
}

.site-tagline {
    font-size: 16px;
    font-weight: 400;
    color: var(--wii-white);
    margin: 4px 0 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.site-ca {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    margin: 6px 0 0;
    font-family: 'Courier New', monospace;
}

.site-links {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.header-link {
    padding: 8px 20px;
    background: var(--wii-white);
    color: var(--wii-blue);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 20px;
    box-shadow: 0 2px 8px var(--wii-shadow);
    transition: all 0.2s ease;
}

.header-link:hover {
    background: var(--wii-blue);
    color: var(--wii-white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    gap: 20px;
    align-items: stretch;
    min-height: calc(100vh - 40px);
}

.generator-section {
    background: var(--wii-white);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px var(--wii-shadow);
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.panel-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
}

.panel-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--wii-text);
    margin: 0;
}

.panel-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.panel-buttons .header-link {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
}

.panel-links {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.panel-link {
    flex: 1;
    padding: 10px 16px;
    background: var(--wii-gray);
    border: none;
    color: var(--wii-text);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.panel-link:hover {
    background: #d8d8d8;
}

.panel-link.crowd-btn {
    background: linear-gradient(135deg, #00b8f5 0%, #00a0dc 100%);
    color: white;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    animation: crowdPulse 2s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(0, 160, 220, 0.4);
}

.panel-link.crowd-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2.5s ease-in-out infinite;
}

.panel-link.crowd-btn:hover {
    background: linear-gradient(135deg, #00c8ff 0%, #00b0ec 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 160, 220, 0.5);
}

@keyframes crowdPulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(0, 160, 220, 0.4); }
    50% { box-shadow: 0 4px 20px rgba(0, 160, 220, 0.7); }
}

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

.panel-stats {
    display: flex;
    gap: 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e8e8e8;
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--wii-blue);
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: #888;
    text-transform: uppercase;
}

.lore {
    font-size: 14px;
    color: var(--wii-text);
    margin-bottom: 16px;
    text-align: center;
}

.generator-form {
    width: 100%;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--wii-text);
}

.prompt-group {
    width: 100%;
}

.prompt-group input {
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    background: var(--wii-gray);
    border: none;
    border-radius: 24px;
    color: var(--wii-text);
    transition: all 0.2s ease;
}

.prompt-group input:focus {
    outline: none;
    background: #f0f0f0;
    box-shadow: 0 0 0 3px rgba(0, 160, 220, 0.3);
}

.upload-group {
    width: 100%;
}

.drop-zone {
    border: 2px dashed #c0c0c0;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    background: var(--wii-gray);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.drop-zone:hover {
    background: #f0f0f0;
    border-color: var(--wii-blue);
}

.drop-zone.drag-over {
    background: rgba(0, 160, 220, 0.1);
    border-color: var(--wii-blue);
}

.drop-zone-text {
    font-size: 12px;
    color: var(--wii-dark-gray);
}

.preview-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-img {
    max-width: 100%;
    max-height: 36px;
    object-fit: contain;
    border-radius: 6px;
}

.clear-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    background: var(--wii-dark-gray);
    border: none;
    color: var(--wii-white);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.clear-btn:hover {
    background: #666;
}

.generate-btn {
    padding: 14px 32px;
    background: linear-gradient(180deg, #00b8f5 0%, #00a0dc 100%);
    border: none;
    color: var(--wii-white);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0, 160, 220, 0.3);
    transition: all 0.2s ease;
    width: 100%;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 160, 220, 0.4);
}

.generate-btn:disabled {
    background: var(--wii-dark-gray);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.flash {
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    border-radius: 12px;
}

.flash.success {
    background: #d4edda;
    color: #155724;
}

.flash.error {
    background: #f8d7da;
    color: #721c24;
}

.flash.warning {
    background: #fff3cd;
    color: #856404;
}

.main-content {
    background: var(--wii-white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--wii-shadow);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--wii-channel-bg);
    border-bottom: 1px solid #d0d0d0;
    gap: 12px;
}

.meme-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--wii-text);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input {
    padding: 8px 14px;
    background: var(--wii-white);
    border: 1px solid #d0d0d0;
    border-radius: 20px;
    color: var(--wii-text);
    font-size: 12px;
    font-family: inherit;
    width: 140px;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--wii-blue);
    box-shadow: 0 0 0 3px rgba(0, 160, 220, 0.2);
}

.sort-select {
    padding: 8px 14px;
    background: var(--wii-white);
    border: 1px solid #d0d0d0;
    border-radius: 20px;
    color: var(--wii-text);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.grid-wrapper {
    padding: 20px;
    flex: 1;
    background: #f5f5f5;
    overflow-y: auto;
}

.grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
}

.grid-item {
    background: var(--wii-white);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 2px 6px var(--wii-shadow);
    transition: all 0.2s ease;
}

.grid-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.img-container {
    position: relative;
    width: 100%;
}

.grid-item img,
.img-container > img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #f0f0f0;
}

.pfp-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--wii-white);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    background: var(--wii-white);
}

.pfp-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 1;
}

.grid-item .prompt {
    padding: 10px 12px;
    font-size: 11px;
    color: var(--wii-text);
    background: var(--wii-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-item.pending,
.grid-item.processing {
    opacity: 0.9;
}

.pending-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--wii-text);
    border-radius: 12px;
}

.processing-bar {
    width: 70%;
    height: 8px;
    background: var(--wii-gray);
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}

.processing-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--wii-blue), var(--wii-light-blue));
    border-radius: 4px;
    animation: progress 1.5s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 10%; }
    50% { width: 90%; }
    100% { width: 10%; }
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--wii-dark-gray);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--wii-gray);
    border-top-color: var(--wii-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.load-more {
    display: block;
    margin: 20px auto;
    padding: 10px 28px;
    background: linear-gradient(180deg, #00b8f5 0%, #00a0dc 100%);
    border: none;
    color: var(--wii-white);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 160, 220, 0.3);
    transition: all 0.2s ease;
}

.load-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 160, 220, 0.4);
}

.pending-spinner {
    width: 100%;
    aspect-ratio: 1;
    background: var(--wii-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px 12px 0 0;
}

.pending-loading-container {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #7fcce8 0%, #d4eef7 100%);
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.pending-mii-logo {
    width: auto;
    height: auto;
}

.pending-wheel {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #00a0dc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.prompt-text {
    padding: 10px 12px;
    font-size: 11px;
    color: var(--wii-text);
    background: var(--wii-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-viewer,
.viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.image-viewer.active,
.viewer.active {
    display: flex;
}

.viewer-content {
    background: var(--wii-white);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.viewer-content > img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

.viewer-images {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 20px;
    background: #f5f5f5;
}

.viewer-full {
    max-width: 60%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}

.viewer-pfp {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--wii-white);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.viewer-prompt {
    padding: 14px 18px;
    font-size: 14px;
    color: var(--wii-text);
    background: var(--wii-white);
    border-top: 1px solid #e0e0e0;
}

.viewer-actions,
.viewer-buttons {
    display: flex;
    gap: 12px;
    padding: 14px 18px;
    background: var(--wii-channel-bg);
    border-top: 1px solid #d0d0d0;
}

.viewer-btn,
.viewer-buttons button,
.viewer-buttons a {
    padding: 10px 24px;
    background: linear-gradient(180deg, #00b8f5 0%, #00a0dc 100%);
    border: none;
    color: var(--wii-white);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.viewer-btn:hover,
.viewer-buttons button:hover,
.viewer-buttons a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 160, 220, 0.4);
}

.close-viewer {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: var(--wii-white);
    cursor: pointer;
    font-weight: 300;
    transition: transform 0.2s;
}

.close-viewer:hover {
    transform: scale(1.1);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--wii-dark-gray);
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--wii-text);
}

.empty-state p {
    font-size: 14px;
}

.info-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.info-popup.active {
    display: flex;
}

.info-popup-content {
    background: var(--wii-white);
    max-width: 450px;
    width: 90%;
    padding: 32px;
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.info-steps {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 28px;
}

.info-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--wii-text);
}

.step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: linear-gradient(180deg, #00b8f5 0%, #00a0dc 100%);
    color: var(--wii-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.info-dismiss {
    width: 100%;
    padding: 14px 28px;
    background: linear-gradient(180deg, #00b8f5 0%, #00a0dc 100%);
    border: none;
    color: var(--wii-white);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: 24px;
    transition: all 0.2s ease;
}

.info-dismiss:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 160, 220, 0.4);
}

.gif-btn {
    padding: 8px 18px;
    background: linear-gradient(180deg, #00b8f5 0%, #00a0dc 100%);
    border: none;
    color: var(--wii-white);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: 16px;
    transition: all 0.2s ease;
}

.gif-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 160, 220, 0.3);
}

.gif-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.gif-popup.active {
    display: flex;
}

.gif-popup-content {
    background: var(--wii-white);
    max-width: 380px;
    width: 90%;
    padding: 28px;
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.gif-popup-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--wii-text);
    text-align: center;
}

.gif-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 24px;
}

.gif-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gif-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--wii-text);
}

.gif-field input {
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    background: var(--wii-gray);
    border: none;
    border-radius: 12px;
    color: var(--wii-text);
    width: 100%;
}

.gif-field input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 160, 220, 0.3);
}

.gif-actions {
    display: flex;
    gap: 12px;
}

.gif-cancel {
    flex: 1;
    padding: 12px 20px;
    background: var(--wii-gray);
    border: none;
    color: var(--wii-text);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    border-radius: 20px;
    transition: background 0.2s;
}

.gif-cancel:hover {
    background: #d8d8d8;
}

.gif-generate {
    flex: 1;
    padding: 12px 20px;
    background: linear-gradient(180deg, #00b8f5 0%, #00a0dc 100%);
    border: none;
    color: var(--wii-white);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.gif-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 160, 220, 0.4);
}

@media (max-width: 900px) {
    body {
        padding: 15px;
    }
    
    .app-container {
        flex-direction: column;
        min-height: auto;
    }
    
    .generator-section {
        width: 100%;
        padding: 20px;
        border-radius: 12px;
    }
    
    .panel-header {
        justify-content: center;
    }
    
    .form-row {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
    }
    
    .prompt-group {
        flex: 1;
        min-width: 200px;
    }
    
    .upload-group {
        width: auto;
        min-width: 160px;
    }
    
    .generate-btn {
        width: auto;
        padding: 12px 28px;
    }
    
    .main-content {
        min-height: 60vh;
    }
}

@media (max-width: 600px) {
    .site-title {
        font-size: 32px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .prompt-group,
    .upload-group {
        width: 100%;
        min-width: 100%;
    }
    
    .generate-btn {
        width: 100%;
    }
    
    .toolbar {
        flex-wrap: wrap;
    }
    
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .grid-wrapper {
        min-height: 50vh;
        padding: 15px;
    }
    
    .main-content {
        border-radius: 12px;
    }
}

@media (max-width: 400px) {
    .site-title {
        font-size: 28px;
    }
    
    .site-ca {
        font-size: 9px;
        word-break: break-all;
    }
    
    .title-icon {
        width: 60px;
        height: 60px;
    }
}
