:root {
    /* Системные safe areas с fallback через env() */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);

    /* Telegram UI safe areas (устанавливаются через JS) */
    --tg-content-safe-area-top: 0px;
    --tg-content-safe-area-bottom: 0px;
    --tg-content-safe-area-left: 0px;
    --tg-content-safe-area-right: 0px;

    /* Комбинированные safe areas (устанавливаются через JS) */
    --combined-safe-area-top: 0px;
    --combined-safe-area-bottom: 0px;
    --combined-safe-area-left: 0px;
    --combined-safe-area-right: 0px;

    /* Высота viewport Telegram */
    --tg-viewport-height: 100vh;
    --tg-viewport-stable-height: 100vh;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 50%, #ddd 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    min-height: var(--tg-viewport-height, 100vh);
    position: relative;
    padding-top: var(--combined-safe-area-top);
    padding-bottom: var(--combined-safe-area-bottom);
    padding-left: var(--combined-safe-area-left);
    padding-right: var(--combined-safe-area-right);
}

.screen {
    min-height: calc(var(--tg-viewport-height, 100vh) - var(--combined-safe-area-top) - var(--combined-safe-area-bottom));
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Экран регистрации */
.register-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
}

.register-container h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #ff6b35, #f7931e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.register-container p {
    color: #666;
    margin-bottom: 30px;
}

.register-icon {
    font-size: 80px;
    margin-bottom: 40px;
    animation: bounce 2s infinite;
}

.register-icon svg {
    width: 80px;
    height: 80px;
    color: #ff6b35;
}

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

#username-input {
    width: 100%;
    max-width: 300px;
    padding: 15px 20px;
    border: 2px solid #ff6b35;
    border-radius: 15px;
    background: #fff;
    color: #333;
    font-size: 16px;
    margin-bottom: 20px;
    outline: none;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#username-input:focus {
    background: #fff;
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.3);
}

#username-input::placeholder {
    color: #999;
}

.primary-btn {
    padding: 15px 50px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(90deg, #ff6b35, #f7931e);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 5px 20px rgba(255, 107, 53, 0.4);
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(255, 107, 53, 0.6);
}

.primary-btn:active {
    transform: scale(0.98);
}

/* Верхняя панель */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.user-info {
    font-size: 14px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-btn {
    padding: 5px 10px;
    font-size: 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 5px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.coins-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
}

.energy-display-top {
    color: #ff6b35;
}

.energy-display-top svg {
    color: #ff6b35;
}

.coin-icon {
    font-size: 28px;
    display: flex;
    align-items: center;
}

.coin-icon svg {
    width: 28px;
    height: 28px;
    color: #ffd700;
}

.energy-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 10px;
    font-size: 16px;
    color: #ff6b35;
}

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

/* Навигация */
.nav-tabs {
    display: flex;
    background: #fff;
    padding: 10px;
    gap: 10px;
    border-bottom: 1px solid #eee;
}

.nav-tab {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #f5f5f5;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-tab.active {
    background: linear-gradient(90deg, #ff6b35, #f7931e);
    color: #fff;
    font-weight: bold;
}

.nav-tab svg {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 4px;
}

.nav-tab.active svg {
    color: #fff;
}

/* Контент табов */
.tab-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.tab-pane {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Таб тапов */
.tap-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    position: relative;
}

.level-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 250px;
    margin-bottom: 30px;
    color: #666;
    font-size: 14px;
}

.level-info strong {
    color: #ff6b35;
}

.tap-button {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(145deg, #fff, #f0f0f0);
    border: 4px solid #ff6b35;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.15),
        0 0 20px rgba(255, 107, 53, 0.2),
        inset 0 -5px 15px rgba(0, 0, 0, 0.05),
        inset 0 5px 15px rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.tap-button:active {
    transform: scale(0.95);
    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.2),
        0 0 40px rgba(255, 107, 53, 0.4),
        inset 0 -2px 10px rgba(0, 0, 0, 0.05),
        inset 0 2px 10px rgba(255, 255, 255, 0.5);
}

.punch-target {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.punch-target svg {
    width: 80px;
    height: 80px;
    color: #ff6b35;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: transform 0.1s ease;
}

.punch-text {
    font-size: 24px;
    font-weight: bold;
    color: #ff6b35;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Анимация удара */
.tap-button.punched {
    animation: punch 0.15s ease-out;
}

.tap-button.punched .punch-target svg {
    animation: pulse 0.3s ease-out;
}

@keyframes punch {
    0% { transform: scale(1); }
    50% { transform: scale(0.92); }
    100% { transform: scale(1); }
}

@keyframes pulse {
    0% { transform: scale(1); filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2)); }
    50% { transform: scale(1.2); filter: drop-shadow(0 4px 15px rgba(255, 107, 53, 0.5)); }
    100% { transform: scale(1); filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2)); }
}

.tap-animations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.tap-animation {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: #ff6b35;
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5);
    }
}

/* Энергия бар */
.energy-bar-container {
    width: 100%;
    max-width: 300px;
    margin-top: 30px;
}

.energy-bar {
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.energy-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    border-radius: 10px;
    transition: width 0.3s;
    width: 100%;
}

/* Таб призов */
#prizes-tab h2, #earn-tab h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #ff6b35;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#prizes-tab h2 svg, #earn-tab h2 svg {
    width: 28px;
    height: 28px;
}

.prizes-list, .tasks-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.prize-card, .task-card {
    background: #fff;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.prize-card:hover, .task-card:hover {
    background: #fff;
    transform: translateX(5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.prize-icon, .task-icon {
    font-size: 40px;
    min-width: 50px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prize-icon svg, .task-icon svg {
    width: 40px;
    height: 40px;
    color: #ff6b35;
}

.prize-info, .task-info {
    flex: 1;
}

.prize-name, .task-name {
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

.prize-price {
    color: #ff6b35;
    font-size: 14px;
}

.task-reward {
    color: #00ff88;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Inline icons for prices and rewards */
.inline-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

.coin-color {
    color: #ffd700;
}

.energy-color {
    color: #ff6b35;
}

.prize-price {
    display: flex;
    align-items: center;
    gap: 4px;
}

.prize-price svg {
    width: 16px;
    height: 16px;
}

.prize-btn, .task-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.prize-btn {
    background: linear-gradient(90deg, #ff6b35, #f7931e);
    color: #fff;
}

.task-btn {
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    color: #fff;
}

.prize-btn:disabled, .task-btn:disabled {
    background: #ddd;
    color: #999;
    cursor: not-allowed;
}

.task-btn.completed {
    background: #00ff88;
}

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: #fff;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 300px;
    margin: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h3 {
    color: #ff6b35;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
}

/* Мобильная адаптация */
@media (max-width: 400px) {
    .nav-tab {
        font-size: 12px;
        padding: 10px 5px;
    }

    .tap-button {
        width: 160px;
        height: 160px;
    }

    .coins-display {
        font-size: 20px;
    }
}
