@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Prompt:wght@300;400;500;600;700&display=swap');

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

:root {
    --bg: #faf8f5; /* Warm neutral background (creamy paper) */
    --card-bg: #ffffff;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --text-primary: #1e1b18; /* Stark warm neutral dark grey */
    --text-secondary: #6e6760;
    --text-muted: #a19a93;
    --border: #e8e3dc; /* Soft warm border lines */
    --hover-bg: #f5f2eb;
    --active-online: #10b981;
    --icon-bg: #faf8f5;
    --icon-color: #6e6760;
    --donate-bg: #faf8f5;
    --header-bg: #f5f2eb;
    --input-bg: #ffffff;
    --btn-primary: #e25c3d; /* Coral primary button color */
    --btn-primary-hover: #cc4d30;
    --btn-primary-text: #ffffff;
    --accent: #e25c3d;
}

.dark {
    --bg: #1c1917; /* Warm charcoal (Stone 900) */
    --card-bg: #292524; /* Warm stone card dark (Stone 800) */
    --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --text-primary: #f5f2eb;
    --text-secondary: #a8a29e;
    --text-muted: #78716c;
    --border: #44403c;
    --hover-bg: #3c3836;
    --active-online: #10b981;
    --icon-bg: #3c3836;
    --icon-color: #a8a29e;
    --donate-bg: #3c3836;
    --header-bg: #221f1d;
    --input-bg: #292524;
    --btn-primary: #e25c3d;
    --btn-primary-hover: #f97316;
    --btn-primary-text: #ffffff;
    --accent: #e25c3d;
}

body {
    font-family: 'Inter', 'Prompt', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.page {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 32px 16px;
}

.card {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 20px 18px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
}

.streamer-info {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 2.5px solid var(--card-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    background: var(--icon-bg);
}

.online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--active-online);
    border-radius: 50%;
    border: 2px solid var(--card-bg);
}

.streamer-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.streamer-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.streamer-name {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.streamer-socials {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--donate-bg);
    color: var(--text-secondary);
    text-decoration: none;
}

