
.profile-wrap {
  max-width: 920px;
  margin: 40px auto 80px;
  padding: 0 20px;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 28px 32px;
  margin-bottom: 28px;
  background: rgba(18, 22, 28, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
}

.profile-avatars {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-shrink: 0;
}

.profile-avatar {
  position: relative;
  text-align: center;
}

.profile-avatar-mc img {
  width: 88px;
  height: 176px;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.profile-avatar-discord img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid #5865f2;
  box-shadow: 0 4px 16px rgba(88, 101, 242, 0.35);
  object-fit: cover;
  background: #2a2a3e;
}

.profile-avatar-label {
  display: block;
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #666;
}

.profile-avatar-mc.is-placeholder img {
  opacity: 0.35;
}

.profile-hero-info {
  flex: 1;
  min-width: 200px;
}

.profile-hero-info h1 {
  font-size: 1.85rem;
  margin: 0 0 10px;
  color: #f0f4ff;
}

.profile-hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.profile-rank-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #1e2a3a;
  color: #888;
  border: 1px solid #333;
}

.profile-rank-badge.has-rank {
  background: rgba(90, 205, 126, 0.12);
  color: #5acd7e;
  border-color: rgba(90, 205, 126, 0.35);
}

.profile-admin-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(224, 90, 90, 0.12);
  color: #e05a5a;
  border: 1px solid rgba(224, 90, 90, 0.35);
}

.profile-since {
  font-size: 0.85rem;
  color: #666;
}

.profile-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 22px;
  border-bottom: 2px solid #333;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.profile-tab {
  background: none;
  border: none;
  color: #888;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}

.profile-tab:hover {
  color: #ccc;
}

.profile-tab.active {
  color: var(--white);
  border-bottom-color: var(--primary-blue);
}

.profile-panel {
  display: none;
}

.profile-panel.active {
  display: block;
}

.profile-card {
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 14px;
  padding: 26px 28px;
  margin-bottom: 20px;
}

.profile-card:last-child {
  margin-bottom: 0;
}

.profile-card h2 {
  font-size: 1rem;
  color: var(--gray);
  margin: 0 0 8px;
  font-weight: 600;
}

.profile-card-desc {
  color: #888;
  font-size: 0.88rem;
  margin: 0 0 20px;
  line-height: 1.5;
}

.profile-field {
  margin-bottom: 16px;
}

.profile-field label {
  display: block;
  font-size: 0.83rem;
  color: #888;
  margin-bottom: 5px;
}

.profile-field input[type="text"],
.profile-field input[type="email"],
.profile-field input[type="password"] {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  padding: 9px 12px;
  background: #0d0d1a;
  border: 1px solid #444;
  border-radius: 7px;
  color: #e0e0e0;
  font-size: 0.95rem;
}

.profile-field input:focus {
  outline: none;
  border-color: #5b8dd9;
}

.profile-btn {
  padding: 9px 20px;
  background: #5b8dd9;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.profile-btn:hover {
  background: #4a7bc8;
}

.profile-btn.danger {
  background: #c0392b;
}

.profile-btn.danger:hover {
  background: #a93226;
}

.profile-btn.secondary {
  background: #333;
  color: #ccc;
}

.profile-btn.secondary:hover {
  background: #444;
  color: #fff;
}

.profile-msg {
  font-size: 0.88rem;
  margin-top: 8px;
  display: none;
  padding: 7px 12px;
  border-radius: 6px;
}

.profile-msg.ok {
  background: #0f2a1a;
  color: #5acd7e;
  display: block;
}

.profile-msg.err {
  background: #2a1010;
  color: #e05a5a;
  display: block;
}

.profile-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.profile-summary-item {
  background: #12122a;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 16px 18px;
}

.profile-summary-item .summary-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  margin-bottom: 6px;
}

.profile-summary-item .summary-value {
  font-size: 0.95rem;
  color: #ddd;
  word-break: break-word;
}

.profile-summary-item .summary-value.linked {
  color: #5acd7e;
}

.profile-summary-item .summary-value.unlinked {
  color: #888;
}

.profile-summary-actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.link-status {
  font-size: 0.9rem;
  min-width: 120px;
}

.link-status.linked {
  color: #5acd7e;
}

.link-status.unlinked {
  color: #888;
}

