:root {
  --glass: rgba(16, 21, 32, 0.58);
  --glass-strong: rgba(16, 21, 32, 0.82);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef1f6;
  --muted: rgba(238, 241, 246, 0.62);
  --amber: #ffbe6b;
  --radio: #b9e6a8;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b101c;
  color: var(--text);
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#scene:active {
  cursor: grabbing;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pill {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.pill > button,
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
}

.pill > button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.pill svg {
  width: 19px;
  height: 19px;
}

.top {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.top .pill {
  pointer-events: auto;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  padding-right: 10px;
  border-right: 1px solid var(--line);
  border-radius: 999px 0 0 999px;
}

.brand svg {
  color: var(--amber);
}

.room b {
  color: var(--muted);
  font-weight: 500;
}

.room svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

#sound .onicon,
#sound.on .off {
  display: none;
}

#sound.on .onicon {
  display: block;
  color: var(--amber);
}

.clock {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 52px);
  left: 22px;
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

#toasts {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 84px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(92vw, 440px);
  pointer-events: none;
}

.toast {
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.35;
  text-align: center;
  animation: toast-in 0.35s ease-out;
  transition: opacity 0.5s, transform 0.5s;
}

.toast.radio {
  color: var(--radio);
}

.toast.out {
  opacity: 0;
  transform: translateY(-6px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.tally {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  transition: opacity 0.3s;
}

.tally p {
  margin: 0;
}

/* 휴전선 248km 중 오늘 다 함께 걸은 만큼 */
.tally .bar {
  width: 200px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.tally .bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--amber);
  transition: width 0.8s ease;
}

.tally b {
  color: var(--amber);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.actions {
  pointer-events: auto;
  padding: 6px;
  gap: 4px;
}

.actions button {
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  height: 58px;
  min-width: 76px;
  padding: 0 14px;
  border-radius: 22px;
  font-size: 12.5px;
}

.actions svg {
  width: 23px;
  height: 23px;
}

.actions button:disabled {
  opacity: 0.4;
  cursor: default;
}

body.watching #btn-watch {
  background: rgba(255, 190, 107, 0.16);
  color: var(--amber);
}

/* 쌍안경 */
#binoc,
#binoc-ui {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s;
}

body.watching #binoc,
body.watching #binoc-ui {
  opacity: 1;
}

body.watching .tally,
body.watching #clock {
  opacity: 0;
}

#binoc-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: calc(max(16px, env(safe-area-inset-bottom)) + 92px);
  gap: 4px;
}

#caption {
  margin: 0;
  min-height: 22px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-shadow: 0 1px 6px #000;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

body.nightvision #scene {
  filter: grayscale(1) sepia(1) hue-rotate(55deg) saturate(2.2) brightness(2.6) contrast(1.15);
}

/* 시트 */
#sheet {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 76px 16px 16px;
  background: rgba(0, 0, 0, 0.25);
}

#sheet[hidden] {
  display: none;
}

#sheet .card {
  width: min(100%, 340px);
  max-height: 70vh;
  overflow: auto;
  padding: 14px;
  border-radius: 20px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

#sheet h3 {
  margin: 2px 6px 10px;
  font-size: 15px;
}

#sheet ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#sheet li > * {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
}

#sheet a:hover {
  background: rgba(255, 255, 255, 0.07);
}

#sheet li.head {
  margin: 10px 8px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#sheet li.head:first-child {
  margin-top: 0;
}

#sheet small {
  color: var(--muted);
  font-size: 12.5px;
}

#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0b101c;
  transition: opacity 0.8s;
}

#loading p {
  color: var(--muted);
  font-size: 14px;
  animation: breathe 1.6s ease-in-out infinite;
}

#loading.done {
  opacity: 0;
  pointer-events: none;
}

@keyframes breathe {
  50% {
    opacity: 0.4;
  }
}

@media (max-width: 480px) {
  .pill > button,
  .brand {
    padding: 0 9px;
    font-size: 13px;
  }
  .actions button {
    min-width: 68px;
    padding: 0 10px;
  }
}
