@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Share+Tech+Mono&display=swap');

/* ═══════════════════════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════════════════════ */
:root {
  --bg:        #080a08;
  --surface:   #0e1210;
  --surface2:  #161c18;
  --surface3:  #1e2620;
  --border:    #2a3428;
  --border2:   #3a4838;

  --accent:     #ff6600;
  --accent-dim: rgba(255,102,0,.12);
  --accent-glow:rgba(255,102,0,.25);

  --green:     #4a9e5c;
  --danger:    #c0392b;
  --danger-dim:rgba(192,57,43,.15);

  --text:       #d0ccc0;
  --text-dim:   #6a7868;
  --text-bright:#ede9e0;

  --radius:    6px;
  --radius-lg: 12px;

  --loot-color:      #c8a84b;
  --boss-color:      #c0392b;
  --quest-color:     #2e86c1;
  --custom-color:    #9b59b6;
  --bot-color:       #e67e22;
  --exit-color:      #27ae60;
  --structure-color: #8e44ad;
  --tain-color:      #6f8313;
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Rajdhani', sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* scanline */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 3px,
    rgba(0,0,0,.06) 3px, rgba(0,0,0,.06) 4px
  );
  pointer-events: none;
  z-index: 10000;
}

/* ═══════════════════════════════════════════════════════════════
   MAP
═══════════════════════════════════════════════════════════════ */
.map-container { display: contents; }

#mapWrapper {
  position: fixed; inset: 0;
  overflow: hidden;
  cursor: crosshair;
  z-index: 1;
  touch-action: none;
}

#map {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
}

#map img {
  display: block;
  width: 100%;
  pointer-events: none;
  image-rendering: crisp-edges;
  -webkit-user-drag: none;
}

/* ═══════════════════════════════════════════════════════════════
   MARKERS
═══════════════════════════════════════════════════════════════ */
.marker {
  position: absolute;
  transform: translate(-50%, -120%);
  cursor: pointer;
  z-index: 100;
  pointer-events: auto;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1);
}

.marker-icon {
  width: 25px; height: 25px;
  border-radius: 50% 50% 50% 0;
  rotate: -45deg;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  box-shadow: 0 2px 9px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.08);
  transition: box-shadow .15s;
}
.marker:hover .marker-icon {
  box-shadow: 0 0 0 3px rgba(255,255,255,.2), 0 4px 16px rgba(0,0,0,.8);
}
.marker-icon span { rotate: 45deg; line-height: 1; }

.marker-icon.loot      { background: var(--loot-color); }
.marker-icon.boss      { background: var(--boss-color); }
.marker-icon.quest     { background: var(--quest-color); }
.marker-icon.custom    { background: var(--custom-color); }
.marker-icon.bot       { background: var(--bot-color); }
.marker-icon.exit      { background: var(--exit-color); }
.marker-icon.structure { background: var(--structure-color); }
.marker-icon.tain      { background: var(--tain-color); }

/* photo marker */
.marker-photo {
  width: 25px; height: 25px;
  border-radius: 50%;
  rotate: -45deg;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border: 1px solid var(--accent);
  box-shadow: 0 2px 10px rgba(0,0,0,.7);
  transition: box-shadow .15s;
}
.marker-photo img { width: 100%; height: 100%; object-fit: cover; rotate: 45deg; }
.marker:hover .marker-photo { box-shadow: 0 0 0 5px var(--accent), 0 4px 16px rgba(0,0,0,.8); }

/* URL-иконки */
.marker-icon.icon-img {
  width: 36px; height: 36px;
  border-radius: 50%;
  rotate: 0deg;
  overflow: hidden;
  border: 2px solid var(--accent);
  background: #222;
}
.marker-icon.icon-img img { width: 100%; height: 100%; object-fit: cover; }

/* tooltip — только десктоп (hover) */
.marker-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8,10,8,.96);
  border: 1px solid var(--border2);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 5px 11px;
  font-size: 11px;
  font-family: 'Share Tech Mono', monospace;
  letter-spacing: .04em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  max-width: 180px;
  text-align: center;
  white-space: nowrap;
  z-index: 300;
}
.marker:hover .marker-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(2px);
}

/* photo preview — только десктоп */
.marker-preview {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  width: 300px; height: 180px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--accent);
  box-shadow: 0 4px 24px rgba(0,0,0,.85);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 500;
  background: var(--surface);
  padding: 3px;
}
.marker-preview img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: calc(var(--radius) - 3px);
}
.marker:hover .marker-preview {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* блокировка системного меню на изображениях маркеров */
.marker img {
  -webkit-touch-callout: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* ═══════════════════════════════════════════════════════════════
   ADD FORM
═══════════════════════════════════════════════════════════════ */
#addForm {
  position: fixed;
  bottom: 76px; left: 50%;
  transform: translateX(-50%);
  z-index: 9100;
  background: rgba(8,10,8,.97);
  border: 1px solid var(--border2);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  width: 340px;
  max-width: calc(100vw - 28px);
  max-height: calc(100dvh - 90px);
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.8);
  backdrop-filter: blur(16px);
}

