/* 오래된 브라우저(안드로이드 5+, iOS 9+) 호환: CSS 변수·grid 미사용, flexbox는 -webkit- 병기
 * 글자 크기는 모두 em 단위. 각 영역(#clock-pane, #cal-pane)의 font-size를 app.js의 fit()이
 * 화면 크기에 맞춰 자동 계산하므로, 어떤 화면 비율에서도 최대 크기로 꽉 차게 표시됩니다. */
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #000; overflow: hidden;
}
body {
  color: #f2f2f2;
  font-family: "Roboto", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#stage {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  box-sizing: border-box;
  padding: 3vmin 4vmin;
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
  -webkit-transition: -webkit-transform 3s ease; transition: transform 3s ease;
}
#clock-pane, #cal-pane { min-width: 0; text-align: center; font-size: 16px; }

/* ----- 가로 배치: 시계(왼쪽) | 달력(오른쪽) ----- */
body.landscape #stage { -webkit-box-orient: horizontal; -webkit-flex-direction: row; flex-direction: row; }
body.landscape #clock-pane { -webkit-box-flex: 1.55; -webkit-flex: 1.55 1 0; flex: 1.55 1 0; }
body.landscape #cal-pane {
  -webkit-box-flex: 1; -webkit-flex: 1 1 0; flex: 1 1 0;
  margin-left: 3vmin; padding-left: 3vmin; border-left: 1px solid #222;
}

/* ----- 세로 배치: 시계(위) / 달력(아래) ----- */
body.portrait #stage { -webkit-box-orient: vertical; -webkit-flex-direction: column; flex-direction: column; }
body.portrait #clock-pane, body.portrait #cal-pane {
  -webkit-box-flex: 0; -webkit-flex: none; flex: none; width: 100%;
}
body.portrait #cal-pane {
  box-sizing: border-box; margin-top: 3vmin; padding-top: 3vmin; border-top: 1px solid #222;
}

/* fit() 측정 대상: 내용 폭만큼만 차지하도록 inline-block */
.fit { display: inline-block; white-space: nowrap; }

/* ---------- 시계 ---------- */
#ampm { font-size: .95em; height: 1.2em; line-height: 1.2em; letter-spacing: .1em; }
#time {
  font-size: 5.2em; line-height: 1; font-weight: 300; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; -webkit-font-feature-settings: "tnum"; font-feature-settings: "tnum";
}
#colon { display: inline-block; margin: 0 .02em; position: relative; top: -.06em; -webkit-transition: opacity .25s; transition: opacity .25s; }
#ss { display: inline-block; min-width: 1.2em; text-align: left; opacity: .75; position: relative; }

/* 시간 아래 줄: [날짜 / 요일·음력] + [캐릭터] — 구형 브라우저 호환을 위해 table 레이아웃 */
#clock-block { text-align: center; }
#info { display: table; width: 100%; }
#info-text { display: table-cell; vertical-align: middle; text-align: center; }
#mascot-cell { display: table-cell; vertical-align: top; width: 1px; }
#mascot { position: relative; margin-left: .1em; }   /* 높이·너비·끌어올림은 테마 정의(themes.js)로 app.js가 설정 */
#mascot img, #mascot svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }
#mascot svg { overflow: visible; }
#date, #date2 { white-space: nowrap; }
/* 연도는 아랫줄(요일) 크기로 작게, 월/일만 강조. .65 = 아랫줄/윗줄 글자 비율 (split .86/1.32, single .72/1.1) */
#date .d-year { font-size: .65em; opacity: .7; margin-right: .1em; }
#lunar { min-height: 1.2em; }

/* ===== 테마 기능 클래스 (body.sec-*, body.date-*) — 새 테마는 themes.js에서 조합해 사용 ===== */
/* 초 위치 */
body.sec-middle   #ss { font-size: .3em;  margin-left: .15em; vertical-align: middle;   top: -.32em; }  /* 분 숫자 세로 가운데 */
body.sec-baseline #ss { font-size: .27em; margin-left: .2em;  vertical-align: baseline; top: 0; }      /* 분 숫자 아래쪽 */
/* 날짜 배치 */
body.date-split  #info  { margin-top: .1em; }        /* 날짜 / 요일 · 음력 */
body.date-split  #date  { font-size: 1.32em; line-height: 1.2; }
body.date-split  #date2 { font-size: .86em; margin-top: .3em; }
body.date-single #info  { margin-top: .35em; }       /* 날짜 요일 / 음력 */
body.date-single #date  { font-size: 1.1em; line-height: 1.3; }
body.date-single #date2 { font-size: .72em; margin-top: .2em; }
body.date-stack  #info  { margin-top: .15em; }       /* 월 일 / 요일 / 년 / 음력 */
body.date-stack  #date  { line-height: 1.22; }
body.date-stack  #date .s-md   { font-size: 1.2em; }
body.date-stack  #date .s-year { font-size: .8em; opacity: .7; }
body.date-stack  #date2 { font-size: .8em; margin-top: .1em; }

