:root {
  --app-bg: #0b1016;
  --panel-bg: #121922;
  --panel-border: #263241;
  --panel-hover: #233142;
  --text-main: #edf2f7;
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  font-family: 'Malgun Gothic', '맑은 고딕', system-ui, -apple-system, Segoe UI,
    Roboto, sans-serif;
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--app-bg);
}

header {
  width: 100%;
  padding: 1px;
  background-color: #0a0f15;
  display: flex;
  justify-content: center;
  border-bottom: none;
}

.main-nav {
  position: sticky;
  top: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 45px;
  padding: 6px 0;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid #cfe8d6;
  box-shadow: 0 8px 24px rgba(22, 101, 52, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.main-nav ul {
  display: flex;
  gap: 14px;
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.main-nav ul li a {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-decoration: none;
  color: #14532d;
  font-weight: 900;
  font-size: 14px;
  line-height: 1;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform 0.18s ease, background-color 0.18s ease,
    color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.main-nav ul li a:hover {
  background-color: #17834d;
  color: #fff;
  border-color: #17834d;
  box-shadow: none;
  transform: none;
}

.main-nav ul li a.active {
  background: #17834d;
  color: #fff;
  border-color: #17834d;
  box-shadow: none;
}

@media (max-width: 480px) {
  .main-nav {
    padding: 6px 0;
  }
  .main-nav ul {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0 10px;
  }
  .main-nav ul li {
    flex: 0 0 auto;
  }
  .main-nav ul li a {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: #14532d;
    font-weight: 900;
  }
  .main-nav ul li a:hover {
    background-color: #17834d;
    color: #fff;
    border-color: #17834d;
    transform: none;
    box-shadow: none;
  }
  .main-nav ul::-webkit-scrollbar {
    display: none;
  }
}

/* Global nav lock: keep the top menu identical across pages. */
.main-nav {
  width: 100% !important;
  min-height: 45px !important;
  padding: 6px 0 !important;
  box-sizing: border-box !important;
}

.main-nav ul {
  width: min(100%, 560px) !important;
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 6px !important;
  margin: 0 auto !important;
  padding: 0 10px !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

.main-nav ul li {
  min-width: 0 !important;
}

.main-nav ul li a {
  width: 100% !important;
  min-height: 32px !important;
  padding: 6px 8px !important;
  border: 1px solid transparent !important;
  box-sizing: border-box !important;
  font-size: 13px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

@media (max-width: 480px) {
  .main-nav ul {
    width: 100% !important;
  }

  .main-nav ul li a {
    min-height: 30px !important;
    padding: 6px 5px !important;
    font-size: 11px !important;
  }
}

/* =====================================
   컨트롤바 상단 고정
   ===================================== */
#controlBar {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100vw;
  justify-content: center;
  align-items: center;
  padding: 6px 30px;
  background-color: var(--panel-bg);
  color: #fff;
  font-size: 14px;
  border-bottom: 1px solid var(--panel-border);
  margin: 0;
  top: 0px;
  box-sizing: border-box;
  z-index: 1000;
  gap: 8px;
  background-color: var(--panel-bg);
  box-sizing: border-box;
}

#controlBar .control-group.control-group-wide {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
}

#controlBar .control-hint {
  font-size: 12px;
  opacity: 0.9;
  white-space: nowrap;
}

#mobileControlContent select {
  width: 100%;
  min-width: 0;
}

#mobileFormationSelector {
  width: 100%;
}

#leagueSelector {
  min-width: 120px;
  max-width: 130px;
}

#fieldPresetSelect {
  min-width: 100px;
  max-width: 100px;
}

#formationSelector {
  min-width: 118px;
  max-width: 118px;
}

#teamSelector {
  min-width: 132px;
  max-width: 132px;
}

#teamSelector::placeholder {
  color: rgba(243, 247, 252, 0.9);
  font-weight: 700;
}

#loadFileBtn {
  min-width: 90px;
  max-width: 90px;
}

#controlBar .file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border: 1px solid #344457;
  border-radius: 4px;
  background-color: #1a2430;
  color: #f3f7fc;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

#controlBar .file-btn:hover {
  background-color: var(--panel-hover);
}

#controlBar button,
#controlBar select,
#controlBar input {
  padding: 4px 8px;
  border: 1px solid #344457;
  border-radius: 4px;
  background-color: #1a2430;
  color: #f3f7fc;
  font-size: 13px;
}

#controlBar button:hover,
#controlBar select:hover,
#controlBar input:hover {
  background-color: var(--panel-hover);
  cursor: pointer;
}

#resetBtn {
  background: linear-gradient(
    180deg,
    rgba(255, 90, 90, 0.3),
    rgba(180, 40, 40, 0.34)
  ) !important;
  border: 1px solid rgba(255, 120, 120, 0.48) !important;
  color: #fff !important;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.12),
    0 4px 14px rgba(0, 0, 0, 0.3);
}
#resetBtn:hover {
  background: linear-gradient(
    180deg,
    rgba(255, 102, 102, 0.36),
    rgba(196, 48, 48, 0.4)
  ) !important;
}

#controlBar .op-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

#controlBar .op-label {
  font-size: 11px;
  font-weight: 800;
  color: #b7c6d8;
  letter-spacing: 0;
  min-width: 52px;
  text-align: center;
}

/* 초기 렌더 플래시 방지: 구형 적용 버튼은 시작부터 숨김 */
#applyFormationA,
#applyFormationB,
#applyNameA,
#applyNameB,
#mobileApplyFormationA,
#mobileApplyFormationB,
#mobileApplyNameA,
#mobileApplyNameB {
  display: none !important;
}

#formationTarget,
#nameTarget {
  min-width: 56px;
  max-width: 64px;
}

.popup.hidden {
  display: none;
}

h1 {
  text-align: center;
  margin: 10px 0;
}

/* =====================================
   중앙 경기장 영역
   ===================================== */

.center {
  display: flex;
  gap: 0px;
  justify-content: center;
  flex-direction: row;
  align-items: flex-start;
  margin: 0;
}

/* =========================
   경기장 래퍼
   ========================= */
.field-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px;
  margin: 0;
}

.field-label {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

/* =========================
   경기장(필드) 기본 스타일
   ========================= */
.field {
  position: relative;
  background: radial-gradient(
      circle at 50% 30%,
      rgba(255, 255, 255, 0.08) 0%,
      rgba(255, 255, 255, 0.03) 35%,
      rgba(0, 0, 0, 0.25) 75%
    ),
    linear-gradient(
      to bottom,
      #102913 0%,
      #256b2c 35%,
      #1d451e 65%,
      #235026 100%
    );
  background-blend-mode: overlay;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid rgba(80, 180, 90, 0.25);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.08),
    inset 0 -2px 6px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  margin: 0;
  overflow: hidden;
}

#field-1,
#field-2 {
  width: 490px;
  height: 798px;
  position: relative;
}

/* =========================
   레이어 순서(핵심)
   1) (있다면) 잔디/필드이미지: z=1
   2) 라인: z=2
   3) 선수(슬롯/이미지): z=3+
   ========================= */

.field-image,
.grass-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.field-lines {
  position: absolute;
  top: 60px;
  bottom: 216px;
  left: 30px;
  right: 30px;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  border-radius: 18px;
}

.field-lines * {
  position: absolute;
  box-sizing: border-box;
  border-color: rgba(255, 255, 255, 0.85);
  z-index: 2;
}

.player-slot.field-slot,
.player-slot.sub-slot,
.player-slot.has-player {
  z-index: 3;
}

.player-box,
.player-img,
.player-name {
  position: relative;
  z-index: 4;
}

/* =========================
   라인 디테일
   ========================= */
.outline {
  inset: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 18px;
}

.center-line {
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.85);
}

