:root {
  --ink: #1a1208;
  --cream: #f7e7c8;
  --amber: #f0a202;
  --ember: #e85d04;
  --moss: #2f5233;
  --night: #120c07;
  --panel: rgba(18, 12, 7, 0.88);
  --line: rgba(247, 231, 200, 0.18);
  --ok: #7cb518;
  --danger: #c1121f;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --dock-h: 64px;
  --top-h: 72px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--cream);
  font-family: var(--font-body);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, #4a2c0a 0%, transparent 55%),
    radial-gradient(circle at 85% 20%, rgba(232, 93, 4, 0.18), transparent 35%),
    var(--night);
  overflow: hidden;
  /* visualViewport задаёт --app-height в app.js — убирает дыру над панелью браузера */
  height: var(--app-height, 100svh);
  max-height: var(--app-height, 100svh);
}

button,
.sticker {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  height: 100%;
  max-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  .app {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

.topbar {
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--top-h);
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(18, 12, 7, 0.96), rgba(18, 12, 7, 0.72));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  font-size: 1.6rem;
  filter: drop-shadow(0 0 10px rgba(240, 162, 2, 0.45));
  animation: bob 2.8s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-3px) rotate(4deg);
  }
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.92rem, 3.6vw, 1.05rem);
  letter-spacing: 0.01em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.mod-badge {
  display: inline-block;
  flex: 0 0 auto;
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  color: #1a1208;
  background: linear-gradient(135deg, #ffe08a, #f0a202);
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.72rem;
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(46vw, 11.5rem);
}

.mode-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(247, 231, 200, 0.08);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--cream);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.8rem;
  min-height: 40px;
  padding: 8px 11px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.7;
}

.mode-btn.is-active {
  background: linear-gradient(135deg, var(--amber), var(--ember));
  color: var(--ink);
  opacity: 1;
  box-shadow: 0 4px 16px rgba(232, 93, 4, 0.35);
  animation: modeGlow 2.4s ease-in-out infinite;
}

@keyframes modeGlow {
  0%,
  100% {
    box-shadow: 0 4px 14px rgba(232, 93, 4, 0.3);
  }
  50% {
    box-shadow: 0 4px 22px rgba(240, 162, 2, 0.55);
  }
}

.map-wrap {
  position: relative;
  min-height: 0;
}

#map {
  height: 100%;
  width: 100%;
  background: #1d1710;
}

