/* 시작 화면 · 맵 선택 카드 · 온라인 패널 · 모달(승패 메시지).
   플레이 중에는 보이지 않는, 화면을 통째로 덮는 UI만 모았다. */

.msg {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  place-items: center;
  background: rgba(6, 8, 11, 0.62);
  text-align: center;
  touch-action: pan-y;
}

.msg.show {
  display: grid;
}

.msg-box {
  width: min(460px, calc(100vw - 40px));
  max-height: min(560px, calc(100dvh - 40px));
  overflow-y: auto;
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(24, 30, 38, 0.96);
  border-radius: 8px;
}

.msg-box h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.msg-box p {
  margin: 0 0 18px;
  color: var(--muted);
}

.msg-ranking {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  text-align: left;
  margin: 0 0 18px;
}

.start-screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: block;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 38%, rgba(242, 193, 78, 0.14), transparent 34%),
    rgba(6, 8, 11, 0.72);
  touch-action: pan-y;
}

.start-screen.hide {
  display: none;
}

/* 설정창은 항상 같은 레이아웃(560px 폭, 항목 구성 동일)으로 그린 뒤,
   화면에 안 들어가면 통째로 축소해서 맞춘다(fitStartCard). 여백이나
   입력칸 크기를 화면 크기별로 바꾸면 브라우저 확대/축소를 할 때마다
   설정창 모양이 달라지는데, 통째로 축소하면 배율과 무관하게 항상 같은
   설정창이 보이고 스크롤도 생기지 않는다.

   가운데 맞추기를 부모(grid의 place-items)에 맡기면 안 된다. transform은
   레이아웃 크기를 바꾸지 않으므로, 카드가 창보다 높으면 부모는 축소 전
   높이(962px)를 기준으로 "넘치는 항목"이라 보고 위쪽 끝에 붙여 버린다.
   그 상태에서 가운데를 축으로 줄이면 카드가 아래로 밀려서, 배율이 맞아도
   시작 버튼이 화면 밖으로 나간다. 그래서 카드 자신을 화면 정중앙에
   붙박아 두고(left/top 50% + translate -50%), 그 자리에서 줄인다.
   이러면 배율이 얼마든 화면 한가운데에 그대로 있는다. */
.start-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 560px;
  padding: 18px 20px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(24, 30, 38, 0.96);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(0,0,0,0.42);
  transform-origin: center center;
  transform: translate(-50%, -50%);
}

.start-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.setting-field {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.setting-field input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 7px;
  background: #252d37;
  color: var(--text);
  font: 800 16px "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
}

.start-card button {
  width: 100%;
  margin-top: 4px;
}

/* 맵 선택은 가로 전체, 그 아래 AI 수 / 게임 시간은 좌우로 나란히. */
#localSettingsGroup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
}

#localSettingsGroup > label.setting-field:first-child,
#localSettingsGroup > #mapSelect {
  grid-column: 1 / -1;
}

/* --- 맵 선택 카드 --- */
.map-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 11px;
}

/* 플레이 방식 3갈래는 한 줄에 셋. */
.map-select.compact3 {
  grid-template-columns: repeat(3, 1fr);
}

.map-card.is-soon {
  opacity: 0.42;
  cursor: default;
}

/* 방 화면을 켜면 설정창이 세로로 두 배 가까이 길어진다(초대 + 자리표 12칸).
   한 단으로 두면 fitStartCard가 0.5배 아래로 줄여야 겨우 들어가서 글씨가
   안 보인다. 그래서 방 화면에서는 카드를 넓히고 두 단으로 눕힌다 —
   왼쪽은 원래의 설정(맵·시간·이름·시작), 오른쪽은 방 관련 전부.
   높이가 절반이 되므로 축소가 걸리지 않는다. */
.start-card.wide {
  width: 940px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
  align-content: start;
}

/* 기본은 왼쪽 단에 쌓인다. 제목만 두 단을 가로지른다. */
.start-card.wide > * {
  grid-column: 1;
}

.start-card.wide > h2 {
  grid-column: 1 / -1;
}