.center-circle {
  width: 120px;
  height: 120px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.penalty {
  width: 40%;
  height: 18%;
  left: 50%;
  transform: translateX(-50%);
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.penalty.top {
  top: 0;
  border-top: none;
}

.penalty.bottom {
  bottom: 0;
  border-bottom: none;
}

.goal {
  width: 20%;
  height: 6%;
  left: 50%;
  transform: translateX(-50%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: transparent;
}

.goal.top {
  top: 0;
}

.goal.bottom {
  bottom: 0;
}

/* =====================================
   슬롯 공통 스타일
   ===================================== */

.player-box {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  pointer-events: none;
  overflow: hidden;
}

.player-name:empty {
  display: none;
}

.player-name:not(:empty) {
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18px;
  line-height: 18px;
  font-size: 11px;
  text-align: center;
  color: #fff;
  background: rgba(37, 36, 36, 0.846);
  pointer-events: none;
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}

.player-slot {
  position: absolute;
  width: 64px;
  height: 84px;
  border-radius: 8px;
  background-color: #fff;
  touch-action: manipulation;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 4px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.092);
  flex-shrink: 0;
  overflow: hidden;
}

.player-slot.selected {
  outline: 2px solid rgba(0, 190, 255, 1);
  outline-offset: 2px;
  box-shadow: 0 0 10px rgba(0, 190, 255, 0.9), 0 0 22px rgba(0, 190, 255, 0.7),
    0 0 36px rgba(0, 190, 255, 0.4);
  transform: translateY(-2px);
}

/* =====================================
   주전 슬롯
   ===================================== */
.player-slot.field-slot {
  width: 64px;
  height: 84px;
  margin: 4px;
  cursor: pointer;
}

.player-slot.field-slot .slot-label,
.player-slot.sub-slot .slot-label {
  position: absolute;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: rgba(201, 178, 178, 0.7);
  pointer-events: none;
}

/* =====================================
   서브 슬롯
   ===================================== */
.player-slot.sub {
  position: relative;
  width: 64px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.sub-slot-container {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 30px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 64px);
  grid-auto-rows: 84px;
  gap: 10px 22px;
  width: max-content;
  justify-content: center;
}

/* =====================================
   후보 슬롯
   ===================================== */
.player-slot.candidate-slot {
  width: 64px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.player-slot.candidate-slot .player-box {
  font-size: 12px;
  color: rgba(110, 96, 96, 0.7);
  font-weight: bold;
  text-align: center;
  line-height: 1.2;
  pointer-events: none;
}

/* =====================================
   후보 컬럼
   ===================================== */
.candidate-column {
  width: 360px;
  min-width: 100px;
  height: 740px;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start !important;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  box-sizing: border-box;
  background-color: rgba(22, 31, 43, 0.94);
  border: 1px solid #3a4c61;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 4px 10px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a6078 #182332;
}

.candidate-column::-webkit-scrollbar {
  width: 10px;
}

.candidate-column::-webkit-scrollbar-track {
  background: #182332;
  border-radius: 999px;
}

.candidate-column::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #58708a, #445a72);
  border-radius: 999px;
  border: 2px solid #182332;
}

.candidate-column::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #6a86a3, #4f6883);
}

/* =========================
   후보 팀 이름 라벨
   ========================= */
.team-box h3,
.team-name {
  width: 100%;
  height: 30px;
  line-height: 30px;
  text-align: center;
  background-color: #16212d;
  color: #b8c5d4;
  border-radius: 8px;
  margin: 0 0 5px 0;
  margin-bottom: 2px !important;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.team-name {
  width: 100%;
  text-align: center;
  background-color: #16212d;
  color: #fff;
  font-weight: bold;
  font-size: 90px;
  padding: 5px 0;
  border-radius: 4px;
  box-sizing: border-box;
}

.team-box {
  width: 100%;
  height: 400px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--team-accent-bg, #172330) 30%, #141e29),
    #141e29
  );
  border: 1px solid
    color-mix(in srgb, var(--team-accent-border, #3a4d62) 65%, #2f3f52);
  border-radius: 8px;
  padding: 4px;
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-content: flex-start;
  gap: 5px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a6078 #162230;
}

.team-box::-webkit-scrollbar {
  width: 8px;
}

.team-box::-webkit-scrollbar-track {
  background: #162230;
  border-radius: 999px;
}

.team-box::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #58708a, #445a72);
  border-radius: 999px;
  border: 1px solid #162230;
}

.team-box::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #6a86a3, #4f6883);
}

.team-title {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--team-accent-bg, #172330);
  color: var(--team-accent-text, #fff);
  border: 1px solid var(--team-accent-border, #3a4d62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 6px rgba(0, 0, 0, 0.2);
  font-weight: bold;
  font-size: clamp(12px, 3vw, 18px);
  border-radius: 4px;
  box-sizing: border-box;
  padding: 0 6px;
  cursor: pointer;
  position: relative;
}

.team-title-label {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 22px 0 2px;
}

.team-move-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.team-move-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* =====================================
   main-content (후보 + 경기장)
   ===================================== */
.main-content {
  display: flex;
  flex-direction: row;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  padding-top: 0 !important;
  width: 100%;
  box-sizing: border-box;
  background: linear-gradient(180deg, #0a0f15 0%, #0d131b 58%, #0f1620 100%);
  margin: 0 auto;
}

.candidate-mobile-wrapper {
  left: 0;
  width: 100%;
  height: 140px;
  background: #0f161f;
  border-top: 1px solid #2e3f52;
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 8px;
  overflow-x: auto;
}

/* =========================
   PC 후보군: 이미지 위 + 이름 아래
   ========================= */

.candidate-column .player-box,
.team-box .player-box {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch;
}

.candidate-column .player-img,
.team-box .player-img {
  width: 100%;
  height: auto;
  display: block;
}

.candidate-column .player-name,
.team-box .player-name {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================
   Compact mode: side has 4+ teams (e.g., 골때녀 8팀)
   - keep within field height, no outer scrollbar
   ========================================================= */
.candidate-column.auto-team-layout {
  height: 798px;
  overflow: hidden;
  gap: 2px;
  padding: 4px;
  margin-top: 0;
}

.candidate-column.auto-team-layout .team-title {
  height: 20px;
  min-height: 20px;
  font-size: 11px;
  line-height: 20px;
  margin-bottom: 0 !important;
  border-radius: 6px;
}

.candidate-column.auto-team-layout .team-title-label {
  padding-right: 18px;
}

.candidate-column.auto-team-layout .team-move-btn {
  width: 16px;
  height: 16px;
  font-size: 10px;
  right: 4px;
}

.candidate-column.auto-team-layout .team-box {
  padding: 0;
  gap: 4px;
  display: grid;
  grid-template-columns: repeat(4, 64px);
  grid-auto-rows: 84px;
  justify-content: center;
  align-content: start;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 미세 오버플로우(1~2px)로 스크롤바 생기는 것 방지 */
.candidate-column.auto-team-layout .team-box .player-slot {
  margin: 0 !important;
}

.candidate-column.auto-team-layout.teams-per-side-4 .team-box {
  height: 172px;
  min-height: 172px;
  overflow-y: hidden;
}

.candidate-column.auto-team-layout.teams-per-side-2 .team-box {
  height: 360px;
  min-height: 360px;
}

@media (orientation: landscape) and (max-width: 900px) {
  .center {
    width: 100%;
    max-width: 100vw;
    display: flex;
    flex-direction: row;
    gap: 0;
    justify-content: center;
    overflow-x: hidden;
    scroll-snap-type: none;
    -webkit-overflow-scrolling: auto;
    padding: 0;
    margin: 0;
  }
  #field-wrapper-1,
  #field-wrapper-2 {
    width: 50vw !important;
    min-width: 50vw !important;
    max-width: 50vw !important;
    box-sizing: border-box;
    padding: 0;
    margin: 0 !important;
    scroll-snap-align: none;
    height: 92vh;
  }
  #field-1,
  #field-2 {
    width: 48vw !important;
    height: 165vh !important;
    margin: 0 auto !important;
    position: relative;
  }
  .field {
    width: 100% !important;
    min-width: 0 !important;
    position: relative;
  }
  .field-lines {
    top: 40px;
    bottom: 130px;
    left: 18px;
    right: 18px;
  }
  .sub-slot-container {
    bottom: 16px !important;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(50vw - 16px);
  }
}

@media (max-width: 768px) {
  .sub-slot-container {
    bottom: 25px;
    grid-template-columns: repeat(5, 40px);
    grid-auto-rows: 56px;
    gap: 8px 16px;
    width: max-content;
    max-width: calc(100vw - 16px);
    margin-left: 0px;
  }
}

/* =========================
   모바일 하단 후보 패널
========================= */
@media (max-width: 768px) {
  .pc-only {
    display: none;
  }
}

@media (max-width: 768px) {
  .mobile-candidate-scroll {
    display: flex;
    width: max-content;
  }
  .mobile-team-box {
    flex: 0 0 auto;
    min-width: 160px;
  }
  .mobile-team-box h3 {
    font-size: 14px;
    margin: 4px 0;
    text-align: center;
  }
  .center {
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    gap: 0px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    justify-content: flex-start;
  }
  #field-wrapper-1,
  #field-wrapper-2 {
    width: 100%;
    min-width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    padding: 0;
    margin: 0 !important;
    margin-left: 0;
    scroll-snap-align: start;
    height: auto;
    min-height: calc(74vh + 50px);
  }
  .field-container {
    height: calc(100vh - 120px);
  }
  .field {
    width: 100%;
    min-width: 100%;
  }
  #field-1,
  #field-2 {
    width: 100vw;
    height: 74vh;
    margin: 0 auto;
    position: relative;
  }
  .candidate-column {
    display: none !important;
  }
}

/* =========================
   모바일: 경기장 2개 크기 조절
   ========================= */
@media (max-width: 768px) {
  .field-image {
    position: absolute;
    top: 70px;
    bottom: 30px;
    left: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    border-radius: 18px;
    overflow: hidden;
  }
  .field-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
  }
  .field-lines {
    position: absolute;
    top: 48px;
    bottom: 146px;
    left: 30px;
    right: 30px;
    z-index: 1;
    pointer-events: none;
    border-radius: 18px;
    overflow: hidden;
  }
  .field-lines * {
    position: absolute;
    box-sizing: border-box;
    border-color: rgba(255, 255, 255, 0.85);
    z-index: 1;
  }
  .grass-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: 0;
    border-radius: 18px;
  }
  .field .grass-layer {
    top: 00px;
    left: 20px;
    right: 20px;
    bottom: 0px;
    border-radius: 12px;
  }
  .outline {
    inset: 0;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 18px;
  }
  .center-line {
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.85);
  }
  .center-circle {
    width: 120px;
    height: 120px;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .penalty {
    width: 40%;
    height: 18%;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid rgba(255, 255, 255, 0.85);
  }
  .penalty.top {
    top: 0;
    border-top: none;
  }
  .penalty.bottom {
    bottom: 0;
    border-bottom: none;
  }
  .goal {
    width: 20%;
    height: 6%;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: transparent;
  }
  .goal.top {
    top: 0;
  }
  .goal.bottom {
    bottom: 0;
  }
}

