.profile-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

.profile-top-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  grid-auto-rows: min-content;
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}
.profile-span-rows { grid-row: span 3; }

.profile-earn-card { margin-bottom: 0; }
.profile-earn-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.profile-earn-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(245, 158, 11, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.profile-earn-head .profile-card-title {
  flex: 1;
  font-size: 11px;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.profile-earn-active { margin-left: auto; }
.profile-earn-value {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 14px;
}
.profile-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.profile-level-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.profile-level-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), #fbbf24);
  width: 0%;
  transition: width 0.3s ease;
}
.profile-earn-footnote {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.profile-earn-footnote-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.4px;
}
.profile-earn-footnote-link {
  font-size: 12.5px;
  font-weight: 700;
  color: #4ade80;
}

.profile-referral-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 14px;
}
.profile-referral-hint strong { color: var(--gold); }
.profile-mini-value-gold { color: var(--gold); }

.profile-premium-note {
  font-size: 11.5px;
  color: var(--muted);
  margin: -6px 0 10px;
}
.profile-upgrade-btn {
  width: 100%;
  opacity: 0.6;
  cursor: not-allowed;
  margin-bottom: 16px;
}

.profile-redeem-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.profile-redeem-row .field-input { flex: 1; }
.profile-redeem-row button { flex-shrink: 0; padding: 0 16px; }

.profile-licenses {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.profile-licenses-title { display: block; margin-bottom: 8px; }
.profile-license-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 12.5px;
  font-weight: 600;
}

.profile-admin-card .profile-redeem-row { margin: 4px 0 6px; }
.profile-admin-card .field-input { max-width: 140px; }
.profile-admin-card #generatedCodeBox { margin-top: 4px; }
.profile-admin-card #generatedCodeText {
  font-family: 'Courier New', monospace;
  font-size: 13.5px;
  letter-spacing: 1px;
}

.profile-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.profile-code-row:first-child { border-top: none; }
.profile-code-row-code {
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.profile-code-row-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.profile-preset-card { margin-bottom: 0; }
.profile-preset-locked {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.profile-preset-lock { font-size: 20px; margin-bottom: 4px; opacity: 0.7; }
.profile-preset-locked strong { font-size: 13.5px; }
.profile-preset-locked p {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.5;
}
.profile-preset-locked button { width: 100%; opacity: 0.6; cursor: not-allowed; }

@media (max-width: 1080px) {
  .profile-top-grid { grid-template-columns: 1fr 1fr; }
  .profile-span-rows { grid-row: span 2; grid-column: span 2; }
}
@media (max-width: 880px) {
  .profile-top-grid { grid-template-columns: 1fr; }
  .profile-span-rows { grid-row: auto; grid-column: auto; }
}

.profile-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 16px;
}
.profile-card:last-child { margin-bottom: 0; }

.profile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.profile-card-title {
  font-size: 15px;
  font-weight: 800;
}
.profile-card-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin: -8px 0 14px;
}

.profile-online-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.profile-avatar-wrap {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--purple);
  padding: 2px;
}
.profile-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.profile-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #fff;
  font-weight: 800;
  font-size: 22px;
}
.profile-avatar-hint {
  font-size: 12px;
  color: var(--muted);
}

#profileForm {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#profileForm .field-hint { margin: -8px 0 0; }

.profile-side {
  display: flex;
  flex-direction: column;
}

.profile-referral-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.profile-referral-code button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.profile-referral-code button:hover { color: var(--text); }

.profile-mini-stats {
  display: flex;
  gap: 12px;
}
.profile-mini-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.profile-mini-value {
  font-size: 22px;
  font-weight: 800;
}

.profile-membership-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  border-top: 1px solid var(--border);
}
.profile-membership-row:first-of-type { border-top: none; padding-top: 0; }

.profile-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 999px;
}
.profile-badge-active {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
}
.profile-badge-soon {
  color: var(--gold);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.profile-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px 0;
  margin: 0;
}

.profile-top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.profile-top-row:first-child { border-top: none; }
.profile-top-rank {
  width: 20px;
  flex-shrink: 0;
  font-weight: 800;
  color: var(--muted);
}
.profile-top-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--card-hover);
}
.profile-top-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.profile-top-wins {
  font-weight: 800;
  color: var(--gold);
  font-size: 12px;
}

@media (max-width: 880px) {
  .profile-grid { grid-template-columns: 1fr; }
}