.social-link svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.social-link:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.streamer-thai {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.goal-bar {
    margin-top: 4px;
}

.goal-text {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.card-body {
    padding: 12px 8px;
}

.label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 12px;
}

.amount-section {
    margin-bottom: 12px;
}

.amount-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.amount-btn {
    padding: 11px 12px;
    background: var(--donate-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: 'Fira Code', 'Prompt', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.amount-btn:hover {
    background: var(--hover-bg);
}

.amount-btn.active {
    border-color: var(--text-primary);
    background: var(--text-primary);
    color: var(--card-bg);
}

.custom-btn {
    padding: 4px;
}

.custom-input {
    width: 100%;
    height: 100%;
    min-height: 38px;
    border: none;
    background: transparent;
    font-family: 'Fira Code', 'Prompt', monospace;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    color: inherit;
    outline: none;
}

.custom-input::placeholder {
    color: var(--text-muted);
}

.custom-input::-webkit-outer-spin-button,
.custom-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.form-group {
    margin-bottom: 4px;
}

.input {
    width: 100%;
    padding: 11px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: 'Fira Code', 'Prompt', monospace;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}

.input:focus {
    border-color: var(--text-primary);
}

.input::placeholder {
    color: var(--text-muted);
}

.textarea-wrapper {
    position: relative;
}

.textarea {
    width: 100%;
    padding: 11px 12px;
    padding-bottom: 28px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: 'Fira Code', 'Prompt', monospace;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    resize: none;
}

.textarea:focus {
    border-color: var(--text-primary);
}

.textarea::placeholder {
    color: var(--text-muted);
}

.char-count {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 10px;
    color: var(--text-muted);
}

.voice-section {
    margin-bottom: 8px;
}

.voice-select-wrapper {
    display: flex;
    gap: 8px;
}

.voice-select {
    flex: 1;
    min-width: 0;
    padding: 11px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: 'Fira Code', 'Prompt', monospace;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-select:focus {
    border-color: var(--text-primary);
}

.preview-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: var(--icon-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--icon-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-btn:hover {
    background: var(--hover-bg);
}

.preview-btn:active {
    transform: scale(0.95);
}

.donate-btn {
    display: flex;
    width: 100%;
    padding: 11px 12px;
    background: var(--btn-primary);
    border: none;
    border-radius: 12px;
    font-family: 'Fira Code', 'Prompt', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--btn-primary-text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.donate-btn:hover {
    background: var(--btn-primary-hover);
}

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

.donate-btn svg {
    fill: currentColor;
}

.btn-text {
    pointer-events: none;
}

.card-footer {
    padding: 8px 20px 12px;
    border-top: 1px solid var(--border);
}

.recent-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.donations-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.donation-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    background: var(--donate-bg);
    border-radius: 8px;
}

.donation-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--icon-bg);
    flex-shrink: 0;
}

.donation-body {
    flex: 1;
    min-width: 0;
}

.donation-info {
    display: flex;
    gap: 6px;
    align-items: baseline;
}

.donation-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.donation-amount {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
}

.donation-message {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.4;
}

.card-footer-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 20px 14px;
}

.footer-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    font-family: 'Fira Code', 'Prompt', monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.footer-toggle:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.footer-toggle:active {
    transform: scale(0.95);
}

.toggle-label {
    pointer-events: none;
}

.moon-icon {
    display: none;
}

.dark .sun-icon {
    display: none;
}

.dark .moon-icon {
    display: block;
}

.footer-sep {
    color: var(--text-muted);
    font-size: 11px;
}

.footer-powered {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    animation: modalIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--icon-bg);
    border: none;
    border-radius: 8px;
    color: var(--icon-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--hover-bg);
}

.modal-body {
    padding: 20px;
}

.qr-section {
    text-align: center;
    margin-bottom: 20px;
}

.qr-amount {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.qr-code {
    width: 200px;
    height: 200px;
    margin: 0 auto 12px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.qr-code img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.qr-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.upload-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.upload-divider::before,
.upload-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.upload-divider span {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
}

.upload-area:hover {
    border-color: var(--text-secondary);
    background: var(--hover-bg);
}

.upload-area svg {
    margin-bottom: 8px;
}

.upload-area p {
    font-size: 12px;
    line-height: 1.6;
}

.upload-link {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: underline;
}

.upload-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

.slip-preview {
    position: relative;
    display: inline-block;
    margin-top: 12px;
}

.slip-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 12px;
    border: 2px solid var(--border);
}

.slip-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--text-primary);
    color: var(--card-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.verify-btn {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: var(--btn-primary);
    border: none;
    border-radius: 12px;
    font-family: 'Fira Code', 'Prompt', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--btn-primary-text);
    cursor: pointer;
    opacity: 0.5;
    pointer-events: none;
}

.verify-btn.active {
    opacity: 1;
    pointer-events: auto;
}

.verify-btn.active:hover {
    background: var(--btn-primary-hover);
}

.verify-result {
    margin-top: 16px;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}

.verify-result.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--accent);
}

.verify-result.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
}

.result-icon {
    margin-bottom: 8px;
}

.result-text {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.result-detail {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--card-bg);
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 32px 0 rgba(0,0,0,0.2);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
}

.toast-content svg {
    color: var(--accent);
    flex-shrink: 0;
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

@media (max-width: 440px) {
    .page {
        padding: 16px 12px;
    }

    .amount-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- Leaderboard System (Claude minimalist style) --- */
.footer-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.footer-tab {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 4px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    position: relative;
}

.footer-tab:hover {
    color: var(--text-primary);
}

.footer-tab.active {
    color: var(--text-primary);
}

.footer-tab.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--donate-bg);
    border-radius: 8px;
    animation: itemIn 0.3s ease;
}

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

.leaderboard-rank-col {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
}

.rank-number {
    font-family: 'Fira Code', monospace;
}

.rank-badge {
    font-size: 14px;
}

.leaderboard-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--icon-bg);
    flex-shrink: 0;
}

.leaderboard-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.leaderboard-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-meta {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 1px;
}

.leaderboard-amount {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    font-family: 'Fira Code', monospace;
}

.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 12px;
}
