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

:root {
    --bg:       var(--tg-theme-bg-color, #ffffff);
    --bg2:      var(--tg-theme-secondary-bg-color, #f1f1f1);
    --text:     var(--tg-theme-text-color, #000000);
    --hint:     var(--tg-theme-hint-color, #999999);
    --link:     var(--tg-theme-link-color, #2481cc);
    --btn:      var(--tg-theme-button-color, #2481cc);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --radius:   14px;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg2);
    border-bottom: 1px solid rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    z-index: 10;
}

.balance-wrap {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.balance-label {
    font-size: 11px;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.balance-value {
    font-size: 18px;
    font-weight: 700;
}

/* Buttons */
.btn-primary {
    background: var(--btn);
    color: var(--btn-text);
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
.btn-primary:active { opacity: .75; }
.btn-primary:disabled { opacity: .5; cursor: default; }

.btn-sm  { padding: 8px 16px; font-size: 13px; border-radius: 20px; }
.btn-full { width: 100%; padding: 16px; font-size: 16px; border-radius: var(--radius); margin-top: 4px; }

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg2);
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.tab {
    flex: 1;
    padding: 11px 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--hint);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}

.tab.active {
    color: var(--btn);
    border-bottom-color: var(--btn);
    font-weight: 700;
}

/* Content */
main { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Gifts grid */
.gifts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.gift-card {
    background: var(--bg2);
    border-radius: 18px;
    padding: 20px 14px 16px;
    text-align: center;
    cursor: pointer;
    transition: transform .12s;
    user-select: none;
}
.gift-card:active { transform: scale(.95); }

.gift-icon { font-size: 52px; line-height: 1; margin-bottom: 10px; }

.gift-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}

.gift-price {
    font-size: 13px;
    color: var(--hint);
    margin-bottom: 10px;
}

.gift-card .btn-primary {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    border-radius: 10px;
}

/* History */
.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 14px;
}

.hi-gift  { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.hi-icon  { width: 28px !important; height: 28px !important; max-width: 28px !important; max-height: 28px !important; object-fit: contain; flex-shrink: 0; }
.hi-to    { font-size: 13px; color: var(--link); margin-bottom: 3px; }
.hi-msg   { font-size: 13px; color: var(--hint); font-style: italic; margin-bottom: 4px; }
.hi-date  { font-size: 11px; color: var(--hint); }
.hi-topup { border-left: 3px solid #f7c948; }
.hi-topup-icon { font-size: 20px; line-height: 1; }

.empty {
    text-align: center;
    color: var(--hint);
    padding: 48px 0;
    font-size: 15px;
}

/* Loading */
.loading { text-align: center; color: var(--hint); padding: 40px 0; }

/* Overlay + sheet */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 50;
    display: flex;
    align-items: flex-end;
}
.overlay.hidden { display: none; }

.sheet {
    background: var(--bg);
    border-radius: 20px 20px 0 0;
    padding: 10px 20px calc(28px + env(safe-area-inset-bottom));
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.sheet-handle {
    width: 36px; height: 4px;
    background: var(--hint);
    border-radius: 2px;
    margin: 2px auto 18px;
    opacity: .35;
}

.sheet h2 { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 6px; }

.sheet-sub { text-align: center; color: var(--hint); font-size: 13px; margin-bottom: 18px; }

/* Form */
.form-group { margin-bottom: 14px; position: relative; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 7px;
}

.hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg2);
    border: 1.5px solid transparent;
    border-radius: var(--radius);
    padding: 13px 14px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    font-family: inherit;
    resize: none;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--btn); }

.form-group textarea { height: 84px; padding-bottom: 24px; }

.char-count {
    position: absolute;
    right: 11px; bottom: 10px;
    font-size: 11px;
    color: var(--hint);
}

/* Amounts */
.amounts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.amount-btn {
    background: var(--bg2);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: 15px 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all .15s;
}
.amount-btn:active, .amount-btn:hover { border-color: var(--btn); color: var(--btn); }

.custom-amount-row {
    display: flex;
    gap: 10px;
}

.custom-amount-row input {
    flex: 1;
    background: var(--bg2);
    border: 1.5px solid transparent;
    border-radius: var(--radius);
    padding: 13px 14px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color .15s;
}
.custom-amount-row input:focus { border-color: var(--btn); }

.custom-amount-row .btn-primary {
    padding: 13px 18px;
    font-size: 14px;
    white-space: nowrap;
}

/* Gift sticker (tgs-player) */
.gift-sticker {
    width: 90px;
    height: 90px;
    margin: 0 auto 6px;
    display: block;
}

.send-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 6px;
}

.send-sticker {
    width: 100px;
    height: 100px;
}

.send-header h2 {
    margin-bottom: 14px;
}