@media (max-width: 768px) {
  .player-slot {
    position: relative;
    width: 40px !important;
    height: 56px !important;
    min-width: 40px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .player-box {
    width: 100%;
    height: 100%;
  }
}

@media (min-width: 481px) and (max-width: 1024px) {
  #candidate-mobile {
    display: flex !important;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    padding: 10px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 12px;
  }
}

@media (max-width: 768px) {
  #candidate-mobile {
    display: flex !important;
    height: auto !important;
    padding: 8px 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }
  #candidate-mobile .mobile-team-box {
    width: 47.8%;
    background-color: #ffffff;
    border: 2px solid #d2d0d0;
    border-radius: 8px;
    padding: 5px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  #candidate-mobile .mobile-team-title {
    width: 100%;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: #272626;
    color: #fff;
    font-weight: bold;
    font-size: clamp(12px, 3vw, 18px);
    line-height: 1;
    border-radius: 4px;
    box-sizing: border-box;
    padding: 0 6px;
    pointer-events: auto;
    z-index: 3;
  }
  #candidate-mobile .mobile-team-title-label {
    display: block;
    max-width: calc(100% - 28px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    pointer-events: none;
  }
  #candidate-mobile .mobile-team-title-menu {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 2;
    cursor: pointer;
    touch-action: manipulation;
  }
  #candidate-mobile .mobile-team-players {
    width: 100%;
    height: 220px;
    background: #fff;
    border: 2px solid #aaa;
    border-radius: 8px;
    padding: 4px;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
    gap: 1px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .player-slot .player-name {
    height: 16px;
    font-size: 8px;
  }
  .field-label {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
  }
}

.player-slot.sub .slot-label {
  color: rgba(200, 200, 200, 0.85);
  font-weight: 500;
}

.player-slot.sub .player-box {
  color: rgba(200, 200, 200, 0.8);
  text-align: center;
}

.mobile-only {
  display: none !important;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block !important;
  }
}

@media (max-width: 900px) {
  #controlBar {
    display: none;
  }
}

.formation-label {
  position: absolute;
  top: 36px;
  left: 49px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .formation-label {
    top: 28px;
    left: 40px;
    font-size: 12px;
  }
}

/* =========================
   League Team Select Modal
========================= */

#modePopup {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: none;
  align-items: center;
  justify-content: center;
}

#modePopup::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

#modePopup .setting-section {
  position: relative;
  background: #111;
  color: #fff;
  width: min(92vw, 420px);
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 16px;
  padding: 18px 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#modePopup h3 {
  margin: 0;
  font-size: 18px;
  text-align: center;
}

#modePopup #closePopup {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: #333;
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

#teamChecklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: 4px;
}

#applyLeagueTeamsBtn {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: #4da3ff;
  color: #000;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 520px) {
  #modePopup .setting-section {
    width: 94vw;
    max-height: 85vh;
  }
}

.row-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

#mobileTeamSelectBtn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
}

.triple-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#mobileLeagueSelector {
  flex: 1.2;
  min-width: 0;
}

#mobileFieldPresetSelect {
  flex: 1;
  min-width: 90px;
  margin-top: 6px;
}

/* =========================================================
   Candidate slots (Team box / Candidate column / Mobile panel)
   - consolidated from style.css (bottom-wins)
   ========================================================= */

.team-box .player-slot,
.candidate-column .player-slot,
#candidate-mobile .mobile-team-players .player-slot {
  width: 64px;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.092);
}

.team-box .player-box,
.candidate-column .player-box,
#candidate-mobile .mobile-team-players .player-box {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch;
  overflow: hidden;
}

.team-box .player-img,
.candidate-column .player-img,
#candidate-mobile .mobile-team-players .player-img,
.team-box .player-slot img,
.candidate-column .player-slot img,
#candidate-mobile .mobile-team-players .player-slot img {
  width: 100% !important;
  height: auto !important;
  object-fit: contain !important;
  display: block;
  border-radius: 8px;
}

.team-box .player-slot {
  background: #ffffff;
}

.team-box .player-name:empty,
.candidate-column .player-name:empty,
#candidate-mobile .mobile-team-players .player-name:empty {
  display: none;
}

.team-box .player-name:not(:empty),
.candidate-column .player-name:not(:empty),
#candidate-mobile .mobile-team-players .player-name:not(:empty) {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  line-height: 18px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(37, 36, 36, 0.846);
  color: #fff;
  border-radius: 0 0 6px 6px;
  pointer-events: none;
}

.team-box .player-img,
.candidate-column .player-img,
#candidate-mobile .mobile-team-players .player-img {
  z-index: 0;
}

.team-box .player-name,
.candidate-column .player-name,
#candidate-mobile .mobile-team-players .player-name {
  z-index: 2;
}

/* =========================================================
   Mobile (<=768px): 후보 슬롯도 40x56으로 축소 + 라운드/폰트 보정
   ========================================================= */
@media (max-width: 768px) {
  #candidate-mobile .mobile-team-players {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-rows: 56px !important;
    justify-items: center !important;
    align-content: start !important;
    column-gap: 2px !important;
    row-gap: 2px !important;
    padding: 3px !important;
  }

  .team-box .player-slot,
  .candidate-column .player-slot,
  #candidate-mobile .mobile-team-players .player-slot {
    width: 40px !important;
    height: 56px !important;
    min-width: 40px;
    margin: 0 !important;
    border-radius: 6px;
  }
  .team-box .player-img,
  .candidate-column .player-img,
  #candidate-mobile .mobile-team-players .player-img,
  .team-box .player-slot img,
  .candidate-column .player-slot img,
  #candidate-mobile .mobile-team-players .player-slot img {
    border-radius: 6px;
  }
  .team-box .player-name:not(:empty),
  .candidate-column .player-name:not(:empty),
  #candidate-mobile .mobile-team-players .player-name:not(:empty) {
    height: 14px;
    line-height: 14px;
    font-size: 8px;
    border-radius: 0 0 6px 6px;
  }
}

/* =========================================================
   FORCE: field/sub slots use contain + full fill
   AND: background white only when image exists
   (paste at very bottom of style.css)
   ========================================================= */

.player-slot.field-slot:has(img.player-img),
.player-slot.field-slot:has(img),
.player-slot.sub:has(img.player-img),
.player-slot.sub:has(img),
.player-slot.sub-slot:has(img.player-img),
.player-slot.sub-slot:has(img) {
  background: rgba(30, 32, 31, 0.55);
  border-radius: 8px;
  border: none !important;
}

.player-slot.field-slot .player-img,
.player-slot.sub .player-img,
.player-slot.sub-slot .player-img,
.player-slot.field-slot img,
.player-slot.sub img,
.player-slot.sub-slot img {
  width: 100% !important;
  height: auto !important;
  object-fit: contain !important;
  object-position: center center !important;
  display: block !important;
  border-radius: 8px;
}

@media (max-width: 768px) {
  .player-slot.field-slot .player-img,
  .player-slot.sub .player-img,
  .player-slot.sub-slot .player-img,
  .player-slot.field-slot img,
  .player-slot.sub img,
  .player-slot.sub-slot img {
    border-radius: 6px;
  }
}

/* =========================
   MOBILE OPTIONS (CLEAN)
   - IDs used:
     #mobileOptionsBtn
     #mobileOptionsPopup
     #mobileControlContent
     #closeMobileOptions
     #mobileOpenSettingsBtn
   - JS toggles .hidden on #mobileOptionsPopup
   ========================= */

@media (min-width: 901px) {
  #mobileOptionsBtn,
  #mobileOptionsPopup,
  #mobileControlContent {
    display: none !important;
  }
}

