:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #aebad1;
  --panel: rgba(7, 10, 21, 0.86);
  --panel-strong: rgba(9, 13, 29, 0.96);
  --cyan: #37d8ff;
  --gold: #ffd34d;
  --rose: #ff5d8f;
  --green: #57f28a;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  background: #05070d;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 16%, rgba(84, 192, 255, 0.26), transparent 34%),
    linear-gradient(180deg, #080b16, #02030a);
}

.town-stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
  isolation: isolate;
  overflow: hidden;
  cursor: none;
}

.town-stage button {
  cursor: none;
}

.town-stage::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(180deg, rgba(2, 3, 10, 0.05), rgba(2, 3, 10, 0.18)),
    radial-gradient(circle at 50% 48%, transparent 42%, rgba(1, 2, 7, 0.44) 100%);
}

.map-content {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100vw, calc(100dvh * 1.2496));
  height: max(100dvh, calc(100vw / 1.2496));
  transform: translate(-50%, -50%);
}

.town-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.16) contrast(1.03);
}

.car-cursor {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  width: 94px;
  height: 64px;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-120px, -120px, 0) rotate(-24deg);
  transform-origin: 50% 58%;
  transition: opacity 140ms ease, filter 140ms ease;
  will-change: transform;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.36));
}

.car-cursor.is-visible {
  opacity: 1;
}

.car-body {
  position: absolute;
  inset: 14px 7px 12px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 29px 34px 18px 18px;
  background: linear-gradient(135deg, #1ec8ff 0 38%, #7f5cff 39% 70%, #ff4f9b 71%);
  box-shadow:
    0 0 18px rgba(55, 216, 255, 0.54),
    0 13px 18px rgba(0, 0, 0, 0.28);
  transform: skewX(-8deg) scaleY(0.86);
  transform-origin: 50% 68%;
}

.car-body::before {
  position: absolute;
  right: 3px;
  bottom: -9px;
  left: 3px;
  height: 9px;
  border-radius: 999px;
  background: rgba(6, 10, 24, 0.72);
  content: "";
}

.car-window {
  position: absolute;
  top: 6px;
  left: 27px;
  width: 27px;
  height: 15px;
  border-radius: 14px 15px 7px 7px;
  background: linear-gradient(135deg, #effbff, #76dfff);
  box-shadow: 22px 3px 0 -3px rgba(238, 251, 255, 0.86);
}

.car-light {
  position: absolute;
  right: 1px;
  width: 11px;
  height: 8px;
  border-radius: 999px;
  background: #ffe66f;
  box-shadow: 0 0 10px rgba(255, 230, 111, 0.84);
}

.car-light-left {
  top: 11px;
}

.car-light-right {
  bottom: 11px;
}

.car-wheel {
  position: absolute;
  bottom: -11px;
  width: 17px;
  height: 17px;
  border: 3px solid rgba(255, 255, 255, 0.74);
  border-radius: 50%;
  background: #111827;
}

.car-wheel-left {
  left: 15px;
}

.car-wheel-right {
  right: 15px;
}

.brand-bar {
  position: absolute;
  z-index: 4;
  top: clamp(14px, 2.2vw, 28px);
  left: clamp(14px, 2.2vw, 28px);
  display: flex;
  align-items: center;
  gap: 12px;
  width: clamp(86px, 9vw, 136px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.brand-bar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.town-banner {
  position: absolute;
  z-index: 4;
  top: clamp(16px, 3vw, 34px);
  left: 50%;
  min-width: min(420px, 62vw);
  padding: 12px 22px 14px;
  border: 3px solid #5b3719;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 233, 158, 0.96), rgba(229, 151, 63, 0.96)),
    #e7a24b;
  box-shadow:
    0 4px 0 #35200e,
    0 14px 34px rgba(0, 0, 0, 0.32);
  color: #3b210d;
  font-size: clamp(1rem, 2.1vw, 1.8rem);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.46);
  transform: translateX(-50%) rotate(-1deg);
}

.town-banner::before,
.town-banner::after {
  position: absolute;
  top: 100%;
  width: 9px;
  height: 20px;
  border-radius: 0 0 4px 4px;
  background: #5b3719;
  content: "";
}

.town-banner::before {
  left: 28px;
}

.town-banner::after {
  right: 28px;
}

.portal {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: clamp(58px, 6.2vw, 86px);
  height: clamp(58px, 6.2vw, 86px);
  padding: 0;
  border: 0;
  background: transparent;
  color: white;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 180ms ease, filter 180ms ease;
}

.portal:hover,
.portal:focus-visible {
  transform: translate(-50%, -50%) scale(1.08);
  filter: drop-shadow(0 0 24px rgba(55, 216, 255, 0.7));
  outline: none;
}

.portal-ring {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.2) 0 26%, transparent 27%),
    conic-gradient(from 30deg, var(--cyan), var(--gold), var(--rose), var(--green), var(--cyan));
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.5) inset,
    0 0 16px rgba(55, 216, 255, 0.72),
    0 0 34px rgba(255, 211, 77, 0.32);
  opacity: 0.86;
  animation: pulse 1.9s ease-in-out infinite;
}

