/* =========================================================
   팩토리 마블 — 대기실
   넓은 화면: 위 막대 + 두 줄(설정·로봇전 | 친구·기록), 화면 높이에 맞춰 스크롤 없음
   좁은 화면: 한 줄로 쌓고 세로로 내려 봄
   ========================================================= */
.lobby-page { display: flex; flex-direction: column; min-height: 100%; }
.lb-top {
  display: flex; align-items: center; gap: 14px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--ink); color: var(--paper);
}
.lb-logo {
  font-family: var(--font-display); font-size: 24px; color: #ffd66b; text-decoration: none; white-space: nowrap;
}
.lb-me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.me-face { width: 38px; height: 38px; border-radius: 50%; background: #fff; border: 3px solid var(--pc); overflow: hidden; flex: none; }
.me-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.me-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.me-txt b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt small { color: #f3dcae; font-weight: 700; font-size: 12.5px; }
.me-stat { color: #f3dcae; font-size: 13.5px; white-space: nowrap; }
.me-stat b { color: #fff; }
.lb-nav { display: flex; gap: 8px; }
.lb-nav .b { color: var(--ink); text-decoration: none; }

.lb-main {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 18px max(16px, env(safe-area-inset-left, 0px));
  width: min(1320px, 100%); margin: 0 auto;
}
.lb-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; }
.lb-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--r-l);
  box-shadow: 0 5px 0 var(--ink);
  padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}
.lb-h { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 22px; display: flex; align-items: center; gap: 8px; line-height: 1.1; }
.lb-h .ic { font-size: 24px; }
.lb-h small { font-family: var(--font-body); font-size: 13px; font-weight: 700; color: var(--ink-3); }

/* 설정 줄 */
.set-row { display: flex; align-items: center; gap: 12px; }
.set-lb { width: 74px; flex: none; font-weight: 800; font-size: 14px; color: var(--ink-2); }
.seg { display: flex; gap: 8px; flex: 1; min-width: 0; }
.seg button {
  flex: 1; min-width: 0;
  border: 2.5px solid var(--ink); border-radius: 12px; background: #fff;
  padding: 7px 6px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
  box-shadow: 0 3px 0 var(--ink);
}
.seg button b { font-family: var(--font-display); font-weight: 400; font-size: 18px; }
.seg button small { font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
.seg button.on { background: var(--gold); }
.seg button.on small { color: var(--ink-2); }

.char-pick { display: flex; gap: 8px; flex: 1; }
.char-pick button {
  flex: 1; min-width: 0;
  border: 2.5px solid var(--ink); border-radius: 14px; background: #fff;
  padding: 4px 2px 3px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  box-shadow: 0 3px 0 var(--ink);
}
.char-pick img { width: 44px; height: 44px; object-fit: contain; }
.char-pick span { font-family: var(--font-display); font-size: 15px; }
.char-pick button.on { background: var(--pcs); border-color: var(--ink); box-shadow: 0 0 0 3px var(--pc), 0 3px 0 var(--ink); }

.set-more { border: 2px dashed var(--ink-3); border-radius: 12px; padding: 6px 12px; }
.set-more summary { cursor: pointer; font-weight: 800; font-size: 14px; color: var(--ink-2); }
.set-more summary span { font-weight: 600; color: var(--ink-3); }
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 10px 0 4px; }
.more-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; font-weight: 800; color: var(--ink-2); }
.more-grid select { border: 2px solid var(--ink); border-radius: 9px; background: #fff; padding: 5px 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); min-width: 0; }

/* 캐릭터 소개 */
.char-info { display: flex; flex-direction: column; gap: 4px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 7px 12px; margin-top: -4px; }
.char-info p { margin: 0; font-size: 13.5px; line-height: 1.4; font-weight: 600; color: var(--ink-2); }
.char-info b { color: var(--ink); font-weight: 800; }
.ci-trait b { font-family: var(--font-display); font-weight: 400; font-size: 16px; margin-right: 2px; }
.ci-ab { display: flex; align-items: flex-start; gap: 5px; }
.ci-ab .ic { font-size: 17px; flex: none; margin-top: 1px; }
.ci-ab b { white-space: nowrap; }
.ci-ab.off { opacity: .55; }
.ci-ab em { font-style: normal; color: var(--warn); }

/* 로봇 단계 */
.set-level { align-items: stretch; }
.set-level .set-lb { padding-top: 10px; }
.levels { flex: 1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.lv {
  border: 2.5px solid var(--ink); border-radius: 12px; background: #fff;
  padding: 6px 2px 5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.12;
  box-shadow: 0 3px 0 var(--ink);
  min-width: 0;
}
.lv-n { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 12.5px; background: var(--paper-2); }
.lv b { font-family: var(--font-display); font-weight: 400; font-size: 16px; white-space: nowrap; }
.lv small { font-size: 11px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.lv.on { background: var(--gold); }
.lv.on small { color: var(--ink-2); }
.lv1 .lv-n { background: #c4ecd2; } .lv2 .lv-n { background: #bfe0ff; } .lv3 .lv-n { background: #ffe27a; } .lv4 .lv-n { background: #ffb6a3; } .lv5 .lv-n { background: #c9b9f2; }
.lb-start { margin-top: 2px; }

/* 이어서 하기 */
.lb-resume { background: #fff4c7; gap: 8px; }
.rs-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px; }
.rs-it {
  display: flex; align-items: center; gap: 10px;
  border: 2.5px solid var(--ink); border-radius: 12px; background: #fff;
  padding: 7px 12px; text-decoration: none; color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}
.rs-it .ic { font-size: 24px; }
.rs-it span { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.rs-it b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-it small { font-size: 12.5px; color: var(--ink-3); font-weight: 700; }
.rs-it em { font-style: normal; font-family: var(--font-display); background: #5ed184; border: 2px solid var(--ink); border-radius: 999px; padding: 3px 12px 2px; white-space: nowrap; }

/* 친구 */
.lb-friends { flex: 1; min-height: 0; }
.fr-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fr-add .field { width: 170px; font-family: var(--font-display); font-size: 17px; letter-spacing: .12em; padding: .32em .7em .26em; }
.fr-mycode { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--ink-2); background: var(--paper-2); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.fr-mycode b { font-family: var(--font-display); font-weight: 400; font-size: 16px; letter-spacing: .08em; color: var(--ink); }
.fr-list {
  flex: 1; min-height: 140px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 2px 4px 4px 2px; margin: 0 -4px 0 -2px;
  scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent;
}
.fr-it {
  display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) 70px 104px 108px 26px; align-items: center; gap: 8px;
  border: 2.5px solid var(--ink); border-radius: 12px; background: #fff;
  padding: 6px 8px; cursor: pointer;
}
.fr-it.on { background: #e3f7e9; box-shadow: inset 0 0 0 2px var(--go); }
.fr-it.no { cursor: default; background: var(--paper); }
.fr-it.no .fr-name, .fr-it.no .fr-av { opacity: .6; }
.fr-it input { width: 18px; height: 18px; accent-color: var(--go-deep); margin: 0; }
.fr-av { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper-2); display: grid; place-items: center; font-family: var(--font-display); font-size: 17px; }
.fr-name { display: flex; align-items: baseline; gap: 6px; min-width: 0; flex-wrap: wrap; row-gap: 0; line-height: 1.2; }
.fr-name b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.fr-name small { font-size: 12.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.fr-grp { font-style: normal; font-size: 11px; font-weight: 800; background: #c4ecd2; border: 1.5px solid var(--ink); border-radius: 999px; padding: 0 6px; white-space: nowrap; }
.fr-code { font-family: var(--font-display); font-size: 14.5px; letter-spacing: .06em; color: var(--ink-2); }
.fr-rec { font-size: 13px; line-height: 1.2; display: flex; flex-direction: column; }
.fr-rec small { font-size: 11.5px; color: var(--ink-3); font-weight: 700; }
.fr-st { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 800; white-space: nowrap; }
.fr-st i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); flex: none; }
.fr-st.ok i { background: #5ed184; }
.fr-st.solo i { background: var(--gold); }
.fr-st.busy { color: var(--warn); }
.fr-st.busy i { background: var(--warn); }
.fr-st.off { color: var(--ink-3); }
.fr-st.off i { background: #d8cbb6; }
.fr-del { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; display: grid; place-items: center; padding: 0; cursor: pointer; }
.fr-del .ic { font-size: 14px; }
.fr-empty { flex: 1; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px; color: var(--ink-2); }
.fr-empty img { height: 88px; }
.fr-empty p { margin: 0; font-size: 14px; line-height: 1.5; }
.fr-empty b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 19px; color: var(--ink); }
.fr-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 2px dashed var(--ink-3); padding-top: 10px; }
.fr-sel { flex: 1; min-width: 160px; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.fr-sel b { color: var(--ink); font-size: 17px; }
.fr-bots { font-size: 13px; font-weight: 800; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.fr-bots select { border: 2px solid var(--ink); border-radius: 9px; background: #fff; padding: 4px 6px; font-weight: 600; }
.fr-invites { display: flex; flex-direction: column; gap: 6px; }
.iv-it { display: flex; align-items: center; gap: 8px; background: #fff4c7; border: 2.5px solid var(--ink); border-radius: 12px; padding: 7px 10px; animation: tIn .3s; }
.iv-it .ic { font-size: 22px; }
.iv-it span { flex: 1; min-width: 0; font-size: 14px; }
.iv-it small { display: block; color: var(--ink-3); font-weight: 700; }

/* 기록 */
.lb-hist { flex: none; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
.hist li { border: 2px solid var(--ink); border-radius: 10px; background: #fff; min-width: 0; }
.h-link { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 5px 9px; color: inherit; text-decoration: none; border-radius: 8px; }
.h-link:hover { background: var(--paper-2); }
.hist li.win { background: #fff4c7; }
.h-rk { grid-row: 1 / 3; font-family: var(--font-display); font-size: 17px; text-align: center; }
.hist li b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-v { font-size: 12px; color: var(--ink-2); font-weight: 700; grid-column: 2; }
.hist li small { grid-column: 3; grid-row: 1 / 3; font-size: 12px; color: var(--ink-3); font-weight: 700; }
.h-empty { grid-column: 1 / -1; display: block !important; text-align: center; color: var(--ink-3); font-weight: 700; font-size: 14px; }

/* 대화상자 */
.dlg { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 16px; }
.dlg-back { position: absolute; inset: 0; background: rgba(43, 33, 24, .55); backdrop-filter: blur(2px); }
.dlg-box { position: relative; width: min(440px, 100%); padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; animation: tIn .25s; }
.dlg-q { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.45; }
.dlg-q b { font-family: var(--font-display); font-weight: 400; font-size: 1.15em; }
.dlg-sub { margin: 4px 0 0; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.dlg-btns { display: flex; gap: 10px; justify-content: flex-end; }
.iv-pop { display: flex; gap: 14px; align-items: center; }
.iv-pop img { height: 96px; flex: none; animation: bob 2s ease-in-out infinite; }

/* 넓은 화면은 한 화면에 맞춤. 혹시 넘치면 잘리지 않고 그 칸만 내려 봄 */
.lb-main { flex: none; }
@media (min-width: 900px) and (min-height: 640px) {
  .lobby-page { height: 100%; overflow: hidden; }
  .lb-main { flex: 1; overflow: hidden; }
  .lb-col { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent; padding-bottom: 6px; margin-bottom: -6px; }
}
/* 낮은 화면(노트북 720~800): 카드 간격·그림을 조금 줄여 한 화면에 */
@media (min-width: 900px) and (max-height: 820px) {
  .lb-main { padding-top: 12px; padding-bottom: 12px; gap: 12px; }
  .lb-col { gap: 12px; }
  .lb-card { padding: 10px 14px 12px; gap: 9px; }
  .lb-h { font-size: 20px; }
  .char-pick img { width: 34px; height: 34px; }
  .char-pick span { font-size: 14px; }
  .seg button { padding: 5px 6px 4px; }
  .seg button b { font-size: 16px; }
  .lv { padding: 4px 2px 3px; }
  .lv-n { width: 20px; height: 20px; font-size: 11.5px; }
  .lb-start { font-size: 20px; padding: .4em 1.2em .34em; }
  .rs-it { padding: 5px 10px; }
  .rs-it small { display: none; }
  .char-info { padding: 5px 10px; }
  .char-info p { font-size: 12.5px; line-height: 1.32; }
  .ci-trait b { font-size: 15px; }
  .h-link { padding: 3px 8px; }
}
/* 중간 폭: 친구 줄 정보를 두 줄로 */
@media (max-width: 1180px) {
  .fr-it { grid-template-columns: 22px 34px minmax(0, 1fr) 98px 26px; grid-template-rows: auto auto; row-gap: 2px; }
  .fr-name { grid-column: 3; grid-row: 1; }
  .fr-code { grid-column: 3; grid-row: 2; font-size: 13px; }
  .fr-rec { grid-column: 4; grid-row: 1 / 3; }
  .fr-st { grid-column: 3; grid-row: 2; justify-self: end; }
  .fr-it input { grid-row: 1 / 3; }
  .fr-av { grid-row: 1 / 3; }
  .fr-del, .fr-del-sp { grid-column: 5; grid-row: 1 / 3; }
}
@media (max-width: 899px) {
  .lb-main { grid-template-columns: minmax(0, 1fr); }
  .lb-friends { min-height: 420px; }
  .more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* 단추 4개(설명서·용어 도감·튜토리얼·나가기)가 이름·전적을 밀어내지 않게: 좁으면 단추를 아랫줄로 */
@media (max-width: 820px) {
  .lb-top { flex-wrap: wrap; gap: 8px 10px; }
  .lb-nav { width: 100%; justify-content: space-between; }
  .lb-nav .b { flex: 1; }
}
@media (max-width: 560px) {
  .lb-logo { font-size: 20px; }
  .me-stat { display: none; }
  .lb-main { padding-top: 12px; gap: 12px; }
  .lb-col { gap: 12px; }
  .set-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .set-lb { width: auto; }
  .set-level .set-lb { padding-top: 0; }
  .levels { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .lv b { font-size: 14px; }
  .lv small { font-size: 10px; }
  .hist { grid-template-columns: minmax(0, 1fr); }
  .fr-add .field { flex: 1; width: auto; }
  .fr-mycode { margin-left: 0; width: 100%; text-align: center; }
  .fr-it { grid-template-columns: 22px 30px minmax(0, 1fr) 26px; }
  .fr-av { width: 30px; height: 30px; font-size: 15px; }
  .fr-rec { grid-column: 3; grid-row: 2; flex-direction: row; gap: 6px; align-items: baseline; }
  .fr-code { display: none; }
  .fr-st { grid-column: 3; grid-row: 1; justify-self: end; }
  .fr-name { grid-column: 3; grid-row: 1; padding-right: 92px; }
  .fr-del, .fr-del-sp { grid-column: 4; }
}

/* 확장판 켜기 (자세한 규칙 안) */
.exp-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13.5px; font-weight: 800; color: var(--ink-2); border-top: 2px dashed var(--paper-3); padding-top: 8px; }
.exp-row > span { display: inline-flex; gap: 6px; align-items: baseline; }
.exp-row a { font-size: 12px; color: var(--ink-3); }
.exp-row label { flex-direction: row !important; align-items: center; gap: 5px !important; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 3px 10px 3px 6px; font-size: 13.5px !important; color: var(--ink) !important; cursor: pointer; }
.exp-row input { width: 16px; height: 16px; accent-color: var(--go-deep); margin: 0; }
