/* 닳는 종 */
:root {
  --accent: #d9b27a;
  --bg: #11112e;
}

html, body { background: var(--bg); }

canvas.stage { opacity: 0; transition: opacity 0.6s ease; cursor: default; }
canvas.stage.ready { opacity: 1; }

/* ── 위: 남은 타종 ── */
.top {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(var(--bar-h) + 40px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.eyebrow {
  font-size: 12px; letter-spacing: 0.3em; padding-left: 0.3em;
  color: var(--accent); opacity: 0.9;
}
.remain {
  margin-top: 2px;
  font-size: clamp(42px, 12.5vw, 86px); font-weight: 200; line-height: 1.12;
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
  text-shadow: 0 2px 28px rgba(8, 6, 28, 0.55);
}
.rule {
  margin-top: 6px; max-width: 21em;
  font-size: 13px; line-height: 1.6; color: var(--dim); word-break: keep-all;
  text-shadow: 0 1px 12px rgba(8, 6, 28, 0.6);
}

/* ── 오른쪽 위: 지금 N명 ── */
.corner {
  position: absolute;
  top: calc(var(--bar-h) + 10px + env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  text-align: right;
}
.corner .live { font-size: 13px; min-height: 0; }
.corner .today { margin-top: 2px; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.ghost-note {
  margin: 3px 0 0 auto; max-width: 12.5em;
  font-size: 11px; line-height: 1.45; color: rgba(172, 196, 255, 0.75); word-break: keep-all;
}
/* 좁은 화면에서는 오른쪽 위 묶음과 가운데 글자('남은 타종', 큰 숫자)가 같은 높이에 걸려요. 셋째 줄(여운)이 겹치지 않게:
   글이 흐를 수 있는 너비를 wear.js(fitGhostNote)가 재서 알려 줘요 — 첫 줄은 '남은 타종' 오른쪽(--note-w1), 그 아래 줄은
   큰 숫자 오른쪽(--note-w2), 높이는 규칙 문장 위까지(--note-h). 왼쪽에 띄운 빈 상자(::before)가 그 모양대로 글을 밀어내요.
   값이 아직 없으면 한국어 기준 어림값(숫자는 가장 길 때도 화면 너비의 절반 이하)을 써요. */
@media (max-width: 620px) {
  .corner { top: calc(var(--bar-h) + 4px + env(safe-area-inset-top)); }
  .corner .live { line-height: 1.3; }
  .corner .today { margin-top: 1px; line-height: 1.35; }
  .ghost-note { margin-top: 0; max-width: none; font-size: 10.5px; line-height: 1.22; overflow-wrap: anywhere; max-height: var(--note-h, 5em); overflow: hidden; }
  .ghost-note::before {
    content: ''; float: left; height: 9em;
    width: calc(100% - var(--note-w2, 25vw - 24px));
    shape-outside: polygon(0 0, calc(100% - (var(--note-w1, 50vw - 56px) - var(--note-w2, 25vw - 24px))) 0, calc(100% - (var(--note-w1, 50vw - 56px) - var(--note-w2, 25vw - 24px))) 1.22em, 100% 1.22em, 100% 100%, 0 100%);
  }
}

/* ── 아래: 내 기록 + 종 치기 ── */
.bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 max(20px, env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.mine {
  min-height: 1.5em;
  font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
}
.mine b { color: var(--accent); font-weight: 500; }
/* 아래 묶음 (위에서 아래로): [제야의 종 줄, 12/24~1/1만] · 내 기록 줄(알림이 잠깐 이 자리를 대신함) · 단추 줄(36px, 늘 자리 있음) · 종 치기.
   알림(토스트)은 떠다니지 않고 내 기록 줄 자리에 잠깐 나타났다 돌아가요(shared/ui.js [data-toast-slot]) — 아무 글자·단추도 덮지 않아요 */
.mine-row { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.mine-slot { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; max-width: 26em; height: 38px; }
.mine-slot .mine { min-height: 0; text-align: center; line-height: 1.45; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; transition: opacity 0.25s; }
.say { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; opacity: 0; transition: opacity 0.25s; pointer-events: none;
  font-size: 13.5px; font-weight: 500; line-height: 1.4; color: #f3efe6; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.85); word-break: keep-all; overflow: hidden; }
.mine-slot.is-saying .mine { opacity: 0; }
.mine-slot.is-saying .say { opacity: 1; }
.share-row { display: flex; justify-content: center; gap: 8px; min-height: 36px; flex-wrap: nowrap; max-width: 100%; } /* the share buttons appear after the first strike: their row is always there, so nothing moves */
.share-row .btn.small.share { white-space: nowrap; }
.btn.small.share { min-height: 36px; padding: 6px 14px; font-size: 12.5px; border-color: rgba(217, 178, 122, 0.55); color: var(--accent); position: relative; }
.btn.small.share::before { content: ''; position: absolute; inset: -4px 0; }

.btn.primary.strike {
  position: relative; overflow: hidden;
  background: var(--accent); color: #24180c;
  letter-spacing: 0.12em;
  box-shadow: 0 6px 30px rgba(217, 178, 122, 0.18);
}
.btn.primary.strike:hover { background: #e6c38f; }
.btn.primary.strike:disabled { opacity: 0.5; }
.btn.primary.strike.cooling:disabled { opacity: 1; box-shadow: none; }
.strike .drain {
  position: absolute; inset: 0; pointer-events: none;
  background: rgba(22, 18, 34, 0.58);
  transform-origin: right center; transform: scaleX(0);
}
.strike .label { position: relative; }

/* 소리 조절 (shared/sound-ui.js): 종 치기 아래 한 줄 */
.snd-row { display: flex; justify-content: center; margin-top: -4px; min-height: var(--tap, 44px); } /* the two buttons arrive after the first paint: keep their 44 px so the block above does not jump */
/* the first-visit bubble goes beside the two buttons, not over the 종 치기 label */
.snd-row .snd--up .snd__hint { top: 50%; bottom: auto; left: calc(100% + 10px); right: auto; transform: translateY(-50%); white-space: normal; width: max-content; max-width: max(64px, calc(50vw - 112px)); line-height: 1.3; }
.snd-row .snd--up .snd__hint::before { top: calc(50% - 5px); bottom: auto; left: -5px; right: auto; border: 5px solid transparent; border-left: 0; border-right-color: #ffd28a; }


/* ── 깨진 뒤 ── */
#closedScreen {
  gap: 12px;
  background: radial-gradient(ellipse at 50% 46%, rgba(12, 11, 28, 0.62), rgba(6, 6, 14, 0.9));
}
#closedScreen .title { color: #efe3cc; margin-bottom: 8px; }
/* 3D: the split bell lies on the platform under the text, so the veil is lighter and the words carry their own shadow */
html.scene-3d #closedScreen { background: radial-gradient(ellipse at 50% 40%, rgba(10, 9, 24, 0.66), rgba(6, 6, 14, 0.4) 62%, rgba(6, 6, 14, 0.18)); }
html.scene-3d #closedScreen > * { text-shadow: 0 1px 12px rgba(0, 0, 0, 0.85); }
#closedScreen .personal { color: var(--accent); font-size: 15px; }
.last-mine { color: var(--accent); font-size: 15px; letter-spacing: 0.04em; }
.farewell { margin-top: 18px; }
#closedScreen .btn { margin-top: 6px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

@media (min-width: 720px) {
  .top { padding-top: calc(var(--bar-h) + 16px + env(safe-area-inset-top)); }
  .rule { font-size: 14px; max-width: 30em; }
  .remain { margin-top: 6px; } /* the 86 px digits' line box reached 2 px into the eyebrow's line at this size */
  .bottom { padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
}

@media (max-height: 560px) {
  .top { padding-top: calc(var(--bar-h) + 26px + env(safe-area-inset-top)); }
  .remain { font-size: clamp(30px, 8vh, 48px); }
  .rule { font-size: 12px; margin-top: 2px; }
  .bottom { gap: 6px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .btn.primary.strike { padding: 10px 20px; }
}

/* 숫자·문장이 서버에서 늦게 들어와도 상자 폭이 그대로라 아무것도 옆으로 밀리지 않게 (가운데 정렬 상자는 꽉 채우고, 오른쪽 위는 폭 고정) */
.top > .eyebrow, .top > .remain { align-self: stretch; }
.top > .rule { align-self: stretch; width: 100%; margin-left: auto; margin-right: auto; }
.corner { width: min(13em, 46vw); }

/* 제야의 종 같이 치기 (wear/nye-bell.js). 12/24 ~ 1/1(한국 시간)에는 nye-boot.js가 첫 그림 전에 html.nye-on 을 붙여서
   종 치기 위에 사건 줄(높이 고정: 큰 줄 2줄까지 + 작은 줄 1줄)과 단추 줄(공유하기 · 새해 카드 · 캘린더, 한 줄 36px)의 자리를
   미리 잡아요. 종 그림은 그 자리를 뺀 공간에 처음부터 맞춰지고, 글자는 서로 겹치지 않고, 서버 답이 와도 아무것도 움직이지 않아요.
   그 밖의 날에는 사건 줄이 없고, 지난해 기록은 위 글자 아래 작은 줄(#nyeRec, 종 그림 위에 얹히고 아무것도 밀지 않음). */
.nye-note { display: none; }
html.nye-on .nye-note { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; height: 60px; width: 100%; max-width: 26em;
  overflow: hidden; text-align: center; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.85); }
html.nye-on .nye-note.is-empty { visibility: hidden; }
.nye-text { font-size: 13.5px; font-weight: 600; color: #f0d6a8; line-height: 1.45; font-variant-numeric: tabular-nums; word-break: keep-all;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.nye-sub { font-size: 12px; color: var(--dim); line-height: 1.45; font-variant-numeric: tabular-nums; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nye-sub:empty { display: none; }
.nye-note.is-live .nye-text { color: #ffe3ad; }
.nye-rec { margin-top: 4px; max-width: 26em; font-size: 12px; line-height: 1.45; color: rgba(240, 214, 168, 0.85); word-break: keep-all; text-shadow: 0 1px 10px rgba(8, 6, 28, 0.7); }
.top.is-nye .eyebrow { color: #ffe3ad; letter-spacing: 0.2em; }
.top.is-nye .remain { font-weight: 300; color: #fff3dc; }
.top.is-newyear .remain { color: #ffe3ad; }
#closedScreen .nye-closed { color: #f0d6a8; font-size: 15px; max-width: 26em; }