.portal-ring::after {
  position: absolute;
  inset: 17%;
  border-radius: inherit;
  content: "";
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.72), transparent 10%),
    radial-gradient(circle, rgba(12, 24, 54, 0.88), rgba(45, 16, 95, 0.66) 64%, transparent 65%);
}

.portal-label {
  position: absolute;
  bottom: -18px;
  max-width: 128px;
  min-height: 25px;
  padding: 6px 10px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(7, 10, 21, 0.88);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
  color: white;
  font-size: clamp(0.62rem, 0.74vw, 0.76rem);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.portal-police {
  top: 32%;
  left: 60%;
}

.portal-coffee {
  top: 45%;
  left: 23.5%;
}

.portal-restaurant {
  top: 50%;
  left: 50.2%;
}

.studio-hotspot {
  position: absolute;
  z-index: 3;
  top: 70%;
  left: 47.6%;
  width: clamp(172px, 18vw, 270px);
  height: clamp(122px, 13vw, 190px);
  padding: 0;
  border: 0;
  background: transparent;
  color: white;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: filter 180ms ease, transform 180ms ease;
}

.studio-hotspot::before {
  position: absolute;
  inset: 9% 2% 4%;
  border: 3px solid rgba(255, 108, 255, 0);
  border-radius: 16px 16px 9px 9px;
  background:
    radial-gradient(circle at 38% 34%, rgba(255, 108, 255, 0.22), transparent 40%),
    radial-gradient(circle at 64% 66%, rgba(55, 216, 255, 0.18), transparent 46%);
  box-shadow:
    0 0 0 rgba(255, 108, 255, 0),
    0 0 0 rgba(55, 216, 255, 0);
  content: "";
  opacity: 0;
  transition: opacity 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.studio-hotspot:hover,
.studio-hotspot:focus-visible {
  filter:
    drop-shadow(0 0 20px rgba(255, 108, 255, 0.62))
    drop-shadow(0 0 18px rgba(55, 216, 255, 0.56));
  outline: none;
  transform: translate(-50%, -50%) scale(1.03);
}

.studio-hotspot:hover::before,
.studio-hotspot:focus-visible::before {
  border-color: rgba(255, 108, 255, 0.66);
  box-shadow:
    0 0 22px rgba(255, 108, 255, 0.48),
    0 0 28px rgba(55, 216, 255, 0.28) inset;
  opacity: 1;
}

.studio-hotspot-pulse {
  position: absolute;
  bottom: 11%;
  left: 50%;
  width: clamp(44px, 4.4vw, 62px);
  height: clamp(44px, 4.4vw, 62px);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.22) 0 26%, transparent 27%),
    conic-gradient(from 30deg, var(--rose), var(--cyan), var(--gold), var(--green), var(--rose));
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.48) inset,
    0 0 14px rgba(255, 108, 255, 0.68),
    0 0 24px rgba(55, 216, 255, 0.4);
  opacity: 0.78;
  animation: studioPulse 1.8s ease-in-out infinite;
}

