:root {
  color-scheme: dark;
  --ink: #f4f8fb;
  --muted: #b2bec9;
  --soft: #83909d;
  --line: rgba(226, 239, 247, 0.16);
  --line-strong: rgba(226, 239, 247, 0.26);
  --glass: rgba(7, 12, 18, 0.68);
  --glass-strong: rgba(10, 16, 24, 0.82);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
  --accent: #39d7d0;
  --accent-rgb: 57, 215, 208;
  --danger: #ff7878;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", system-ui, sans-serif;
  background: #05080d;
  color: var(--ink);
}

button,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 640px;
  overflow: hidden;
  isolation: isolate;
}

#map,
.map-vignette {
  position: absolute;
  inset: 0;
}

#map {
  z-index: 0;
  background: #070b12;
}

.map-vignette {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(3, 6, 10, 0.72), rgba(3, 6, 10, 0.18) 38%, rgba(3, 6, 10, 0.36)),
    linear-gradient(180deg, rgba(3, 6, 10, 0.7), rgba(3, 6, 10, 0) 30%, rgba(3, 6, 10, 0.68));
}

.brand-bar,
.video-card,
.directory,
.map-controls {
  position: absolute;
  z-index: 4;
}

.brand-bar {
  top: 22px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.wordmark {
  pointer-events: auto;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 17px;
  font-weight: 760;
  letter-spacing: 0;
}

.wordmark-mark {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 7px rgba(var(--accent-rgb), 0.12), 0 0 34px rgba(var(--accent-rgb), 0.72);
}

.glass-panel {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.28);
  -webkit-backdrop-filter: blur(22px) saturate(1.28);
}

.video-card {
  left: 24px;
  top: 84px;
  width: min(520px, calc(100vw - 48px));
  min-width: 360px;
  min-height: 330px;
  max-width: min(900px, calc(100vw - 48px));
  max-height: calc(100vh - 132px);
  border-radius: 8px;
  overflow: hidden;
  resize: both;
  transition: width 240ms ease, transform 240ms ease, opacity 240ms ease;
}

.video-card.is-resizing .player::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  background: transparent;
}

.video-card:hover,
.directory:hover {
  transform: translateY(-2px);
}

.video-card.is-resizing,
.video-card.is-resizing:hover {
  transform: none;
}

.video-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
}

.title-block {
  min-width: 0;
}

.kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.2;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 760;
  line-height: 1.18;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.control-button:hover,
select:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.11);
}

.player-frame {
  padding: 0 14px;
}

.player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: #020407;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.player iframe,
.youtube-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-meta {
  margin: 0;
  padding: 12px 16px 15px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.player-notice {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid rgba(255, 120, 120, 0.34);
  border-radius: 8px;
  background: rgba(38, 10, 14, 0.78);
  padding: 10px 12px;
  color: var(--ink);
  backdrop-filter: blur(14px);
}

.player-notice strong {
  color: #ffb0b0;
  font-size: 13px;
  line-height: 1.2;
}

.player-notice span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
  background: var(--shadow-strong);
}

.popup-backdrop.is-open {
  display: grid;
}

.popup-panel {
  position: relative;
  width: min(420px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  border-radius: 8px;
  padding: 22px;
}

.popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--glass);
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.popup-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popup-content[hidden] {
  display: none;
}

.popup-visual {
  width: 100%;
  aspect-ratio: 16 / 7;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(var(--accent-rgb), 0.22), transparent 52%),
    var(--glass);
}

.popup-content h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 760;
  line-height: 1.25;
  letter-spacing: 0;
}

.popup-content p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.popup-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid rgba(var(--accent-rgb), 0.58);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--ink);
  font-size: 15px;
  font-weight: 740;
  line-height: 1.2;
  text-decoration: none;
}

.popup-follow {
  width: fit-content;
  color: var(--accent);
  font-size: 14px;
  font-weight: 740;
  line-height: 1.4;
  text-decoration: none;
}

.popup-content--ad {
  min-height: 260px;
  justify-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}

.directory {
  right: 24px;
  top: 84px;
  width: min(390px, calc(100vw - 48px));
  max-height: calc(100vh - 176px);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 240ms ease, max-height 220ms ease;
}

.directory.collapsed {
  max-height: 58px;
}

.directory.collapsed .cam-list {
  display: none;
}

.directory-toggle {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.directory-toggle strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

#drawerIcon {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.cam-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--accent-rgb), 0.52) rgba(255, 255, 255, 0.06);
}

.cam-btn {
  position: relative;
  width: 100%;
  min-height: 78px;
  padding: 13px 14px 13px 42px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.cam-btn::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 20px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.12), 0 0 22px rgba(var(--accent-rgb), 0.55);
}

.cam-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.38);
  background: rgba(255, 255, 255, 0.085);
}

