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

body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, #1f2026 0%, #0c0d10 100%);
    color: #f5f5f7;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
    font: inherit;
}

.info-container {
    flex: 1;
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    padding: 0 16px;
}

.back-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0 16px;
}

.back-btn,
.edit-btn,
.btn-save,
.btn-add-link,
.btn-logout-info,
.link-remove,
.balance-quick-action {
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 13px;
    font-weight: 700;
}

.back-bar .title {
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 16px;
    color: #86efac;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.28);
    font-size: 13px;
    font-weight: 800;
}

.edit-btn.cancel {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.28);
}

.back-btn:hover,
.edit-btn:hover,
.btn-save:hover,
.btn-add-link:hover,
.btn-logout-info:hover,
.link-remove:hover,
.balance-quick-action:hover {
    transform: translateY(-2px);
}

.back-btn:active,
.edit-btn:active,
.btn-save:active,
.btn-add-link:active,
.btn-logout-info:active,
.link-remove:active,
.balance-quick-action:active {
    transform: scale(0.97);
}

.info-card {
    padding: 24px 20px;
    border-radius: 16px;
    background: rgba(26, 28, 34, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
}

.info-card.edit-mode {
    background: rgba(20, 21, 26, 0.95);
    border-color: rgba(34, 197, 94, 0.3);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(34, 197, 94, 0.15) inset;
}

#infoMessage {
    display: none;
    margin-bottom: 16px;
    padding: 10px 14px;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}

.sync-status {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 0 0 12px;
    color: #94a3b8;
    font-size: 12px;
}

.sync-dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
    background: #22c55e;
}

.sync-dot.syncing {
    background: #fbbf24;
    animation: pulse 0.8s ease-in-out infinite;
}

.sync-dot.error {
    background: #ef4444;
}

@keyframes pulse {
    50% { opacity: 0.45; transform: scale(0.86); }
}

/* ============================================================
   Profile Header (Avatar + Name Area)
   ============================================================ */
.profile-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 20px;
}

.edit-mode .profile-header {
    align-items: flex-start;
    padding: 16px;
    border-radius: 12px;
    background: rgba(32, 34, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.avatar-big {
    width: 76px;
    height: 76px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: #272832;
    color: #fff;
    font-size: 30px;
    font-weight: 800;
    user-select: none;
}

.avatar-big img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-edit-hint {
    display: none;
}

.edit-mode .avatar-big {
    cursor: pointer;
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.edit-mode .avatar-big:hover {
    transform: translateY(-2px);
    border-color: rgba(34, 197, 94, 0.8);
}

.edit-mode .avatar-edit-hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    padding: 4px 0;
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.65);
    font-size: 11px;
    font-weight: 700;
}

#avatarInput {
    display: none;
}

