:root {
    --bg-gradient: linear-gradient(180deg, #100a1c 0%, #07040d 100%);
    --card-bg: #150f26;
    --card-border: rgba(138, 43, 226, 0.15);
    --primary: #9b4dff;
    --primary-glow: rgba(155, 77, 255, 0.3);
    --text-main: #ffffff;
    --text-muted: #a39cb5;
    --success: #00ff88;
    --success-glow: rgba(0, 255, 136, 0.2);
    --gold: #fbbf24;
    --gold-glow: rgba(251, 191, 36, 0.2);
    --cyan: #22d3ee;
    --cyan-glow: rgba(34, 211, 238, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    padding: 15px 15px 90px 15px;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* Profile Header Section */
.profile-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: linear-gradient(135deg, #150f26 0%, #1e133a 100%);
    border-color: rgba(155, 77, 255, 0.25);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-container {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--primary);
    background: #0b0714;
    box-shadow: 0 0 10px var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-info h2 {
    font-size: 1.15rem;
    font-weight: 800;
}

.rank-badge {
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(155, 77, 255, 0.2);
    border: 1px solid var(--primary);
    color: #c084fc;
    letter-spacing: 0.5px;
}

.balances-row {
    display: flex;
    gap: 10px;
}

.balance-item {
    flex: 1;
    background: rgba(0, 0, 0, 0.25);
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.balance-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.balance-item .val {
    font-size: 1.05rem;
    font-weight: 800;
}

.select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.select-wrapper select {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--primary);
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 15px;
    margin: 0;
}

.select-wrapper select option {
    background: var(--card-bg);
    color: white;
    font-family: 'Outfit', sans-serif;
}

.select-arrow {
    position: absolute;
    right: 0;
    pointer-events: none;
    color: var(--primary);
    font-size: 0.85rem;
}

/* Inputs and Rows */
.input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.input-row input {
    flex: 1;
    min-width: 0; /* Critical flex fix to allow inputs to shrink on narrow mobile screens */
}

.input-row button {
    flex-shrink: 0; /* Prevent buttons from shrinking/truncating text */
}

.nickname-section label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
}

input[type="text"], input[type="password"] {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    width: 100%;
}

input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

button {
    padding: 12px 18px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(90deg, #8a2be2, var(--primary));
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

button:active {
    opacity: 0.8;
}

/* Grids and Cards */
.grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Minecraft Outline Glows based on ID */
.item-card.vip, .item-card.vipplus, .item-card.premium, .item-card.deluxe, .item-card.legend, .item-card.ultra {
    border-color: rgba(155, 77, 255, 0.25);
    box-shadow: inset 0 0 12px rgba(155, 77, 255, 0.05), 0 4px 15px rgba(0,0,0,0.3);
}

.item-card.key_default, .item-card.key_resources, .item-card.key_currency {
    border-color: rgba(34, 211, 238, 0.25);
    box-shadow: inset 0 0 12px rgba(34, 211, 238, 0.05), 0 4px 15px rgba(0,0,0,0.3);
}

.item-card.coins_10k, .item-card.coins_50k, .item-card.coins_100k {
    border-color: rgba(251, 191, 36, 0.25);
    box-shadow: inset 0 0 12px rgba(251, 191, 36, 0.05), 0 4px 15px rgba(0,0,0,0.3);
}

.item-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.item-details h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(155, 77, 255, 0.2);
    border: 1px solid var(--primary);
    color: #d8b4fe;
    align-self: flex-start;
}

.badge.key {
    background: rgba(34, 211, 238, 0.2);
    border-color: var(--cyan);
    color: #99f6e4;
}

.badge.money {
    background: rgba(251, 191, 36, 0.2);
    border-color: var(--gold);
    color: #fde047;
}

.item-card h3 {
    font-size: 1.05rem;
    font-weight: 800;
}

.item-card .desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.price-buy-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 80px;
    flex-shrink: 0;
}

.price-buy-col .price {
    font-size: 1.15rem;
    font-weight: 800;
}

.buy-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
    width: 100%;
    text-align: center;
}

.buy-btn[data-item^="key_"] {
    background: linear-gradient(90deg, #0891b2, var(--cyan));
}

.buy-btn[data-item^="coins_"] {
    background: linear-gradient(90deg, #d97706, var(--gold));
    color: black;
    font-weight: 800;
}

/* Tabs Toggle Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Floating Bottom Navigation Footer (Crowntasks Style) */
.footer-nav {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 440px;
    height: 62px;
    background: rgba(21, 15, 38, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    z-index: 99;
}

.nav-item {
    flex: 1;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    padding: 0;
    border-radius: 0;
    transition: all 0.2s;
}

.nav-item .icon {
    font-size: 1.25rem;
    transition: transform 0.2s;
}

.nav-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-item.active .icon {
    transform: translateY(-2px);
}

.nav-item.active .label {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transform: translateY(20px);
    transition: transform 0.2s;
    background: #150f26;
    border: 1px solid var(--card-border);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal h2 {
    font-size: 1.3rem;
    font-weight: 800;
    text-align: center;
}

.order-info {
    background: rgba(0, 0, 0, 0.25);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.order-info span {
    font-weight: 600;
    color: var(--primary);
}

.payment-methods {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.payment-methods .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.methods-grid {
    display: flex;
    gap: 10px;
}

.method-card {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.method-card.active {
    border-color: var(--primary);
    background: rgba(155, 77, 255, 0.1);
}

.method-icon {
    font-size: 1.3rem;
}

.pay-btn-confirm {
    width: 100%;
    padding: 12px 0;
    border-radius: 10px;
    border: none;
    background: var(--success);
    color: black;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
}

.pay-btn-cancel {
    width: 100%;
    padding: 10px 0;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.success-card {
    align-items: center;
    text-align: center;
    padding: 30px 20px;
}

.success-icon {
    font-size: 2.2rem;
    color: black;
    background: var(--success);
    width: 54px;
    height: 54px;
    line-height: 54px;
    border-radius: 50%;
    margin-bottom: 10px;
}

.success-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.success-card span {
    font-weight: 600;
    color: white;
}

.info-note {
    font-size: 0.75rem !important;
}

/* Admin Styles */
.purchase-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
}
.purchase-item-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.purchase-item-details .nick {
    font-weight: 800;
    color: var(--primary);
}
.purchase-item-details .item {
    color: var(--text-main);
    font-size: 0.75rem;
}
.purchase-item .price {
    font-weight: 800;
    color: var(--success);
    font-size: 0.85rem;
}
.purchase-item .time {
    color: var(--text-muted);
    font-size: 0.65rem;
    text-align: right;
    margin-top: 2px;
}
.admin-edit-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.admin-edit-field label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}
.admin-edit-field input {
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    color: white;
    font-size: 0.9rem;
    outline: none;
}
.admin-edit-field input:focus {
    border-color: var(--primary);
}
