/* ==================== PROFILE PAGE ==================== */

.profile-page {
    max-width: 1120px;
}

.profile-page .glass-panel {
    border-radius: 8px;
}

.profile-hidden {
    display: none;
}

.profile-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.profile-overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
}

.profile-primary-column,
.profile-secondary-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Back button */
.back-btn {
    color: var(--neon-cyan);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 12px;
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}
.back-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

/* Header link */
.header-link {
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 14px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    transition: all 0.2s;
}
.header-link:hover {
    color: var(--text-silver);
    border-color: rgba(255,255,255,0.2);
}

/* ==================== LOADING ==================== */
.profile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    gap: 15px;
    color: var(--text-muted);
}
.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0, 240, 255, 0.15);
    border-top-color: var(--neon-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== NOT LOGGED IN ==================== */
.profile-not-logged-in {
    text-align: center;
    padding: 50px 30px;
}

.profile-not-logged-in-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.profile-not-logged-in-copy {
    color: var(--text-muted);
    margin: 10px 0 20px;
}

.profile-not-logged-in h3 {
    color: var(--text-silver);
    font-size: 1.1rem;
    margin: 0 0 8px;
}
.btn-primary {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--neon-red), #cc2222);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-family: 'Kanit', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s;
}
.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(255, 60, 60, 0.4);
    transform: translateY(-2px);
}

/* ==================== USER CARD ==================== */
.user-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    flex-wrap: wrap;
    gap: 20px;
}
.user-card-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex: 1 1 420px;
}

.user-info {
    flex: 1 1 auto;
    min-width: 0;
}

.user-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.user-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--neon-cyan);
    object-fit: cover;
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.3);
}
.platform-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.platform-badge.line {
    background: #00B900;
    color: white;
}
.platform-badge.telegram {
    background: #0088cc;
    color: white;
}
.user-display-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    color: var(--text-silver);
    margin: 0 0 4px;
    letter-spacing: 1px;
}
.user-platform-id {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: 0 0 8px;
}
.user-id-card {
    min-width: min(100%, 420px);
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 240, 255, 0.18);
    background: rgba(0, 240, 255, 0.05);
}
.user-id-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.user-id-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.user-id-value {
    flex: 1 1 220px;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(6, 6, 18, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-silver);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.82rem;
    word-break: break-all;
}
.copy-user-id-btn {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 240, 255, 0.24);
    background: rgba(0, 240, 255, 0.08);
    color: var(--neon-cyan);
    font-family: 'Kanit', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.copy-user-id-btn:hover {
    background: rgba(0, 240, 255, 0.14);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}
.user-id-help {
    margin-top: 8px;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.profile-avatar-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.avatar-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 240, 255, 0.26);
    background: rgba(0, 240, 255, 0.08);
    color: var(--neon-cyan);
    font-family: 'Kanit', sans-serif;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.avatar-upload-btn:hover {
    background: rgba(0, 240, 255, 0.14);
    box-shadow: 0 0 14px rgba(0, 240, 255, 0.18);
}

.avatar-upload-status {
    color: var(--text-muted);
    font-size: 0.76rem;
    line-height: 1.5;
}

.avatar-upload-status.is-error {
    color: #ff7a7a;
}

.avatar-upload-status.is-success {
    color: var(--neon-green);
}
.user-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(100px, 1fr));
    gap: 14px;
    min-width: min(100%, 280px);
}
.user-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}
.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ==================== PROGRESS CARD ==================== */
.profile-progress-card {
    padding: 18px 22px;
}
.profile-progress-card .progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--text-silver);
}
.profile-progress-card .progress-count {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--neon-green);
    text-shadow: 0 0 8px rgba(0, 255, 170, 0.4);
}
.profile-progress-card .progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 10px;
}
.profile-progress-card .progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--neon-red), #ff6644, var(--neon-green));
    border-radius: 10px;
    transition: width 0.6s ease;
}
.profile-progress-card .progress-dots {
    display: flex;
    justify-content: space-between;
}
.profile-progress-card .progress-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 40, 0.8);
    transition: all 0.3s;
}
.profile-progress-card .progress-dot span {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
}
.profile-progress-card .progress-dot.filled {
    border-color: var(--neon-green);
    background: rgba(0, 255, 170, 0.15);
    box-shadow: 0 0 10px rgba(0, 255, 170, 0.3);
}
.profile-progress-card .progress-dot.filled span {
    color: var(--neon-green);
}

