/* ── PLAYER PROFILE MODAL ── */
#playerProfileOverlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(4,4,12,0.92);
  backdrop-filter: blur(20px);
  z-index: 800;
  overflow-y: auto;
  padding: 74px 16px 60px;
}
#playerProfileOverlay.open { display: block; }

.profile-wrap {
  max-width: 780px;
  margin: 0 auto;
  animation: fadeUp 0.3s ease;
}

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 28px 28px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  border-bottom: none;
  flex-wrap: wrap;
}

.profile-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.8em;
  letter-spacing: 2px;
  flex-shrink: 0;
  border: 2px solid;
}

.profile-id-chip {
  font-size: 11px; font-weight: 800; letter-spacing: 3px;
  padding: 3px 10px; border-radius: 20px; margin-bottom: 6px;
  display: inline-block;
}

.profile-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2em, 6vw, 3.2em);
  letter-spacing: 4px;
  line-height: 1;
  margin-bottom: 6px;
}

.profile-meta-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.profile-meta-chip {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  padding: 4px 11px; border-radius: 20px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2);
}

/* Stats bar — win-rate hero + a compact tile grid for the rest */
.profile-stats-bar {
  display: block;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top: none; border-bottom: none;
}
.pd-statbar { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: stretch; }
.pd-stat-hero {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  min-width: 116px; padding: 10px 22px; border-radius: 14px;
  background: linear-gradient(160deg, rgba(240,192,64,0.14), rgba(240,192,64,0.03));
  border: 1px solid rgba(240,192,64,0.3);
}
.pd-stat-hero .v { font-family: 'Bebas Neue', sans-serif; font-size: 3.1em; line-height: 0.82; letter-spacing: 1px; }
.pd-stat-hero .l { font-size: 10px; font-weight: 800; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; margin-top: 6px; }
.pd-stat-hero .sub { font-size: 9px; color: var(--muted2); margin-top: 2px; letter-spacing: 0.5px; }
.pd-stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pd-stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 6px; text-align: center;
  display: flex; flex-direction: column; justify-content: center;
}
.pd-stat-tile .v { font-family: 'Bebas Neue', sans-serif; font-size: 1.55em; line-height: 1; letter-spacing: 0.5px; }
.pd-stat-tile .l { font-size: 8.5px; font-weight: 800; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin-top: 3px; }
@media (max-width: 520px) {
  .pd-statbar { grid-template-columns: 1fr; }
  .pd-stat-hero { padding: 12px; }
}

/* Body */
.profile-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 18px 18px;
  padding: 24px 28px;
}

.profile-section-title {
  font-size: 10px; font-weight: 800; letter-spacing: 3px;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: 12px; margin-top: 24px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.profile-section-title:first-child { margin-top: 0; }

/* ── Identity chips (เพศ / มือถนัด / ตำแหน่ง) ── */
.pd-identity { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-identity:not(:empty) { margin-bottom: 4px; }
.pd-chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  padding: 7px 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
}
.pd-chip-lbl { font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--muted); }
.pd-chip b { color: var(--text); font-weight: 700; }

/* ── Scout notes (free text written by the desk) ── */
.pd-notes { display: grid; gap: 10px; }
.pd-note {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border2);
  border-radius: 10px;
  padding: 11px 14px;
  background: rgba(255,255,255,0.015);
}
.pd-note-title {
  font-size: 10px; font-weight: 800; letter-spacing: 1.5px;
  text-transform: uppercase; margin-bottom: 5px;
}
.pd-note-text { font-size: 13px; line-height: 1.75; color: var(--text2); white-space: pre-wrap; }
.pd-note-good { border-left-color: var(--green); }
.pd-note-good .pd-note-title { color: var(--green); }
.pd-note-bad { border-left-color: var(--danger); }
.pd-note-bad .pd-note-title { color: var(--danger); }
.pd-note-note { border-left-color: var(--gold); }
.pd-note-note .pd-note-title { color: var(--gold); }

@media (min-width: 700px) {
  .pd-notes { grid-template-columns: 1fr 1fr; }
  .pd-note-note { grid-column: 1 / -1; }
}

/* Edit fields */
.profile-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.profile-field { display: flex; flex-direction: column; gap: 5px; }
.profile-field label {
  font-size: 10px; font-weight: 700; letter-spacing: 2px;
  color: var(--muted); text-transform: uppercase;
}
.profile-field input, .profile-field select, .profile-field textarea {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: 'Space Grotesk', sans-serif; font-size: 13px;
  font-weight: 600; padding: 9px 12px; outline: none;
  transition: border-color 0.18s;
  resize: vertical;
}
.profile-field input:focus, .profile-field select:focus, .profile-field textarea:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,200,66,0.08);
}
.profile-field textarea { min-height: 72px; }

