html, body, #map {
  margin: 0;
  height: 100%;
  background: #121316;
  font: 14px/1.3 system-ui, sans-serif;
  color: #e4e4e8;
  touch-action: manipulation;
  overflow: hidden;
}
html[data-ot-theme="light"],
html[data-ot-theme="light"] body,
html[data-ot-theme="light"] #map {
  background: #e8e6df;
  color: #1c1e24;
}
.leaflet-container {
  background: #1c1e24;
  touch-action: none;
}
html[data-ot-theme="light"] .leaflet-container {
  background: #d9d4c8;
}
html[data-ot-theme="dark"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.92);
}
html[data-ot-theme="light"] .leaflet-tile-pane {
  filter: none;
}
html[data-ot-theme="unicorn"] .leaflet-tile-pane {
  filter: url(#ot-unicorn-map) contrast(1.18) saturate(1.4);
}
.panel {
  position: fixed;
  top: 16px;
  z-index: 500;
  width: 220px;
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 12px;
  background: rgba(46, 48, 54, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}
.panel.left { left: 16px; }
.panel.right { right: 16px; }
html[data-ot-theme="light"] .panel {
  background: rgba(32, 34, 40, 0.92);
  color: #f3f4f6;
  border-color: rgba(0, 0, 0, 0.4);
}
.panel h1, .panel h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}
.panel h2 {
  margin-top: 12px;
  font-size: 13px;
  opacity: 0.85;
}
.user-row, .rank-row, .brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
html[data-ot-theme="light"] .user-row,
html[data-ot-theme="light"] .rank-row,
html[data-ot-theme="light"] .brand-row {
  border-top-color: rgba(20, 22, 28, 0.08);
}
.user-row .name {
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-row .name.viewing {
  color: #e8c24a;
}
.user-row button, .theme-btn, .tool-btn, #admin-modal button {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}
.user-row button.on, .theme-btn.on, .tool-btn.on {
  background: rgba(232, 194, 74, 0.28);
  color: #e8c24a;
}
.brand-row img, .rank-row img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}
.score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.themes, #tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.themes { margin-top: 10px; }
#tools {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 520;
}
.tool-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(46, 48, 54, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.tool-btn svg {
  width: 20px;
  height: 20px;
}
html[data-ot-theme="light"] .tool-btn {
  background: rgba(32, 34, 40, 0.92);
  border-color: rgba(0, 0, 0, 0.4);
  color: #f3f4f6;
}
#ping-time {
  position: absolute;
  z-index: 650;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(28, 30, 36, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f2f3f6;
  font-size: 12px;
  pointer-events: none;
  max-width: 260px;
  white-space: normal;
}
#ping-time a {
  pointer-events: auto;
  color: #e8c24a;
}
html[data-ot-theme="light"] #ping-time {
  background: rgba(250, 250, 252, 0.96);
  color: #1c1e24;
  border-color: rgba(20, 22, 28, 0.2);
}
.muted {
  opacity: 0.6;
  font-size: 12px;
}
.last-pin {
  background: #e8c24a;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(232, 194, 74, 0.25);
}
.last-pin.fresh {
  animation: last-pulse 1.6s ease-out infinite;
}
@keyframes last-pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 194, 74, 0.55); }
  100% { box-shadow: 0 0 0 14px rgba(232, 194, 74, 0); }
}
.ot-venue-pin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(46, 48, 54, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ot-venue-pin img {
  width: 14px;
  height: 14px;
  object-fit: contain;
}
.ot-venue-cluster {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(46, 48, 54, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #f2f3f6;
  font: 11px/28px system-ui, sans-serif;
  text-align: center;
}
#admin-modal {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(8, 9, 12, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
#admin-modal[hidden] { display: none; }
#admin-modal form {
  width: 240px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(28, 30, 36, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
#admin-modal input {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  box-sizing: border-box;
}
#admin-modal .row { display: flex; gap: 8px; }
.adj-btn {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  cursor: pointer;
}
html.ot-edit-trail #map {
  cursor: crosshair;
}
#ot-theme-mascot {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: 107px;
  height: 85px;
  z-index: 480;
  pointer-events: none;
  isolation: isolate;
  overflow: visible;
}
#ot-theme-mascot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-repeat: no-repeat;
  background-size: 640px 85px;
  background-position: 0 0;
  animation: ot-mascot-run 0.72s steps(6) infinite;
}
html[data-ot-theme="dark"] #ot-theme-mascot,
html[data-ot-theme="light"] #ot-theme-mascot,
html[data-ot-theme="unicorn"] #ot-theme-mascot {
  display: block;
}
html[data-ot-theme="dark"] #ot-theme-mascot::after {
  background-image: url("/hud/icons/batman-run.png?v=4");
}
html[data-ot-theme="light"] #ot-theme-mascot::after {
  background-image: url("/hud/icons/galadriel-run.png?v=4");
  animation-duration: 1.08s;
}
html[data-ot-theme="unicorn"] #ot-theme-mascot::after {
  background-image: url("/hud/icons/unicorn-run.png");
}
@keyframes ot-mascot-run {
  to { background-position: -640px 0; }
}
#ot-theme-mascot.ot-mascot-loading::after {
  animation:
    ot-mascot-run 0.36s steps(6) infinite,
    ot-mascot-busy 0.7s ease-in-out infinite;
}
html[data-ot-theme="dark"] #ot-theme-mascot.ot-mascot-loading::after {
  animation: ot-mascot-run 0.36s steps(6) infinite;
}
html[data-ot-theme="light"] #ot-theme-mascot.ot-mascot-loading::after {
  animation: ot-mascot-run 0.48s steps(6) infinite;
}
html[data-ot-theme="unicorn"] #ot-theme-mascot.ot-mascot-loading::after {
  animation: ot-mascot-run 0.36s steps(6) infinite;
}
html[data-ot-theme="light"] #ot-theme-mascot.ot-mascot-loading::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 176px;
  height: 156px;
  margin-left: -88px;
  z-index: 0;
  pointer-events: none;
  transform-origin: 50% 70%;
  background-repeat: no-repeat;
  background-position: 50% 16%, 16% 74%, 84% 70%, 50% 58%;
  background-size: 92px 92px, 22px 34px, 18px 28px, 150% 150%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80'%3E%3Cpolygon fill='%23fff6d8' stroke='%23d4b45a' stroke-width='1.1' points='40,4 44,30 70,14 50,36 76,40 50,44 70,66 44,50 40,76 36,50 10,66 30,44 4,40 30,36 10,14 36,30'/%3E%3Ccircle cx='40' cy='40' r='6.5' fill='%23ffe9a0'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 36'%3E%3Cpath fill='%23c9a227' d='M12 2C6 12 5 20 12 34C19 20 18 12 12 2Z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 36'%3E%3Cpath fill='%23d4b45a' d='M12 2C7 13 6 21 12 34C18 21 17 13 12 2Z'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 55%, rgba(255,248,220,0.85) 0%, rgba(232,200,106,0.45) 34%, transparent 78%);
  filter: drop-shadow(0 0 14px rgba(232, 200, 106, 0.7));
  animation: ot-earendil 2.2s ease-in-out infinite;
}
html[data-ot-theme="dark"] #ot-theme-mascot.ot-mascot-loading::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 150px;
  height: 178px;
  margin-left: -75px;
  z-index: 0;
  pointer-events: none;
  transform-origin: 50% 100%;
  clip-path: polygon(46% 100%, 54% 100%, 86% 4%, 14% 4%);
  background-repeat: no-repeat;
  background-position: 50% 18%, 50% 100%;
  background-size: 54px 26px, 100% 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 28'%3E%3Cpath fill='%23121418' d='M32 26C28 18 22 15 8 17 14 10 17 6 22 9 24 4 28 2 32 10 36 2 40 4 42 9 47 6 50 10 56 17 42 15 36 18 32 26Z'/%3E%3C/svg%3E"),
    linear-gradient(to top, rgba(255,220,120,0.08) 0%, rgba(255,236,160,0.42) 28%, rgba(255,248,210,0.78) 58%, rgba(255,255,240,0.2) 100%);
  filter: drop-shadow(0 0 16px rgba(255, 230, 140, 0.65));
  animation: ot-batsignal 1.7s ease-in-out infinite;
}
html[data-ot-theme="unicorn"] #ot-theme-mascot.ot-mascot-loading::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 168px;
  height: 26px;
  margin-left: -84px;
  z-index: 0;
  pointer-events: none;
  border-radius: 40%;
  transform: perspective(70px) rotateX(58deg) scaleX(1.12);
  transform-origin: center bottom;
  background-image: repeating-linear-gradient(90deg, #ff3b9a 0 9px, #ffd000 9px 18px, #3dff7a 18px 27px, #3dd0ff 27px 36px, #b44dff 36px 45px);
  background-size: 45px 100%;
  box-shadow: 0 0 14px rgba(255, 90, 210, 0.45);
  animation: ot-unicorn-road 1.8s ease-in-out infinite, ot-unicorn-road-scroll 0.55s linear infinite;
}
@keyframes ot-unicorn-road {
  0%, 100% { opacity: 0; }
  28%, 72% { opacity: 1; }
}
@keyframes ot-unicorn-road-scroll {
  to { background-position: 45px 0; }
}
@keyframes ot-earendil {
  0%, 100% { opacity: 0.12; transform: rotate(-10deg) scale(0.9); }
  38% { opacity: 1; transform: rotate(8deg) scale(1.08); }
  62% { opacity: 0.35; transform: rotate(-3deg) scale(1); }
  80% { opacity: 0.85; transform: rotate(5deg) scale(1.04); }
}
@keyframes ot-batsignal {
  0%, 100% { opacity: 0.28; transform: rotate(-7deg) scaleY(0.92); }
  32% { opacity: 1; transform: rotate(5deg) scaleY(1.06); }
  58% { opacity: 0.45; transform: rotate(-2deg) scaleY(1); }
  76% { opacity: 0.9; transform: rotate(3deg) scaleY(1.03); }
}
@keyframes ot-mascot-busy {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.45) drop-shadow(0 0 12px rgba(255, 255, 255, 0.45)); }
}
.street {
  display: block;
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
}
#status {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 520;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(46, 48, 54, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  pointer-events: none;
}
html[data-ot-theme="light"] #status {
  background: rgba(250, 248, 242, 0.92);
  border-color: rgba(20, 22, 28, 0.12);
}