/* 방 관련(역할 고르기 · 초대 · 자리표)은 통째로 오른쪽 단으로 보낸다.
   제목 아래(2번째 줄)에서 시작해 끝까지 차지한다. */
.start-card.wide > #onlinePanel {
  grid-column: 2;
  grid-row: 2 / 99;
}

/* 맵 카드를 한 줄에 넷으로 눕힌다. 2x2로 두면 미리보기 그림 때문에
   설정창이 250px 길어지고, 그만큼 전체가 더 작게 축소된다.
   넷을 눕히면 130px로 줄고, 그림도 맵을 알아볼 만큼은 남는다. */
#mapSelect {
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

#mapSelect .map-card {
  padding: 6px;
}

#mapSelect .map-thumb {
  max-height: 62px;
  margin-bottom: 4px;
}

#mapSelect .map-desc {
  display: none;
}

/* --- 방 화면 --- */
.room-panel {
  margin-top: 10px;
}

.room-controls .setting-field {
  margin-bottom: 5px;
}

.room-fill {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

button.mini {
  padding: 4px 9px;
  font-size: 11px;
  border-radius: 6px;
  width: auto;
}

/* 팀 묶음을 3열로 깐다. 6팀이면 2줄, 4팀이면 2줄, 3팀이면 1줄이라
   설정창이 세로로 길어지지 않는다(fitStartCard가 덜 축소한다). */
.room-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 8px;
}

/* 개인전은 팀 상자가 없으므로 12칸을 바로 격자에 깐다. */
.room-board.solo {
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.room-board.solo .room-seat {
  margin-top: 0;
}

.room-team {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 4px 5px 5px;
  background: rgba(0,0,0,0.18);
}

.room-team-name {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 0;
}

/* 한 칸은 버튼 둘로 나뉜다 — 넓은 쪽은 "내가 여기로", 작은 쪽은 방장의
   AI 넣기/빼기. 하나로 두면 빈자리에서 둘 중 하나만 할 수 있다. */
.room-seat {
  display: flex;
  align-items: stretch;
  gap: 3px;
  margin-top: 2px;
}

.room-seat .seat-main {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 auto;
  width: auto;
  min-height: 21px;
  margin-top: 0;
  padding: 2px 6px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: #232b36;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.room-seat.empty .seat-main {
  color: var(--muted);
  border-style: dashed;
  background: transparent;
}

.room-seat.ai .seat-main {
  color: var(--muted);
}

.room-seat.me .seat-main {
  outline: 2px solid var(--accent);
}

.room-seat .seat-main[disabled] {
  cursor: default;
  opacity: 0.85;
}

.room-seat .seat-side {
  flex: 0 0 auto;
  width: auto;
  min-width: 34px;
  margin-top: 0;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--muted);
  cursor: pointer;
}

.room-seat .tag {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
}

.room-hint {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

.code-row-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  margin: -4px 0 6px;
}

.code-row-sub b {
  color: var(--accent);
  letter-spacing: 1px;
}

/* 설명 줄이 필요 없는 짧은 선택지(경기 방식)는 네 개를 한 줄에 눕힌다.
   2x2로 두면 설정창이 90px 높아지고, 그만큼 전체가 더 작게 축소된다. */
.map-select.compact {
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

#onlineRoleSelect.compact {
  grid-template-columns: repeat(2, 1fr);
}

.map-select.compact .map-card {
  padding: 7px 5px;
  text-align: center;
}

.map-select.compact .map-name {
  font-size: 12px;
}

.map-card {
  display: block;
  width: 100%;
  height: auto;
  padding: 8px;
  border: 2px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  background: #232b36;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.map-card.selected {
  border-color: var(--accent);
  background: #2c3542;
}

/* 높이를 48px로 고정하면 카드가 넓어질수록 썸네일이 가로로 심하게
   늘어난다(카드 폭 190px 기준 약 4:1). 실제 맵 비율(2200x1500 = 약 3:2)에
   가깝게 aspect-ratio로 잡아 도면이 덜 찌그러져 보이게 한다. */