.dock {
  z-index: 500;
  padding: 8px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  .dock {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
}

.dock-mini {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.dock-mini #locateBtn {
  flex: 1 1 auto;
  min-height: 44px;
  font-size: 0.95rem;
}

.dock-toggle {
  flex: 0 0 auto;
  min-width: 4.5rem;
  min-height: 44px;
}

.dock.is-collapsed {
  --dock-h: 64px;
}

.dock:not(.is-collapsed) {
  --dock-h: auto;
}

.dock-panel {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.dock-panel[hidden] {
  display: none !important;
}

.dock-hint {
  margin: 0 0 8px;
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stickers {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.stickers::-webkit-scrollbar {
  display: none;
}

.sticker {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 64px;
  max-width: 78px;
  min-height: 54px;
  padding: 6px 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(247, 231, 200, 0.06);
  color: var(--cream);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.64rem;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.sticker:hover {
  transform: translateY(-2px);
}

.sticker:active {
  transform: scale(0.94);
}

.sticker.is-selected {
  border-color: var(--amber);
  background: rgba(240, 162, 2, 0.18);
  box-shadow: 0 0 0 1px rgba(240, 162, 2, 0.35);
}

.sticker.is-selected .sticker-emoji {
  animation: emojiWiggle 1.1s ease-in-out infinite;
}

.sticker.is-tap {
  animation: stickerPop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.sticker-emoji {
  font-size: 1.35rem;
  line-height: 1;
  display: inline-block;
}

@keyframes emojiWiggle {
  0%,
  100% {
    transform: rotate(-6deg) scale(1);
  }
  50% {
    transform: rotate(8deg) scale(1.12);
  }
}

@keyframes stickerPop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.dock-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.dock-actions .ghost-btn:not([hidden]),
.dock-actions #installBtn:not([hidden]) {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 10px 12px;
  font-size: 0.82rem;
}

.dock-actions [hidden] {
  display: none !important;
}

.ghost-btn,
.primary-btn,
.danger-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 800;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.ghost-btn:active,
.primary-btn:active,
.danger-btn:active {
  transform: scale(0.96);
}

.primary-btn.is-pulse-once {
  animation: ctaPulse 0.55s ease;
}

@keyframes ctaPulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  40% {
    transform: scale(1.04);
    filter: brightness(1.12);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.ghost-btn {
  background: rgba(247, 231, 200, 0.08);
  color: var(--cream);
  border: 1px solid var(--line);
}

.ghost-btn.is-on {
  border-color: var(--ok);
  color: #c6f6a1;
}

.primary-btn {
  background: linear-gradient(135deg, var(--amber), var(--ember));
  color: var(--ink);
}

.danger-btn {
  background: rgba(193, 18, 31, 0.9);
  color: #fff;
}

.sheet {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: #20160d;
  color: var(--cream);
  width: min(92vw, 360px);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.sheet[open] {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.sheet::backdrop {
  background: rgba(8, 5, 2, 0.62);
  animation: fadeIn 0.22s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sheet-inner {
  padding: 18px;
}

.sheet h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.sheet p {
  margin: 0 0 12px;
  opacity: 0.85;
  line-height: 1.4;
}

.sheet input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--cream);
  font: inherit;
  font-size: 16px; /* iOS: без автозума при фокусе */
  margin-bottom: 10px;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.setup-actions .primary-btn,
.setup-actions .ghost-btn {
  flex: 1 1 auto;
  min-width: 7.5rem;
}

.sheet-error {
  color: #ff8a80;
}

.sheet-wide {
  width: min(94vw, 420px);
}

.field-label {
  display: block;
  font-size: 0.78rem;
  opacity: 0.75;
  margin: 0 0 4px;
}

.rating-lead {
  margin-top: -4px;
}

.rating-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 12px;
}

.rating-grid h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1rem;
}

.rating-list {
  margin: 0;
  padding-left: 1.25rem;
  line-height: 1.45;
  font-size: 0.9rem;
}

.rating-list li {
  margin-bottom: 4px;
}

.rating-empty {
  opacity: 0.65;
  list-style: none;
  margin-left: -1.25rem;
}

.ymaps-2-1-79-map,
.ymaps-2-1-79-inner-panes {
  background: #1d1710 !important;
}

/* Не перекрываем копирайт / «Открыть в Яндекс Картах» */
.ymaps-2-1-79-copyright,
.ymaps-2-1-79-map-copyrights-promo {
  z-index: 450 !important;
}

.ymaps-2-1-79-controls__control_toolbar {
  margin-top: 8px !important;
  margin-right: 8px !important;
}

.marker-anchor {
  position: relative;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
}

.marker-wrap {
  width: 44px !important;
  height: 52px !important;
  min-width: 44px;
  min-height: 52px;
  position: absolute !important;
  display: block !important;
  box-sizing: border-box !important;
  background: transparent !important;
  border: 0 !important;
  overflow: visible;
  pointer-events: auto;
  /* запрет старого ромба / transform-якоря */
  transform: none !important;
}

.wish-field {
  display: grid;
  gap: 4px;
  margin: 0 0 8px;
}

.wish-field .wish-label {
  font-size: 0.78rem;
  color: rgba(255, 248, 230, 0.72);
}

.wish-field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 248, 230, 0.22);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff8e6;
  padding: 10px 12px;
  font: inherit;
}

.wish-field input::placeholder {
  color: rgba(255, 248, 230, 0.45);
}

.marker-wish {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(240, 162, 2, 0.14);
  color: #fff8e6;
  font-size: 0.95rem;
  line-height: 1.35;
}

.sheet-wish {
  margin-bottom: 10px;
}

.marker-drag-hint {
  margin: 0 0 10px;
  font-size: 0.92rem;
  color: rgba(255, 248, 230, 0.82);
}

body.is-moving-marker {
  cursor: crosshair;
}

body.is-moving-marker .dock {
  outline: 2px solid rgba(240, 162, 2, 0.55);
  outline-offset: -2px;
}

body.is-moving-marker #statusLine {
  color: #f0a202;
}

.marker-bob {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  transform-origin: 50% 100%;
  animation: markerPulseScale 2.8s ease-in-out infinite;
  pointer-events: none;
}

.marker-bob.anim-a { animation-delay: 0s; }
.marker-bob.anim-b { animation-delay: -0.7s; }
.marker-bob.anim-c { animation-delay: -1.4s; }
.marker-bob.anim-d { animation-delay: -2.1s; }
.marker-bob.anim-candy {
  animation: markerCandyScale 2.2s ease-in-out infinite;
}

.marker-bob.is-pop {
  animation: markerPopIn 0.55s cubic-bezier(0.2, 0.9, 0.25, 1.35);
}

/* Только scale — без translateY, чтобы остриё не «уплывало» от дома */
@keyframes markerPulseScale {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@keyframes markerCandyScale {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes markerPopIn {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  70% {
    transform: scale(1.12);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.marker-pin {
  position: absolute;
  left: 2px;
  top: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid rgba(255, 248, 230, 0.9);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  font-size: 1.2rem;
  /* критично: никакого rotate — иначе якорь уезжает при зуме */
  transform: none !important;
}

.marker-point {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 0;
  margin-left: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 12px solid #e85d04;
  display: block;
}

.marker-point.candy_open { border-top-color: #e85d04; }
.marker-point.pumpkin { border-top-color: #c36f09; }
.marker-point.star { border-top-color: #e64980; }
.marker-point.spider { border-top-color: #343a40; }
.marker-point.skull { border-top-color: #495057; }

.marker-pin .marker-emoji {
  line-height: 1;
  display: inline-block;
  animation: emojiBob 2.4s ease-in-out infinite;
}

@keyframes emojiBob {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.marker-count {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 5px;
  border-radius: 999px;
  background: #120c07;
  color: #f7e7c8;
  border: 1.5px solid #f0a202;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35rem;
  text-align: center;
  box-sizing: border-box;
}

.marker-count.is-hidden {
  display: none;
}

.marker-pin.candy_open {
  background: linear-gradient(145deg, #f0a202, #e85d04);
}

.marker-pin.pumpkin {
  background: linear-gradient(145deg, #ffa62b, #c36f09);
}

.marker-pin.star {
  background: linear-gradient(145deg, #ffa8cc, #e64980);
}

.marker-pin.spider {
  background: linear-gradient(145deg, #6c757d, #343a40);
}

.marker-pin.skull {
  background: linear-gradient(145deg, #adb5bd, #495057);
}

.pulse-ring {
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(240, 162, 2, 0.55);
  }
  100% {
    box-shadow: 0 0 0 16px rgba(240, 162, 2, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .marker-bob,
  .marker-pin .marker-emoji,
  .sticker.is-selected .sticker-emoji,
  .mode-btn.is-active,
  .brand-mark,
  .pulse-ring {
    animation: none !important;
  }
}

@media (min-width: 800px) {
  .brand-sub {
    max-width: none;
  }

  .dock {
    padding: 12px 16px;
  }

  .dock-hint {
    -webkit-line-clamp: unset;
    display: block;
    font-size: 0.86rem;
  }

  .dock-actions {
    flex-wrap: wrap;
  }

  .dock-actions .ghost-btn,
  .dock-actions #installBtn {
    flex: 0 0 auto;
    min-height: 42px;
  }
}

@media (max-width: 360px) {
  .mode-btn {
    padding: 8px 9px;
    font-size: 0.74rem;
  }

  .brand-mark {
    font-size: 1.35rem;
  }
}
