/* ============================================================================
   RESET AND BASE
   ============================================================================ */

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 15px;
    padding-bottom: 90px;
    /* Space for bottom nav on mobile */
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 100%;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 15px;
    margin: 0 auto;
}

.game-container {
    max-width: 700px;
    margin: 0 auto;
}

/* ============================================================================
   HEADER AND AUTH
   ============================================================================ */

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #ddd;
}

.auth-btn {
    background: white;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.auth-btn:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

/* ============================================================================
   BOTTOM NAVIGATION BAR - MOBILE APP STYLE
   ============================================================================ */

/* Bottom Navigation - Mobile First */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    text-decoration: none;
    color: #666;
    transition: all 0.2s;
    border-radius: 12px;
    min-width: 70px;
    position: relative;
    min-height: 60px;
    justify-content: center;
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 24px;
    line-height: 1;
    transition: transform 0.2s;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.nav-badge {
    position: absolute;
    top: 6px;
    right: 12px;
    background: #e0e0e0;
    color: #666;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.nav-item.active {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.nav-item.active .nav-icon {
    transform: scale(1.15);
}

.nav-item.active .nav-badge {
    background: #667eea;
    color: white;
}

.nav-item.active .nav-label {
    font-weight: 700;
}

.nav-item.completed .nav-badge {
    background: #52c41a;
    color: white;
}

/* Hide top breadcrumb on mobile */
.breadcrumb-nav {
    display: none;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1 {
    margin-bottom: 20px;
    font-size: 2em;
    color: #333;
    text-align: center;
}

h3 {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 15px;
}

h4 {
    font-size: 1.1em;
    color: #555;
    margin-bottom: 12px;
    font-weight: 600;
}

/* ============================================================================
   BUTTON SYSTEM
   ============================================================================ */

.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover:not(:disabled) {
    background: #e8e8e8;
    border-color: #ccc;
}

.btn-green {
    background: linear-gradient(135deg, #52c41a 0%, #45a017 100%);
}

.btn-green:hover:not(:disabled) {
    background: linear-gradient(135deg, #45a017 0%, #3a8914 100%);
}

.btn-red {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
}

.btn-red:hover:not(:disabled) {
    background: linear-gradient(135deg, #ff5252 0%, #ff3838 100%);
}

.btn-orange {
    background: linear-gradient(135deg, #ff9500 0%, #e6850e 100%);
}

.btn-orange:hover:not(:disabled) {
    background: linear-gradient(135deg, #e6850e 0%, #cc7508 100%);
}

.btn-purple {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.btn-purple:hover:not(:disabled) {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.btn-large {
    padding: 16px 32px;
    font-size: 16px;
    border-radius: 16px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-direction: column;
    margin: 10px 0;
}

.shop-btn {
    width: 100%;
    padding: 10px 20px;
    font-size: 13px;
}

.btn-price {
    font-size: 16px;
    font-weight: 700;
    display: block;
}

.btn-currency {
    font-size: 11px;
    opacity: 0.9;
    display: block;
    margin-top: 2px;
}

/* ============================================================================
   PANELS AND CONTAINERS
   ============================================================================ */

.story-panel {
    background: #f8f9fa;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.story-text {
    font-size: 16px;
    line-height: 1.6;
    color: #555;
    margin-bottom: 15px;
}

/* ============================================================================
   CHOICE CARDS (INDEX PAGE)
   ============================================================================ */

.choice-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 30px;
}

.choice-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e0e0e0;
}

.choice-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.choice-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.choice-card h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
}

.choice-card p {
    font-size: 14px;
    color: #666;
    margin: 0 0 12px 0;
}

.choice-badge {
    padding: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 12px;
    color: #888;
}

/* ============================================================================
   DISCOVERY / BALANCE DISPLAYS
   ============================================================================ */

.discovery-box,
.balance-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 32px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 20px;
}

.balance-panel {
    padding: 20px;
}

.discovery-label,
.balance-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.discovery-amount {
    font-size: 48px;
    font-weight: 700;
    margin: 20px 0;
}

.balance-amount {
    font-size: 32px;
    font-weight: 700;
}

.discovery-message {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.6;
    font-style: italic;
}

.discovery-link,
.balance-link {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-size: 12px;
    margin-top: 10px;
    transition: all 0.2s;
    font-weight: 600;
}

.discovery-link:hover,
.balance-link:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.balance-link {
    padding: 8px 16px;
    font-size: 11px;
}

/* ============================================================================
   UPLOAD AREA
   ============================================================================ */

.upload-area {
    border: 2px dashed #ccc;
    border-radius: 15px;
    padding: 20px 15px;
    margin-bottom: 15px;
}

/* ============================================================================
   IMAGES AND VIDEO
   ============================================================================ */

.preview-image,
.result-image {
    max-width: 100%;
    max-height: 40vh;
    border-radius: 10px;
    margin: 15px auto;
    cursor: pointer;
    object-fit: contain;
    display: block;
}

.video-container {
    width: 100%;
    margin: 15px 0;
    border-radius: 15px;
    overflow: hidden;
}

.character-video {
    width: 100%;
    height: auto;
}

/* ============================================================================
   STATS
   ============================================================================ */

.stats-container {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    padding: 18px;
    margin: 15px 0;
}

.stat-row {
    display: flex;
    align-items: center;
    margin-bottom: 14px;
    font-size: 13px;
}

.stat-label {
    min-width: 90px;
    font-weight: 600;
    font-size: 13px;
}

.stat-bar {
    flex: 1;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    margin: 0 8px;
}

.stat-fill {
    height: 100%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 10px;
    transition: width 0.8s ease;
}

.stat-value {
    min-width: 30px;
    font-weight: bold;
    text-align: right;
    font-size: 13px;
}

.stat-total {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

/* ============================================================================
   SHOP (EQUIP LEADER PAGE)
   ============================================================================ */

.shop-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.shop-item {
    background: white;
    padding: 16px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.shop-icon {
    font-size: 40px;
}

.shop-details {
    width: 100%;
}

.shop-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.shop-description {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.modify-panel {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.edit-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    font-family: inherit;
    resize: vertical;
    min-height: 70px;
    transition: border-color 0.2s;
}

.edit-textarea:focus {
    outline: none;
    border-color: #8b5cf6;
}

/* ============================================================================
   IMAGE HISTORY
   ============================================================================ */

.history-images {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 5px 0;
}

.history-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all 0.2s;
    object-fit: cover;
    flex-shrink: 0;
}

.history-image:hover {
    transform: scale(1.05);
    border-color: #667eea;
}

.history-image.original {
    border-color: #52c41a;
    border-width: 3px;
}

/* ============================================================================
   PROGRESS (BEGIN CAMPAIGN PAGE)
   ============================================================================ */

.progress-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 20px;
}

.progress-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.progress-timer {
    font-size: 32px;
    font-weight: 700;
    font-family: monospace;
}

.progress-message {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 8px;
}

/* ============================================================================
   PROCESSING OVERLAY
   ============================================================================ */

.processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.processing-overlay.show {
    display: flex;
}

.processing-content {
    background: white;
    border-radius: 15px;
    padding: 30px 25px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 90%;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   ERROR MESSAGES
   ============================================================================ */

.error-message {
    background: #ff6b6b;
    color: white;
    padding: 12px;
    border-radius: 8px;
    margin: 12px 0;
    display: none;
    font-size: 13px;
}

.error-message.show {
    display: block;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.hidden {
    display: none !important;
}

.help-text {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Tablet+ (480px) - Switch to top navigation */
@media (min-width: 480px) {
    body {
        padding-bottom: 15px;
    }

    .container {
        padding: 20px;
    }

    /* Hide bottom nav, show top breadcrumb */
    .bottom-nav {
        display: none;
    }

    .breadcrumb-nav {
        display: flex;
        gap: 8px;
        margin-bottom: 20px;
        padding: 12px;
        background: #f8f9fa;
        border-radius: 12px;
        overflow-x: auto;
    }

    .breadcrumb-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 12px 20px;
        border-radius: 10px;
        text-decoration: none;
        color: #666;
        font-size: 13px;
        white-space: nowrap;
        transition: all 0.2s;
        background: white;
        border: 2px solid #e0e0e0;
    }

    .breadcrumb-item:hover {
        background: #667eea;
        color: white;
        transform: translateY(-2px);
    }

    .breadcrumb-item.active {
        background: #667eea;
        color: white;
        border-color: #667eea;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }

    .breadcrumb-item.completed {
        border-color: #52c41a;
    }

    .breadcrumb-icon {
        font-size: 20px;
    }

    .breadcrumb-text {
        font-weight: 600;
        font-size: 13px;
    }

    .breadcrumb-badge {
        background: rgba(255, 255, 255, 0.3);
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 11px;
        font-weight: 700;
        margin-left: 4px;
    }

    .breadcrumb-item:not(.active) .breadcrumb-badge {
        background: #e0e0e0;
        color: #666;
    }

    .breadcrumb-item:hover .breadcrumb-badge {
        background: rgba(255, 255, 255, 0.4);
        color: white;
    }

    .breadcrumb-item.active .breadcrumb-badge {
        background: rgba(255, 255, 255, 0.3);
        color: white;
    }

    .breadcrumb-item.completed .breadcrumb-badge {
        background: #52c41a;
        color: white;
    }

    .choice-grid {
        grid-template-columns: 1fr 1fr;
    }

    h1 {
        font-size: 2.5em;
    }

    .button-row {
        flex-direction: row;
    }

    .button-row .btn {
        width: auto;
        flex: 1;
    }

    .shop-item {
        flex-direction: row;
        text-align: left;
    }

    .shop-icon {
        font-size: 32px;
        min-width: 48px;
    }

    .shop-details {
        flex: 1;
    }

    .shop-btn {
        width: auto;
        margin-top: 0;
    }
}

/* Desktop (768px+) */
@media (min-width: 768px) {
    body {
        padding: 30px;
        padding-bottom: 30px;
    }

    .container {
        padding: 40px;
    }

    h1 {
        font-size: 3em;
    }

    .story-panel,
    .stats-container {
        padding: 30px;
    }

    .breadcrumb-nav {
        gap: 24px;
    }

    .breadcrumb-item:not(:last-child)::after {
        content: '→';
        margin-left: 8px;
        color: #ccc;
        font-size: 16px;
    }
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid #667eea;
}

.toast.success {
    border-left-color: #52c41a;
}

.toast.error {
    border-left-color: #ff6b6b;
}

.toast.warning {
    border-left-color: #ff9500;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
    line-height: 1;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: #333;
}

.toast-message {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    white-space: pre-line;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    background: #f0f0f0;
    color: #666;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

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

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOut 0.3s ease;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        padding: 14px 16px;
    }

    .toast-icon {
        font-size: 20px;
    }

    .toast-title {
        font-size: 13px;
    }

    .toast-message {
        font-size: 12px;
    }
}

#alternativeCarousel img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}