#mc-username-input {
  width: 200px;
  padding: 8px 10px;
  background: #0d0d1a;
  border: 1px solid #444;
  border-radius: 7px;
  color: #e0e0e0;
}

.mc-pending-panel {
  display: none;
  margin-top: 16px;
  padding: 14px 16px;
  background: #12122a;
  border: 1px solid #3a4a6a;
  border-radius: 8px;
}

.mc-pending-panel.visible {
  display: block;
}

.mc-pending-panel p {
  margin: 0 0 8px;
  color: #c8d8f0;
}

.mc-pending-panel .mc-pending-cmd {
  margin: 0 0 10px;
  font-family: var(--font-mono, monospace);
  font-size: 1.2rem;
  color: #7ec8ff;
}

.mc-pending-panel .mc-pending-note {
  margin: 0 0 12px;
  color: #888;
  font-size: 0.85rem;
}

.connection-block {
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid #2a2a3a;
}

.connection-block:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.connection-block h3 {
  font-size: 0.95rem;
  color: #ccc;
  margin: 0 0 8px;
}

.purchase-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid #2a2a3a;
  font-size: 0.92rem;
  color: #ccc;
}

.purchase-row:last-child {
  border-bottom: none;
}

.purchase-rank-name {
  font-weight: 700;
}

.purchase-date {
  color: #666;
  font-size: 0.82rem;
}

.purchase-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.purchase-cancel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.purchase-note {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #e0b060;
}

.purchase-note.muted {
  color: #888;
}

.sub-card {
  border: 1px solid #2e2e42;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  background: #12121f;
}

.sub-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.sub-rank {
  font-size: 1.05rem;
  font-weight: 700;
  color: #e8e8f0;
}

.sub-meta {
  margin-top: 4px;
  color: #5acd7e;
  font-size: 0.9rem;
}

.sub-status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.sub-status.is-active {
  background: #0f2a1a;
  color: #5acd7e;
}

.sub-status.is-ending {
  background: #2a220f;
  color: #e0b060;
}

.sub-details {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.sub-details > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.88rem;
  color: #ccc;
}

.sub-detail-label {
  color: #777;
  min-width: 150px;
}

.sub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-ending-note {
  font-size: 0.82rem;
  color: #888;
}

.profile-pm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.profile-pm-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.profile-pm-modal {
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 14px;
  width: 420px;
  max-width: 95vw;
  max-height: min(92dvh, 720px);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  margin: auto;
}

.profile-pm-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 28px 16px;
}

.profile-pm-footer {
  flex-shrink: 0;
  padding: 0 28px 24px;
  border-top: 1px solid #2a2a3a;
}

.profile-pm-footer .profile-btn {
  width: 100%;
}

.profile-pm-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  background: none;
  border: none;
  color: #888;
  font-size: 1.4rem;
  cursor: pointer;
}

.profile-pm-close:hover {
  color: #fff;
}

.profile-pm-modal h2 {
  margin: 0 0 6px;
  font-size: 1.3rem;
  padding-right: 28px;
}

.profile-pm-subtitle {
  color: #999;
  font-size: 0.9rem;
  margin: 0 0 16px;
}

#profile-pm-element {
  position: relative;
  min-height: 88px;
  margin-bottom: 12px;
}

#profile-pm-element-inner {
  min-height: 88px;
}

.profile-pm-loading,
.profile-pm-loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 0;
  color: #aaa;
  font-size: 0.95rem;
}

.profile-pm-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 46, 0.92);
  transition: opacity 0.2s;
}

.profile-pm-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.profile-pm-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: #5b8dd9;
  animation: profile-pm-spin 0.7s linear infinite;
}

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

.profile-pm-error {
  display: none;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #2a1010;
  color: #e05a5a;
  font-size: 0.88rem;
}

.profile-pm-error.visible {
  display: block;
}

.profile-btn.sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.profile-btn.ghost {
  background: transparent;
  border: 1px solid rgba(224, 90, 90, 0.45);
}

.no-auth-msg {
  text-align: center;
  padding: 100px 20px;
  color: #888;
  font-size: 1rem;
}

.no-auth-msg a {
  color: #5b8dd9;
  cursor: pointer;
}

@media (max-width: 600px) {
  .profile-hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 22px 20px;
  }

  .profile-avatars {
    width: 100%;
    justify-content: center;
  }

  .profile-hero-info h1 {
    font-size: 1.5rem;
  }

  .profile-tab {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
}