/* Match history rows */
.profile-match-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  flex-wrap: wrap;
  transition: border-color 0.15s;
}
.profile-match-row:hover { border-color: var(--border2); }
.profile-match-id { font-family:'Bebas Neue',sans-serif; font-size:1.1em; letter-spacing:2px; color:var(--gold); flex-shrink:0; min-width:42px; }
.profile-match-result { font-size:11px; font-weight:800; padding:3px 9px; border-radius:6px; flex-shrink:0; }
.profile-match-vs { font-size:13px; font-weight:600; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.profile-match-score { font-family:'Bebas Neue',sans-serif; font-size:1.1em; letter-spacing:1px; flex-shrink:0; }
.profile-match-tags { display:flex; gap:4px; flex-wrap:wrap; width:100%; margin-top:4px; }

/* Achievement tags display */
.profile-tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; }

/* Close btn */
.profile-close-btn {
  position: fixed; top: 20px; right: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text2); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s; z-index: 10;
}
.profile-close-btn:hover { background: var(--surface3); color: var(--text); }

/* Save profile btn */
.profile-save-row {
  display: flex; gap: 10px; margin-top: 20px;
  padding-top: 16px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* Clickable player row in admin table */
.player-row-clickable { cursor: pointer; }
.player-row-clickable:hover td { background: rgba(245,200,66,0.04); }

@media (max-width: 600px) {
  #playerProfileOverlay { padding-top: 60px; }
  .profile-header { padding: 20px 16px 16px; gap: 14px; }
  .pd-avatar-wrap .pav { --pav-size: 84px !important; }
  .profile-body { padding: 18px 16px; }
  .profile-close-btn { top: 12px; right: 12px; }
}


/* ── Photo controls in the profile header ── */
.pd-avatar-wrap { position: relative; flex-shrink: 0; }
.pd-avatar-btn {
  position: absolute;
  right: 0; bottom: 2px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--gold);
  color: #14140c;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.pd-avatar-btn:hover { transform: scale(1.1); }
.pd-admin-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pd-admin-row .btn { font-size: 12px; padding: 5px 11px; }

/* ── Match history: partner + opponents ── */
.profile-match-pair { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pmr-line { display: flex; align-items: center; gap: 5px; font-size: 12.5px; min-width: 0; }
.pmr-line b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmr-lbl {
  font-size: 9.5px; font-weight: 800; letter-spacing: 1px;
  color: var(--muted); text-transform: uppercase;
  flex-shrink: 0; min-width: 34px;
}

/* ── Play-style chips in read mode ── */
.pd-chip-style {
  background: rgba(168,85,247,0.1);
  border-color: rgba(168,85,247,0.28);
  color: #c084fc;
  font-weight: 700;
  font-size: 12px;
}

/* ── Style picker in edit mode ── */
.pd-style-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 7px;
  margin-top: 4px;
}
.pd-style-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s;
  user-select: none;
}
.pd-style-opt:hover { border-color: var(--border2); }
.pd-style-opt input { accent-color: var(--gold); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
.pd-style-opt.on {
  background: rgba(245,200,66,0.08);
  border-color: rgba(245,200,66,0.3);
  color: var(--gold);
}

/* ── Edit-mode note fields ── */
.pd-edit-notes { display: grid; gap: 12px; margin-top: 16px; }
.pd-edit-notes textarea { min-height: 84px; }
@media (min-width: 700px) {
  .pd-edit-notes { grid-template-columns: 1fr 1fr; }
  .pd-edit-notes .profile-field:last-child { grid-column: 1 / -1; }
}

/* On a phone the id + result + score already fill the line, so the
   partner/opponent names get their own full-width row instead of
   being ellipsised down to a few characters. */
@media (max-width: 600px) {
  .profile-match-row { row-gap: 6px; }
  .profile-match-pair { flex-basis: 100%; order: 3; }
  .profile-match-score { margin-left: auto; }
  .pmr-line { font-size: 13px; }
}

/* ── Career: totals + one row per season ── */
.pd-career-tot {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.pd-career-tot > div {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 6px;
  text-align: center;
}
.pd-career-tot b {
  display: block;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pd-career-tot span {
  font-size: 8.5px; font-weight: 800; letter-spacing: 1.3px;
  color: var(--muted); text-transform: uppercase;
}
.pd-career-note {
  font-size: 11.5px; color: var(--gold);
  background: rgba(245,200,66,0.07);
  border: 1px solid rgba(245,200,66,0.18);
  border-radius: 8px; padding: 7px 11px; margin-bottom: 10px;
}
.pd-career-list { display: flex; flex-direction: column; gap: 7px; }
.pd-career-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 10px;
  padding: 10px 13px;
}
.pd-career-row.is-current { background: rgba(245,200,66,0.05); }
.pdc-year {
  font-family: 'Bebas Neue', sans-serif; font-size: 1.35em; letter-spacing: 2px;
  color: var(--text); min-width: 58px; flex-shrink: 0;
}
.pdc-now {
  display: block; font-family: 'Space Grotesk', sans-serif;
  font-size: 8.5px; font-weight: 800; letter-spacing: 1px; color: var(--gold);
}
.pdc-team { font-size: 12.5px; font-weight: 700; min-width: 92px; flex-shrink: 0; }
.pdc-team span { display: block; font-size: 10px; font-weight: 600; color: var(--muted); }
.pdc-stats {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--text2); margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.pdc-stats .sep { color: var(--border2); }

/* ── Past-season match log ── */
.pd-past-season { margin-bottom: 14px; }
.pd-past-head {
  display: flex; align-items: baseline; gap: 9px;
  font-family: 'Bebas Neue', sans-serif; font-size: 1.2em; letter-spacing: 2px;
  color: var(--gold); margin-bottom: 7px;
}
.pd-past-head span {
  font-family: 'Space Grotesk', sans-serif; font-size: 10.5px;
  letter-spacing: 0; color: var(--muted); font-weight: 600;
}

@media (max-width: 600px) {
  .pdc-stats { margin-left: 0; width: 100%; }
  .pd-career-row { gap: 8px; }
}

/* ── Back button (labeled, top-left) ── */
.profile-back-btn {
  position: fixed;
  top: 20px; left: 20px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 16px 0 12px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.15s;
}
.profile-back-btn:hover { background: var(--surface3); color: var(--text); transform: translateX(-2px); }
.profile-back-btn:active { transform: scale(0.96); }

/* bigger photo sits taller than the id/name column on desktop; keep the
   header aligned to the top so the name still starts at the same line */
.pd-avatar-wrap .pav { --pav-size: 170px; }
.pd-avatar-click { line-height: 0; border-radius: 50%; }
.pd-avatar-click.zoomable { cursor: zoom-in; }
.pd-avatar-click.zoomable:hover .pav { border-color: var(--gold); }

@media (max-width: 600px) {
  .profile-back-btn { top: 12px; left: 12px; height: 36px; padding: 0 13px 0 10px; font-size: 13px; }
  .pd-avatar-wrap .pav { --pav-size: 124px !important; }
}

/* ══════════════════════════════════════════
   PHOTO LIGHTBOX + FOCAL-POINT ADJUSTER
   ══════════════════════════════════════════ */
.plb {
  display: none; position: fixed; inset: 0; z-index: 1200;
  background: rgba(4,4,12,0.93); backdrop-filter: blur(16px);
  align-items: center; justify-content: center; padding: 40px 20px;
}
.plb.open { display: flex; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.plb-close {
  position: fixed; top: 20px; right: 20px; width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text2);
  font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.plb-close:hover { background: var(--surface3); color: var(--text); }
.plb-box { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 100%; }
.plb-img {
  max-width: min(540px, 90vw); max-height: 72vh; border-radius: 18px; object-fit: contain;
  border: 1px solid var(--border2); box-shadow: 0 30px 80px rgba(0,0,0,.7);
}
.plb-name { font-family: 'Bebas Neue', sans-serif; font-size: 1.8em; letter-spacing: 2px; color: var(--text); text-align: center; }
.plb-meta { font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--muted); margin-top: 2px; text-align: center; }

/* adjuster sits above the open profile overlay (z 800) */
#photoAdjustModal { z-index: 1100; }
.padj-frame {
  width: 220px; height: 220px; margin: 4px auto 0; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--gold); position: relative; cursor: grab;
  box-shadow: 0 0 0 6px rgba(245,200,66,0.08); touch-action: none; user-select: none;
}
.padj-frame:active { cursor: grabbing; }
.padj-img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.padj-frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}

/* ══════════════════════════════════════════
   AWARDS SHOWCASE — medals on the profile (gold SVG star, English labels)
   ══════════════════════════════════════════ */
#pdAwards:empty { display: none; }
.award-star { display: block; }
/* compact horizontal medal chips (was big square cards + an oversized
   corner star on the avatar, both now gone) */
.pd-awards-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.pd-award-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 13px 8px 10px; border-radius: 12px;
  background: linear-gradient(150deg, rgba(240,192,64,0.12), rgba(240,192,64,0.02));
  border: 1px solid rgba(240,192,64,0.32);
}
.pd-award-star { line-height: 0; flex-shrink: 0; filter: drop-shadow(0 2px 6px rgba(240,192,64,0.35)); }
.pd-award-txt { display: flex; flex-direction: column; line-height: 1.15; }
.pd-award-title { font-family: 'Bebas Neue', sans-serif; font-size: 1rem; letter-spacing: 1px; color: var(--gold); }
.pd-award-sub { font-size: 0.64rem; color: var(--muted); font-weight: 600; }