/* ==================== TABS ==================== */
.profile-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-family: 'Kanit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 22px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -1px;
}
.tab-btn:hover {
    color: var(--text-silver);
}
.tab-btn.active {
    color: var(--neon-cyan);
    border-bottom-color: var(--neon-cyan);
}

/* ==================== LIST ==================== */
.profile-list {
    padding: 6px 0;
    min-height: 80px;
}
.list-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    padding: 30px 20px;
}
.list-item {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeInUp 0.4s ease-out both;
    transition: background 0.2s;
    scroll-margin-top: 16px;
}
.list-item:last-child {
    border-bottom: none;
}
.list-item:hover {
    background: rgba(255, 255, 255, 0.02);
}
.item-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.item-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.item-number {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 3px 7px;
    flex-shrink: 0;
    margin-top: 2px;
}
.item-detail {
    flex: 1;
    min-width: 0;
}
.item-primary {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-silver);
    margin-bottom: 3px;
}
.staff-fullname {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.item-secondary {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.item-reject-note {
    font-size: 0.78rem;
    color: var(--neon-red);
    margin-top: 4px;
}
.item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}
.slip-thumb-link {
    display: block;
}

.slip-thumb-btn {
    display: block;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.slip-thumb-btn:focus-visible {
    outline: 2px solid rgba(0, 240, 255, 0.4);
    outline-offset: 4px;
    border-radius: 8px;
}

.slip-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s;
}
.slip-thumb:hover {
    transform: scale(1.1);
}

/* ==================== BADGES ==================== */
.item-badge {
    flex-shrink: 0;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.item-badge.pending {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}
.item-badge.approved {
    background: rgba(0, 255, 170, 0.15);
    color: var(--neon-green);
    border: 1px solid rgba(0, 255, 170, 0.3);
}
.item-badge.rejected {
    background: rgba(255, 60, 60, 0.15);
    color: var(--neon-red);
    border: 1px solid rgba(255, 60, 60, 0.3);
}
.item-badge.won {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.3);
}
.item-badge.lost {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.item-badge.waiting {
    background: rgba(0, 240, 255, 0.1);
    color: var(--neon-cyan);
    border: 1px solid rgba(0, 240, 255, 0.2);
}

/* ==================== LOTTERY ITEMS ==================== */
.lotto-item .item-main {
    align-items: center;
}
.lotto-number-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--neon-cyan);
    text-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
    min-width: 56px;
    text-align: center;
    flex-shrink: 0;
}
.reward-amount {
    font-size: 0.82rem;
    color: #ffd700;
    font-weight: 700;
    margin-top: 4px;
}
.reward-gv {
    font-size: 0.82rem;
    color: var(--neon-green);
    font-weight: 700;
    margin-top: 4px;
}

/* ==================== RESPONSIVE ==================== */

