:root {
  font-family: Inter, ui-rounded, "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #362b50;
  background: #e9e3f7;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { overflow: hidden; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.is-hidden { display: none !important; }

#ak-meu-mundo-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  width: 100%;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
}

.ak-game { position: relative; width: 100%; height: 100%; overflow: hidden; background: #e9e3f7; }

/* ========================= MAPA ========================= */
.ak-map-view {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: linear-gradient(180deg, #79d4ff 0%, #dff5ff 100%);
}

.ak-map-topbar {
  position: relative;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 74px;
  padding: max(10px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid rgba(74,53,122,.12);
  box-shadow: 0 9px 28px rgba(49,32,85,.17);
  backdrop-filter: blur(15px);
}

.ak-brand { display: flex; align-items: center; gap: 11px; min-width: max-content; color: #6f42d8; }
.ak-brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #9d6fff, #6635d2);
  box-shadow: 0 10px 23px rgba(100,54,204,.31);
  font-size: 23px;
  font-weight: 950;
}
.ak-brand-copy { display: grid; line-height: 1.08; }
.ak-brand-copy strong { font-size: 19px; font-weight: 950; }
.ak-brand-copy small { margin-top: 4px; color: #7c708e; font-size: 12px; font-weight: 800; }
.ak-brand-text { font-weight: 950; }
.ak-map-top-actions { margin-left: auto; display: flex; gap: 8px; }

.ak-map-scroll {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: none;
  scrollbar-width: none;
  background: #8edcff;
}
.ak-map-scroll::-webkit-scrollbar { display: none; }

.ak-map-canvas {
  position: relative;
  /* O mundo fica propositalmente maior que a janela para poder ser explorado. */
  width: max(1480px, 125vw, calc((100dvh - 74px) * 16 / 9));
  min-width: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: inset 0 0 80px rgba(0,65,114,.12);
}
.ak-map-canvas.is-panning { cursor: grabbing; }
.ak-map-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.ak-map-hotspots, .ak-map-free-slots { position: absolute; inset: 0; pointer-events: none; }

.ak-map-hotspot {
  position: absolute;
  z-index: 8;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  color: inherit;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.ak-map-hotspot:hover,
.ak-map-hotspot:active,
.ak-map-hotspot:focus,
.ak-map-hotspot:focus-visible {
  border: 0 !important;
  outline: 0;
  color: inherit;
  background: transparent !important;
  box-shadow: none !important;
}
.ak-map-hotspot:focus-visible .ak-hotspot-pulse {
  outline: 4px solid rgba(255,255,255,.98);
  outline-offset: 5px;
}
.ak-hotspot-pulse {
  position: relative;
  display: block;
  width: 46px;
  height: 46px;
  border: 5px solid rgba(255,255,255,.96);
  border-radius: 50%;
  background: linear-gradient(145deg,#8d5df2,#6131c8);
  box-shadow: 0 7px 20px rgba(49,25,94,.38), 0 0 0 8px rgba(139,87,239,.23);
  transition: transform .16s ease;
}
.ak-hotspot-pulse::before {
  content: '';
  position: absolute;
  inset: -12px;
  border: 3px solid rgba(255,255,255,.75);
  border-radius: 50%;
  animation: ak-map-pulse 1.9s ease-out infinite;
}
.ak-hotspot-pulse::after {
  content: '▶';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-left: 3px;
  color: white;
  font-size: 16px;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.22));
}
.ak-map-hotspot:hover .ak-hotspot-pulse { transform: scale(1.12); }
.ak-hotspot-label {
  position: absolute;
  top: calc(50% + 35px);
  padding: 7px 13px;
  border-radius: 999px;
  color: #513c7a;
  background: rgba(255,255,255,.96);
  box-shadow: 0 8px 19px rgba(42,28,75,.22);
  font-size: 12px;
  font-weight: 950;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .16s ease, transform .16s ease;
  white-space: nowrap;
}
.ak-map-hotspot:hover .ak-hotspot-label,
.ak-map-hotspot:focus-visible .ak-hotspot-label { opacity: 1; transform: translateY(0); }

@keyframes ak-map-pulse {
  0% { transform: scale(.75); opacity: .95; }
  80%,100% { transform: scale(1.45); opacity: 0; }
}

.ak-map-free-slot {
  position: absolute;
  z-index: 9;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
  border: 4px dashed rgba(255,255,255,.93);
  border-radius: 50%;
  color: white;
  background: rgba(111,66,216,.72);
  box-shadow: 0 8px 25px rgba(55,31,98,.34);
  cursor: pointer;
  pointer-events: auto;
}
.ak-map-free-slot span { font-size: 34px; line-height: 1; }

.ak-map-hint {
  position: absolute;
  z-index: 30;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 999px;
  color: white;
  background: rgba(38,26,67,.72);
  box-shadow: 0 10px 24px rgba(38,26,67,.25);
  backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 900;
  pointer-events: none;
}

.ak-map-dock {
  position: absolute;
  z-index: 45;
  right: 16px;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 24px;
  background: rgba(255,255,255,.91);
  box-shadow: 0 16px 42px rgba(40,24,72,.29);
  backdrop-filter: blur(14px);
  scrollbar-width: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(calc(100% + 34px));
  transition: transform .24s ease, opacity .2s ease, visibility .2s ease;
}
.ak-map-dock.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.ak-map-dock::-webkit-scrollbar { display: none; }
.ak-map-location-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 155px;
  min-height: 66px;
  padding: 6px 12px 6px 7px;
  border: 2px solid transparent;
  border-radius: 18px;
  color: #45355f;
  background: #f8f5ff;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.ak-map-location-card:hover { transform: translateY(-3px); border-color: #b89be9; background: white; }
.ak-map-location-card img { width: 56px; height: 56px; object-fit: contain; flex: 0 0 auto; }
.ak-map-location-card span { display: grid; min-width: 0; text-align: left; }
.ak-map-location-card strong { font-size: 13px; font-weight: 950; }
.ak-map-location-card small { margin-top: 3px; color: #887b9b; font-size: 10px; font-weight: 800; white-space: nowrap; }

.ak-map-toast {
  position: absolute;
  z-index: 80;
  top: 94px;
  left: 50%;
  max-width: min(90%, 480px);
  padding: 13px 19px;
  transform: translate(-50%, -15px);
  opacity: 0;
  pointer-events: none;
  border-radius: 16px;
  color: white;
  background: rgba(52,36,80,.94);
  box-shadow: 0 12px 32px rgba(33,20,56,.32);
  font-weight: 850;
  transition: opacity .2s ease, transform .2s ease;
}
.ak-map-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ========================= BOTÕES ========================= */
.ak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 15px;
  color: #4d3c70;
  background: #f2edfb;
  font-weight: 900;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
.ak-btn:hover { transform: translateY(-1px); background: #e9e0fa; }
.ak-btn:active { transform: translateY(1px) scale(.98); }
.ak-btn:disabled { opacity: .38; cursor: default; transform: none; }
.ak-btn-primary { color: white; background: linear-gradient(145deg, #8d5df2, #6d3ad2); box-shadow: 0 8px 18px rgba(109,58,210,.22); }
.ak-btn-primary:hover { background: linear-gradient(145deg, #996cf6, #713bd7); }
.ak-btn-danger { color: #b53159; background: #ffe9ef; }

/* ========================= EDITOR ========================= */
.ak-editor-view {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: linear-gradient(145deg, #f8f4ff, #e8e1fb);
}
.ak-topbar {
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid rgba(88,57,145,.13);
  box-shadow: 0 7px 24px rgba(71,47,111,.10);
}
.ak-editor-brand { margin-right: 2px; }
.ak-location-select {
  min-width: 150px;
  height: 44px;
  padding: 0 38px 0 14px;
  border: 2px solid #ded4f2;
  border-radius: 15px;
  color: #49386c;
  background: #faf8ff;
  font-weight: 850;
  outline: none;
}
.ak-spacer { flex: 1; }
.ak-actions { display: flex; align-items: center; gap: 8px; }
.ak-save-status { min-width: 116px; text-align: right; font-size: 13px; font-weight: 800; color: #77688e; }
.ak-main { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: 0; padding: 12px; gap: 12px; }

.ak-catalog {
  z-index: 15;
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(88,57,145,.12);
  border-radius: 25px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 17px 45px rgba(65,43,103,.12);
}
.ak-catalog-head { position: relative; padding: 16px 16px 10px; }
.ak-catalog-title { margin: 0 0 12px; font-size: 20px; font-weight: 950; }
.ak-search { width: 100%; height: 43px; padding: 0 14px; border: 2px solid #e7def5; border-radius: 14px; background: #fbf9ff; outline: none; }
.ak-search:focus { border-color: #9f7ae8; }
.ak-categories { display: flex; gap: 7px; overflow-x: auto; padding: 0 16px 12px; scrollbar-width: none; }
.ak-categories::-webkit-scrollbar { display: none; }
.ak-category { min-width: max-content; padding: 9px 12px; border: 0; border-radius: 13px; background: #f3effa; color: #67557f; font-size: 13px; font-weight: 900; cursor: pointer; }
.ak-category.is-active { color: white; background: #7c4dff; }
.ak-items { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; overflow-y: auto; padding: 4px 14px 18px; }
.ak-item { position: relative; display: grid; min-height: 128px; place-items: center; padding: 9px; border: 2px solid transparent; border-radius: 19px; background: #f7f3ff; cursor: pointer; transition: transform .15s ease,border-color .15s ease; }
.ak-item:hover { transform: translateY(-2px); border-color: #c7aff4; }
.ak-item img { width: 82px; height: 82px; object-fit: contain; pointer-events: none; }
.ak-item span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-size: 12px; font-weight: 900; color: #4d3c70; }
.ak-empty { grid-column: 1/-1; padding: 30px 10px; text-align: center; color: #877b99; }

.ak-stage-wrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; border-radius: 27px; background: #f7f3ff; box-shadow: 0 17px 45px rgba(65,43,103,.13); }
.ak-stage { width: 100%; height: 100%; min-height: 300px; touch-action: none; }
.ak-stage canvas { display: block; width: 100%; height: 100%; }
.ak-object-tools { position: absolute; left: 50%; bottom: 18px; z-index: 12; display: none; align-items: center; gap: 7px; padding: 8px; transform: translateX(-50%); border: 1px solid rgba(91,54,155,.12); border-radius: 19px; background: rgba(255,255,255,.94); box-shadow: 0 12px 35px rgba(51,33,83,.2); backdrop-filter: blur(10px); }
.ak-object-tools.is-visible { display: flex; }
.ak-object-tools .ak-btn { min-width: 42px; min-height: 42px; padding: 0 11px; border-radius: 13px; }
.ak-open-catalog { display: none; position: absolute; left: 14px; bottom: 15px; z-index: 13; }
.ak-catalog-close { display: none; }
.ak-toast { position: absolute; top: 16px; left: 50%; z-index: 30; max-width: min(90%,430px); padding: 12px 18px; transform: translate(-50%,-15px); opacity: 0; pointer-events: none; border-radius: 16px; color: white; background: rgba(54,39,83,.92); font-weight: 800; box-shadow: 0 12px 30px rgba(34,24,52,.28); transition: opacity .2s ease,transform .2s ease; }
.ak-toast.is-visible { transform: translate(-50%,0); opacity: 1; }
.ak-load-more { grid-column: 1/-1; width: 100%; margin-top: 5px; }

@media (max-width: 900px) {
  .ak-map-topbar { min-height: 66px; padding: 8px 10px; }
  .ak-brand-copy small { display: none; }
  .ak-brand-copy strong { font-size: 16px; }
  .ak-brand-mark { width: 43px; height: 43px; border-radius: 15px; }
  .ak-map-top-actions .ak-btn { padding: 0 11px; }
  .ak-map-canvas { width: calc((100dvh - 66px) * 16 / 9); min-width: 1050px; }
  .ak-map-hint { top: 80px; font-size: 12px; }
  .ak-map-dock { right: 8px; bottom: 8px; left: 8px; }
  .ak-map-location-card { min-width: 142px; }
  .ak-hotspot-label { opacity: 1; transform: none; padding: 6px 10px; }

  .ak-topbar { min-height: 64px; padding: 8px 10px; gap: 7px; }
  .ak-editor-brand { display: none; }
  .ak-location-select { min-width: 122px; max-width: 150px; height: 42px; }
  .ak-save-status { display: none; }
  .ak-btn-label { display: none; }
  .ak-actions { gap: 5px; }
  .ak-actions .ak-btn { padding: 0 10px; }
  .ak-main { grid-template-columns: 1fr; padding: 8px; }
  .ak-stage-wrap { border-radius: 21px; }
  .ak-catalog { position: fixed; inset: auto 8px 8px 8px; z-index: 100; max-height: min(72dvh,610px); transform: translateY(calc(100% + 20px)); transition: transform .25s ease; border-radius: 25px; }
  .ak-catalog.is-open { transform: translateY(0); }
  .ak-catalog-close { display: inline-flex; position: absolute; top: 11px; right: 11px; }
  .ak-open-catalog { display: inline-flex; }
  .ak-items { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .ak-item { min-height: 112px; }
  .ak-item img { width: 70px; height: 70px; }
  .ak-object-tools { bottom: 14px; max-width: calc(100% - 120px); overflow-x: auto; }
}

@media (max-width: 560px) {
  #ak-meu-mundo-root { min-height: 480px; }
  .ak-map-top-actions .ak-center-map span,
  .ak-map-top-actions .ak-open-locations span { display: none; }
  .ak-map-top-actions .ak-btn { min-width: 43px; padding: 0 10px; }
  .ak-map-hint { max-width: calc(100% - 20px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ak-location-select { min-width: 105px; max-width: 120px; padding-left: 9px; }
  .ak-actions .ak-btn:nth-child(1), .ak-actions .ak-btn:nth-child(2) { display: none; }
  .ak-items { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; padding-inline: 10px; }
  .ak-item { min-height: 104px; padding: 5px; }
  .ak-item img { width: 62px; height: 62px; }
  .ak-object-tools .ak-btn { min-width: 40px; padding: 0 10px; }
}

/* ========================= MAPA: ZOOM E GESTOS V2.2 ========================= */
.ak-map-canvas {
  width: var(--ak-map-width, max(1480px, 125vw, calc((100dvh - 74px) * 16 / 9)));
  flex: 0 0 auto;
  will-change: width;
}

.ak-map-zoom-controls {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  overflow: hidden;
  border: 1px solid rgba(91, 54, 155, .12);
  border-radius: 15px;
  background: #f2edfb;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
}

.ak-map-zoom-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  border: 0;
  color: #513d76;
  background: transparent;
  font-size: 22px;
  font-weight: 950;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease, opacity .15s ease;
}

.ak-map-zoom-button:hover { background: #e7def8; }
.ak-map-zoom-button:active { transform: scale(.92); }
.ak-map-zoom-button:disabled { opacity: .32; cursor: default; transform: none; }
.ak-map-zoom-value {
  min-width: 54px;
  padding: 0 7px;
  text-align: center;
  color: #695685;
  font-size: 12px;
  font-weight: 950;
  pointer-events: none;
}

.ak-map-hint-touch { display: none; }

/* Impede seleção/arraste nativo dos elementos sobre o mapa sem bloquear o pan. */
.ak-map-canvas,
.ak-map-canvas * {
  -webkit-user-drag: none;
}

@media (max-width: 900px), (pointer: coarse) {
  .ak-map-zoom-controls { display: none; }
  .ak-map-hint-desktop { display: none; }
  .ak-map-hint-touch { display: inline; }
  .ak-map-canvas {
    width: var(--ak-map-width, 1080px);
    min-width: 0;
  }
}