@media (max-width: 900px) {
  /* =========================
     1) HAMBURGER (floating)
     ========================= */
  #mobileOptionsBtn {
    display: grid !important;
    position: fixed;
    left: 0px;
    top: 28px;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 12px;
    background: rgba(14, 14, 16, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
    color: #fff;
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
    padding: 0;
    z-index: 20000;
  }
  #mobileOptionsBtn:active {
    transform: translateY(1px);
  }
  #mobileOptionsBtn.hidden {
    display: none !important;
  }
  /* =========================
     2) OVERLAY
     ========================= */
  #mobileOptionsPopup {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.18s ease, visibility 0.18s ease;
  }
  #mobileOptionsPopup.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  /* =========================
     3) DRAWER PANEL (3-zone layout)
     - header (top, sticky)
     - body (scrollable, centered spacing)
     - actions/footer (bottom sticky)
     ========================= */
  #mobileControlContent {
    position: absolute;
    left: 0;
    top: 0;
    height: 100vh;
    width: min(88vw, 380px);
    background: linear-gradient(
      180deg,
      rgba(18, 18, 20, 0.96),
      rgba(12, 12, 14, 0.94)
    );
    color: #fff;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 22px 0 60px rgba(0, 0, 0, 0.55);
    padding: 12px;
    transform: translateX(0);
    transition: transform 0.22s ease;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
    overflow: hidden;
  }
  #mobileOptionsPopup.hidden #mobileControlContent {
    transform: translateX(-102%);
  }
  /* =========================
     4) HEADER (top)
     ========================= */
  #mobileControlContent .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  #closeMobileOptions {
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    padding: 0 12px;
  }
  #closeMobileOptions:active {
    transform: translateY(1px);
  }
  /* =========================
     5) BODY (middle, scroll)
     - body 안에서 “섹션 카드” 느낌으로 배분
     ========================= */
  #mobileControlContent .drawer-body {
    overflow: auto;
    padding: 2px 2px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
  }
  #mobileControlContent .drawer-body::-webkit-scrollbar {
    width: 8px;
  }
  #mobileControlContent .drawer-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
  }
  #mobileControlContent .mobile-setting-block {
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  #mobileControlContent .drawer-actions {
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  #mobileControlContent .triple-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: center;
  }
  /* =========================
     6) FORM CONTROLS
     ========================= */
  #mobileControlContent select,
  #mobileControlContent input[type='text'],
  #mobileControlContent input[type='number'] {
    height: 40px;
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
  }
  #mobileControlContent input[type='file'] {
    width: 100%;
    height: auto !important;
    color: rgba(255, 255, 255, 0.88);
    font-size: 13px;
  }
  #mobileControlContent label {
    display: block;
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.2px;
  }
  /* =========================
     7) BUTTONS
     ========================= */
  #mobileControlContent button {
    height: 40px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 900;
    font-size: 13px;
    padding: 0 12px;
    margin: 0;
    box-shadow: none;
    min-width: 0;
  }
  #mobileControlContent button:active {
    transform: translateY(1px);
  }
  #mobileOpenSettingsBtn {
    background: rgba(37, 99, 235, 0.9) !important;
    border-color: rgba(37, 99, 235, 0.55) !important;
  }
  #mobileShareBtn {
    background: rgba(16, 185, 129, 0.22);
    border-color: rgba(16, 185, 129, 0.32);
  }
  #mobileResetBtn {
    background: linear-gradient(
      180deg,
      rgba(255, 90, 90, 0.32),
      rgba(180, 40, 40, 0.38)
    ) !important;
    border: 1px solid rgba(255, 120, 120, 0.45) !important;
    color: #fff !important;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.12),
      0 4px 14px rgba(0, 0, 0, 0.35);
    position: absolute !important;
    top: 10px !important;
    right: 56px !important;
    height: 34px !important;
    padding: 0 10px !important;
    border-radius: 9px !important;
    font-weight: 900;
    font-size: 11px;
    width: auto !important;
    min-width: 0 !important;
    grid-column: auto;
    z-index: 4;
  }
  #mobileResetBtn:active {
    transform: translateY(1px) scale(0.98);
  }
  /* =========================
     8) OPTIONAL: backdrop click area
     ========================= */
  #mobileOptionsPopup .drawer-backdrop {
    position: absolute;
    inset: 0;
  }
  #mobileTeamSelector {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.12),
      rgba(255, 255, 255, 0.05)
    ) !important;
    border: 0 !important;
    outline: none !important;
    color: #fff !important;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.06),
      0 2px 8px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(2px);
  }
  #mobileTeamSelector::placeholder {
    color: rgba(255, 255, 255, 0.55);
    font-weight: 600;
  }
}

/* =========================
   ADD: Tablet + Landscape tuning (MOBILE OPTIONS)
   - 기존 스타일은 그대로 두고 "추가"만 하세요
   ========================= */

@media (min-width: 901px) and (max-width: 1200px) {
  #mobileOptionsBtn,
  #mobileOptionsPopup,
  #mobileControlContent {
    display: unset !important;
  }
  #mobileOptionsBtn {
    display: grid !important;
    top: 18px;
    left: 10px;
  }
  #mobileControlContent {
    width: min(56vw, 420px);
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  #mobileControlContent {
    width: min(78vw, 560px);
    padding: 10px;
    gap: 8px;
    overflow: auto;
  }
  #mobileControlContent .drawer-header {
    padding: 8px 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  #closeMobileOptions {
    min-height: 32px;
    height: auto;
    border-radius: 11px;
    font-size: 12px;
    padding: 6px 10px;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 122, 122, 0.68) !important;
    background: linear-gradient(
      180deg,
      rgba(255, 92, 92, 0.95),
      rgba(210, 44, 44, 0.95)
    ) !important;
    color: #fff !important;
    font-weight: 800;
  }
  #mobileControlContent .drawer-guide-btn {
    min-height: 34px;
    height: auto;
    border-radius: 11px;
    font-size: 12px;
    padding: 6px 11px;
    flex: 1 1 auto;
    width: 100% !important;
    border: 1px solid rgba(94, 169, 255, 0.6) !important;
    background: linear-gradient(
      180deg,
      rgba(45, 115, 220, 0.92),
      rgba(28, 82, 176, 0.92)
    ) !important;
    color: #fff !important;
    font-weight: 800;
  }
  #mobileControlContent .drawer-body {
    gap: 8px;
    padding-bottom: 8px;
  }
  #mobileControlContent .mobile-setting-block {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding: 6px 8px;
    border-radius: 12px;
    flex-wrap: wrap !important;
  }
  #mobileControlContent .mobile-setting-block label {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.1;
    flex: 0 0 72px;
    white-space: nowrap;
  }
  #mobileControlContent select,
  #mobileControlContent input[type='text'],
  #mobileControlContent input[type='number'] {
    height: auto !important;
    min-height: 36px !important;
    padding: 6px 12px !important;
    border-radius: 12px;
    font-size: 13px;
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 100%;
  }
  #mobileControlContent button {
    height: auto !important;
    min-height: 34px !important;
    border-radius: 12px;
    font-size: 12px;
    padding: 6px 10px;
    flex: 0 0 auto;
    min-width: 0;
  }
  #mobileControlContent .drawer-actions {
    padding: 8px;
    border-radius: 12px;
    gap: 8px;
  }
  #mobileResetBtn {
    top: 10px !important;
    right: 12px !important;
    height: auto !important;
    min-height: 32px !important;
    padding: 6px 12px !important;
    border-radius: 11px !important;
    font-size: 11px !important;
  }
  #mobileControlContent .mobile-file-btn {
    height: 30px !important;
    padding: 2px 4px 0 !important;
    flex: 0 0 auto;
  }
}

#mobileControlContent .mobile-setting-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 !important;
  justify-content: center !important;
}

@media (max-width: 768px) {
  #mobileScreenshotBtn {
    order: 2;
  }
  #mobileSaveBtn {
    order: 0;
  }
  #mobileLoadFile {
    order: 1;
    height: 12px;
  }
}

#mobileControlContent .mobile-setting-block label {
  margin: 0;
  padding: 0;
  line-height: 1;
}

#mobileControlContent .mobile-file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90%;
  margin-left: auto;
  margin-right: 0;
  height: 30px;
  padding: 2px 4px 0;
  border-radius: 8px;
  background: #2a2a2a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  height: 30px !important;
  padding: 2px 4px 0 !important;
}

#mobileControlContent .mobile-file-btn:active {
  transform: translateY(1px);
}

#mobileTeamSelector {
  height: 36px !important;
  padding: 4px 12px !important;
  line-height: 40px !important;
  font-size: 14px !important;
}

#mobileControlContent .mobile-setting-block.teamname-block {
  padding: 10px 10px !important;
}

#mobileControlContent .mobile-setting-block.teamname-block #mobileTeamSelector {
  width: 100%;
  margin: 0;
}

#mobileControlContent .teamname-apply-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 6px;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  padding: 6px 8px !important;
}

#mobileControlContent .teamname-apply-row #mobileTeamSelector {
  width: auto !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

#mobileTeamApplyMenuBtn {
  height: 40px;
  min-width: 74px;
  width: 74px !important;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 214, 92, 0.9);
  background: linear-gradient(180deg, #ffd85b, #f2b72f);
  color: #1d1300;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 74px !important;
  flex: 0 0 auto !important;
  visibility: visible !important;
  opacity: 1 !important;
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
}

#mobileControlContent .drawer-actions-bottom {
  width: 100% !important;
  display: block !important;
  align-self: stretch !important;
  padding: 8px !important;
  box-sizing: border-box !important;
}

#mobileControlContent .drawer-actions-bottom .drawer-guide-btn {
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  min-height: 32px !important;
  padding: 6px 12px !important;
  font-size: 11px !important;
  border-radius: 11px !important;
  border: 1px solid rgba(80, 162, 255, 0.78) !important;
  background: linear-gradient(
    180deg,
    rgba(48, 132, 244, 0.96),
    rgba(27, 88, 186, 0.96)
  ) !important;
  color: #f8fbff !important;
  font-weight: 800 !important;
  text-align: center !important;
}

#mobileTeamApplyMenuBtn:disabled {
  opacity: 0.45;
  filter: grayscale(0.2);
}

#mobileControlContent #mobileTeamApplyMenuBtn {
  display: inline-flex !important;
}

#mobileControlContent .teamname-apply-row datalist {
  display: none !important;
}

#candidate-mobile .mobile-team-title-menu {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

@media (max-width: 1024px) {
  .player-slot.field-slot .slot-label,
  .player-slot.sub-slot .slot-label,
  .player-slot.sub .slot-label {
    font-size: 9px !important;
    line-height: 1.05 !important;
    letter-spacing: 0 !important;
    font-weight: 700 !important;
  }
  .sub-slot-container .player-slot .slot-label {
    font-size: 9px !important;
    line-height: 1.05 !important;
    letter-spacing: 0 !important;
    font-weight: 700 !important;
  }
  .player-slot.sub .sub-label {
    font-size: 9px !important;
    line-height: 1.05 !important;
    letter-spacing: 0 !important;
    font-weight: 700 !important;
  }
}

/* =========================================================
   FINAL MOBILE MENU UX
   - bookmark tab + right slide drawer
   ========================================================= */