/* ==================== RANK CARD ==================== */
.rank-card {
    padding: 24px;
}
.rank-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    text-align: center;
}
.rank-icon-wrap {
    width: 132px;
    height: 118px;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--rank-color, #888) 58%, rgba(255, 255, 255, 0.12));
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 50% 18%, color-mix(in srgb, var(--rank-color, #888) 22%, transparent), transparent 48%),
        rgba(20, 20, 40, 0.8);
    box-shadow: 0 0 28px color-mix(in srgb, var(--rank-color, #888) 42%, transparent),
                inset 0 0 18px color-mix(in srgb, var(--rank-color, #888) 18%, transparent);
    flex-shrink: 0;
    animation: rankPulse 2.5s ease-in-out infinite;
}
@keyframes rankPulse {
    0%, 100% { box-shadow: 0 0 28px color-mix(in srgb, var(--rank-color, #888) 42%, transparent); }
    50% { box-shadow: 0 0 42px color-mix(in srgb, var(--rank-color, #888) 62%, transparent); }
}
.rank-icon {
    display: block;
    width: 124px;
    height: 110px;
    object-fit: contain;
    filter: drop-shadow(0 0 14px color-mix(in srgb, var(--rank-color, #888) 52%, transparent));
}
.rank-icon.rank-visual-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}
.rank-info {
    flex: 1;
    min-width: 0;
}
.rank-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 2px;
}
.rank-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.65rem;
    font-weight: 900;
    letter-spacing: 2px;
    text-shadow: 0 0 12px currentColor;
    overflow-wrap: anywhere;
}
.rank-stats-mini {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.rank-reset-note {
    margin-top: 4px;
    color: rgba(0, 240, 255, 0.78);
    font-size: 0.78rem;
    line-height: 1.45;
}

/* Rank tier track dots */
.rank-tier-track {
    display: flex;
    justify-content: space-between;
    gap: 3px;
    margin-bottom: 16px;
    padding: 0 4px;
}
.rank-tier-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 40, 0.6);
    opacity: 0.4;
    transition: all 0.3s;
}
.rank-tier-dot span {
    font-size: 1rem;
}
.rank-tier-logo {
    display: block;
    width: 34px;
    height: 34px;
    object-fit: contain;
}
.rank-tier-logo.rank-visual-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.rank-tier-dot.achieved {
    opacity: 1;
    border-color: var(--tier-color);
    background: color-mix(in srgb, var(--tier-color) 15%, transparent);
    box-shadow: 0 0 10px color-mix(in srgb, var(--tier-color) 30%, transparent);
}

/* Rank progress to next */
.rank-progress-section {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 12px;
}
.rank-next-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.rank-next-tier {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
}
.rank-inline-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
}
.rank-inline-logo.rank-visual-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.rank-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 6px;
}
.rank-progress-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.8s ease;
}
.rank-progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.rank-max-label {
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ==================== REWARD SUMMARY ==================== */
.reward-summary {
    padding: 22px 24px;
}

.profile-history-board {
    padding: 20px 22px;
}

.profile-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}

.profile-section-header h3 {
    margin: 0;
    color: var(--text-silver);
    font-size: 1rem;
}

.profile-section-copy {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.profile-section-meta {
    flex-shrink: 0;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.18);
    color: var(--neon-cyan);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.78rem;
}

.profile-activity-list {
    padding: 0;
}

.activity-type-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-silver);
    font-size: 0.7rem;
    font-weight: 700;
}

.activity-type-pill-transaction {
    color: #ffb3b3;
    border-color: rgba(255, 60, 60, 0.18);
    background: rgba(255, 60, 60, 0.08);
}

.activity-type-pill-guess {
    color: var(--neon-cyan);
    border-color: rgba(0, 240, 255, 0.18);
    background: rgba(0, 240, 255, 0.08);
}
.reward-summary-header {
    font-family: 'Kanit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-silver);
    margin-bottom: 14px;
}
.reward-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.reward-card {
    text-align: center;
    padding: 16px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(20, 20, 40, 0.6);
    transition: transform 0.2s, box-shadow 0.2s;
}
.reward-card:hover {
    transform: translateY(-2px);
}
.reward-cashback {
    border-color: rgba(255, 215, 0, 0.25);
    background: rgba(255, 215, 0, 0.05);
}
.reward-cashback:hover {
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.15);
}
.reward-gv-card {
    border-color: rgba(0, 255, 170, 0.25);
    background: rgba(0, 255, 170, 0.05);
}
.reward-gv-card:hover {
    box-shadow: 0 4px 16px rgba(0, 255, 170, 0.15);
}
.reward-card-icon {
    font-size: 1.6rem;
    margin-bottom: 6px;
}
.reward-card-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 900;
    margin-bottom: 2px;
}
.reward-cashback .reward-card-value {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}
.reward-gv-card .reward-card-value {
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(0, 255, 170, 0.4);
}
.reward-card-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.reward-card-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.reward-card-sub strong {
    color: var(--text-silver);
}
.reward-card-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 6px;
    opacity: 0.7;
}
.reward-pending-note {
    text-align: center;
    font-size: 0.8rem;
    color: var(--neon-cyan);
    margin-top: 10px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.15);
}

@media (max-width: 1024px) {
    .profile-overview-grid {
        display: flex;
        flex-direction: column;
        gap: 14px;
        margin-bottom: 14px;
    }
    .profile-primary-column {
        display: contents;
    }
    .user-card {
        order: 1;
    }
    .profile-secondary-column {
        order: 2;
        width: 100%;
        min-width: 0;
    }
    .profile-history-board {
        order: 3;
    }
    /* Force every profile panel to fill the available width on tablet/mobile */
    .profile-overview-grid > *,
    .profile-primary-column > *,
    .profile-secondary-column > *,
    .user-card,
    .profile-history-board,
    .profile-progress-card,
    .rank-card,
    .reward-summary {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    /* User-card stacks: avatar+info on top row, stats on next row, both full-width */
    .user-card-left {
        flex: 1 1 100%;
        min-width: 0;
    }
    .user-stats {
        flex: 1 1 100%;
        min-width: 0;
    }
    /* Slim the page padding so content has more room */
    .profile-page {
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (max-width: 760px) {
    .profile-page {
        padding: 10px 12px 18px;
    }
    .profile-page header {
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 14px;
        padding-bottom: 12px;
    }
    .profile-page .logo-area {
        gap: 8px;
        min-width: 0;
    }
    .profile-page .logo-icon {
        display: none;
    }
    .profile-page header h1 {
        font-size: 0.95rem;
        letter-spacing: 0;
        text-transform: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .profile-page .subtitle {
        display: none;
    }
    .profile-header-actions {
        gap: 6px;
        margin-left: auto;
        flex-wrap: nowrap;
    }
    .profile-header-actions .header-link[href="index.html"] {
        display: none;
    }
    .back-btn,
    .header-link {
        padding: 5px 8px;
        font-size: 0.78rem;
    }
    .profile-secondary-column {
        gap: 10px;
    }
    .user-card {
        align-items: stretch;
        gap: 12px;
        padding: 14px;
    }
    .user-card-left {
        width: 100%;
        flex: 1 1 auto;
        align-items: flex-start;
        gap: 10px;
    }
    .user-avatar {
        width: 56px;
        height: 56px;
        border-width: 2px;
    }
    .platform-badge {
        bottom: -3px;
        right: -5px;
        padding: 1px 6px;
        font-size: 0.58rem;
    }
    .user-display-name {
        font-size: 0.95rem;
        line-height: 1.25;
        letter-spacing: 0;
        margin-bottom: 2px;
        overflow-wrap: anywhere;
    }
    .user-platform-id {
        display: none;
    }
    .user-id-card {
        width: 100%;
        min-width: 0;
        padding: 8px;
        margin-top: 6px;
    }
    .user-id-label {
        margin-bottom: 4px;
        font-size: 0.68rem;
    }
    .user-id-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: stretch;
        gap: 6px;
    }
    .user-id-value {
        flex: none;
        padding: 7px 8px;
        font-size: 0.68rem;
        line-height: 1.3;
        max-height: 2.9em;
        overflow: auto;
    }
    .copy-user-id-btn {
        min-width: 62px;
        padding: 7px 9px;
        font-size: 0.74rem;
    }
    .user-id-help {
        display: none;
    }
    .profile-avatar-tools {
        align-items: flex-start;
        gap: 6px;
        margin-top: 8px;
    }
    .avatar-upload-btn {
        padding: 7px 9px;
        font-size: 0.74rem;
    }
    .avatar-upload-status {
        font-size: 0.7rem;
        line-height: 1.35;
    }
    .avatar-upload-status:not(.is-error):not(.is-success) {
        display: none;
    }
    .user-stats {
        width: 100%;
        min-width: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }
    .user-stat {
        align-items: center;
        min-width: 0;
        padding: 8px 4px;
        gap: 2px;
        text-align: center;
    }
    .stat-value {
        max-width: 100%;
        overflow: hidden;
        font-size: 1rem;
        line-height: 1.1;
        text-overflow: ellipsis;
    }
    .stat-label {
        font-size: 0.62rem;
        line-height: 1.2;
        white-space: normal;
    }
    .profile-progress-card,
    .rank-card,
    .reward-summary,
    .profile-history-board {
        padding: 12px;
    }
    .profile-progress-card .progress-header {
        gap: 8px;
        margin-bottom: 8px;
        font-size: 0.8rem;
    }
    .profile-progress-card .progress-count {
        font-size: 0.9rem;
    }
    .profile-progress-card .progress-track {
        height: 8px;
        margin-bottom: 8px;
    }
    .profile-progress-card .progress-dot {
        width: 26px;
        height: 26px;
        border-width: 1px;
    }
    .rank-display {
        gap: 10px;
        margin-bottom: 12px;
    }
    .rank-icon-wrap {
        width: 96px;
        height: 86px;
        border-width: 2px;
    }
    .rank-icon {
        width: 90px;
        height: 80px;
    }
    .rank-icon.rank-visual-fallback {
        font-size: 2rem;
    }
    .rank-label {
        font-size: 0.64rem;
        letter-spacing: 0.08em;
    }
    .rank-name {
        font-size: 1.2rem;
        letter-spacing: 0.08em;
    }
    .rank-stats-mini {
        font-size: 0.7rem;
    }
    .rank-tier-track {
        gap: 4px;
        margin-bottom: 10px;
        padding: 0;
    }
    .rank-tier-dot {
        width: 34px;
        height: 34px;
        border-width: 1px;
    }
    .rank-tier-dot span {
        font-size: 0.78rem;
    }
    .rank-tier-logo {
        width: 29px;
        height: 29px;
    }
    .rank-tier-logo.rank-visual-fallback {
        font-size: 1rem;
    }
    .rank-progress-section {
        padding-top: 10px;
    }
    .rank-next-label {
        margin-bottom: 6px;
        font-size: 0.72rem;
    }
    .rank-progress-details {
        gap: 8px;
        font-size: 0.68rem;
    }
    .reward-summary-header {
        margin-bottom: 10px;
        font-size: 0.9rem;
    }
    .reward-summary-grid {
        gap: 6px;
    }
    .reward-card {
        min-width: 0;
        padding: 10px 6px;
    }
    .reward-card-icon {
        font-size: 1.15rem;
        margin-bottom: 2px;
    }
    .reward-card-value {
        font-size: 0.92rem;
        overflow-wrap: anywhere;
    }
    .reward-card-label {
        margin-bottom: 2px;
        font-size: 0.7rem;
    }
    .reward-card-sub {
        font-size: 0.62rem;
        line-height: 1.35;
    }
    .reward-card-count {
        margin-top: 4px;
        font-size: 0.62rem;
    }
    .reward-pending-note {
        margin-top: 8px;
        padding: 7px;
        font-size: 0.72rem;
    }
    .profile-section-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 10px;
    }
    .profile-section-header h3 {
        font-size: 0.9rem;
    }
    .profile-section-copy {
        display: none;
    }
    .profile-section-meta {
        padding: 5px 8px;
        font-size: 0.68rem;
        align-self: flex-start;
    }
    .profile-list {
        min-height: 56px;
    }
    .list-empty {
        padding: 18px 12px;
        font-size: 0.8rem;
    }
    .profile-activity-list .list-item {
        margin-bottom: 8px;
        padding: 10px 12px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.06);
        background: rgba(255, 255, 255, 0.03);
    }
    .list-item {
        padding: 10px 12px;
    }
    .item-main {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }
    .item-info {
        gap: 8px;
        width: 100%;
    }
    .item-number {
        display: none;
    }
    .item-primary {
        margin-bottom: 2px;
        font-size: 0.82rem;
        line-height: 1.3;
    }
    .staff-fullname {
        display: none;
    }
    .item-secondary,
    .item-reject-note {
        font-size: 0.7rem;
        line-height: 1.35;
    }
    .item-right {
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
        gap: 6px;
        max-width: none;
        width: 100%;
    }
    .slip-thumb {
        width: 34px;
        height: 34px;
    }

    .slip-thumb-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
    }
    .item-badge {
        border-radius: 8px;
        padding: 3px 7px;
        font-size: 0.65rem;
        line-height: 1.2;
        letter-spacing: 0;
        text-align: center;
        white-space: nowrap;
    }
    .activity-type-pill {
        gap: 4px;
        padding: 2px 6px;
        border-radius: 8px;
        font-size: 0.63rem;
    }
    .lotto-number-display {
        min-width: 38px;
        font-size: 1.2rem;
    }
    .reward-amount,
    .reward-gv {
        font-size: 0.72rem;
    }

    .profile-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 14px 0 10px;
        border-bottom: none;
    }

    .tab-btn {
        margin-bottom: 0;
        min-height: 44px;
        padding: 10px 12px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.03);
        font-size: 0.82rem;
        line-height: 1.25;
    }

    .tab-btn.active {
        border-color: rgba(0, 240, 255, 0.3);
        border-bottom-color: rgba(0, 240, 255, 0.3);
        background: rgba(0, 240, 255, 0.08);
        box-shadow: 0 0 14px rgba(0, 240, 255, 0.12);
    }

    .tab-content {
        display: block;
    }
}