/* 캐릭터 위치: mascot-left = [캐릭터(시계 영역 높이 가득)] | [시:분 / 날짜 세로 쌓기] */
body.mascot-left #clock-block { display: inline-table; }
body.mascot-left #mascot-cell { display: table-cell; vertical-align: middle; }
body.mascot-left #mascot { margin-left: 0; margin-right: .45em; }
body.mascot-left #clock-main { display: table-cell; vertical-align: middle; text-align: left; }
body.mascot-left #info, body.mascot-left #info-text { display: block; text-align: left; }
body.mascot-left #ampm { font-size: .8em; }
body.mascot-left #time { font-size: 2.3em; }
/* 가로 화면: 캐릭터가 크게 들어가도록 시계 영역을 넓힘 (기본 1.55 : 1 → 2.4 : 1) */
body.landscape.mascot-left #clock-pane { -webkit-box-flex: 2.4; -webkit-flex: 2.4 1 0; flex: 2.4 1 0; }

/* ---------- 날씨 (flex 대신 inline-block: 구형 브라우저 안정성) ---------- */
#weather > div { display: inline-block; vertical-align: middle; }
#w-icon { font-size: 1.9em; line-height: 1; }
#w-temp { font-size: 2.5em; font-weight: 300; line-height: 1; margin: 0 .3em 0 .2em; }
#w-detail { text-align: left; font-size: .6em; line-height: 1.45; }
#w-desc { font-size: 1.15em; }
#w-place { font-size: .48em; margin-top: .4em; }

/* ---------- 달력 ---------- */
#cal-title { font-size: 1em; margin: .9em 0 .4em; }
#cal { border-collapse: collapse; margin: 0 auto; }
#cal th, #cal td { text-align: center; padding: .12em .08em; font-size: .8em; font-weight: 400; }
#cal th { font-size: .62em; opacity: .75; padding-bottom: .5em; }
#cal td span {
  display: inline-block; width: 1.9em; height: 1.9em; line-height: 1.9em;
  border-radius: 50%;
}
#cal .sun { color: #ff5a5a; }
#cal .sat { color: #5aa0ff; }
#cal .hol { color: #ff5a5a; }
#cal td.today span { color: #000 !important; font-weight: 700; }
#holiday { font-size: .5em; margin-top: .6em; line-height: 1.5; min-height: 1.5em; }

/* 가로 화면: 오른쪽 영역은 높이가 부족하므로 날씨·달력을 세로로 압축 */
body.landscape #w-icon { font-size: 1.6em; }
body.landscape #w-temp { font-size: 2.1em; }
body.landscape #w-place { margin-top: .25em; }
body.landscape #cal-title { margin: .6em 0 .25em; }
body.landscape #cal th { padding-bottom: .25em; }
body.landscape #cal th, body.landscape #cal td { padding-top: .06em; padding-bottom: .06em; }
body.landscape #cal td span { width: 1.65em; height: 1.65em; line-height: 1.65em; }
body.landscape #holiday { margin-top: .35em; }

/* ---------- 야간 디밍 / 안내 ---------- */
#dim {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: #000; opacity: 0; pointer-events: none;
  -webkit-transition: opacity 2s; transition: opacity 2s;
}
#hint {
  position: fixed; left: 0; right: 0; bottom: 2vmin; text-align: center;
  font-size: 14px; color: #666; pointer-events: none;
  -webkit-transition: opacity 1s; transition: opacity 1s;
}

/* ---------- 설정 ---------- */
.hide { display: none !important; }
#settings {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, .94);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  color: #eee; font-size: 17px;
  -webkit-user-select: auto; user-select: auto;
}
#settings .panel { max-width: 640px; margin: 0 auto; padding: 20px 18px 40px; }
#settings h2 { font-size: 24px; margin: 4px 0 16px; font-weight: 500; }
#settings h3 { font-size: 15px; color: #8ab4f8; margin: 0 0 10px; font-weight: 500; }
#settings .group { border-top: 1px solid #333; padding: 14px 0 6px; }
#settings .row {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-flex-wrap: wrap; flex-wrap: wrap;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  margin-bottom: 10px;
}
#settings .row > * { margin-right: 10px; }
#settings label { line-height: 1.6; }
#settings input[type=text] {
  -webkit-box-flex: 1; -webkit-flex: 1 1 160px; flex: 1 1 160px;
  min-width: 0; padding: 9px 10px; font-size: 16px;
  background: #1b1b1b; color: #eee; border: 1px solid #444; border-radius: 6px;
}
#settings select {
  padding: 8px; font-size: 16px; background: #1b1b1b; color: #eee;
  border: 1px solid #444; border-radius: 6px;
}
#settings input[type=checkbox] { width: 20px; height: 20px; vertical-align: -4px; margin-right: 6px; }
#settings input[type=range] { -webkit-box-flex: 1; -webkit-flex: 1 1 160px; flex: 1 1 160px; }
#settings button {
  padding: 9px 16px; font-size: 16px; color: #eee; background: #2a2a2a;
  border: 1px solid #555; border-radius: 6px;
}
#settings button.primary { display: block; width: 100%; margin-top: 18px; padding: 13px; background: #1a73e8; border-color: #1a73e8; color: #fff; font-size: 18px; }
#set-results button { display: block; width: 100%; text-align: left; margin: 0 0 6px; background: #1b1b1b; }
#settings .note { font-size: 14px; color: #9a9a9a; line-height: 1.5; margin-bottom: 8px; }