@media (max-width: 1200px) {
  #mobileOptionsBtn {
    position: fixed !important;
    left: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 21000 !important;
    width: 28px !important;
    height: 96px !important;
    border-radius: 0 12px 12px 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-left: 0 !important;
    background: linear-gradient(
      180deg,
      rgba(20, 28, 46, 0.96),
      rgba(10, 14, 24, 0.96)
    ) !important;
    color: #f8fbff !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    letter-spacing: 0 !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35) !important;
  }

  #mobileOptionsPopup {
    position: fixed !important;
    inset: 0 !important;
    z-index: 20990 !important;
    display: block !important;
    pointer-events: auto !important;
  }
  #mobileOptionsPopup.hidden {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
  #mobileOptionsPopup .drawer-backdrop {
    position: absolute !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.45) !important;
    opacity: 0 !important;
    transition: opacity 0.22s ease !important;
  }
  #mobileOptionsPopup.open .drawer-backdrop {
    opacity: 1 !important;
  }

  #mobileControlContent {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    height: 100dvh !important;
    width: min(86vw, 430px) !important;
    max-width: 430px !important;
    border-radius: 16px 0 0 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    background: linear-gradient(
      180deg,
      rgba(16, 20, 30, 0.98),
      rgba(9, 12, 20, 0.98)
    ) !important;
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45) !important;
    transform: translateX(105%) !important;
    transition: transform 0.24s ease !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  #mobileOptionsPopup.open #mobileControlContent {
    transform: translateX(0) !important;
  }

  #mobileControlContent .drawer-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex !important;
    justify-content: flex-end !important;
    padding: 10px !important;
    background: rgba(12, 16, 24, 0.92) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  }
  #closeMobileOptions {
    height: 34px !important;
    border-radius: 10px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
    font-weight: 800 !important;
  }

  #mobileControlContent .drawer-body {
    padding: 10px !important;
    padding-top: 10px !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    overflow: auto !important;
  }
  /* 내부 메뉴 섹션화(HTML 구조 변경 없이) */
  #mobileControlContent .drawer-body > .mobile-setting-block,
  #mobileControlContent .drawer-body > .drawer-actions {
    position: relative;
    margin-top: 0 !important;
  }
  #mobileControlContent
    .drawer-body
    > .mobile-setting-block:nth-of-type(1)::before {
    content: '리그 / 필드';
  }
  #mobileControlContent
    .drawer-body
    > .mobile-setting-block:nth-of-type(2)::before {
    content: '포메이션';
  }
  #mobileControlContent .drawer-body > .drawer-actions:nth-of-type(1)::before {
    content: '포메이션 적용';
  }
  #mobileControlContent
    .drawer-body
    > .mobile-setting-block.teamname-apply-row::before {
    content: '팀 이름';
  }
  #mobileControlContent .drawer-body > .drawer-actions:nth-of-type(2)::before {
    content: '저장 / 공유';
  }
  #mobileControlContent .drawer-body > .mobile-setting-block::before,
  #mobileControlContent .drawer-body > .drawer-actions::before {
    content: none !important;
    display: none !important;
  }
  #mobileControlContent .mobile-setting-block,
  #mobileControlContent .drawer-actions {
    margin: 0 !important;
    padding: 10px !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
  }
  #mobileControlContent .drawer-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  /* 포메이션 아래 의미없는 빈칸(숨겨진 버튼 컨테이너) 제거 */
  #mobileControlContent .drawer-body > .drawer-actions:nth-of-type(1) {
    display: none !important;
  }
  #mobileControlContent .drawer-body > .mobile-setting-block:empty,
  #mobileControlContent .drawer-body > .drawer-actions:empty {
    display: none !important;
  }
  /* 포메이션 적용 구간(첫 번째 actions)의 불필요한 검은 바 제거 */
  #mobileControlContent .drawer-body > .drawer-actions:nth-of-type(1) {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 4px 0 2px !important;
    border-radius: 0 !important;
  }
  #mobileControlContent .triple-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  #mobileControlContent select,
  #mobileControlContent input[type='text'],
  #mobileControlContent input[type='number'],
  #mobileTeamSelector {
    height: 40px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
  }

  #mobileResetBtn {
    position: static !important;
    top: auto !important;
    right: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 34px !important;
    padding: 0 10px !important;
    border-radius: 9px !important;
    font-size: 11px !important;
    z-index: auto !important;
    grid-column: 1 / -1 !important;
    order: -100 !important;
    margin-bottom: 6px !important;
  }
}

.player-slot:has(.player-img[src]) {
  background: transparent !important;
}

.player-slot:has(.player-img[src]) .player-box {
  background: transparent !important;
}

.event-toast-title,
.event-toast-sub {
  color: #ffffff !important;
}

.tactic-fade {
  animation: tacticFade 260ms ease-in-out;
}

@keyframes tacticFade {
  from {
    filter: brightness(1.25) saturate(1.2);
  }
  to {
    filter: brightness(1) saturate(1);
  }
}

#eventReplayOverlay .er-line {
  display: none !important;
}

#eventReplayOverlay .er-body {
  padding: 6px 8px 12px !important;
  min-height: 18px !important;
}

#scoreBadgeCenter {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
}

.er-toast-title {
  color: #f8fafc;
}

.er-toast-sub {
  color: #fdba74;
}

.er-toast-title,
.er-toast-sub {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

#fieldLabelA,
#fieldLabelB {
  display: inline-block;
  text-align: center;
  white-space: nowrap;
}
.field-team-logo {
  position: absolute;
  left: 5%;
  top: 50%;
  transform: translate(-140%, -50%);
  pointer-events: none;
}

.player-slot,
.player-slot * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.player-slot img {
  -webkit-user-drag: none;
}

/* =========================
   Overlay Text Modal Styles
   (for #shotTextPopup markup)
   ========================= */

#shotTextPopup {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: none;
}

#shotTextPopup.show {
  display: block;
}

#shotTextPopup .shot-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

#shotTextPopup .shottext-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 460px);
  background: #30353a;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 18px 18px 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
}

#shotTextPopup .shottext-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

#shotTextPopup .shottext-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
  font-size: 14px;
  opacity: 0.95;
}

#shotTextPopup .shottext-toggle input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: #4b8cff;
}

#shotTextPopup .shottext-textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  box-sizing: border-box;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
}

#shotTextPopup .shottext-textarea::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

#shotTextPopup .shottext-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

#shotTextPopup .shottext-actions button {
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

#shotTextPopup .shottext-actions button:hover {
  background: rgba(255, 255, 255, 0.12);
}

#shotTextPopup .shottext-save {
  background: #4b8cff;
  border-color: rgba(75, 140, 255, 0.55);
}

#shotTextPopup .shottext-save:hover {
  background: #3b7cff;
}

#shotTextPopup .shottext-close {
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 420px) {
  #shotTextPopup .shottext-panel {
    width: 92vw;
    padding: 16px 16px 14px;
    border-radius: 14px;
  }
  #shotTextPopup .shottext-title {
    font-size: 17px;
  }
}

@keyframes tapFeedback {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(0.94);
  }
  70% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

.player-slot.tap {
  animation: tapFeedback 160ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.player-number {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  font-family: 'DIN Condensed', 'DIN Alternate', 'Inter', 'Roboto Condensed',
    system-ui, sans-serif;
  color: #ffffff;
  background: transparent;
  text-shadow: -0.8px 0 0 rgba(0, 0, 0, 0.95), 0.8px 0 0 rgba(0, 0, 0, 0.95),
    0 -0.8px 0 rgba(0, 0, 0, 0.95), 0 0.8px 0 rgba(0, 0, 0, 0.95),
    -1.4px 0 0 rgba(0, 0, 0, 0.65), 1.4px 0 0 rgba(0, 0, 0, 0.65),
    0 -1.4px 0 rgba(0, 0, 0, 0.65), 0 1.4px 0 rgba(0, 0, 0, 0.65),
    -1px -1px 0 rgba(0, 0, 0, 0.65), 1px -1px 0 rgba(0, 0, 0, 0.65),
    -1px 1px 0 rgba(0, 0, 0, 0.65), 1px 1px 0 rgba(0, 0, 0, 0.65);
  letter-spacing: -0.02em;
  pointer-events: none;
}

.player-captain {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-top: 28px solid rgba(0, 0, 0, 0.75);
  border-right: 28px solid transparent;
  z-index: 6;
  pointer-events: none;
  color: transparent;
  font-size: 0;
}

.player-captain::after {
  content: 'C';
  position: absolute;
  top: -28px;
  left: 4px;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
    1px 1px 0 #000;
}

.player-tooltip {
  position: fixed;
  z-index: 99999;
  min-width: 220px;
  max-width: 320px;
  background: rgba(15, 15, 18, 0.95);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  padding: 10px 12px;
  font-size: 12px;
  top: 12px;
  left: 50%;
}

.player-tooltip .tt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.player-tooltip .tt-name {
  font-weight: 800;
  font-size: 13px;
}

.player-tooltip .tt-sub {
  opacity: 0.85;
  font-size: 11px;
}

.player-tooltip .tt-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 6px 0;
}

.player-tooltip .tt-label {
  width: 54px;
  opacity: 0.7;
  flex: 0 0 auto;
}

.player-tooltip .tt-value {
  flex: 1 1 auto;
  word-break: break-word;
}

.player-tooltip .tt-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.player-tooltip .tt-ig {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  text-decoration: none;
  opacity: 0.92;
}

.player-tooltip .tt-ig:hover {
  opacity: 1;
}

.player-tooltip .ig-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
}

.player-tooltip .tt-ig .ig-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  color: #fff;
}