.cam-btn.active {
  border-color: rgba(var(--accent-rgb), 0.7);
  background: rgba(var(--accent-rgb), 0.13);
}

.cam-btn.is-offline {
  opacity: 0.62;
}

.cam-btn.is-offline::before {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(255, 120, 120, 0.12), 0 0 22px rgba(255, 120, 120, 0.42);
}

.cam-btn strong,
.cam-btn span {
  display: block;
  overflow-wrap: anywhere;
}

.cam-btn strong {
  font-size: 15px;
  font-weight: 740;
  line-height: 1.35;
}

.cam-btn span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.cam-status-badge {
  display: none;
  margin-top: 8px;
  width: fit-content;
  border: 1px solid rgba(255, 120, 120, 0.34);
  border-radius: 999px;
  padding: 4px 8px;
  color: #ffb0b0;
  background: rgba(255, 120, 120, 0.1);
  font-size: 12px;
  font-style: normal;
  font-weight: 740;
  line-height: 1;
}

.cam-btn.is-offline .cam-status-badge {
  display: inline-flex;
}

.map-controls {
  left: 50%;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px;
  transform: translateX(-50%);
}

.control-button,
select {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 680;
  line-height: 1;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.control-button {
  padding: 0 15px;
}

.control-button.active {
  border-color: rgba(var(--accent-rgb), 0.58);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.14);
}

select {
  max-width: 116px;
  padding: 0 12px;
  appearance: none;
}

.cam-group-title {
  margin: 8px 4px 1px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cam-group-title:first-child {
  margin-top: 2px;
}

.tour-countdown {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.42);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tour-countdown[hidden] {
  display: none;
}

.style-select {
  position: relative;
  display: inline-flex;
}

.style-select__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.style-select__chevron {
  font-size: 11px;
  color: var(--muted);
}

.style-select__menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 6;
  min-width: 148px;
  margin: 0;
  padding: 6px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.28);
  -webkit-backdrop-filter: blur(22px) saturate(1.28);
}

.style-select__menu[hidden] {
  display: none;
}

.style-select__menu li {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 660;
  line-height: 1;
  cursor: pointer;
  outline: none;
  transition: background 140ms ease, color 140ms ease;
}

.style-select__menu li:hover,
.style-select__menu li:focus-visible {
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent);
}

.style-select__menu li[aria-selected="true"] {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 12, 18, 0.68);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.34);
}

.maplibregl-ctrl-top-left {
  top: 132px;
  left: 24px;
}

.view-map .video-card {
  width: min(390px, calc(100vw - 48px));
}

.view-map .player-meta {
  display: none;
}

.view-map .directory {
  max-height: 58px;
}

.view-map .directory .cam-list {
  display: none;
}

@media (min-width: 1500px) {
  .video-card {
    width: 600px;
  }

  .directory {
    width: 430px;
  }
}

@media (max-width: 1020px) {
  .app-shell {
    min-height: 620px;
  }

  .brand-bar {
    top: 14px;
    left: 14px;
    right: 14px;
  }

  .video-card {
    left: 14px;
    right: 14px;
    top: 66px;
    width: auto;
    min-width: 0;
    min-height: 0;
    max-width: none;
    max-height: none;
    resize: none;
  }

  .directory {
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 78px;
    width: auto;
    max-height: min(42vh, 360px);
    border-radius: 8px 8px 0 0;
  }

  .directory.collapsed {
    max-height: 58px;
  }

  .map-controls {
    left: 14px;
    right: 14px;
    bottom: 14px;
    justify-content: center;
    transform: none;
  }

  .maplibregl-ctrl-top-left {
    top: 58vh;
    left: 14px;
  }

  .view-map .video-card {
    width: auto;
  }

  .view-map .video-card {
    transform: translateY(calc(-100% + 58px));
  }
}

@media (max-width: 620px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    min-height: 100dvh;
  }

  .wordmark {
    font-size: 16px;
  }

  .video-card {
    top: 60px;
  }

  .video-card__top {
    padding: 13px 13px 10px;
  }

  h1 {
    font-size: 19px;
  }

  .player-frame {
    padding: 0 10px;
  }

  .player-meta {
    padding: 10px 13px 13px;
    font-size: 14px;
  }

  .directory {
    bottom: 74px;
    max-height: 38vh;
  }

  .cam-list {
    padding: 10px;
  }

  .cam-btn {
    min-height: 72px;
    padding: 12px 12px 12px 38px;
  }

  .cam-btn span {
    font-size: 14px;
  }

  .map-controls {
    gap: 6px;
    padding: 6px;
    overflow-x: auto;
  }

  .control-button,
  select {
    min-height: 38px;
    flex: 0 0 auto;
    font-size: 14px;
  }
}
