* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
    --bg: #1a1410;
    --bg2: #2a1f15;
    --card: #3a2a1c;
    --gold: #ffcc33;
    --gold2: #ffa726;
    --gold-dark: #b36b00;
    --text: #f5e6c8;
    --muted: #a89678;
    --danger: #ef5350;
    --ok: #66bb6a;
    --border: #4a3826;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100%;
    overflow: hidden;
    user-select: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}

.avatar {
    background: var(--card);
    border: none;
    color: var(--text);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
}

.balance {
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    color: #1a1a1a;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
}

main {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
}

.view { display: none; animation: fade .2s ease; }
.view.active { display: block; }

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

/* Хранилище */
.storage {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 700;
}
.storage-item {
    background: var(--card);
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* Статистика */
.stats-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    flex: 1;
    background: var(--card);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border);
}
.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stat-value { font-size: 16px; font-weight: 700; }

/* Кнопка-яйцо */
.click-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    position: relative;
}

#click-btn {
    width: 220px;
    height: 260px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: radial-gradient(ellipse at 35% 30%, #ffe9a8, #ffcc33 40%, #e89b1c 75%, #b36b00);
    border: 6px solid #8b5a00;
    box-shadow: 0 10px 0 #6b4400, 0 12px 30px rgba(255, 153, 0, .35), inset 0 -20px 30px rgba(139, 90, 0, .4);
    color: #3d2600;
    font-weight: 900;
    font-size: 70px;
    cursor: pointer;
    transition: transform .06s ease, box-shadow .06s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#click-btn:active {
    transform: translateY(6px);
    box-shadow: 0 4px 0 #6b4400, 0 6px 15px rgba(255, 153, 0, .35), inset 0 -20px 30px rgba(139, 90, 0, .4);
}

.float-num {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 28px;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    opacity: 0;
}

.float-num.show {
    animation: floatUp 1s ease-out;
}

@keyframes floatUp {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-80px); }
}

/* Нижняя панель */
.bottom-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
}

.auto-btn {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.auto-btn.active {
    background: linear-gradient(135deg, var(--ok), #4caf50);
    color: #fff;
    border-color: var(--ok);
}

.prestige-info {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
}

/* Улучшения */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.tab {
    flex: 1;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
}
.tab.active {
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    color: #1a1a1a;
    font-weight: 700;
    border-color: var(--gold);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.upgrade-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.upgrade-info { flex: 1; min-width: 0; }
.upgrade-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.upgrade-effect { color: var(--gold); font-size: 12px; }
.upgrade-level { color: var(--muted); font-size: 12px; }
.upgrade-price { color: var(--gold); font-weight: 700; font-size: 13px; margin-top: 4px; }

.buy-btn {
    background: linear-gradient(135deg, var(--ok), #4caf50);
    border: none;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    min-width: 80px;
}
.buy-btn:disabled {
    background: var(--border);
    color: var(--muted);
    cursor: not-allowed;
}

/* Продажа */
.market-prices {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}
.price-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.price-row:last-of-type { border-bottom: none; }
.price { color: var(--gold); font-weight: 700; }
.market-timer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-top: 8px;
}

.sell-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.sell-tab {
    flex: 1;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
}
.sell-tab.active {
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    color: #1a1a1a;
    font-weight: 700;
    border-color: var(--gold);
}

.sell-info {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.8;
}

.sell-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.sell-btn {
    padding: 14px 8px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}
.sell-btn.sell-all {
    background: linear-gradient(135deg, var(--ok), #4caf50);
    color: #fff;
    border-color: var(--ok);
}
.sell-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* Престиж */
.prestige-info-block {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}
.prestige-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}
.progress-bar {
    background: var(--border);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin: 10px 0;
}
.progress-fill {
    background: linear-gradient(90deg, var(--gold), var(--gold2));
    height: 100%;
    width: 0%;
    transition: width .3s;
}
.prestige-hint {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.warn {
    color: var(--muted);
    font-size: 12px;
    margin: 8px 0 14px;
    line-height: 1.5;
}

.action-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    color: #1a1a1a;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    margin-bottom: 10px;
}
.action-btn:disabled {
    background: var(--border);
    color: var(--muted);
}
.action-btn.danger {
    background: linear-gradient(135deg, #ab47bc, #7e57c2);
    color: #fff;
}

/* Рейтинг */
.rating-list {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 12px;
}
.rating-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.rating-item:last-child { border-bottom: none; }
.rating-item .place { color: var(--gold); font-weight: 700; margin-right: 8px; }
.rating-item .name { flex: 1; }
.rating-item .mult { color: var(--gold); font-weight: 700; }

.my-rating {
    background: linear-gradient(135deg, #3a2a1c, #5a3a1c);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    font-size: 14px;
}

/* Профиль */
.profile-info {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}
.profile-info .row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.profile-info .row:last-child { border-bottom: none; }
.profile-info .row span { color: var(--muted); }

/* Навигация */
nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--bg2);
    border-top: 1px solid var(--border);
}
.nav-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 10px 2px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.nav-btn.active { color: var(--gold); font-weight: 700; }

/* Тост */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.85);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1000;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}
.toast.show { opacity: 1; }
