* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    line-height: 1.6;
}

#app {
    min-height: 100vh;
    background: #0f0f0f;
    padding-bottom: 60px; /* Уменьшено для компактной навигации */
}

/* Header */
.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 12px 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    border-bottom: 1px solid #333;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.exchange-rate {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8em;
    text-align: center;
}

.rate-label {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.rate-value {
    color: #4a6bff;
    font-weight: 600;
    line-height: 1.3;
}

.rate-value small {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85em;
    font-weight: normal;
}

.user-balance {
    background: rgba(255,255,255,0.1);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    color: #fff;
    border: 1px solid #333;
}

/* Main Content */
.main-content {
    padding: 20px;
    min-height: calc(100vh - 120px); /* Учтено уменьшение высоты навигации */
    background: #0f0f0f;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a1a;
    display: flex;
    justify-content: space-around;
    padding: 8px 0 6px 0; 
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    z-index: 1000;
    border-top: 1px solid #333;
    height: 58px;
}


.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; 
    padding: 6px 2px 4px 2px; 
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
    color: #e0e0e0;
    flex: 1;
    max-width: 70px;
    min-height: 44px;
    text-align: center;
    margin: 0 2px;
}

.nav-item.active {
    opacity: 1;
    background: rgba(74, 107, 255, 0.2);
    color: #4a6bff;
}

.nav-icon {
    font-size: 1.1em;
    margin-bottom: 4px; 
    line-height: 1;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item span {
    font-size: 0.6em;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Forms */
.purchase-form {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 1px solid #333;
    max-height: 80vh;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #e0e0e0;
    font-size: 0.9em;
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #333;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    background: #2d2d2d;
    color: #e0e0e0;
}

.form-input:focus {
    outline: none;
    border-color: #4a6bff;
}

.form-input::placeholder {
    color: #666;
}

.form-input:invalid {
    border-color: #ef4444;
}

/* Stars Grid - 2 ряда по 3 кнопки */
.stars-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px; /* Уменьшен gap для компактности */
    margin-bottom: 8px;
}

.star-option {
    padding: 10px 5px;
    border: 2px solid #333;
    border-radius: 8px;
    background: #2d2d2d;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #e0e0e0;
    font-size: 0.8em;
    text-align: center;
    min-height: 40px; /* Фиксированная высота для выравнивания */
    display: flex;
    align-items: center;
    justify-content: center;
}

.payment-method-compact {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.payment-option {
    flex: 1;
    padding: 10px;
    border: 2px solid #333;
    border-radius: 8px;
    background: #2d2d2d;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #e0e0e0;
    text-align: center;
    font-size: 0.8em;
}

.payment-option.active {
    border-color: #4a6bff;
    background: #4a6bff;
    color: white;
}

.star-option:hover, .star-option.active {
    border-color: #4a6bff;
    background: #4a6bff;
    color: white;
}

/* Buttons */
.primary-button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4a6bff 0%, #6d28d9 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.primary-button:hover {
    transform: translateY(-2px);
}

.secondary-button {
    padding: 10px 15px;
    background: #4b5563;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.secondary-button:hover {
    background: #6b7280;
}

/* Info Cards */
.info-card {
    background: #1a1a1a;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 1px solid #333;
}

.info-card h3 {
    margin-bottom: 15px;
    color: #fff;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #333;
}

.info-item:last-child {
    border-bottom: none;
}

.info-item span:first-child {
    color: #a0a0a0;
}

.info-item span:last-child {
    color: #e0e0e0;
    font-weight: 500;
}

/* Price Display */
.price-display {
    background: #2d2d2d;
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
    border: 1px solid #333;
}

.price-item {
    display: flex;
    justify-content: space-between;
    font-size: 1.1em;
    color: #e0e0e0;
}

.price-item strong {
    color: #4a6bff;
}

.price-item strong.error {
    color: #ef4444;
}

/* Referral */
.referral-link {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.referral-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: #2d2d2d;
    border-radius: 10px;
    border: 1px solid #333;
}

.stat-item span {
    color: #a0a0a0;
    display: block;
    margin-bottom: 5px;
}

.stat-item strong {
    color: #4a6bff;
    font-size: 1.1em;
}

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    border: 1px solid #333;
}

