/* © 2026 김용현 */
* { margin: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #05080f; font-family: 'Segoe UI', 'Malgun Gothic', sans-serif; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#labels { position: fixed; inset: 0; pointer-events: none; }
.no-labels #labels { display: none; }
#labels * { pointer-events: none; }
.label { color: #dde; font-size: 13px; text-shadow: 0 0 4px #000; transition: opacity .4s; }
.label-season { color: #9cf; font-weight: 600; font-size: 15px; }
.near .label-season { opacity: 0; }
.far .label-lat, .far .label-wind, .far .label-polar, .far .label-belt { opacity: 0; }
.label-belt { font-size: 12px; font-weight: 600; }
.label-low  { color: #ff9b8a; }
.label-high { color: #8fb6ff; }
.label-wind { font-weight: 700; font-size: 12px; }
.label-trade { color: #ff8866; }
.label-west  { color: #77aaff; }
.label-polarwind { color: #cc99ff; }
.label-polar { color: #ffe9a0; font-weight: 700; }
#remote { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(10,16,30,.82); border: 1px solid #2a3a55; border-radius: 14px;
  padding: 10px 16px; color: #cde; backdrop-filter: blur(8px); min-width: 740px; z-index: 10; }
#remote .row { display: flex; align-items: center; gap: 8px; padding: 3px 0; flex-wrap: wrap; }
#remote .grp { font-size: 12px; color: #89a; width: 34px; flex-shrink: 0; }
#remote button { background: #1c2940; color: #cde; border: 1px solid #34507a; border-radius: 8px;
  padding: 4px 10px; cursor: pointer; font-size: 13px; }
#remote button:hover { background: #28405f; }
#remote input[type=range] { accent-color: #4a90d9; }
#daySlider { flex: 1; min-width: 180px; }
#remote label { font-size: 13px; display: flex; gap: 4px; align-items: center; cursor: pointer; }
#hud { font-size: 13px; color: #ffd97a; }
.spacer { flex: 1; }
#remoteBar button { padding: 3px 8px; font-size: 12px; }

/* 좌/우 배치: 세로로 긴 패널 */
#remote.pos-left, #remote.pos-right {
  top: 12px; bottom: 12px; transform: none;
  min-width: 0; width: 248px; overflow-y: auto;
}
#remote.pos-left  { left: 12px; right: auto; }
#remote.pos-right { right: 12px; left: auto; }
#remote.pos-left .row, #remote.pos-right .row { flex-direction: column; align-items: stretch; }
#remote.pos-left .grp, #remote.pos-right .grp { width: auto; }
#remote.pos-left input[type=range], #remote.pos-right input[type=range] { width: 100%; min-width: 0; }
#remote.pos-left #remoteBar, #remote.pos-right #remoteBar { flex-direction: row; align-items: center; }
#remote.pos-left #toggles, #remote.pos-right #toggles {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; /* 세로 모드: 체크란 2열 */
}
#toggles .master { color: #ffd97a; font-weight: 600; }

/* 모바일: 리모콘을 화면 하단에 전체 폭으로 고정, 섹션별 그리드 정리 (좌/우 배치 무시) */
@media (max-width: 768px) {
  #remote, #remote.pos-left, #remote.pos-right {
    top: auto; bottom: 0; left: 0; right: 0; transform: none;
    width: 100%; min-width: 0; max-height: 55vh; overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 16px 16px 0 0;
    padding: 6px 12px calc(10px + env(safe-area-inset-bottom));
  }
  #remote.pos-left .row, #remote.pos-right .row { flex-direction: row; align-items: center; }
  #remote.pos-left .grp, #remote.pos-right .grp { width: 34px; }
  #remote .row { padding: 7px 0; }
  #remote .row + .row { border-top: 1px solid rgba(64, 90, 134, .3); } /* 섹션 구분선 */
  #remote button { padding: 6px 8px; font-size: 12px; }
  #remote label { font-size: 12px; }

  /* 상단 바: 위치 버튼 숨기고 전체화면/숨기기 반반 */
  #remoteBar .grp, #posLeft, #posBottom, #posRight, #remoteBar .spacer { display: none; }
  #remoteBar button { flex: 1; }

  /* 자전·공전: [라벨|버튼|슬라이더] 2행 그리드 */
  #motion { display: grid; grid-template-columns: 34px auto 1fr; gap: 6px 8px; align-items: center; }
  #motion input[type=range] { width: 100%; min-width: 0; }

  /* 날짜: 슬라이더 전체 폭 + 절기 4등분 (괄호 날짜는 생략 — HUD에 표시됨) */
  #dateRow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px 6px; }
  #dateRow .grp { display: none; }
  #daySlider { grid-column: 1 / -1; width: 100%; min-width: 0; }
  .season .sdate { display: none; }

  /* 토글: 3열 그리드 */
  #toggles, #remote.pos-left #toggles, #remote.pos-right #toggles {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px;
  }

  /* 시점: 3열 그리드 */
  #views { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  #views .grp { display: none; }

  #hudRow { justify-content: center; }
  #hud { font-size: 12px; }
  #copyright { font-size: 10px; }
  #remoteShow { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
}
.label-moon { color: #ccc; font-size: 12px; }
.label-sun { color: #ffdd66; font-weight: 700; font-size: 17px; text-shadow: 0 0 8px #b8860b, 0 0 4px #000; }
#copyright { font-size: 11px; color: #67809a; justify-content: center; }
#copyright a { color: #7ea7d8; text-decoration: none; }
#copyright a:hover { text-decoration: underline; }

/* 숨기기 / 다시 표시 */
#remote.hidden, #remoteShow.hidden { display: none; }
#remoteShow { position: fixed; right: 16px; bottom: 16px; z-index: 10; font-size: 20px;
  background: rgba(10,16,30,.85); border: 1px solid #34507a; border-radius: 12px;
  padding: 8px 12px; color: #cde; cursor: pointer; }
#remoteShow:hover { background: #28405f; }

/* 축척 안내 (? 버튼 + 패널) */
#helpBtn { position: fixed; top: 14px; right: 16px; z-index: 11; width: 34px; height: 34px;
  border-radius: 50%; background: rgba(10,16,30,.85); border: 1px solid #34507a;
  color: #cde; font-size: 17px; font-weight: 700; cursor: pointer; }
#helpBtn:hover { background: #28405f; }
#helpPanel { position: fixed; top: 56px; right: 16px; z-index: 11; width: 420px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 80px); overflow-y: auto;
  background: rgba(10,16,30,.92); border: 1px solid #2a3a55; border-radius: 14px;
  padding: 14px 16px; color: #cde; backdrop-filter: blur(8px); font-size: 13px; }
#helpPanel.hidden { display: none; }
.help-head { display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; font-weight: 700; color: #ffd97a; margin-bottom: 8px; }
#helpClose { background: none; border: none; color: #89a; font-size: 15px; cursor: pointer; }
#helpClose:hover { color: #fff; }
.help-intro { margin-bottom: 8px; line-height: 1.5; }
#helpPanel table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
#helpPanel th, #helpPanel td { border: 1px solid #2a3a55; padding: 5px 7px; text-align: left; line-height: 1.4; }
#helpPanel th { background: #1c2940; color: #9fc1e8; font-size: 12px; }
#helpPanel td { font-size: 12px; }
.help-note { color: #9ab; line-height: 1.55; margin-bottom: 6px; }