.player-tooltip .tt-ig:hover .ig-icon {
  color: #ff4fd8;
}

.player-tooltip .tt-edit {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.95;
}

.player-tooltip .tt-edit:hover {
  background: rgba(255, 255, 255, 0.14);
}

.player-tooltip .tt-edit svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

.stats-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.stats-modal .panel {
  width: 100%;
  max-width: 360px;
  background: rgba(15, 15, 18, 0.98);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  padding: 14px;
}

.stats-modal .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.stats-modal .title {
  font-weight: 900;
}

.stats-modal .close {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.stats-modal .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats-modal label {
  font-size: 11px;
  opacity: 0.75;
  display: block;
  margin-bottom: 6px;
}

.stats-modal input {
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  outline: none;
}

.stats-modal .actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.stats-modal .btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.stats-modal .btn.primary {
  background: rgba(255, 255, 255, 0.14);
  font-weight: 800;
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
}

.rank-table th,
.rank-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.rank-table thead th {
  position: sticky;
  top: 0;
  background: #fff;
}

.rank-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.03);
}

.team-box h3,
.mobile-team-title {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.mobile-team-title {
  touch-action: manipulation;
}

@media (max-width: 768px) {
  .player-name:not(:empty) {
    bottom: 0;
    height: 14px;
    line-height: 14px;
    font-size: 9px;
    border-radius: 0 0 6px 6px;
  }
}

.player-slot.field-slot .player-img,
.player-slot.sub .player-img,
.player-slot.sub-slot .player-img {
  width: 100% !important;
  height: auto;
  object-fit: cover;
}

.player-img {
  z-index: 0;
}

.player-name {
  z-index: 2;
}

@media (max-width: 768px) {
  .player-number {
    font-size: 8px;
    padding: 1px 3px;
    border-radius: 4px;
    top: 2px;
    right: 1px;
  }
  .player-captain {
    border-top-width: 18px;
    border-right-width: 18px;
  }
  .player-captain::after {
    top: -15px;
    left: 3px;
    font-size: 6px;
  }
}

#modePopup .popup-content,
#modePopup .modal-content,
#modePopup .popup-inner {
  background: rgba(18, 18, 20, 0.92);
  color: #fff;
}

#modePopup:not(.hidden) {
  position: fixed;
  inset: 0;
  display: flex;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
}

#leagueSection {
  background: rgba(18, 18, 20, 0.94);
  color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.team-check-row {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
}

#leagueSection hr,
#leagueSection .divider {
  border-color: rgba(252, 249, 252, 0.702);
}

/* ============================
   Mobile sliding drawer (hamburger/bookmark-tab)
   - overrides without touching existing style.css
   ============================ */

@media (hover: hover) and (pointer: fine) {
  #mobileOptionsBtn,
  #mobileOptionsPopup,
  #mobileControlContent {
    display: none !important;
  }
}

/* =========================
   Screenshot Popup (Responsive)
========================= */

#screenshotPopup {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
}

#screenshotPopup.show,
#screenshotPopup:not(.hidden) {
  display: flex;
}

#screenshotPopup .shot-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

#screenshotPopup .shot-panel {
  position: relative;
  background: #111;
  color: #fff;
  width: min(92vw, 420px);
  border-radius: 16px;
  padding: 20px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#screenshotPopup h3 {
  margin: 0;
  font-size: 18px;
  text-align: center;
}

#screenshotPopup button {
  width: 100%;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

#screenshotPopup .shot-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#screenshotPopup .shot-actions button {
  padding: 12px 10px;
  background: #2a2a2a;
  color: #fff;
}

#screenshotPopup .shot-actions button:hover {
  background: #3a3a3a;
}

#screenshotPopup #closeShot {
  margin-top: 6px;
  padding: 10px;
  background: #444;
  color: #fff;
}

@media (max-width: 900px) {
  #screenshotPopup .shot-panel {
    width: min(94vw, 380px);
  }
}

@media (max-width: 520px) {
  #screenshotPopup .shot-panel {
    width: 92vw;
    padding: 16px 14px;
  }
  #screenshotPopup .shot-actions {
    grid-template-columns: 1fr;
  }
}

/* ===== 스크린샷 모드: 빈 슬롯 테두리 자국(다이아) 방지 ===== */

body.screenshot-mode .player-slot.sub .sub-label {
  transform: translateZ(0);
}

#field-1,
#field-2,
.pitch,
.field,
.pitch-wrap {
  position: relative;
}

.player-slot.goal-flash {
  outline: 2px solid #ff3b3b;
  outline-offset: 2px;
  border-radius: 14px;
  animation: goalFlashRed 0.35s ease-in-out 3 alternate;
}

@keyframes goalFlashRed {
  from {
    box-shadow: 0 0 2px rgba(255, 59, 59, 0.35), 0 0 8px rgba(255, 59, 59, 0.2);
  }
  to {
    box-shadow: 0 0 10px rgba(255, 59, 59, 1), 0 0 22px rgba(255, 59, 59, 0.85),
      0 0 36px rgba(255, 59, 59, 0.65);
  }
}

.screenshot-mode * {
  transition: none !important;
}

/* Field starter slot: keep silhouette glow, remove subtle rectangular slot frame only */
.field
  .player-slot.field-slot.has-player:not(.selected):not(.flash-goal):not(.flash-yellow):not(.flash-red):not(.flash-sub):not(.flash-assist):not(.flash-swap):not(.flash-event) {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

.field .player-slot.field-slot.has-player .player-box {
  background: transparent !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

.field .player-slot.field-slot.has-player .player-img,
.field .player-slot.field-slot.has-player svg {
  background: transparent !important;
  border-radius: 0 !important;
  isolation: isolate;
}



.field .player-slot.has-player .player-img,
.field .player-slot.has-player svg {
  filter: drop-shadow(0 0 1px rgba(120, 200, 255, 0.95))
    drop-shadow(0 0 4px rgba(120, 200, 255, 0.6))
    drop-shadow(0 0 8px rgba(120, 200, 255, 0.35));
}

body.screenshot-mode .field .player-slot.has-player .player-img,
body.screenshot-mode .field .player-slot.has-player svg {
  -webkit-filter: drop-shadow(0 0 1px rgba(120, 200, 255, 0.95))
    drop-shadow(0 0 4px rgba(120, 200, 255, 0.6))
    drop-shadow(0 0 8px rgba(120, 200, 255, 0.35)) !important;
  filter: drop-shadow(0 0 1px rgba(120, 200, 255, 0.95))
    drop-shadow(0 0 4px rgba(120, 200, 255, 0.6))
    drop-shadow(0 0 8px rgba(120, 200, 255, 0.35)) !important;
}

.er-goal-scorer {
  font-size: 1.25em;
  font-weight: 900;
  color: #ffcc33;
  text-shadow: 0 0 6px rgba(255, 200, 80, 0.7);
}

.er-goal-assist {
  font-weight: 600;
  color: #ffe7a0;
}

/* =========================================================
   HARD OVERRIDE: Tablet/Mobile Landscape layout lock
   - 일부 기기(넓은 태블릿)에서도 확실히 적용되도록 범위를 넓힘
   ========================================================= */
@media (orientation: landscape) and (max-width: 1366px) {
  :root {
    --lSafeL: env(safe-area-inset-left, 0px);
    --lSafeR: env(safe-area-inset-right, 0px);
    --lW: calc(100vw - var(--lSafeL) - var(--lSafeR));
    --lPad: 6px;
    --lGap: 6px;
    --lShrink: calc(38px + var(--landAutoShrink, 0px));
    --lFieldW: calc(
      ((var(--lW) - (var(--lPad) * 2) - var(--lGap)) / 2) - var(--lShrink)
    );
  }

  html,
  body {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .main-content {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: center !important;
    width: var(--lW) !important;
    max-width: var(--lW) !important;
    margin: 0 auto !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .candidate-column {
    display: none !important;
  }

  .center {
    width: var(--lW) !important;
    max-width: var(--lW) !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: flex-start !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    scroll-snap-type: none !important;
  }

  .center > .field-wrapper {
    flex: 0 0 50% !important;
    width: 50% !important;
    min-width: 50% !important;
    max-width: 50% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  #field-1,
  #field-2 {
    width: calc(100% - 32px) !important;
    max-width: calc(100% - 32px) !important;
    min-width: calc(100% - 32px) !important;
    height: auto !important;
    aspect-ratio: 490 / 798 !important;
    min-height: 0 !important;
    margin: 0 auto !important;
  }

  #candidate-mobile {
    display: flex !important;
    flex-wrap: nowrap !important;
    /* 하단은 "상단 한 경기장 폭" 기준으로 2박스 */
    width: calc((var(--lW) / 2) - 20px) !important;
    max-width: calc((var(--lW) / 2) - 20px) !important;
    margin: 8px auto 0 !important;
    padding: 0 !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }

  #candidate-mobile .mobile-team-box {
    flex: 0 0 calc((((var(--lW) / 2) - 20px) - 8px) / 2) !important;
    width: calc((((var(--lW) / 2) - 20px) - 8px) / 2) !important;
    min-width: calc((((var(--lW) / 2) - 20px) - 8px) / 2) !important;
    max-width: calc((((var(--lW) / 2) - 20px) - 8px) / 2) !important;
  }

  .sub-slot-container {
    max-width: calc(50vw - 40px) !important;
    overflow: hidden !important;
  }
}

/* =========================================================
   Mobile/Tablet final sizing:
   - safe-area(기기 버튼/제스처 영역) 감안
   - 하단 팀박스 2개가 상단 경기장 가로폭과 정렬
   ========================================================= */
@media (max-width: 1024px) {
  .center,
  #candidate-mobile {
    --safeL: env(safe-area-inset-left, 0px);
    --safeR: env(safe-area-inset-right, 0px);
    --stageW: calc(100vw - var(--safeL) - var(--safeR));
    --stagePad: 10px;
    --stageGap: 8px;
    --candidatePad: var(--stagePad);
  }

  #candidate-mobile {
    width: var(--stageW) !important;
    max-width: var(--stageW) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: var(--candidatePad) !important;
    padding-right: var(--candidatePad) !important;
    box-sizing: border-box !important;
    gap: var(--stageGap) !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x proximity;
  }

  #candidate-mobile .mobile-team-box {
    flex: 0 0
      calc((var(--stageW) - (var(--candidatePad) * 2) - var(--stageGap)) / 2) !important;
    width: calc(
      (var(--stageW) - (var(--candidatePad) * 2) - var(--stageGap)) / 2
    ) !important;
    min-width: calc(
      (var(--stageW) - (var(--candidatePad) * 2) - var(--stageGap)) / 2
    ) !important;
    max-width: calc(
      (var(--stageW) - (var(--candidatePad) * 2) - var(--stageGap)) / 2
    ) !important;
    scroll-snap-align: start;
  }
}