.history-item:hover {
    background: #2d2d2d;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 480px) {
    .bottom-nav {
        padding: 7px 0 5px 0; 
        height: 55px;
    }
    
    .nav-item {
        padding: 5px 1px 3px 1px; 
        max-width: 65px;
        min-height: 40px;
        margin: 0 1px;
    }
    
    .nav-icon {
        font-size: 1em;
        margin-bottom: 3px; 
        height: 18px;
    }
    
    .nav-item span {
        font-size: 0.55em;
        height: 10px;
    }
}

@media (max-width: 360px) {
    .nav-item span {
        font-size: 0.5em;
    }
    
    .nav-item {
        max-width: 60px;
        margin: 0 1px;
    }
    
    .nav-icon {
        margin-bottom: 2px; 
    }
}

@media (max-width: 320px) {
    .nav-item span {
        font-size: 0.45em;
        letter-spacing: -0.5px; 
    }
    
    .nav-item {
        max-width: 55px;
    }
    
    .nav-icon {
        font-size: 0.9em;
    }
}

.purchase-form::-webkit-scrollbar {
    width: 4px;
}

.purchase-form::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.purchase-form::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

/* Scrollbar for Webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a6bff;
}

.referral-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #333;
    font-size: 0.9em;
}

.referral-item:last-child {
    border-bottom: none;
}

.referral-item span:first-child {
    color: #4a6bff;
}

.referral-item span:last-child {
    color: #a0a0a0;
    font-size: 0.8em;
}

.secondary-button.small {
    padding: 6px 10px;
    font-size: 0.75em;
    background: #4b5563;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.secondary-button.small:hover {
    background: #6b7280;
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .form-group .form-input {
        margin-bottom: 8px;
    }
    
    .secondary-button.small {
        font-size: 0.7em;
        padding: 5px 8px;
    }
}

.form-input select {
    width: 100%;
    padding: 12px;
    border: 2px solid #333;
    border-radius: 10px;
    font-size: 16px;
    background: #2d2d2d;
    color: #e0e0e0;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.form-input select:focus {
    outline: none;
    border-color: #4a6bff;
}

.form-input select option {
    background: #2d2d2d;
    color: #e0e0e0;
    padding: 10px;
}

/* Стиль для информации о бонусах */
#bonusInfo {
    color: #10b981;
    font-size: 0.9em;
    border-top: 1px solid #333;
    padding-top: 10px;
    margin-top: 10px;
    display: none;
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .form-input select {
        font-size: 14px;
        padding: 10px;
        background-position: right 8px center;
    }
}

.original-price {
    color: #a0a0a0;
    font-size: 0.9em;
}

.discount-info {
    color: #10b981;
    font-size: 0.8em;
    font-weight: 500;
}

.wallet-connect {
    display: flex;
    align-items: center;
}

.ton-connect-button {
    background: linear-gradient(135deg, #0098ea 0%, #0077cc 100%) !important;
    border-radius: 12px !important;
    border: none !important;
    padding: 8px 16px !important;
    font-size: 0.85em !important;
    font-weight: 600 !important;
}

.wallet-info {
    animation: fadeIn 0.3s ease;
}

.wallet-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.wallet-action-button {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #333;
    border-radius: 6px;
    background: #2d2d2d;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.3s ease;
}

.wallet-action-button:hover {
    background: #3d3d3d;
    border-color: #4a6bff;
}

.wallet-action-button.disconnect {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.wallet-action-button.disconnect:hover {
    background: #dc2626;
}

/* Адаптивность для кнопки кошелька */
@media (max-width: 480px) {
    .ton-connect-button {
        padding: 6px 12px !important;
        font-size: 0.75em !important;
    }
    
    .wallet-actions {
        flex-direction: column;
        gap: 6px;
    }
}
