/*
  한 수 제한 시간 (public/turn-timer.js 공용). patch.css 토큰만 씁니다.
  .turn-timer           남은 초 배지: data-state = calm | warn | urgent | over, data-mine = true | false
  .turn-timer-vignette  내 차례의 시간이 얼마 남지 않으면 화면 가장자리가 붉어지는 덮개(클릭을 막지 않음)
  .turn-timer-notice    '시간 초과 — 무작위로 놓았어요' 같은 짧은 알림
*/
.turn-timer {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  min-width: 58px;
  height: 36px;
  padding: 0 10px 2px;
  border: var(--seam-width) solid var(--seam-strong);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  line-height: 32px;
  overflow: hidden;
  transition: background-color var(--quick) var(--ease), color var(--quick) var(--ease), border-color var(--quick) var(--ease);
}
.turn-timer[hidden] { display: none; }
.turn-timer-count { font-size: var(--text-lg); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.turn-timer small { font-size: var(--text-xs); font-weight: 650; color: inherit; opacity: .8; }
.turn-timer-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--indigo);
  transform-origin: left center;
  transition: transform 100ms linear;
}
.turn-timer[data-state="warn"] { border-color: var(--safflower); background: var(--safflower-tint); color: var(--safflower); }
.turn-timer[data-state="warn"] .turn-timer-bar { background: var(--safflower); }
.turn-timer[data-state="urgent"], .turn-timer[data-state="over"] { border-color: var(--safflower); background: var(--safflower); color: var(--on-dye); }
.turn-timer[data-state="urgent"] .turn-timer-bar, .turn-timer[data-state="over"] .turn-timer-bar { background: var(--on-dye); }
.turn-timer[data-state="urgent"][data-mine="true"] { animation: turn-timer-shake 500ms steps(2, end) infinite; }

/* 붉은 기운: 가운데는 비우고 가장자리부터. 맥박은 째깍 소리와 함께 한 번씩. */
.turn-timer-vignette {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 40%, color-mix(in srgb, var(--safflower) 28%, transparent) 72%, color-mix(in srgb, var(--safflower) 62%, transparent) 100%);
  box-shadow: inset 0 0 0 6px color-mix(in srgb, var(--safflower) 70%, transparent);
}
.turn-timer-vignette.is-beating { animation: turn-timer-beat 420ms var(--ease); }

.turn-timer-notice {
  position: fixed;
  z-index: 80;
  top: calc(var(--header-height, 56px) + 12px);
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: var(--seam-width) solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-dye);
  font-size: var(--text-sm);
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.turn-timer-notice[hidden] { display: none; }
.turn-timer-notice.is-showing { animation: turn-timer-notice 3200ms var(--ease) both; }

@keyframes turn-timer-beat {
  0% { filter: brightness(1.35) saturate(1.3); }
  100% { filter: none; }
}
@keyframes turn-timer-shake {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-1px) rotate(-1.5deg); }
}
@keyframes turn-timer-notice {
  0% { opacity: 0; transform: translate(-50%, -8px) scale(.96); }
  8%, 86% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -4px); }
}

@media (max-width: 760px) {
  .turn-timer { min-width: 36px; height: 30px; padding: 0 5px 2px; line-height: 26px; }
  .turn-timer small { display: none; }
  .turn-timer-count { font-size: var(--text-md); }
}
@media (prefers-reduced-motion: reduce) {
  .turn-timer, .turn-timer-bar { transition: none; }
  .turn-timer[data-state="urgent"][data-mine="true"], .turn-timer-vignette.is-beating { animation: none; }
  .turn-timer-notice.is-showing { animation: none; }
}
@media (forced-colors: active) {
  .turn-timer-vignette { display: none; }
}
