/* FCoach Web — 데스크톱 앱(APP_QSS)의 다크 팔레트를 그대로 옮김 */
:root {
  --bg: #15171c;
  --card: #232730;
  --card2: #20232b;
  --line: #2f3540;
  --text: #e6e6e6;
  --text2: #cfd3da;
  --subtle: #8a909b;
  --win: #43a047;
  --loss: #e53935;
  --draw: #9aa0aa;
  --blue: #42a5f5;
  --primary: #1e88e5;
  --gold: #ffca28;
  --orange: #fb8c00;
  --teal: #26a69a;
  --cyan: #26c6da;
  --indigo: #5c6bc0;
  --purple: #ab47bc;
  --fc: #9ccc65;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
               "Malgun Gothic", "맑은 고딕", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body { padding-top: var(--safe-top); padding-bottom: var(--safe-bot); }

button, input, select { font-family: inherit; font-size: 15px; }
button { cursor: pointer; }

.hidden { display: none !important; }
.subtle { color: var(--subtle); font-size: 12.5px; }
.spacer { flex: 1; }

/* ---------- 로그인 ---------- */
#login {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 24px;
}
#login .logo { font-size: 44px; }
#login h1 { margin: 0; font-size: 22px; }
#login input {
  width: 100%; max-width: 320px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px;
}
#login button {
  width: 100%; max-width: 320px;
  background: var(--primary); color: #fff; border: none;
  border-radius: 9px; padding: 12px; font-weight: 700;
}
#login .err { color: var(--loss); font-size: 13px; min-height: 18px; }

/* ---------- 상단 바 ---------- */
header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(21, 23, 28, .94);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px 0;
  padding-top: calc(8px + var(--safe-top));
}
.topline { display: flex; align-items: center; gap: 8px; }
.topline .brand { font-weight: 800; font-size: 16px; letter-spacing: -.3px; }
.topline .nick { color: var(--blue); font-weight: 700; }
.iconbtn {
  background: var(--card); border: 1px solid var(--line); color: var(--text2);
  border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center;
  font-size: 15px; padding: 0;
}
.iconbtn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.iconbtn:disabled { opacity: .45; }

.controls { display: flex; gap: 6px; padding: 8px 0; }
.controls select {
  flex: 1; min-width: 0;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%238a909b'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center;
  padding-right: 24px;
}

/* 진행바 */
#progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
#progress > div { height: 100%; background: var(--primary); width: 0; transition: width .25s; }
#syncline { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; }

/* 탭 바 */
nav.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 0 0; margin: 0 -12px; padding-left: 12px; padding-right: 12px;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  flex: 0 0 auto;
  background: transparent; border: none; color: var(--subtle);
  padding: 9px 11px 10px; font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
nav.tabs button.on { color: #fff; border-bottom-color: var(--primary); }

/* ---------- 본문 ---------- */
main { padding: 12px; padding-bottom: calc(28px + var(--safe-bot)); }
section.panel { display: none; }
section.panel.on { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px;
}
.card .t { color: var(--subtle); font-size: 11.5px; }
/* 좁은 화면에선 값이 줄바꿈되지 않게 살짝 줄인다 */
.card .v { font-size: clamp(15px, 4.6vw, 19px); font-weight: 800; margin-top: 2px; letter-spacing: -.4px; }

.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 620px) {
  .grid2 { grid-template-columns: repeat(4, 1fr); }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
}

/* 도넛을 카드 2개 높이로 그리드에 끼워넣어 여백 없이 붙인다 */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.hero .donut {
  grid-column: 1; grid-row: span 2;
  display: grid; place-items: center; padding: 6px;
}
.hero .donut svg { width: 100%; max-width: 132px; height: auto; }
.hero .cards { display: contents; }
@media (min-width: 620px) {
  .hero { grid-template-columns: repeat(4, 1fr); }
}