@media (max-width: 520px) {
    .profile-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .profile-tabs {
        grid-template-columns: 1fr;
    }

    .user-id-row {
        grid-template-columns: 1fr;
    }

    .copy-user-id-btn {
        width: 100%;
        min-height: 40px;
    }

    .profile-avatar-tools {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .avatar-upload-btn {
        width: 100%;
        min-height: 40px;
    }

    .reward-summary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .item-right {
        align-items: flex-start;
    }

    .item-badge {
        max-width: 100%;
        white-space: normal;
    }
}

@media (max-width: 380px) {
    .profile-page {
        padding: 8px 10px 16px;
    }
    .user-card-left {
        gap: 8px;
    }
    .user-avatar {
        width: 50px;
        height: 50px;
    }
    .user-stats {
        gap: 5px;
    }
    .stat-value {
        font-size: 0.92rem;
    }
    .stat-label {
        font-size: 0.62rem;
    }
    .profile-progress-card .progress-dot {
        width: 24px;
        height: 24px;
    }
    .rank-tier-dot {
        width: 30px;
        height: 30px;
    }
    .rank-tier-logo {
        width: 25px;
        height: 25px;
    }
    .reward-card-sub {
        display: none;
    }
    .item-right {
        max-width: 72px;
    }
}

/* ==================== Custom Display Name (User Profile) ==================== */

.user-name-block {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.name-edit-btn {
    background: transparent;
    border: 1px solid rgba(0, 240, 255, 0.4);
    color: #00f0ff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.name-edit-btn:hover {
    background: rgba(0, 240, 255, 0.12);
    transform: scale(1.05);
}

.user-line-name-secondary {
    margin: 4px 0 0;
    font-size: 13px;
    color: #00f0ff;
    opacity: 0.85;
    font-weight: 400;
}

.user-line-name-secondary:empty {
    display: none;
}

.user-name-cooldown-hint {
    margin: 4px 0 0;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.user-name-cooldown-hint:empty {
    display: none;
}

/* ==================== Name Edit Modal ==================== */

.name-edit-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 18, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: nameEditFadeIn 0.18s ease;
}

.name-edit-modal-overlay[hidden] {
    display: none !important;
}

/* Big "Change Name" button next to photo upload */
.name-change-btn {
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.4);
    color: #00f0ff;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Kanit', sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.name-change-btn:hover {
    background: rgba(0, 240, 255, 0.16);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 240, 255, 0.2);
}