/* ═══════════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════════ */
#modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8000;
  backdrop-filter: blur(6px);
}
#modal.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  width: 700px;
  max-width: calc(100vw - 32px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.8);
  animation: modalIn .2s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modalIn {
  from { transform: translateY(12px) scale(.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

.modal-title {
  font-size: 22px; font-weight: 600;
  letter-spacing: .06em;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-bright);
  flex-wrap: wrap;
}

.modal-type-badge {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px; letter-spacing: .12em;
  padding: 2px 8px; border-radius: 20px;
  font-weight: 400; text-transform: uppercase;
}

.badge-loot      { background: rgba(200,168,75,.15);  color: var(--loot-color);      border: 1px solid rgba(200,168,75,.3); }
.badge-boss      { background: rgba(192,57,43,.15);   color: var(--boss-color);      border: 1px solid rgba(192,57,43,.3); }
.badge-quest     { background: rgba(46,134,193,.15);  color: var(--quest-color);     border: 1px solid rgba(46,134,193,.3); }
.badge-custom    { background: rgba(155,89,182,.15);  color: var(--custom-color);    border: 1px solid rgba(155,89,182,.3); }
.badge-bot       { background: rgba(230,126,34,.15);  color: var(--bot-color);       border: 1px solid rgba(230,126,34,.3); }
.badge-exit      { background: rgba(39,174,96,.15);   color: var(--exit-color);      border: 1px solid rgba(39,174,96,.3); }
.badge-structure { background: rgba(142,68,173,.12);  color: var(--structure-color); border: 1px solid rgba(142,68,173,.3); }
.badge-tain      { background: rgba(111,131,19,.15);  color: var(--tain-color);      border: 1px solid rgba(111,131,19,.3); }

.modal-close {
  background: none; border: none;
  color: var(--text-dim);
  font-size: 18px; cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius);
  transition: color .15s, background .15s;
  line-height: 1; flex-shrink: 0;
}
.modal-close:hover { color: var(--text); background: var(--surface3); }

.modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}

.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.modal-photo {
  width: 100%; max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.modal-desc {
  font-size: 14px; line-height: 1.6;
  color: var(--text);
}

.modal-desc-wrap {
  max-height: 200px; overflow-y: auto; padding-right: 4px;
}
.modal-desc-wrap::-webkit-scrollbar { width: 4px; }
.modal-desc-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
.modal-desc-wrap h1, .modal-desc-wrap h2 { font-size: 1.1em; margin: .3em 0; }
.modal-desc-wrap ul, .modal-desc-wrap ol  { padding-left: 1.4em; margin: .3em 0; }
.modal-desc-wrap strong { color: #fff; }
.modal-desc-wrap em     { font-style: italic; }
.modal-desc-wrap u      { text-decoration: underline; }
.modal-desc-wrap s      { text-decoration: line-through; }
.modal-desc-wrap iframe { width: 100%; height: 200px; border: none; border-radius: 6px; }

.modal-coords {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px; color: var(--text-dim);
  letter-spacing: .06em;
}

.modal-extras { display: flex; flex-direction: column; gap: 6px; }
.modal-extra-row { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.modal-extra-label { color: rgba(255,255,255,.5); white-space: nowrap; min-width: 80px; }
.modal-extra-value { color: #e0d8cc; }

.modal-footer {
  padding: 10px 18px;
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

/* editForm */
#editForm { display: none; }
#editForm.active { display: flex; }

/* extra fields */
.extra-field-row { display: flex; gap: 6px; align-items: center; }
.extra-field-row input { flex: 1; }
.extra-field-row .extra-field-remove { flex-shrink: 0; }

/* icon section */
.icon-section { display: flex; flex-direction: column; gap: 6px; }
.icon-section .form-label { margin-bottom: 0; }

/* ═══════════════════════════════════════════════════════════════
   FORM ELEMENTS
═══════════════════════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; letter-spacing: .12em;
  color: var(--text-dim); text-transform: uppercase;
}

.modal-body input[type="text"],
.modal-body input[type="url"],
.modal-body textarea,
.modal-body select,
#addForm input[type="text"],
#addForm input[type="url"],
#addForm textarea,
#addForm select {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px; font-weight: 500;
  padding: 7px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface3);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus,
#addForm input:focus,
#addForm textarea:focus,
#addForm select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { resize: vertical; min-height: 72px; }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════════ */
.modal-footer .btn,
#addForm .btn {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600; font-size: 13px;
  letter-spacing: .06em;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface3);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.modal-footer .btn:hover,
#addForm .btn:hover { background: var(--surface2); transform: translateY(-1px); }
.modal-footer .btn:active,
#addForm .btn:active { transform: translateY(0); }

.modal-footer .btn-primary,
#addForm .btn-primary { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.modal-footer .btn-primary:hover,
#addForm .btn-primary:hover { background: var(--accent); color: #000; box-shadow: 0 4px 16px var(--accent-glow); }

.modal-footer .btn-danger,
#addForm .btn-danger { border-color: var(--danger); color: var(--danger); background: var(--danger-dim); }
.modal-footer .btn-danger:hover,
#addForm .btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { font-size: 12px; padding: 5px 10px; }

/* ═══════════════════════════════════════════════════════════════
   ZOOM
═══════════════════════════════════════════════════════════════ */
#zoomControls {
  position: fixed;
  bottom: 20px; right: 10px;
  z-index: 9000;
  display: flex; flex-direction: column; gap: 5px;
}

.zoom-btn {
  width: 40px; height: 40px;
  background: rgba(8,10,8,.9);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 20px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  backdrop-filter: blur(10px);
}
.zoom-btn:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); transform: scale(1.08); }
.zoom-btn:active { transform: scale(.96); }

/* ═══════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════ */
#toastContainer {
  position: fixed; top: 70px; right: 16px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px; font-weight: 500;
  animation: toastIn .2s ease, toastOut .3s ease 2.7s forwards;
  max-width: 240px;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
}
.toast.err { border-left-color: var(--danger); }

