:root {
  --navy: #00244a;
  --gold: #f8b500;
  --ink: #16202e;
  --muted: #5b6676;
  --danger: #b42318;
  --surface: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: #eef1f5;
}

[hidden] { display: none !important; }

/* ---------- 참가 코드 ---------- */
#join {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--navy);
}

#join-form {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 24px;
}

#join-form h1 { margin: 0 0 4px; font-size: 24px; color: var(--navy); }
#join-form p { margin: 0 0 20px; color: var(--muted); font-size: 15px; line-height: 1.5; }
#join-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

#join-code {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  font-size: 22px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  border: 2px solid #c9d1dc;
  border-radius: 10px;
}
#join-code:focus { outline: none; border-color: var(--navy); }

#join-form .error { margin: 10px 0 0; color: var(--danger); font-size: 14px; }

#join-form button {
  width: 100%;
  height: 52px;
  margin-top: 16px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  border: none;
  border-radius: 10px;
}
#join-form button:disabled { opacity: 0.6; }

/* ---------- 지도 ---------- */
#app { position: absolute; inset: 0; }
.view { position: absolute; inset: 0 0 calc(56px + env(safe-area-inset-bottom, 0px)) 0; overflow-y: auto; }
#map { position: absolute; inset: 0; }

/* 하단 탭 */
#tabs {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--surface);
  border-top: 1px solid #d8dde5;
  z-index: 1100;
}
#tabs button {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-top: 3px solid transparent;
}
#tabs button.active { color: var(--navy); border-top-color: var(--gold); }

/* 나침반·점수 화면 공통 */
#view-compass, #view-scores { padding: 64px 20px 24px; background: #eef1f5; }
.field-label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; }
select, #view-scores input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  font-size: 17px;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid #c9d1dc;
  border-radius: 10px;
}
#view-compass button, #view-scores form button[type="submit"] {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  border: none;
  border-radius: 10px;
}
#view-compass button.secondary { color: var(--navy); background: none; border: 2px solid var(--navy); }

/* 나침반 */
#compass-dial {
  width: min(64vw, 280px);
  aspect-ratio: 1;
  margin: 24px auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 6px solid var(--navy);
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(0, 36, 74, 0.18);
}
#compass-arrow { width: 62%; height: 62%; transition: transform 0.25s ease-out; }
#compass-arrow path { fill: var(--gold); stroke: var(--navy); stroke-width: 4; stroke-linejoin: round; }
#compass-dial.waiting #compass-arrow { opacity: 0.25; }
#compass-dial.north-up { border-style: dashed; }
#compass-dial.arrived { border-color: #1f8a4c; }
#compass-dial.arrived #compass-arrow path { fill: #1f8a4c; stroke: #1f8a4c; }
#compass-distance { margin: 12px 0 4px; text-align: center; font-size: 24px; font-weight: 800; color: var(--navy); }
#compass-hint { margin: 0; text-align: center; font-size: 14px; line-height: 1.5; color: var(--muted); min-height: 42px; }

/* 점수 */
#view-scores h2 { margin: 8px 0 10px; font-size: 20px; color: var(--navy); }
#view-scores h3 { margin: 20px 0 8px; font-size: 15px; color: var(--ink); }
#score-form { margin-bottom: 28px; padding: 16px; background: var(--surface); border-radius: 14px; }
#score-form h2 { margin-top: 0; }
#score-message { margin: 12px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
#score-message.good { color: #1f8a4c; }
#score-message.bad { color: var(--danger); }
#score-history { list-style: none; margin: 0; padding: 0; }
#score-history li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; font-size: 15px; border-top: 1px solid #e6eaf0;
}
#score-history li.voided { color: var(--muted); text-decoration: line-through; }
#score-history button {
  min-height: 36px; padding: 0 12px; font-size: 14px; color: var(--danger);
  background: none; border: 1px solid var(--danger); border-radius: 8px;
}
#board-message { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
#board { list-style: none; margin: 0; padding: 0; }
#board li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 8px;
  background: var(--surface); border-radius: 12px;
}
#board li.mine { outline: 3px solid var(--gold); }
#board .rank { width: 28px; font-size: 18px; font-weight: 800; color: var(--navy); text-align: center; }
#board .name { flex: 1; font-size: 16px; font-weight: 600; }
#board .total { font-size: 18px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.team-badge.small { width: 30px; height: 30px; font-size: 13px; border-width: 2px; box-shadow: none; }

.popup-guide {
  display: block; width: 100%; min-height: 40px; margin-top: 10px;
  font-size: 14px; font-weight: 700; color: #fff;
  background: var(--navy); border: none; border-radius: 8px;
}

#status {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  font-size: 14px;
  color: #fff;
  background: rgba(22, 32, 46, 0.88);
  border-radius: 999px;
}

#me-chip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 10px;
  z-index: 999;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.94);
  border: none;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  min-height: 32px;
}

#locate {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 1000;
  min-height: 48px;
  padding: 0 22px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  border: none;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
#locate:disabled { opacity: 0.55; }

/* Leaflet divIcon 기본 흰 상자 제거 */
.leaflet-div-icon.bare { background: none; border: none; }

/* 반 마커: 색 배지 + 반 번호 */
.team-badge {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.team-badge.mine { outline: 3px solid var(--gold); outline-offset: 2px; }
/* 한동안 소식이 없는 반은 흐리게 */
.team-badge.stale { opacity: 0.45; }

/* 스팟 마커: 핀 + 이름 */
.spot { display: flex; flex-direction: column; align-items: center; }
.spot-pin {
  width: 22px;
  height: 22px;
  background: var(--gold);
  border: 4px solid var(--navy);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}
.spot-icon { width: 44px; height: 44px; object-fit: contain; }
.spot-name {
  margin-top: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
/* 멀리서 볼 때는 이름을 숨겨 지도가 덮이지 않게 한다 */
.zoom-far .spot-name { display: none; }

/* 내 위치 (서버로 보내지 않고 화면에만 표시) */
.my-dot {
  width: 18px;
  height: 18px;
  background: #1a73e8;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(26, 115, 232, 0.25);
}

.leaflet-popup-content { font-size: 14px; line-height: 1.5; margin: 12px 14px; }
.leaflet-popup-content strong { display: block; font-size: 15px; color: var(--navy); }

#admin-link { display: block; margin-top: 20px; padding: 14px; text-align: center; font-size: 15px; font-weight: 700; color: var(--navy); background: var(--surface); border-radius: 12px; }