@media (max-width: 1024px) and (orientation: landscape) {
  :root {
    --land-safeL: env(safe-area-inset-left, 0px);
    --land-safeR: env(safe-area-inset-right, 0px);
    --landW: calc(100vw - var(--land-safeL) - var(--land-safeR));
    --landGap: 8px;
    --landPad: 6px;
    --fieldShrink: 28px;
  }

  #candidate-mobile {
    /* 상단 필드의 실제 좌우 인셋(센터 정렬 + 필드폭 보정)과 맞춤 */
    --candidatePad: var(--landPad);
  }

  .center {
    width: var(--landW) !important;
    max-width: var(--landW) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: var(--landPad) !important;
    padding-right: var(--landPad) !important;
    box-sizing: border-box !important;
    gap: var(--landGap) !important;
  }

  .center > .field-wrapper {
    flex: 0 0 calc((var(--landW) - (var(--landPad) * 2) - var(--landGap)) / 2) !important;
    width: calc(
      (var(--landW) - (var(--landPad) * 2) - var(--landGap)) / 2
    ) !important;
    min-width: calc(
      (var(--landW) - (var(--landPad) * 2) - var(--landGap)) / 2
    ) !important;
    max-width: calc(
      (var(--landW) - (var(--landPad) * 2) - var(--landGap)) / 2
    ) !important;
  }

  #field-1,
  #field-2 {
    width: calc(
      (
        ((var(--landW) - (var(--landPad) * 2) - var(--landGap)) / 2) -
          var(--fieldShrink)
      )
    ) !important;
    max-width: calc(
      (
        ((var(--landW) - (var(--landPad) * 2) - var(--landGap)) / 2) -
          var(--fieldShrink)
      )
    ) !important;
    height: calc(
      (
        (
            ((var(--landW) - (var(--landPad) * 2) - var(--landGap)) / 2) -
              var(--fieldShrink)
          ) * 1.63
      )
    ) !important;
    min-height: 520px !important;
  }
}

/* =========================================================
   Alignment lock:
   상단 경기장 트랙 폭과 하단 팀박스 트랙 폭을 정확히 일치
   ========================================================= */
@media (max-width: 1024px) {
  .center {
    --safeL2: env(safe-area-inset-left, 0px);
    --safeR2: env(safe-area-inset-right, 0px);
    --safeW2: calc(100vw - var(--safeL2) - var(--safeR2));
  }
}

@media (max-width: 1024px) and (orientation: portrait) {
  .center {
    --fieldTrackW: calc(var(--safeW2) - 20px);
  }

  #field-1,
  #field-2 {
    width: var(--fieldTrackW) !important;
    max-width: var(--fieldTrackW) !important;
  }

  #candidate-mobile {
    /* #candidate-mobile는 .center의 자식이 아니므로 safe-area 포함 변수 직접 선언 */
    --safeL2: env(safe-area-inset-left, 0px);
    --safeR2: env(safe-area-inset-right, 0px);
    --safeW2: calc(100vw - var(--safeL2) - var(--safeR2));
    --fieldTrackW: calc(var(--safeW2) - 20px);
    width: var(--fieldTrackW) !important;
    max-width: var(--fieldTrackW) !important;
    margin: 8px auto 0 !important;
    padding: 0 !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
  }

  #candidate-mobile .mobile-team-box {
    /* 첫 화면에는 2팀만 보이고, 이후 팀은 가로 스크롤 */
    flex: 0 0 calc((var(--fieldTrackW) - 8px) / 2) !important;
    width: calc((var(--fieldTrackW) - 8px) / 2) !important;
    min-width: calc((var(--fieldTrackW) - 8px) / 2) !important;
    max-width: calc((var(--fieldTrackW) - 8px) / 2) !important;
  }
}

@media (max-width: 1024px) and (orientation: landscape) {
  .center {
    --fieldTrackW: calc(
      ((var(--landW) - (var(--landPad) * 2) - var(--landGap)) / 2) -
        var(--fieldShrink)
    );
  }

  #field-1,
  #field-2 {
    width: var(--fieldTrackW) !important;
    max-width: var(--fieldTrackW) !important;
  }

  #candidate-mobile {
    width: calc((var(--fieldTrackW) * 2) + var(--landGap)) !important;
    max-width: calc((var(--fieldTrackW) * 2) + var(--landGap)) !important;
    margin: 8px auto 0 !important;
    padding: 0 !important;
    gap: var(--landGap) !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }

  #candidate-mobile .mobile-team-box {
    flex: 0 0 var(--fieldTrackW) !important;
    width: var(--fieldTrackW) !important;
    min-width: var(--fieldTrackW) !important;
    max-width: var(--fieldTrackW) !important;
  }
}

/* =========================================================
   Mobile/Tablet: 1 Viewport = 1 Field (A/B swipe pages)
   ========================================================= */
@media (max-width: 1024px) {
  .center {
    width: 100vw !important;
    max-width: 100vw !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory !important;
    -webkit-overflow-scrolling: touch !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    padding: 0 !important;
    margin: 0 !important;
    scroll-behavior: smooth;
  }

  .center > .field-wrapper {
    flex: 0 0 100vw !important;
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
    scroll-snap-align: start !important;
    scroll-snap-stop: always;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }

  #field-1,
  #field-2 {
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
    min-width: 0 !important;
    height: 74vh !important;
    margin: 0 auto !important;
    position: relative !important;
  }

  .sub-slot-container {
    max-width: calc(100vw - 18px) !important;
    margin-left: 0 !important;
  }
}

/* Landscape(모바일/태블릿)에서는 2구장 동시표시(무스크롤) */
@media (max-width: 1024px) and (orientation: landscape) {
  .main-content {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: center !important;
    width: 100vw !important;
    max-width: 100vw !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  .candidate-column {
    display: none !important;
  }

  #candidate-mobile {
    display: flex !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  .center {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    scroll-snap-type: none !important;
    justify-content: center !important;
    gap: 0 !important;
  }

  .center > .field-wrapper {
    flex: 0 0 50vw !important;
    width: 50vw !important;
    min-width: 50vw !important;
    max-width: 50vw !important;
    scroll-snap-align: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #field-1,
  #field-2 {
    width: calc(50vw - 8px) !important;
    max-width: calc(50vw - 8px) !important;
    /* 세로모드 체감 비율 유지: 화면을 넘어가도 필드를 충분히 크게 */
    height: calc((50vw - 18px) * 1.63) !important;
    min-height: 520px !important;
    margin: 0 auto !important;
  }

  .field-lines {
    top: 44px !important;
    /* 골키퍼 하단선과 맞도록 하단 라인을 위로 끌어올림 */
    bottom: 150px !important;
    left: 20px !important;
    right: 20px !important;
  }

  .sub-slot-container {
    /* 서브슬롯은 경기장 라인 아래로 분리 */
    bottom: 6px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
}

/* =========================================================
   FINAL LOCK: Team boxes per field
   - Portrait: 1 field viewport -> 2 team boxes
   - Landscape: 2 fields viewport -> 4 team boxes (2 per field)
   ========================================================= */
@media (max-width: 1024px) {
  :root {
    --m-safe-l: env(safe-area-inset-left, 0px);
    --m-safe-r: env(safe-area-inset-right, 0px);
    --m-vw: calc(100vw - var(--m-safe-l) - var(--m-safe-r));
    --m-pad: 10px;
    --m-gap: 8px;
    --m-field-track: calc(var(--m-vw) - (var(--m-pad) * 2));
  }

  #candidate-mobile {
    width: var(--m-field-track) !important;
    max-width: var(--m-field-track) !important;
    margin: 8px auto 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: var(--m-gap) !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    box-sizing: border-box !important;
  }

  #candidate-mobile .mobile-team-box {
    flex: 0 0 calc((var(--m-field-track) - var(--m-gap)) / 2) !important;
    width: calc((var(--m-field-track) - var(--m-gap)) / 2) !important;
    min-width: calc((var(--m-field-track) - var(--m-gap)) / 2) !important;
    max-width: calc((var(--m-field-track) - var(--m-gap)) / 2) !important;
  }

  /* Landscape mobile/tablet: long team names should stay on one line */
  #candidate-mobile .mobile-team-title,
  #candidate-mobile .mobile-team-box h3 {
    font-size: 11px !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: keep-all !important;
    letter-spacing: 0 !important;
  }
}