@keyframes toastIn  { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); }   to { opacity:0; transform:translateX(16px); } }

/* ═══════════════════════════════════════════════════════════════
   QUILL DARK THEME
═══════════════════════════════════════════════════════════════ */
.ql-toolbar.ql-snow {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.15) !important;
  border-bottom: none !important;
  border-radius: 6px 6px 0 0;
  padding: 6px;
}
.ql-container.ql-snow {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.15) !important;
  border-radius: 0 0 6px 6px;
  min-height: 90px; max-height: 180px;
  overflow-y: auto;
  font-size: 14px; color: #e0d8cc;
}
.ql-editor { min-height: 80px; padding: 8px 10px; }
.ql-editor.ql-blank::before { color: rgba(255,255,255,.3); font-style: normal; }
.ql-toolbar .ql-stroke { stroke: rgba(255,255,255,.7) !important; }
.ql-toolbar .ql-fill   { fill:   rgba(255,255,255,.7) !important; }
.ql-toolbar .ql-picker-label { color: rgba(255,255,255,.7) !important; }
.ql-toolbar button:hover .ql-stroke,
.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent) !important; }
.ql-toolbar button:hover .ql-fill,
.ql-toolbar button.ql-active .ql-fill   { fill:   var(--accent) !important; }
.ql-toolbar .ql-picker-options { background: #1a1b1c; border-color: rgba(255,255,255,.15) !important; }
.ql-toolbar .ql-picker-item { color: #e0d8cc !important; }

/* emoji picker */
.emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.emoji-btn {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px; padding: 4px 6px;
  font-size: 18px; cursor: pointer;
  transition: background .15s, border-color .15s; line-height: 1;
}
.emoji-btn:hover  { background: rgba(255,255,255,.14); }
.emoji-btn.active { border-color: var(--accent); background: rgba(255,102,0,.18); }

/* ═══════════════════════════════════════════════════════════════
   MOBILE — тач-устройства
═══════════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  /* скрываем tooltip и preview на всех тач-устройствах */
  .marker-tooltip { display: none !important; }
  .marker-preview { display: none !important; }

  /* блокируем системное меню при долгом нажатии */
  .marker img,
  .marker-photo img,
  .marker-icon img {
    -webkit-touch-callout: none;
    pointer-events: none;
    user-select: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BREAKPOINTS
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* modal — bottom sheet на мобиле */
  .modal-box {
    position: fixed;
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    border-radius: 12px 12px 0 0;
    animation: sheetIn .25s cubic-bezier(.34,1.56,.64,1);
  }
  @keyframes sheetIn {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  .modal-title { font-size: 18px; gap: 6px; }
  .modal-photo { max-height: 200px; }
  .modal-body  { padding: 12px 14px; }
  
  .marker-icon,
  .marker-photo {
    width: 6px;
    height: 6px;
    font-size: 4px;
  }

  #addForm {
    bottom: 0;
    left: 0; right: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    max-height: 90dvh;
    border-radius: 12px 12px 0 0;
    border-top: 2px solid var(--accent);
  }

  /* блокируем авто-зум iOS на инпутах */
  input[type="text"],
  input[type="url"],
  textarea, select { font-size: 16px !important; }

  .zoom-btn { width: 44px; height: 44px; font-size: 30px; }
}

@media (max-width: 430px) {
  .modal-title { font-size: 16px; }
  .modal-footer { gap: 5px; padding: 5px 8px; }
  .modal-footer .btn { font-size: 12px; padding: 5px 8px; }
  
  .marker-icon,
  .marker-photo {
    width: 6px;
    height: 6px;
    font-size: 4px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   LEVEL CONTROLS
═══════════════════════════════════════════════════════════════ */
#levelControls {
  position: fixed;
  bottom: 20px; left: 10px;
  z-index: 9000;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
 #levelLabel {
  font-family: 'Share Tech Mono', monospace;
  font-size: 8px;
  letter-spacing: .1em;
  color: var(--accent);
  background: rgba(8,10,8,.9);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
  min-width: 35px;
  white-space: nowrap;
}

#levelUp, #levelDown {
  width: 40px; height: 40px;
  background: rgba(8,10,8,.9);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 18px; line-height: 1;
  cursor: pointer;
 }