.studio-hotspot-pulse::after {
  position: absolute;
  inset: 18%;
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.72), transparent 10%),
    radial-gradient(circle, rgba(12, 24, 54, 0.88), rgba(75, 18, 98, 0.62) 64%, transparent 65%);
  content: "";
}

.studio-hotspot-label {
  position: absolute;
  bottom: -14px;
  left: 50%;
  min-height: 27px;
  padding: 7px 11px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: rgba(7, 10, 21, 0.9);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.34),
    0 0 18px rgba(255, 108, 255, 0.42);
  color: white;
  font-size: clamp(0.64rem, 0.8vw, 0.84rem);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
}

.studio-hotspot-label::first-letter {
  color: #ff8dff;
  text-shadow:
    0 0 6px rgba(255, 255, 255, 0.8),
    0 0 14px rgba(255, 108, 255, 0.9);
}

.video-dock {
  position: fixed;
  z-index: 8;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(460px, 100vw);
  height: 100dvh;
  padding: max(22px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom));
  background: var(--panel-strong);
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: -28px 0 80px rgba(0, 0, 0, 0.5);
  transform: translateX(105%);
  transition: transform 240ms ease;
}

.video-dock.is-open {
  transform: translateX(0);
}

.dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dock-kicker {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dock-header h1 {
  margin: 0;
  font-size: clamp(1.55rem, 5vw, 2.25rem);
  line-height: 1;
}

.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.dock-actions {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.file-loader input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-loader span,
.link-form button,
.cover-loader span,
.retry-video,
.remove-video {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #2bd7ff, #8f68ff 62%, #ff5d8f);
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.link-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
}

.link-form input {
  min-width: 0;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.upload-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-progress {
  position: relative;
  overflow: hidden;
  height: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--upload-progress, 0%);
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2bd7ff, #8f68ff 58%, #ffdf5a);
  box-shadow: 0 0 18px rgba(43, 215, 255, 0.35);
  transition: width 0.22s ease;
}

.upload-progress.is-indeterminate span {
  width: 42%;
  min-width: 86px;
  animation: uploadSlide 1.05s ease-in-out infinite;
}

.upload-progress.is-complete span {
  background: linear-gradient(90deg, #42f59b, #2bd7ff);
}

.upload-progress.is-error span {
  width: 100%;
  background: linear-gradient(90deg, #ff5d8f, #ffb84d);
}

@keyframes uploadSlide {
  0% {
    transform: translateX(-115%);
  }

  100% {
    transform: translateX(260%);
  }
}

.collection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
  min-height: 0;
}

.video-card {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.video-media {
  position: relative;
  background:
    linear-gradient(rgba(8, 12, 28, 0.2), rgba(8, 12, 28, 0.72)),
    var(--cover, radial-gradient(circle at 48% 36%, rgba(55, 216, 255, 0.38), transparent 32%)),
    #02030a;
  background-position: center;
  background-size: cover;
}

.video-media.is-processing {
  display: grid;
  place-items: center;
  min-height: 112px;
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(circle at 50% 42%, rgba(55, 216, 255, 0.34), transparent 28%),
    linear-gradient(135deg, rgba(43, 215, 255, 0.18), rgba(255, 93, 143, 0.16)),
    #02030a;
}

.video-media.is-processing::before {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.22);
  border-top-color: #37d8ff;
  border-radius: 50%;
  content: "";
  animation: spin 1s linear infinite;
}

.video-card video,
.video-card iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
}

.video-media-title {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  overflow: hidden;
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(4, 7, 17, 0.78);
  color: #f7fbff;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-cover {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background:
    linear-gradient(rgba(8, 12, 28, 0.35), rgba(8, 12, 28, 0.72)),
    var(--cover, radial-gradient(circle at 50% 35%, rgba(55, 216, 255, 0.35), transparent 30%)),
    #02030a;
  background-position: center;
  background-size: cover;
  color: white;
  cursor: pointer;
}

.video-cover::before {
  width: 58px;
  height: 58px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.46);
  content: "";
}

.video-cover::after {
  position: absolute;
  margin-left: 5px;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 18px solid white;
  content: "";
}

.video-card-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px;
}