@media (max-width: 1024px) and (orientation: landscape) {
  :root {
    --m-safe-l: env(safe-area-inset-left, 0px);
    --m-safe-r: env(safe-area-inset-right, 0px);
    --m-vw: calc(100vw - var(--m-safe-l) - var(--m-safe-r));
    --m-pad: 6px;
    --m-gap: 8px;
    --m-field-track: calc(
      (var(--m-vw) - (var(--m-pad) * 2) - var(--m-gap)) / 2
    );
  }

  #candidate-mobile {
    width: calc((var(--m-field-track) * 2) + var(--m-gap)) !important;
    max-width: calc((var(--m-field-track) * 2) + var(--m-gap)) !important;
    margin: 8px auto 0 !important;
    padding: 0 !important;
    gap: var(--m-gap) !important;
  }

  #candidate-mobile .mobile-team-box {
    flex: 0 0 calc((var(--m-field-track) - var(--m-gap)) / 2) !important;
    width: calc((var(--m-field-track) - var(--m-gap)) / 2) !important;
    min-width: calc((var(--m-field-track) - var(--m-gap)) / 2) !important;
    max-width: calc((var(--m-field-track) - var(--m-gap)) / 2) !important;
  }
}

/* =========================
   Mobile guide popup
   ========================= */
#mobileGuideBtn {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.45);
}

#mobileGuidePopup {
  position: fixed;
  inset: 0;
  z-index: 120000;
}

#mobileGuidePopup.hidden {
  display: none !important;
}

#mobileGuidePopup .guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

#mobileGuidePopup .guide-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 640px);
  max-height: 84vh;
  border-radius: 14px;
  border: 1px solid rgba(130, 168, 255, 0.35);
  background: linear-gradient(
    180deg,
    rgba(15, 24, 42, 0.98),
    rgba(8, 14, 28, 0.98)
  );
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.46);
  overflow: hidden;
}

#mobileGuidePopup .guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

#mobileGuidePopup .guide-head h3 {
  margin: 0;
  font-size: 15px;
  color: #f4f8ff;
}

#mobileGuidePopup .guide-head button {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 129, 129, 0.65);
  background: linear-gradient(
    180deg,
    rgba(255, 92, 92, 0.95),
    rgba(210, 44, 44, 0.95)
  );
  color: #fff;
  font-weight: 800;
}

#mobileGuidePopup .guide-body {
  padding: 12px;
  overflow: auto;
  max-height: calc(84vh - 50px);
  font-size: 13px;
  line-height: 1.45;
  color: #dce7ff;
}

#mobileGuidePopup .guide-body h4 {
  margin: 12px 0 8px;
  font-size: 13px;
  color: #fff;
}

#mobileGuidePopup .guide-body ul {
  margin: 0 0 8px;
  padding-left: 18px;
}

#mobileGuidePopup .guide-body li {
  margin-bottom: 5px;
}

/* =========================================================
   SUB bench zone (visual panel + balanced 10-slot layout)
   ========================================================= */
.field-wrapper {
  --bench-slot-w: 64px;
  --bench-slot-h: 84px;
  --bench-gap-x: 12px;
  --bench-gap-y: 8px;
  --bench-pad-x: 10px;
  --bench-pad-y: 10px;
  --bench-panel-w: 392px; /* 64*5 + 12*4 + 10*2 */
}

.field-wrapper > .sub-slot-container {
  position: absolute !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  bottom: 8px !important;
  z-index: 7 !important;
  display: grid !important;
  grid-template-columns: repeat(5, var(--bench-slot-w)) !important;
  grid-auto-rows: var(--bench-slot-h) !important;
  gap: var(--bench-gap-y) var(--bench-gap-x) !important;
  width: min(calc(100% - 20px), var(--bench-panel-w)) !important;
  padding: var(--bench-pad-y) var(--bench-pad-x) !important;
  justify-content: center !important;
  align-content: center !important;
  box-sizing: border-box !important;
  border-radius: 16px !important;
  border: 1.5px solid rgba(255, 255, 255, 0.34) !important;
  background: linear-gradient(
      180deg,
      rgba(15, 37, 20, 0.78),
      rgba(9, 22, 13, 0.72)
    ),
    radial-gradient(
      circle at 50% 12%,
      rgba(255, 255, 255, 0.09),
      rgba(255, 255, 255, 0)
    );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 10px rgba(0, 0, 0, 0.34), 0 8px 18px rgba(0, 0, 0, 0.36) !important;
  overflow: hidden !important;
}

.field-wrapper > .sub-slot-container::before {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.field-wrapper > .sub-slot-container::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  top: 50%;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.field-wrapper > .sub-slot-container .player-slot.sub {
  position: relative;
  z-index: 1;
}

@media (max-width: 1024px) {
  .field-wrapper {
    --bench-slot-w: 52px;
    --bench-slot-h: 70px;
    --bench-gap-x: 9px;
    --bench-gap-y: 7px;
    --bench-pad-x: 8px;
    --bench-pad-y: 8px;
    --bench-panel-w: 312px; /* 52*5 + 9*4 + 8*2 */
  }
  .field-wrapper > .sub-slot-container {
    bottom: 6px !important;
    width: min(calc(100% - 14px), var(--bench-panel-w)) !important;
    border-radius: 14px !important;
  }
}

@media (max-width: 768px) {
  .field-wrapper {
    --bench-slot-w: 40px;
    --bench-slot-h: 56px;
    --bench-gap-x: 8px;
    --bench-gap-y: 6px;
    --bench-pad-x: 7px;
    --bench-pad-y: 7px;
    --bench-panel-w: 245px; /* 40*5 + 8*4 + 7*2 */
  }
  .field-wrapper > .sub-slot-container {
    bottom: 5px !important;
    width: min(calc(100% - 10px), var(--bench-panel-w)) !important;
    border-radius: 12px !important;
  }
  .field-wrapper > .sub-slot-container::before {
    inset: 5px;
    border-radius: 9px;
  }
}

/* =========================================================
   Urban dark tune: deep black base + charcoal team panels
   ========================================================= */
:root {
  --app-bg: #07090d;
  --panel-bg: #11151b;
  --panel-border: #2a313a;
  --panel-hover: #1d242d;
}

body {
  background-color: var(--app-bg) !important;
}

.main-content {
  background: linear-gradient(
    180deg,
    #080b10 0%,
    #0b0f14 55%,
    #0d1117 100%
  ) !important;
}

.candidate-column {
  background-color: rgba(28, 32, 38, 0.94) !important;
  border-color: #3a414b !important;
}

.team-box {
  background: linear-gradient(
    180deg,
    rgba(47, 52, 59, 0.88),
    rgba(34, 38, 44, 0.9)
  ) !important;
  border-color: #4a515b !important;
}

.team-box::-webkit-scrollbar-track {
  background: #262b33 !important;
}

.team-box::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #66707d, #4b535e) !important;
  border-color: #262b33 !important;
}

.candidate-column::-webkit-scrollbar-track {
  background: #252b33 !important;
}

.candidate-column::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #66707d, #4b535e) !important;
  border-color: #252b33 !important;
}
/* =========================================================
   Fix: 모바일/태블릿 스크린샷에서 선수 이름 바가 이미지에 딱 붙도록
   ========================================================= */
@media (max-width: 1024px) {
  /* 스크린샷 모드에서만 적용 – 선수 이미지 하단 정렬 + 이름 바 틈 제거 */
  body.screenshot-mode .player-slot.field-slot .player-img,
  body.screenshot-mode .player-slot.sub .player-img {
    object-position: center bottom !important; /* 이미지를 하단으로 정렬 */
  }

  body.screenshot-mode .player-name:not(:empty) {
    bottom: 0 !important;
    margin-bottom: 0 !important;
    height: 14px !important;
    line-height: 14px !important;
    border-radius: 0 0 6px 6px !important;
  }
}
/* =============================================
   선수 이름 바 통일 (주전/서브/모든 해상도)
   ============================================= */

/* PC (기본) */
.player-slot .player-name {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 18px;
  line-height: 18px;
}

/* 모바일 (화면 너비 768px 이하) */
@media (max-width: 768px) {
  .player-slot .player-name {
    height: 14px !important;
    line-height: 14px !important;
  }
}

/* 퇴장 선수 가슴 카드 - 기본은 숨김 */
.player-redcard-badge {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%) translateZ(0);
  z-index: 99999;
  width: 20px;
  height: 28px;
  background: #e74c3c;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  pointer-events: none;
  display: none !important;
}

/* data-visible="true"일 때만 보임 (JS에서 제어) */
.player-redcard-badge[data-visible="true"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
  animation: redcardBadgePop 0.4s ease-out 1;
}

/* PC에서 약간 크게 */
@media (min-width: 769px) {
  .player-redcard-badge {
    width: 22px;
    height: 32px;
    top: 52%;
  }
}

/* 카드 내부 하이라이트 (선택) */
.player-redcard-badge::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 18px;
  background: rgba(255,255,255,0.12);
  border-radius: 1px;
}

/* 작은 RED 텍스트 */
.player-redcard-badge::after {
  content: "RED";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 6px;
  font-weight: 800;
  color: rgba(255,255,255,0.8);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

@keyframes redcardBadgePop {
  0% {
    transform: translate(-50%, -50%) scale(0.2) rotate(-20deg);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1) rotate(3deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
}