.profile-name-area {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.display-name-wrap {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.display-name {
    color: #fff;
    font-size: 21px;
    font-weight: 800;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

#displayNameInput {
    display: none;
    width: 100%;
    min-height: 44px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #121318;
    color: #fff;
    outline: none;
    font-size: 15px;
    font-weight: 700;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#displayNameInput:focus,
#bioInput:focus,
.link-input:focus {
    border-color: #22c55e;
    background: rgba(18, 19, 24, 0.95);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.user-email {
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-all;
}

.user-badge {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 3px 10px;
    border-radius: 6px;
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.25);
    font-size: 12px;
    font-weight: 800;
}

/* ============================================================
   Profile Balances Grid (M幣餘額)
   ============================================================ */
/* ============================================================
   M幣資產卡片 (iOS 毛玻璃旗艦版)
   ============================================================ */
.profile-coin-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px;
    margin: 14px 0 20px;
    border-radius: 16px;
    border: 1px solid rgba(250, 204, 21, 0.28);
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.1) 0%, rgba(20, 24, 30, 0.6) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 24px rgba(250, 204, 21, 0.08);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.profile-coin-panel:hover {
    transform: translateY(-2px);
    border-color: rgba(250, 204, 21, 0.45);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 30px rgba(250, 204, 21, 0.15);
}

.coin-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.coin-panel-label {
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.coin-panel-body {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #facc15;
}

.coin-panel-body strong {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -0.5px;
    line-height: 1;
    text-shadow: 0 2px 10px rgba(250, 204, 21, 0.3);
}

.coin-panel-unit {
    font-size: 15px;
    font-weight: 800;
    color: #fde047;
    margin-top: 6px;
}

.balance-coin-img {
    width: 28px;
    height: 28px;
    image-rendering: pixelated;
    filter: drop-shadow(0 2px 6px rgba(250, 204, 21, 0.4));
    flex-shrink: 0;
}

.divider {
    margin: 18px 0;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ============================================================
   Bio Section
   ============================================================ */
.bio-section {
    margin-bottom: 16px;
}

.edit-mode .bio-section,
.edit-mode .links-section {
    padding: 16px;
    border-radius: 12px;
    background: rgba(32, 34, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.bio-label,
.links-section .label {
    display: block;
    margin-bottom: 8px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.4px;
}

.bio-text {
    min-height: 38px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

#bioInput {
    display: none;
    width: 100%;
    min-height: 110px;
    max-height: 220px;
    resize: vertical;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #121318;
    color: #f8fafc;
    outline: none;
    font-size: 14px;
    line-height: 1.6;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.bio-char-count {
    margin-top: 5px;
    color: #64748b;
    font-size: 11px;
    text-align: right;
    font-weight: 700;
}

/* ============================================================
   Links Section
   ============================================================ */
.links-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.edit-mode .links-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.link-item {
    margin-bottom: 10px;
}

.link-display {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #86efac;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    word-break: break-all;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.link-display:hover {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.25);
    transform: translateX(3px);
}

.link-edit-row {
    display: none;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border-radius: 10px;
    background: #121318;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.link-input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #1a1b22;
    color: #f8fafc;
    outline: none;
    font-size: 13px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.link-input.is-invalid {
    border-color: rgba(239, 68, 68, 0.8);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.link-remove {
    min-width: 60px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    font-size: 12px;
    font-weight: 800;
}

.btn-add-link {
    display: none;
    width: 100%;
    min-height: 44px;
    padding: 10px;
    margin-top: 8px;
    border: 1px dashed rgba(34, 197, 94, 0.35);
    color: #86efac;
    background: rgba(34, 197, 94, 0.08);
    font-size: 13px;
    font-weight: 800;
}

.btn-save {
    display: none;
    width: 100%;
    min-height: 48px;
    margin-top: 18px;
    padding: 12px;
    border: none;
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 4px 18px rgba(34, 197, 94, 0.25);
}

.logout-wrapper {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.btn-logout-info {
    min-height: 40px;
    padding: 8px 24px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.06);
    font-size: 13px;
    font-weight: 800;
}

/* ============================================================
   Mode Toggle States
   ============================================================ */
.view-mode .edit-only,
.view-mode .btn-save,
.view-mode .btn-add-link {
    display: none !important;
}

.edit-mode .view-only {
    display: none !important;
}

.edit-mode #displayNameInput,
.edit-mode #bioInput,
.edit-mode .btn-save,
.edit-mode .btn-add-link {
    display: block !important;
}

.edit-mode .link-display {
    display: none !important;
}

.edit-mode .link-edit-row {
    display: grid !important;
}

.footer {
    margin-top: auto;
    padding: 14px 10px;
    color: #64748b;
    text-align: center;
    font-size: 11px;
}

/* ============================================================
   Loading Overlay
   ============================================================ */
#infoLoading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(14px) saturate(1.08);
    -webkit-backdrop-filter: blur(14px) saturate(1.08);
}

#infoLoading.is-visible {
    display: flex;
}

.loading-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #f5f5f7;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 0.72s linear infinite;
}

.loading-title {
    margin-top: 18px;
    font-size: 15px;
    font-weight: 800;
}

.loading-subtitle {
    margin-top: 6px;
    color: rgba(245, 245, 247, 0.7);
    font-size: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Responsive Design for Mobile
   ============================================================ */
@media (max-width: 640px) {
    .info-container {
        margin: 10px auto;
        padding: 0 12px;
    }

    .info-card {
        padding: 18px 14px;
        border-radius: 14px;
    }

    .profile-header {
        gap: 14px;
        margin-bottom: 16px;
    }

    .avatar-big {
        width: 68px;
        height: 68px;
        border-radius: 15px;
        font-size: 26px;
    }

    .display-name {
        font-size: 19px;
    }

    .user-email {
        font-size: 12px;
    }

    .profile-balances-grid {
        gap: 10px;
        margin: 14px 0 18px;
    }

    .balance-card {
        padding: 12px 14px;
    }

    .balance-amount-row strong {
        font-size: 21px;
    }

    .back-bar .title {
        font-size: 17px;
    }
}

@media (max-width: 440px) {
    .profile-balances-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .avatar-big {
        width: 62px;
        height: 62px;
        border-radius: 14px;
        font-size: 24px;
    }

    .display-name {
        font-size: 18px;
    }

    .link-edit-row {
        gap: 6px;
        padding: 6px;
    }

    .link-remove {
        min-width: 52px;
        padding: 0 8px;
    }
}

