/* Telegram WebApp theme variables */
:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #0088cc;
    --tg-theme-button-color: #0088cc;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #f1f1f1;
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.build-version {
    text-align: center;
    padding: 6px 0 10px;
    font-size: 11px;
    opacity: 0.6;
}

/* Economy header */
.economy-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 11;
}

.economy-item {
    font-size: 14px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #000000);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
    position: sticky;
    top: 44px;
    z-index: 10;
}

.tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--tg-theme-text-color, #000000);
    transition: background-color 0.2s;
    border-bottom: 2px solid transparent;
}

.tab:active {
    background-color: rgba(0, 0, 0, 0.05);
}

.tab.active {
    border-bottom-color: var(--tg-theme-button-color, #0088cc);
    color: var(--tg-theme-button-color, #0088cc);
}

/* Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.view h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--tg-theme-text-color, #000000);
}

/* Cards grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Character card */
.character-card {
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

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

.character-card.available {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.character-card.available.selected {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.character-card.locked {
    opacity: 0.6;
    background: #e0e0e0;
}

.character-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.locked-badge {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 8px;
}

.selected-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #4CAF50;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* Location card */
.location-card {
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.location-card:active {
    transform: scale(0.98);
}

.location-card.unlocked {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: #000;
}

.location-card.locked {
    opacity: 0.6;
    background: #e0e0e0;
}

.location-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.location-description {
    font-size: 13px;
    opacity: 0.8;
    flex: 1;
}

/* Gift card */
.gift-card {
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.gift-card:active {
    transform: scale(0.98);
}

.gift-card.received {
    opacity: 0.6;
    background: #e0e0e0;
}

.gift-card.paid {
    border: 2px solid #ff9800;
}

.gift-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.gift-description {
    font-size: 13px;
    opacity: 0.8;
    flex: 1;
}

.gift-section-title {
    grid-column: 1 / -1;
    margin-top: 6px;
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 700;
    opacity: 0.8;
}

.gift-count {
    position: absolute;
    left: 8px;
    top: 8px;
    background: #5c6bc0;
    color: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.story-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.story-actions .action-btn {
    width: auto;
    padding: 8px 10px;
    font-size: 13px;
}

.replay-btn {
    min-width: 36px;
    padding: 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
}

.received-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #4CAF50;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.price-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ff9800;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* Donate section */
.donate-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.donate-block {
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
    border-radius: 12px;
    padding: 20px;
}

.donate-block h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.donate-block p {
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 16px;
}

.action-btn {
    width: 100%;
    padding: 12px;
    background: var(--tg-theme-button-color, #0088cc);
    color: var(--tg-theme-button-text-color, #ffffff);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.action-btn:active {
    opacity: 0.8;
}

/* Shop */
.shop-section {
    margin-bottom: 16px;
}

.shop-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.shop-card {
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.shop-description {
    font-size: 13px;
    opacity: 0.8;
}

.shop-price {
    font-size: 14px;
    font-weight: 600;
}

.notice {
    padding: 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--tg-theme-text-color, #000000);
    margin-bottom: 12px;
}

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

.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 360px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
}
