/* ── 전체 레이아웃: 세로 스택 ─────────────────────────────── */
.profile-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1000px;
  margin: 0 auto;
}

/* ── 프로필 카드 (전체 너비, 가로형) ─────────────────────── */
.profile-card {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.profile-card-inner {
  position: relative;
  padding: 32px 36px;
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* 배경 인덱스별 */
.profile-bg-0 { background: linear-gradient(120deg, #1c1c1e 0%, #2a2a2d 100%); }
.profile-bg-1 { background: linear-gradient(120deg, #1a1a1c 0%, #3a2a2e 100%); }
.profile-bg-2 { background: linear-gradient(120deg, #1a1c1c 0%, #2a3030 100%); }
.profile-bg-3 { background: linear-gradient(120deg, #0f1b2d 0%, #1a3450 100%); }
.profile-bg-4 { background: linear-gradient(120deg, #0d1f15 0%, #1a3828 100%); }
.profile-bg-5 { background: linear-gradient(120deg, #1a0d2e 0%, #2e1a4e 100%); }
.profile-bg-6 { background: linear-gradient(120deg, #1f1200 0%, #3d2800 100%); }
.profile-bg-7 { background: linear-gradient(120deg, #0d0f1f 0%, #1a1d3a 100%); }
.profile-bg-8 { background: linear-gradient(120deg, #1f0d16 0%, #3a1a28 100%); }
.profile-bg-9 { background: linear-gradient(120deg, #0d1f1a 0%, #1a3830 100%); }

/* ── 카드 내부: 아이콘 왼쪽 + 정보 오른쪽 ───────────────── */
.profile-card-body {
  position: relative;   /* 스티커 레이어 위로 올라오게 */
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 28px;
}

/* ── 액자 + 아이콘 ───────────────────────────────────────── */
.profile-frame {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
}

.profile-frame-0  { border-color: #4b5563; }
.profile-frame-1  { border-color: var(--accent); box-shadow: 0 0 14px rgba(233,69,96,.5); }
.profile-frame-2  { border-color: #c084fc;  box-shadow: 0 0 14px rgba(192,132,252,.5); }
.profile-frame-3  { border-color: #22d3ee; box-shadow: 0 0 14px rgba(34,211,238,.55); }
.profile-frame-4  { border-color: #4ade80; box-shadow: 0 0 14px rgba(74,222,128,.55); }
.profile-frame-5  { border-color: #fb923c; box-shadow: 0 0 14px rgba(251,146,60,.55); }
.profile-frame-6  { border-color: #fbbf24; box-shadow: 0 0 14px rgba(251,191,36,.55); }
.profile-frame-7  { border-color: #f472b6; box-shadow: 0 0 14px rgba(244,114,182,.55); }
.profile-frame-8  { border-color: transparent; background: linear-gradient(var(--surface2),var(--surface2)) padding-box, linear-gradient(135deg,#e94560,#c084fc) border-box; box-shadow: 0 0 16px rgba(233,69,96,.45); }
.profile-frame-9  { border-color: transparent; background: linear-gradient(var(--surface2),var(--surface2)) padding-box, linear-gradient(135deg,#22d3ee,#4ade80) border-box; box-shadow: 0 0 16px rgba(34,211,238,.45); }
.profile-frame-10 { border-color: transparent; background: linear-gradient(var(--surface2),var(--surface2)) padding-box, linear-gradient(135deg,#fbbf24,#fb923c) border-box; box-shadow: 0 0 16px rgba(251,191,36,.45); }
.profile-frame-11 { border-color: #e94560; box-shadow: 0 0 0 3px rgba(233,69,96,.22), 0 0 14px rgba(233,69,96,.35); }
.profile-frame-12 { border-color: #fff; box-shadow: 0 0 20px rgba(255,255,255,.65), 0 0 8px rgba(255,255,255,.45); }

.profile-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #2e2e4d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}

.profile-icon-0::after { content: '👤'; }
.profile-icon-1::after { content: '⚔️'; }
.profile-icon-2::after { content: '👑'; }
.profile-icon-3::after { content: '🐉'; }
.profile-icon-4::after { content: '🔥'; }
.profile-icon-5::after { content: '🎮'; }
.profile-icon-6::after { content: '🌟'; }
.profile-icon-7::after { content: '🏆'; }

/* ── 레벨 배지 ───────────────────────────────────────────── */
.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  vertical-align: middle;
  margin-left: 8px;
}
.level-badge.tier-1  { background: rgba(120,120,130,.3); color: #9ca3af; }         /* Lv 1-4   */
.level-badge.tier-2  { background: rgba(59,130,246,.25); color: #93c5fd; }         /* Lv 5-9   */
.level-badge.tier-3  { background: rgba(139,92,246,.28); color: #c4b5fd; }         /* Lv 10-14 */
.level-badge.tier-4  { background: rgba(245,158,11,.25); color: #fcd34d; }         /* Lv 15-19 */
.level-badge.tier-5  { background: rgba(239,68,68,.25);  color: #fca5a5; }         /* Lv 20+   */

/* XP 진행 바 */
.xp-bar-wrap {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.xp-bar-track {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
  max-width: 200px;
}
.xp-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width .4s ease;
}
.xp-label {
  font-size: .68rem;
  color: rgba(255,255,255,.4);
  white-space: nowrap;
}

/* 포인트 표시 (본인만) */
.points-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: .78rem;
  color: rgba(255,255,255,.55);
}
.points-value {
  font-weight: 700;
  color: #fcd34d;
}

/* ── 텍스트 정보 (왼쪽 정렬) ────────────────────────────── */
.profile-info {
  flex: 1;
  text-align: left;
}

.profile-username {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: .02em;
}

.profile-bio {
  font-size: .9rem;
  color: rgba(255,255,255,.7);
  margin-bottom: 10px;
  word-break: break-word;
  max-width: 600px;
  line-height: 1.5;
}
.profile-bio.placeholder {
  font-style: italic;
  color: rgba(255,255,255,.35);
}

.profile-since {
  font-size: .75rem;
  color: rgba(255,255,255,.4);
}

/* 편집 버튼: 카드 오른쪽 끝 */
.profile-edit-btn {
  flex-shrink: 0;
  align-self: flex-start;
}

/* ── 스티커 레이어 ───────────────────────────────────────── */
.sticker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.sticker {
  position: absolute;
  width: 32px;
  height: 32px;
  font-size: 1.6rem;
  transform: translate(-50%, -50%);
}

.sticker-0::after  { content: '⭐'; }
.sticker-1::after  { content: '💎'; }
.sticker-2::after  { content: '🏆'; }
.sticker-3::after  { content: '🎯'; }

/* ── 하단: 전적 + 이력 나란히 ───────────────────────────── */
.profile-bottom {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 700px) {
  .profile-bottom { grid-template-columns: 1fr; }
  .profile-card-body { flex-wrap: wrap; }
}

/* ── 전적 카드 / 이력 카드 ───────────────────────────────── */
.stats-card,
.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stats-title {
  font-size: .82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.stats-row {
  display: flex;
  text-align: center;
  margin-bottom: 14px;
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }

.stat-num { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-lbl { font-size: .75rem; color: var(--text-muted); }

.stat-item.win  .stat-num { color: #4caf7d; }
.stat-item.loss .stat-num { color: var(--accent); }
.stat-item.draw .stat-num { color: #c084fc; }
.stat-item.rate .stat-num { color: var(--text); }

.win-bar-wrap {
  height: 6px;
  border-radius: 99px;
  background: rgba(233,69,96,.2);
  overflow: hidden;
}
.win-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: #4caf7d;
  transition: width .4s ease;
}

/* ── 대전 이력 테이블 ─────────────────────────────────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.history-table th {
  text-align: left;
  padding: 6px 10px;
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.history-table tr:last-child td { border-bottom: none; }

.history-date { color: var(--text-muted); font-size: .8rem; }

.result-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .8rem;
  font-weight: 700;
}
.result-badge.win  { background: rgba(76,175,125,.2);  color: #4caf7d; }
.result-badge.loss { background: rgba(233,69,96,.2);   color: var(--accent); }
.result-badge.draw { background: rgba(192,132,252,.2); color: #c084fc; }

.empty-history {
  color: var(--text-muted);
  font-size: .88rem;
  text-align: center;
  padding: 20px 0;
}

/* ── 프로필 편집 페이지 ───────────────────────────────────── */
.edit-layout {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.edit-layout > h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.edit-preview {
  opacity: .9;
}
.edit-preview .profile-card-inner {
  padding: 24px 28px;
  min-height: 120px;
}

.edit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.edit-section-title {
  font-size: .82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.edit-bio {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
}
.edit-bio:focus { outline: none; border-color: var(--accent); }
.bio-counter { font-size: .75rem; color: var(--text-muted); text-align: right; margin-top: 4px; }

/* ── 옵션 그리드 ─────────────────────────────────────────── */
.picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.picker-item {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.picker-item input[type="radio"] { display: none; }

.picker-swatch {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  transition: border-color .15s, box-shadow .15s;
}

.picker-item input[type="radio"]:checked ~ .picker-swatch {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.picker-swatch .profile-icon {
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  background: transparent;
  border-radius: 0;
}

.picker-label {
  font-size: .72rem;
  color: var(--text-muted);
}

/* Frame picker swatches */
.picker-frame-swatch {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  transition: box-shadow .15s;
}
.picker-item input[type="radio"]:checked ~ .picker-frame-swatch {
  box-shadow: 0 0 0 2px var(--accent);
}

/* BG picker swatches */
.picker-bg-swatch {
  width: 80px;
  height: 48px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  transition: border-color .15s, box-shadow .15s;
}
.picker-item input[type="radio"]:checked ~ .picker-bg-swatch {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.picker-item:has(input[type="radio"]:checked) .picker-label {
  color: var(--accent);
}

.edit-actions {
  display: flex;
  gap: 10px;
}

@media (max-width: 600px) {
  .picker-grid { gap: 8px; }
  .picker-swatch { width: 52px; height: 52px; }
}