/* 폼 스트립 */
.formstrip { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.formstrip .chip {
  /* flex 컨테이너 안에서 눌리면 글자가 상자를 벗어난다. 절대 줄어들지 않게. */
  flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
  /* <i> 로 만들었다가 이탤릭으로 나온 적이 있어 명시적으로 눕힌다 */
  font-style: normal;
  /* 한글 글리프는 기본 line-height 로 두면 상자 안에서 아래로 밀린다 */
  line-height: 1;
  text-align: center;
  font-variant-numeric: normal;
}
.chip.win { background: var(--win); }
.chip.loss { background: var(--loss); }
.chip.draw { background: var(--draw); }
.cur-streak { font-weight: 800; margin-right: 4px; }

/* 섹션 제목 */
h3.sec {
  font-size: 13px; color: var(--text2); font-weight: 700;
  margin: 16px 0 7px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
h3.sec:first-child { margin-top: 4px; }

/* 표 */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 13px; background: #1b1e25; }
th, td { padding: 7px 9px; text-align: right; white-space: nowrap; }
th { background: var(--card); color: var(--text2); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
th:first-child, td:first-child { text-align: left; }
tbody tr:nth-child(even) { background: var(--card2); }
tbody tr.total { font-weight: 800; background: #262b35; }
td.win { color: var(--win); } td.loss { color: var(--loss); }
td.warn { color: var(--orange); }

/* 강화등급 배지 */
.gbadge {
  display: inline-block; margin-left: 5px; padding: 0 5px;
  border-radius: 4px; font-size: 10.5px; font-weight: 800;
  line-height: 16px; vertical-align: middle; white-space: nowrap;
}

/* 공격력·수비력 막대 */
.pbar { position: relative; min-width: 54px; height: 18px; }
.pbar i {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 16px; border-radius: 4px;
}
.pbar span { position: relative; font-weight: 700; font-size: 12.5px; padding-right: 3px; }
td.pw.weak { opacity: .5; }

/* 선수 탭 '최근' 칸 */
td.recent { color: var(--subtle); font-size: 12px; }

/* 선수 시즌 배지 (spId 앞 3자리로 뽑은 카드 등급) */
.sbadge {
  display: inline-block; margin-left: 5px; padding: 1px 5px;
  background: #2f3a4f; color: #9fb3d1;
  border-radius: 4px; font-size: 10.5px; font-weight: 700;
  line-height: 1.5; vertical-align: middle; white-space: nowrap;
}
.pname { font-weight: 600; }
/* 넥슨 공식 시즌 아이콘. 가로가 제각각이라 높이만 고정한다 */
.sicon {
  height: 15px; width: auto; margin-left: 5px;
  vertical-align: -2px; display: inline-block;
}

/* 미니 막대 (기간별 FC) */
.minibar { position: relative; min-width: 92px; }
.minibar i {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 15px; background: rgba(156, 204, 101, .32); border-radius: 4px;
}
.minibar span { position: relative; padding-right: 4px; }

/* 승률 바 행 (등급별·시간대·세션) */
.wrrow { display: flex; align-items: center; gap: 9px; padding: 7px 0; }
.wrrow .nm { flex: 0 0 84px; font-weight: 700; font-size: 13.5px; }
.wrrow .bar { flex: 1; height: 16px; background: #1b1e25; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; position: relative; }
.wrrow .bar > i { display: block; height: 100%; border-radius: 7px; }
.wrrow .bar > b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.wrrow .rec { flex: 0 0 108px; text-align: right; color: var(--subtle); font-size: 12px; }

/* 인사이트 */
.insight {
  display: flex; gap: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; overflow: hidden;
}
.insight > i { flex: 0 0 4px; }
.insight > p { margin: 0; padding: 11px 12px 11px 0; font-size: 14px; }
.insight.good > i { background: var(--win); }
.insight.bad > i { background: var(--loss); }
.insight.info > i { background: var(--blue); }

/* 최근 경기 카드 */
.match {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; margin-bottom: 6px;
}
.match .res {
  flex: 0 0 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: #fff;
}
.match .mid { flex: 1; min-width: 0; }
.match .score { font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.match .opp { color: var(--subtle); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .opp.ff { color: #6b7280; font-style: italic; }
.match .right { text-align: right; flex: 0 0 auto; }
.match .right .fc { color: var(--fc); font-weight: 700; font-size: 13px; }
.match .right .tm { color: var(--subtle); font-size: 11px; }

/* 스쿼드 */
.pitch { width: 100%; border-radius: 12px; overflow: hidden; display: block; }
.squadrow {
  display: flex; align-items: center; gap: 9px;
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; margin-bottom: 5px;
}
.posbadge {
  flex: 0 0 44px; text-align: center; background: #2f3a4f; color: #9fb3d1;
  border-radius: 6px; padding: 2px 0; font-weight: 700; font-size: 11.5px;
}
.squadrow .nm { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.squadrow .st { margin-left: auto; color: var(--subtle); font-size: 11.5px; white-space: nowrap; }

.tclist { margin: 6px 0 12px; }
.tclist .tc { font-size: 13px; margin-bottom: 4px; }
.tclist .tc.on { color: var(--fc); }
.tclist .tc.off { color: var(--subtle); }

/* 차트 */
.chart { width: 100%; height: 150px; display: block; }
.chartbox { background: #1b1e25; border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px 4px; margin-bottom: 12px; }

/* 필터 줄 */
.filters { display: flex; gap: 6px; margin-bottom: 9px; }
.filters select, .filters input {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; min-width: 0;
}
.filters input { flex: 1; }

/* 액션 버튼 */
.actions { display: flex; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
.actions button, .actions a {
  flex: 1; min-width: 100px; text-align: center; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 10px; font-size: 13.5px; font-weight: 600;
}

/* 설정 시트 */
#sheet {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .55);
  display: flex; align-items: flex-end;
}
#sheet .inner {
  width: 100%; background: var(--bg); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(24px + var(--safe-bot));
  max-height: 88vh; overflow-y: auto;
}
#sheet h2 { margin: 0 0 12px; font-size: 17px; }
#sheet label { display: block; font-size: 12.5px; color: var(--subtle); margin: 12px 0 5px; }
#sheet input[type=text], #sheet input[type=password] {
  width: 100%; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
}
#sheet .row { display: flex; align-items: center; gap: 9px; margin-top: 14px; }
#sheet .btn {
  width: 100%; background: var(--primary); border: none; color: #fff;
  border-radius: 9px; padding: 11px; font-weight: 700; margin-top: 14px;
}
#sheet .btn.ghost { background: var(--card); border: 1px solid var(--line); color: var(--text); }
#sheet .btn.danger { background: var(--card); border: 1px solid var(--loss); color: var(--loss); }
#sheet a { color: var(--blue); }

/* 토스트 */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + var(--safe-bot)); z-index: 80;
  background: #2c313c; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 20px; font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 88vw; text-align: center;
}
#toast.on { opacity: 1; }

.empty { color: #6b7280; text-align: center; padding: 36px 12px; }