.map-thumb {
  width: 100%;
  aspect-ratio: 8 / 5;
  max-height: 132px;
  border-radius: 6px;
  margin-bottom: 6px;
  border: 1px solid rgba(0,0,0,0.35);
}

/* 대저택: 방과 복도가 보이는 평면도처럼. 벽(밝은 선)으로 방을 나누고
   군데군데 가구를 점으로 찍어 "실내"라는 게 한눈에 읽히도록 했다. */
.map-thumb.mansion {
  background:
    /* 가구 */
    linear-gradient(0deg, #c8a06a 0 100%) 12% 24% / 13% 16% no-repeat,
    linear-gradient(0deg, #8fa4c4 0 100%) 74% 22% / 15% 13% no-repeat,
    linear-gradient(0deg, #c8a06a 0 100%) 16% 76% / 16% 13% no-repeat,
    linear-gradient(0deg, #8fa4c4 0 100%) 78% 78% / 12% 16% no-repeat,
    /* 세로 벽 두 개 (가운데는 복도로 끊어 둔다) */
    linear-gradient(0deg, #e6ebf3 0 38%, transparent 38% 62%, #e6ebf3 62% 100%) 34% 0 / 4% 100% no-repeat,
    linear-gradient(0deg, #e6ebf3 0 38%, transparent 38% 62%, #e6ebf3 62% 100%) 66% 0 / 4% 100% no-repeat,
    /* 가로 벽 (좌우로 문을 하나씩 낸다) */
    linear-gradient(90deg, #e6ebf3 0 22%, transparent 22% 34%, #e6ebf3 34% 70%, transparent 70% 82%, #e6ebf3 82% 100%) 0 50% / 100% 7% no-repeat,
    /* 바깥 벽 */
    linear-gradient(0deg, #e6ebf3 0 100%) 0 0 / 100% 6% no-repeat,
    linear-gradient(0deg, #e6ebf3 0 100%) 0 100% / 100% 6% no-repeat,
    linear-gradient(0deg, #e6ebf3 0 100%) 0 0 / 4% 100% no-repeat,
    linear-gradient(0deg, #e6ebf3 0 100%) 100% 0 / 4% 100% no-repeat,
    linear-gradient(160deg, #47536b, #2a303c);
}

/* 공원: 가운데 호수와 다리, 그 둘레를 도는 산책로(액자 모양)와 가로수.
   둘레 산책로는 inset 그림자 두 겹으로 그리면 액자 모양이 깔끔하게 나온다. */
.map-thumb.park {
  box-shadow: inset 0 0 0 3px #5f9e51, inset 0 0 0 9px #d8c49a;
  background:
    /* 산책로 안쪽을 따라 늘어선 가로수 */
    radial-gradient(circle 2.5px at 16% 27%, #2f6b45 0 100%, transparent 100%),
    radial-gradient(circle 2.5px at 34% 27%, #2f6b45 0 100%, transparent 100%),
    radial-gradient(circle 2.5px at 66% 27%, #2f6b45 0 100%, transparent 100%),
    radial-gradient(circle 2.5px at 84% 27%, #2f6b45 0 100%, transparent 100%),
    radial-gradient(circle 2.5px at 16% 73%, #2f6b45 0 100%, transparent 100%),
    radial-gradient(circle 2.5px at 34% 73%, #2f6b45 0 100%, transparent 100%),
    radial-gradient(circle 2.5px at 66% 73%, #2f6b45 0 100%, transparent 100%),
    radial-gradient(circle 2.5px at 84% 73%, #2f6b45 0 100%, transparent 100%),
    /* 호수를 가로지르는 다리 */
    linear-gradient(0deg, #b98a54 0 100%) 50% 50% / 34% 4px no-repeat,
    /* 중앙 호수 */
    radial-gradient(ellipse 17% 30% at 50% 50%, #5b9ede 0 100%, transparent 100%),
    linear-gradient(160deg, #6fae5c, #3e6b3f);
}

/* 농장: 초록 이랑 위에 격자로 난 흙길, 길 옆의 사일로와 붉은 헛간.
   이랑은 repeating-linear-gradient 한 줄이면 "밭"이라는 게 바로 읽힌다. */
.map-thumb.cornfield {
  background:
    /* 헛간 (붉은 지붕) */
    linear-gradient(0deg, #a8452f 0 100%) 88% 93% / 17% 20% no-repeat,
    /* 사일로 두 개 */
    linear-gradient(0deg, #d5d7cc 0 100%) 61% 12% / 5% 15% no-repeat,
    linear-gradient(0deg, #bcbfb4 0 100%) 61% 22% / 4% 11% no-repeat,
    /* 트랙터 길 (가로 2줄 + 세로 2줄 = 밭이 아홉 칸으로 나뉜다) */
    linear-gradient(0deg, #c2a06d 0 100%) 0 32% / 100% 9% no-repeat,
    linear-gradient(0deg, #c2a06d 0 100%) 0 68% / 100% 9% no-repeat,
    linear-gradient(0deg, #c2a06d 0 100%) 32% 0 / 6% 100% no-repeat,
    linear-gradient(0deg, #c2a06d 0 100%) 68% 0 / 6% 100% no-repeat,
    /* 옥수수 이랑 */
    repeating-linear-gradient(90deg, #47762f 0 5px, #568a39 5px 10px);
}

/* 원형 격투장: 맵 전체가 원 하나다. 모래 원판 + 체크무늬 회랑 + 관중석.
   썸네일은 폭이 높이의 약 1.8배라, 원으로 보이려면 가로 %가 세로 %의
   절반쯤이어야 한다(공원 호수의 17%/30%과 같은 계산). */
.map-thumb.arena {
  background:
    /* 중앙 단상 */
    radial-gradient(ellipse 4.5% 8% at 50% 50%, #dde1e6 0 100%, transparent 100%),
    /* 모래 원판 + 가장자리 띠 */
    radial-gradient(ellipse 19.5% 35% at 50% 50%, #c6a46d 0 92%, #8a6f42 92% 100%, transparent 100%),
    /* 외벽 */
    radial-gradient(ellipse 26.5% 48% at 50% 50%, transparent 0 93%, #767d8a 93% 100%, transparent 100%),
    /* 관중석 — 원 바깥을 전부 덮어 네 모서리를 만든다 */
    radial-gradient(ellipse 27% 48.5% at 50% 50%, transparent 0 100%, #30343c 100%),
    /* 회랑 체크무늬 — 위 두 층 사이의 고리에만 보인다 */
    repeating-conic-gradient(from 0deg at 50% 50%, #5d6572 0deg 15deg, #4c5360 15deg 30deg),
    linear-gradient(160deg, #343a44, #23272f);
}

.map-card .map-name {
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 2px;
}

.map-card .map-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.online-panel {
  border-top: 1px solid rgba(255,255,255,0.12);
  margin-top: 4px;
  padding-top: 14px;
}


.code-row {
  display: flex;
  gap: 8px;
}

/* 참가 코드 입력칸. 대문자로 보여 주고 글자 사이를 벌려 읽기 쉽게 한다. */
.code-row input {
  flex: 1 1 auto;
  text-align: center;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* 초대 링크는 주소라서 대문자로 바꾸면 안 된다(보기에도 링크 같지 않다).
   위 규칙을 되돌린다. */
.code-row input#roomLinkDisplay {
  text-align: left;
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
}

.code-row button {
  flex: 0 0 auto;
  width: auto;
  margin-top: 0;
  padding: 0 14px;
}

.online-status {
  margin: 8px 0 4px;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 16px;
}

.online-status.err {
  color: #ff8a8a;
}

.online-status.ok {
  color: #8dffb8;
}

.lobby-guest-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 7px;
  background: #232b36;
  font-size: 13px;
  font-weight: 700;
  margin-top: 6px;
}

.lobby-guest-row .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8dffb8;
  flex: 0 0 auto;
}