.name-change-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

@keyframes nameEditFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.name-edit-modal-content {
    width: 100%;
    max-width: 480px;
    padding: 28px 24px 22px;
    border-radius: 14px;
    border: 1px solid rgba(0, 240, 255, 0.35);
    box-shadow: 0 0 50px rgba(0, 240, 255, 0.2);
    position: relative;
}

.name-edit-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.name-edit-modal-close:hover {
    color: #ff3c3c;
}

.name-edit-modal-title {
    margin: 0 0 6px;
    color: #00f0ff;
    font-size: 20px;
}

.name-edit-modal-hint {
    margin: 0 0 18px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

.name-edit-modal-hint span {
    color: #ff3c3c;
    font-weight: 700;
}

.name-edit-label {
    display: block;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 6px;
}

.name-edit-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 240, 255, 0.35);
    color: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.18s ease;
}

.name-edit-input:focus {
    outline: none;
    border-color: #00f0ff;
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.18);
}

.name-edit-counter {
    margin-top: 4px;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.5);
    text-align: right;
}

.name-edit-line-name-block {
    margin: 14px 0;
    padding: 10px 12px;
    background: rgba(0, 240, 255, 0.06);
    border-radius: 8px;
    border-left: 3px solid #00f0ff;
    font-size: 13px;
}

.name-edit-line-label {
    color: rgba(255, 255, 255, 0.6);
    margin-right: 6px;
}

.name-edit-line-value {
    color: #00f0ff;
    font-weight: 600;
}

.name-edit-status {
    margin: 8px 0 14px;
    font-size: 12.5px;
    min-height: 18px;
}

.name-edit-status.error {
    color: #ff3c3c;
}

.name-edit-status.warning {
    color: #ffc107;
}

.name-edit-status.success {
    color: #00ffaa;
}

.name-edit-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.name-edit-actions .btn-action {
    flex: 1 1 auto;
    min-width: 100px;
}

.btn-ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.85);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 480px) {
    .name-edit-modal-content {
        padding: 22px 18px 18px;
    }
    .name-edit-modal-title {
        font-size: 18px;
    }
    .name-edit-actions .btn-action {
        flex-basis: 100%;
    }
}