.video-card-title {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
  color: #eef4ff;
  font-size: 0.82rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-warning {
  margin: 0;
  padding: 10px 12px 0;
  color: #ffd34d;
  font-size: 0.86rem;
  line-height: 1.35;
}

.remove-video,
.retry-video {
  min-height: 34px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
}

.retry-video {
  background: rgba(55, 216, 255, 0.22);
}

.cover-loader input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.cover-loader span {
  min-height: 34px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.92) rotate(0deg);
  }
  50% {
    transform: scale(1.08) rotate(8deg);
  }
}

@keyframes studioPulse {
  0%,
  100% {
    transform: translateX(-50%) scale(0.92) rotate(0deg);
  }

  50% {
    transform: translateX(-50%) scale(1.07) rotate(8deg);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .app-shell {
    display: block;
    width: 100%;
    height: 100dvh;
    overflow: auto;
    background: #05070d;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
  }

  .town-stage {
    width: clamp(820px, 235vw, 980px);
    height: auto;
    aspect-ratio: 1402 / 1122;
    margin-left: calc((clamp(820px, 235vw, 980px) - 100vw) / 2);
    min-height: 0;
    cursor: auto;
    box-shadow: none;
  }

  .map-content {
    inset: 0;
    width: 100%;
    height: 100%;
    transform: none;
  }

  .town-stage button {
    cursor: pointer;
  }

  .car-cursor {
    display: none;
  }

  .town-map {
    object-fit: fill;
    object-position: center;
  }

  .brand-bar {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    width: 76px;
  }

  .town-banner {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 10px;
    left: auto;
    min-width: 0;
    max-width: calc(100vw - 108px);
    padding: 9px 12px 10px;
    font-size: 0.86rem;
    transform: rotate(-1deg);
  }

  .town-banner::before,
  .town-banner::after {
    height: 14px;
  }

  .portal {
    width: 68px;
    height: 68px;
    touch-action: manipulation;
  }

  .portal-label {
    bottom: -20px;
    max-width: 122px;
    min-height: 28px;
    padding: 7px 10px;
    font-size: 0.68rem;
  }

  .portal-police {
    top: 32%;
    left: 60%;
  }

  .portal-coffee {
    top: 45%;
    left: 23.5%;
  }

  .portal-restaurant {
    top: 50%;
    left: 50.2%;
  }

  .studio-hotspot {
    top: 70%;
    left: 47.6%;
    width: 190px;
    height: 142px;
    touch-action: manipulation;
  }

  .studio-hotspot-pulse {
    bottom: 11%;
    width: 54px;
    height: 54px;
  }

  .studio-hotspot-label {
    bottom: -12px;
    font-size: 0.7rem;
  }

  .video-dock {
    top: auto;
    bottom: 0;
    width: 100vw;
    height: min(78dvh, 680px);
    padding: 18px 16px max(18px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    border-left: 0;
    border-radius: 18px 18px 0 0;
    transform: translateY(105%);
  }

  .video-dock.is-open {
    transform: translateY(0);
  }

  .dock-header {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .dock-header h1 {
    font-size: clamp(1.45rem, 8vw, 2rem);
  }

  .icon-button {
    width: 46px;
    height: 46px;
  }

  .file-loader span {
    min-height: 48px;
  }

  .link-form {
    grid-template-columns: 1fr;
  }

  .link-form input,
  .link-form button {
    min-height: 48px;
  }

  .video-card-footer {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .empty-state {
    min-height: 180px;
  }
}
