/* ============================================================
   BlueMap
   A modern, minimal interface for browsing Minecraft worlds.
   ============================================================ */

@font-face {
  font-family: Quicksand;
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: local("Quicksand"),
       url(./Quicksand-06927fae.ttf) format("truetype-variations");
}

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */

:root {
  font-family: Quicksand, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;

  --r-xs: 4px; --r-sm: 6px;  --r-md: 10px;
  --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  --ease:     cubic-bezier(.32, .72, 0, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --t-fast: var(--dur-1) var(--ease);
  --t-mid:  var(--dur-2) var(--ease);
  --t-slow: var(--dur-3) var(--ease);

  --bg:            #0e0d12;
  --bg-elevated:   #16151c;
  --bg-hover:      #1d1c24;
  --bg-active:     #262430;
  --bg-glass:      rgba(14, 13, 18, .72);

  --border:        rgba(255, 255, 255, .06);
  --border-strong: rgba(255, 255, 255, .10);

  --fg:            #ebe9f0;
  --fg-muted:      #9b95a8;
  --fg-subtle:     #6a6475;

  --accent:        #9932CC;
  --accent-hover:  #a945db;
  --accent-muted:  #7a28a3;
  --accent-subtle: rgba(153, 50, 204, .12);
  --accent-ring:   rgba(153, 50, 204, .35);

  --danger: #ef4444;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .30);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .40),
               0 1px 3px  rgba(0, 0, 0, .25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55),
               0 4px 12px  rgba(0, 0, 0, .35);
  --shadow-ring: 0 0 0 3px var(--accent-ring);

  --theme-switch-button-on: var(--accent);
  --theme-stars-day:    #ffffff;
  --theme-moon-day:     #c9b6de;
  --theme-stars-night:  #262430;
  --theme-moon-night:   #0e0d12;
}

:root .theme-light {
  font-weight: 500;
  --bg:            #ffffff;
  --bg-elevated:   #f8f7fa;
  --bg-hover:      #f0eff4;
  --bg-active:     #e6e4ec;
  --bg-glass:      rgba(255, 255, 255, .78);
  --border:        rgba(20, 15, 30, .08);
  --border-strong: rgba(20, 15, 30, .14);
  --fg:            #17151b;
  --fg-muted:      #6a6475;
  --fg-subtle:     #97919f;
  --accent:        #8429b3;
  --accent-hover:  #9932CC;
  --accent-muted:  #6f2296;
  --accent-subtle: rgba(153, 50, 204, .10);
  --accent-ring:   rgba(153, 50, 204, .25);
  --shadow-sm: 0 1px 2px rgba(20, 15, 30, .06);
  --shadow-md: 0 4px 16px rgba(20, 15, 30, .10),
               0 1px 3px  rgba(20, 15, 30, .06);
  --shadow-lg: 0 16px 48px rgba(20, 15, 30, .14),
               0 4px 12px  rgba(20, 15, 30, .08);
  --theme-stars-day:    #6a6475;
  --theme-moon-day:     #17151b;
  --theme-stars-night:  #ffffff;
  --theme-moon-night:   #c9b6de;
}

:root .theme-contrast {
  --bg:            #000000;
  --bg-elevated:   #0b0a0e;
  --bg-hover:      #17151c;
  --bg-active:     #221f2a;
  --bg-glass:      rgba(0, 0, 0, .82);
  --border:        rgba(255, 255, 255, .12);
  --border-strong: rgba(255, 255, 255, .20);
  --fg:            #ffffff;
  --fg-muted:      #b8b0c1;
  --fg-subtle:     #8a8294;
  --accent:        #b26fdd;
  --accent-hover:  #c58ee8;
  --accent-muted:  #9932CC;
  --accent-subtle: rgba(178, 111, 221, .18);
  --accent-ring:   rgba(178, 111, 221, .40);
}

@media (prefers-color-scheme: light) {
  :root {
    font-weight: 500;
    --bg:            #ffffff;
    --bg-elevated:   #f8f7fa;
    --bg-hover:      #f0eff4;
    --bg-active:     #e6e4ec;
    --bg-glass:      rgba(255, 255, 255, .78);
    --border:        rgba(20, 15, 30, .08);
    --border-strong: rgba(20, 15, 30, .14);
    --fg:            #17151b;
    --fg-muted:      #6a6475;
    --fg-subtle:     #97919f;
    --accent:        #8429b3;
    --accent-hover:  #9932CC;
    --accent-muted:  #6f2296;
    --accent-subtle: rgba(153, 50, 204, .10);
    --accent-ring:   rgba(153, 50, 204, .25);
    --shadow-sm: 0 1px 2px rgba(20, 15, 30, .06);
    --shadow-md: 0 4px 16px rgba(20, 15, 30, .10),
                 0 1px 3px  rgba(20, 15, 30, .06);
    --shadow-lg: 0 16px 48px rgba(20, 15, 30, .14),
                 0 4px 12px  rgba(20, 15, 30, .08);
    --theme-stars-day:    #6a6475;
    --theme-moon-day:     #17151b;
    --theme-stars-night:  #ffffff;
    --theme-moon-night:   #c9b6de;
  }
  :root .theme-dark {
    --bg:            #0e0d12;
    --bg-elevated:   #16151c;
    --bg-hover:      #1d1c24;
    --bg-active:     #262430;
    --bg-glass:      rgba(14, 13, 18, .72);
    --border:        rgba(255, 255, 255, .06);
    --border-strong: rgba(255, 255, 255, .10);
    --fg:            #ebe9f0;
    --fg-muted:      #9b95a8;
    --fg-subtle:     #6a6475;
    --accent:        #9932CC;
    --accent-hover:  #a945db;
    --accent-muted:  #7a28a3;
    --accent-subtle: rgba(153, 50, 204, .12);
    --accent-ring:   rgba(153, 50, 204, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .30);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .40),
                 0 1px 3px  rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55),
                 0 4px 12px  rgba(0, 0, 0, .35);
    --theme-stars-day:    #ffffff;
    --theme-moon-day:     #c9b6de;
    --theme-stars-night:  #262430;
    --theme-moon-night:   #0e0d12;
  }
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  font-size: inherit;
  text-align: left;
  margin: 1em 0 .5em;
  padding: 0;
}

h1, h2 {
  position: relative;
  font-size: 1.05em;
  letter-spacing: -.005em;
  padding-left: var(--sp-3);
  padding-bottom: var(--sp-2);
  margin: var(--sp-4) var(--sp-2) var(--sp-2);
  width: calc(100% - var(--sp-3));
  color: var(--fg);
}
h1::before, h2::before {
  content: "";
  position: absolute;
  left: 0; top: .25em;
  width: 2px; height: .85em;
  border-radius: 1px;
  background: var(--accent);
  opacity: .9;
}
h1::after, h2::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--border);
}
h1 { text-align: center; padding-left: 0; margin-left: 0; width: 100%; }
h1::before { display: none; }

p { margin: .5em 0; padding: 0; }

a {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--accent-subtle);
  transition: color var(--t-fast), text-decoration-color var(--t-fast);
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: .78em;
  line-height: 1;
}

input {
  display: inline-block;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
  font: inherit;
  color: inherit;
  background: transparent;
}
input::placeholder { color: var(--fg-subtle); opacity: 1; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); background-clip: padding-box; }

/* ============================================================
   3. NUMERIC FIELDS — THIN SINGLE-LINE COORDINATES
   ============================================================
   Layout (all on ONE row, nothing can break it):
       [ X ]  481     [ Z ]  120
   Every layout property is forced with !important so that no
   external / inherited CSS can push the value below the badge.
   ============================================================ */

.number-input {
  /* Force horizontal single-line layout, no matter what */
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;

  /* Thin row */
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;

  padding: 0 8px !important;
  margin: 0 !important;

  background: transparent;
  border-radius: var(--r-sm);
  color: var(--fg);
  white-space: nowrap !important;
  vertical-align: middle;
  transition: background var(--t-fast);
}
.number-input:hover { background: var(--bg-hover); }

/* Axis badge — small chip at the left, on the same line */
.number-input .label {
  display: inline-flex !important;
  flex: 0 0 auto !important;
  align-items: center !important;
  justify-content: center !important;

  width: auto !important;
  min-width: 20px !important;
  height: 18px !important;
  padding: 0 5px !important;
  margin: 0 !important;

  background: var(--bg-elevated);
  border-radius: var(--r-xs);
  color: var(--fg-muted);
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1 !important;
  white-space: nowrap !important;

  pointer-events: none;
  user-select: none;
  transition: color var(--t-fast), background var(--t-fast);
}
.number-input:hover .label {
  color: var(--accent-hover);
  background: var(--accent-subtle);
}

/* Value — inline, fixed width, right-aligned digits, same row */
.number-input input {
  display: inline-block !important;
  flex: 0 0 auto !important;

  width: 5ch !important;
  min-width: 0 !important;
  height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;

  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: inherit;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  text-align: right !important;
  vertical-align: middle;

  -moz-appearance: textfield;
  appearance: textfield;
}
.number-input input::-webkit-inner-spin-button,
.number-input input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Two coordinate fields side by side, inline, no stretching */
.position-input {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 0 !important;
  padding: 0 !important;
  user-select: none;
}
.position-input > * {
  flex: 0 0 auto !important;
  width: auto !important;
}
.position-input > * + * {
  margin-left: 2px !important;
  padding-left: 2px !important;
  border-left: 1px solid var(--border);
}

/* ============================================================
   4. SVG BUTTONS
   ============================================================ */

.svg-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: auto;
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  background: transparent;
  color: var(--fg-muted);
  border: none;
  padding: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.svg-button:hover  { background: var(--bg-hover);  color: var(--fg); }
.svg-button.active { background: var(--bg-active); color: var(--accent-hover); }
.svg-button:active { background: var(--bg-active); }

.svg-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  transition: fill var(--t-fast);
  z-index: 1;
}

.compass svg { width: 20px; height: 20px; }
.compass svg .north { fill: var(--accent-hover); transition: fill var(--t-fast); }
.compass svg .south { fill: var(--fg-muted);     transition: fill var(--t-fast); }
.compass:hover  svg .north { fill: var(--accent); }
.compass:active svg .north { fill: var(--accent-hover); }
.compass:active svg .south { fill: var(--fg-muted); }

.day-night-switch svg        { fill: var(--theme-moon-day);   transition: fill var(--t-fast); }
.day-night-switch svg circle { fill: var(--theme-stars-day);  transition: fill var(--t-fast); }
.day-night-switch:active svg        { fill: var(--theme-moon-night); }
.day-night-switch:active svg circle { fill: var(--theme-stars-night); }

.controls-switch { display: flex; }

.menu-button svg { width: 20px; height: 20px; }
.menu-button svg g {
  transform-origin: center;
  transition: transform var(--t-mid);
}
.menu-button svg path {
  transform: translate(0) rotate(0);
  transition: transform var(--t-mid), fill var(--t-fast);
}
.menu-button svg path:nth-child(1) { transform-origin: 15px  9px; }
.menu-button svg path:nth-child(2) { transform-origin: 15px 15px; }
.menu-button svg path:nth-child(3) { transform-origin: 15px 21px; }

.menu-button.close svg path:nth-child(1) { transform: translateY( 5.75px) rotate( 45deg); }
.menu-button.close svg path:nth-child(2) { transform: translate(-100%)      rotate(  0);    }
.menu-button.close svg path:nth-child(3) { transform: translateY(-5.75px) rotate(-45deg); }

.menu-button.close.back svg g                { transform: scale(.75); }
.menu-button.close.back svg path:nth-child(1){ transform: translateY( 10px) rotate( 30deg); }
.menu-button.close.back svg path:nth-child(2){ transform: translate(-150%)  rotate(  0);    }
.menu-button.close.back svg path:nth-child(3){ transform: translateY(-10px) rotate(-30deg); }

/* ============================================================
   5. SIMPLE BUTTONS
   ============================================================ */

.side-menu .simple-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
  color: var(--fg);
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.side-menu .simple-button > .label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-menu .simple-button:hover { background: var(--bg-hover); }
.side-menu .simple-button.active {
  background: var(--bg-hover);
  color: var(--fg);
  font-weight: 600;
}
.side-menu .simple-button.active::before {
  content: "";
  position: absolute;
  left: 0; top: 30%; bottom: 30%;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.side-menu .simple-button > .submenu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  flex-shrink: 0;
}
.side-menu .simple-button > .submenu-icon > svg {
  width: 18px; height: 18px;
  fill: var(--fg-subtle);
  transform: scale(.9);
  transition: fill var(--t-fast);
}
.side-menu .simple-button:hover > .submenu-icon > svg { fill: var(--fg); }
.side-menu .simple-button > .submenu-icon > svg path:nth-child(1) {
  transform-origin: 15px 9px;
  transform: translateY(10px) rotate(-30deg);
}
.side-menu .simple-button > .submenu-icon > svg path:nth-child(2) {
  transform-origin: 15px 21px;
  transform: translateY(-10px) rotate(30deg);
}
.side-menu .simple-button:active { background: var(--bg-active); }
.side-menu .simple-button:active > .submenu-icon > svg { fill: var(--fg); }

/* ============================================================
   6. TEXT INPUT
   ============================================================ */

.side-menu .text-input {
  width: 100%;
  min-height: 40px;
  padding: 0 var(--sp-3);
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: none;
  transition: background var(--t-fast),
              border-color var(--t-fast),
              box-shadow var(--t-fast);
}
.side-menu .text-input:hover { border-color: var(--border-strong); }
.side-menu .text-input:focus {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

/* ============================================================
   7. SWITCH
   ============================================================ */

.side-menu .switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
  border-radius: var(--r-full);
  background: var(--bg-active);
  cursor: pointer;
  transition: background var(--t-mid);
}
.side-menu .switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--fg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-mid), background var(--t-mid);
}
.side-menu .switch.on { background: var(--accent); }
.side-menu .switch.on::after { transform: translateX(14px); background: #fff; }

.side-menu .switch-button {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast);
}
.side-menu .switch-button > .label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-menu .switch-button:hover { background: var(--bg-hover); }

/* ============================================================
   8. SLIDER
   ============================================================ */

.side-menu .slider {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.side-menu .slider:hover { background: var(--bg-hover); }

.side-menu .slider > .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 13px;
  color: var(--fg-muted);
}
.side-menu .slider > .label > .value {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  transition: color var(--t-fast);
}
.side-menu .slider:hover > .label > .value { color: var(--accent-hover); }

.side-menu .slider > label { display: block; }
.side-menu .slider > label > input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  margin: var(--sp-2) 0 var(--sp-1);
  border-radius: var(--r-full);
  background: var(--bg-active);
  outline: none;
  cursor: pointer;
  transition: background var(--t-fast);
}
.side-menu .slider > label > input:hover { background: var(--border-strong); }
.side-menu .slider > label > input::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--fg);
  border: none;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: transform var(--t-fast), background var(--t-fast);
}
.side-menu .slider > label > input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--accent-hover);
}
.side-menu .slider > label > input::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.05);
}
.side-menu .slider > label > input::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--fg);
  border: none;
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.side-menu .slider > label > input::-moz-range-thumb:hover { background: var(--accent-hover); }

/* ============================================================
   9. CHOICE BOX
   ============================================================ */

.choice-box {
  display: flex;
  align-items: stretch;
  padding: 3px;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  overflow: hidden;
}
.choice-box .title {
  display: flex;
  align-items: center;
  padding: 0 var(--sp-3);
  color: var(--fg-subtle);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.choice-box .choices { display: flex; flex: 1; gap: 2px; min-width: 0; }
.choice-box .choices .choice {
  flex: 1;
  padding: 6px var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
  color: var(--fg-muted);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--t-fast), color var(--t-fast);
}
.choice-box .choices .choice:hover { background: var(--bg-hover); color: var(--fg); }
.choice-box .choices .choice.selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   10. MAP BUTTON
   ============================================================ */

.side-menu .map-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.side-menu .map-button:hover { background: var(--bg-hover); }
.side-menu .map-button.selected {
  background: var(--bg-hover);
  color: var(--fg);
  font-weight: 600;
}
.side-menu .map-button.selected::before {
  content: "";
  position: absolute;
  left: 0; top: 30%; bottom: 30%;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
}
.side-menu .map-button .sky {
  flex-shrink: 0;
  width: 8px; height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border-strong);
}
.side-menu .map-button.selected .sky { box-shadow: 0 0 0 1px var(--fg-subtle); }
.side-menu .map-button .id {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   11. GROUP
   ============================================================ */

.side-menu .group {
  position: relative;
  margin: var(--sp-5) 0 var(--sp-3);
  padding: var(--sp-4) var(--sp-2) var(--sp-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.side-menu .group:first-child { margin-top: var(--sp-3); }
.side-menu .group > .title {
  position: absolute;
  top: 0; left: var(--sp-3);
  transform: translateY(-50%);
  padding: 0 var(--sp-2);
  background: var(--bg);
  color: var(--fg-subtle);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.side-menu .group > .content { max-height: 15em; overflow-y: auto; }

/* ============================================================
   12. MARKER ITEM & MARKER SET
   ============================================================ */

.side-menu .marker-item {
  display: flex;
  align-items: stretch;
  margin: 2px 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  user-select: none;
  transition: opacity var(--t-mid), filter var(--t-mid), background var(--t-fast);
}
.side-menu .marker-item.marker-hidden { opacity: .45; filter: grayscale(.8); }

.side-menu .marker-item .marker-button {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 1;
  min-width: 0;
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  transition: background var(--t-fast);
}
.side-menu .marker-item .marker-button:hover { background: var(--bg-hover); }
.side-menu .marker-item .marker-button > .info { flex: 1; min-width: 0; }
.side-menu .marker-item .marker-button > .info .label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-menu .marker-item .marker-button > .info .stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: 2px;
  font-size: 11px;
  color: var(--fg-subtle);
}
.side-menu .marker-item .marker-button > .info .stats > div { white-space: nowrap; }
.side-menu .marker-item .marker-button > .info .stats > div:not(:first-child) {
  padding-left: var(--sp-2);
  border-left: 1px solid var(--border);
}
.side-menu .marker-item .marker-button > .icon {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--bg-hover);
  overflow: hidden;
}
.side-menu .marker-item .marker-button > .icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.side-menu .marker-item > .follow-player-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  cursor: pointer;
  background: transparent;
  color: var(--fg-subtle);
  transition: background var(--t-fast), color var(--t-fast);
}
.side-menu .marker-item > .follow-player-button:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.side-menu .marker-item > .follow-player-button.active {
  background: var(--accent-subtle);
  color: var(--accent-hover);
}
.side-menu .marker-item > .follow-player-button > svg {
  width: 16px; height: 16px;
  fill: currentColor;
  stroke: currentColor;
}
.side-menu .marker-item > .follow-player-button:active { background: var(--bg-active); }

.side-menu .marker-set {
  display: flex;
  align-items: stretch;
  margin: 2px 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  user-select: none;
}
.side-menu .marker-set > .info {
  flex: 1;
  min-width: 0;
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  transition: background var(--t-fast);
}
.side-menu .marker-set > .info:hover { background: var(--bg-hover); }

.side-menu .marker-set > .info > .marker-set-switch { position: relative; }
.side-menu .marker-set > .info > .marker-set-switch .label {
  display: block;
  margin-right: 44px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-menu .marker-set > .info > .marker-set-switch > .switch {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}
.side-menu .marker-set > .info > .stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: 2px;
  font-size: 11px;
  color: var(--fg-subtle);
}
.side-menu .marker-set > .info > .stats > div:not(:first-child) {
  padding-left: var(--sp-2);
  border-left: 1px solid var(--border);
}
.side-menu .marker-set > .open-menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  color: var(--fg-subtle);
  transition: background var(--t-fast), color var(--t-fast);
}
.side-menu .marker-set > .open-menu-button.active { cursor: pointer; }
.side-menu .marker-set > .open-menu-button.active:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.side-menu .marker-set > .open-menu-button.active > svg {
  width: 16px; height: 16px;
  fill: currentColor;
}
.side-menu .marker-set > .open-menu-button.active > svg path:nth-child(1) {
  transform-origin: 15px 9px;
  transform: translateY(10px) rotate(-30deg);
}
.side-menu .marker-set > .open-menu-button.active > svg path:nth-child(2) {
  transform-origin: 15px 21px;
  transform: translateY(-10px) rotate(30deg);
}
.side-menu .marker-set > .open-menu-button.active:active { background: var(--bg-active); }
.side-menu .marker-set > .open-menu-button:not(.active) svg { display: none; }

/* ============================================================
   13. CONTROL BAR
   ============================================================ */

.control-bar {
  position: fixed;
  top: var(--sp-3);
  left: var(--sp-3);
  display: flex;
  align-items: center;
  height: 44px;
  width: calc(100% - var(--sp-3) * 2);
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 500;
  animation: slide-down var(--dur-3) var(--ease-out) both;
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.control-bar::before {
  content: "";
  position: absolute;
  top: 0; left: var(--sp-4); right: var(--sp-4);
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-strong) 50%, transparent);
  pointer-events: none;
}

/* Coordinate block — compact, inline, hugs its content */
.control-bar .pos-input {
  flex: 0 0 auto !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  display: inline-flex !important;
  align-items: center;
  height: 100%;
  padding: 0 var(--sp-2);
}

.control-bar > :not(:first-child) { border-left: 1px solid var(--border); }
.control-bar .space { width: var(--sp-2); flex-shrink: 0; }
.control-bar .space.greedy { flex-grow: 1; }
.control-bar .space,
.control-bar .space + * { border-left: none; }

@media (max-width: 575.98px) {
  .control-bar {
    top: 0; left: 0;
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
  }
  .control-bar::before { display: none; }
  .control-bar .thin-hide { display: none; }
  .control-bar .space     { width: 1px; }
}

/* ============================================================
   14. SIDE MENU
   ============================================================ */

.side-menu {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  max-width: 20em;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  background: var(--bg);
  color: var(--fg);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

.side-menu-enter-active,
.side-menu-leave-active { transition: opacity var(--t-mid), transform var(--t-mid); }
.side-menu-enter,
.side-menu-leave-to {
  opacity: 0;
  transform: translateX(-12px);
  pointer-events: none;
}
.side-menu-enter *,
.side-menu-leave-to * { pointer-events: none !important; }

.side-menu > .menu-button {
  position: absolute;
  top: var(--sp-2); left: var(--sp-2);
  margin: 0;
  border-radius: var(--r-sm);
  z-index: 3;
}
.side-menu > .menu-button.full-close { right: var(--sp-2); left: unset; }

.side-menu > .title {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 56px;
  padding: 0 56px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-align: center;
  color: var(--fg-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-menu > .content {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: var(--sp-3) var(--sp-3) var(--sp-5);
  overflow-x: hidden;
  overflow-y: auto;
}

.side-menu > .content hr {
  margin: var(--sp-4) 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* ============================================================
   15. ZOOM BUTTONS
   ============================================================ */

#zoom-buttons {
  position: fixed;
  right: var(--sp-3);
  bottom: var(--sp-3);
  display: flex;
  flex-direction: column;
  width: 44px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 500;
  animation: slide-up var(--dur-3) var(--ease-out) both;
  animation-delay: 60ms;
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

#zoom-buttons .svg-button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 0;
}
#zoom-buttons .svg-button + .svg-button { border-top: 1px solid var(--border); }

/* ============================================================
   16. APP & MAP
   ============================================================ */

#map-container { position: absolute; inset: 0; width: 100%; height: 100%; }

#app {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  font-size: 1rem;
  z-index: 10000;
}
@media (max-width: 575.98px) { #app { font-size: 1.35rem; } }

#app .map-state-message {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: var(--sp-4) var(--sp-5);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: .01em;
  text-align: center;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}

/* ============================================================
   17. INFO PANEL — no rounded image
   ============================================================ */

.info-content { font-size: 13px; }

.info-content table {
  width: 100%;
  border-collapse: collapse;
}
.info-content table tr th,
.info-content table tr td {
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
}
.info-content table tr:first-child th,
.info-content table tr:first-child td { border-top: none; }
.info-content table tr th {
  font-weight: 500;
  text-align: inherit;
  color: var(--fg-muted);
  background: transparent;
}
.info-content .info-footer {
  margin-top: var(--sp-3);
  text-align: center;
  color: var(--fg-subtle);
}

/* Square corners for any image inside the info section */
.info-content img,
.info-content picture,
.info-content picture img,
.info-content svg,
.info-content video,
.info-content canvas,
.info-content .bm-info img,
.bm-info img,
.bm-info-content img {
  border-radius: 0 !important;
  overflow: visible;
}

/* Also strip the frame / shadow / outline if a wrapper rounds it */
.info-content figure,
.info-content picture {
  border-radius: 0 !important;
  overflow: visible !important;
}

/* ============================================================
   18. MOBILE CONTROLS
   ============================================================ */

#ff-mobile-controls { font-size: 15vw; }
#ff-mobile-controls.disabled { display: none; }
@media (orientation: portrait) { #ff-mobile-controls { font-size: 15vh; } }

#ff-mobile-controls .button {
  width: 1em;
  margin: .1em;
  opacity: .5;
  pointer-events: auto;
  transition: opacity var(--t-fast);
}
#ff-mobile-controls .button:hover   { opacity: .85; }
#ff-mobile-controls .button svg       { fill: var(--bg); }
#ff-mobile-controls .button svg:active{ fill: var(--accent); opacity: .9; }
#ff-mobile-controls .button svg.down  { transform: scaleY(-1); }

#ff-mobile-controls .move-fields   { position: fixed; bottom: var(--sp-1); left:  var(--sp-1); }
#ff-mobile-controls .height-fields { position: fixed; bottom: var(--sp-1); right: var(--sp-1); }

/* ============================================================
   19. MAP MARKERS & POPUPS
   ============================================================ */

#map-container .bm-marker-html { position: relative; user-select: none; }
#map-container .bm-marker-html .bm-marker-poi-label {
  position: absolute;
  top: 0; left: 0;
  opacity: 0;
  transition: opacity var(--t-fast);
}
#map-container .bm-marker-html .bm-marker-poi-icon {
  opacity: 1;
  filter: drop-shadow(var(--shadow-sm));
  transition: opacity var(--t-fast);
}
#map-container .bm-marker-html.bm-marker-highlight .bm-marker-poi-label { opacity: 1; }
#map-container .bm-marker-html.bm-marker-highlight .bm-marker-poi-icon  { opacity: 0; }

#map-container .bm-marker-html .bm-marker-poi-label,
#map-container .bm-marker-labelpopup,
#map-container .bm-marker-popup {
  max-width: 16em;
  padding: var(--sp-3);
  transform: translate(-50%, -100%) translateY(-8px);
  color: var(--fg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.5;
}
#map-container .bm-marker-html .bm-marker-poi-label > hr,
#map-container .bm-marker-labelpopup > hr,
#map-container .bm-marker-popup > hr {
  margin: var(--sp-2) calc(var(--sp-3) * -1);
  border: none;
  border-top: 1px solid var(--border);
}
#map-container .bm-marker-html .bm-marker-poi-label::after,
#map-container .bm-marker-labelpopup::after,
#map-container .bm-marker-popup::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border: 8px solid transparent;
  border-top-color: var(--bg-elevated);
  border-bottom: 0;
  filter: drop-shadow(0 1px 0 var(--border-strong));
}

#map-container .bm-marker-popup .group[data-tooltip] {
  position: relative;
  margin: calc(var(--sp-3) * -1);
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  transition: background var(--t-fast);
}
#map-container .bm-marker-popup .group[data-tooltip]:hover { background: var(--bg-hover); }
#map-container .bm-marker-popup .group[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  display: block;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--bg);
  color: var(--fg);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  animation: tooltip-in var(--t-fast) both;
  z-index: 1;
}
@keyframes tooltip-in {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to   { opacity: 1; transform: translate(-50%, 0);   }
}
#map-container .bm-marker-popup .group[data-tooltip]:active { background: var(--bg-active); }
#map-container .bm-marker-popup .group > .label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
#map-container .bm-marker-popup .group > .content {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-3);
}
#map-container .bm-marker-popup .group > .content > .entry { text-align: center; }
#map-container .bm-marker-popup .group > .content > .entry > .label {
  display: block;
  font-size: 11px;
  color: var(--fg-subtle);
}
#map-container .bm-marker-popup .files { font-size: 11px; color: var(--fg-subtle); }

#map-container .bm-marker-player {
  position: relative;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5));
}
#map-container .bm-marker-player img {
  width: 32px;
  image-rendering: pixelated;
  transition: width var(--t-fast);
}
#map-container .bm-marker-player .bm-player-name {
  position: absolute;
  top: -6px; left: 50%;
  transform: translate(-50%, -100%);
  padding: 4px 8px;
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  transition: opacity var(--t-fast);
}
#map-container .bm-marker-player[distance-data=med] img,
#map-container .bm-marker-player[distance-data=far] img { width: 16px; }
#map-container .bm-marker-player[distance-data=med] .bm-player-name,
#map-container .bm-marker-player[distance-data=far] .bm-player-name { opacity: 0; }

/* ============================================================
   20. ERROR SCREEN
   ============================================================ */

#bm-app-err {
  position: relative;
  width: 100vw; height: 100vh;
  background: var(--bg);
  color: var(--fg);
}
#bm-app-err > div {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  max-width: 24em;
  padding: 0 var(--sp-4);
}
#bm-app-err > div img {
  width: 90%;
  max-width: 160px;
  min-width: 80px;
  margin: 0 0 var(--sp-6);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}
#bm-app-err > div .bm-app-err-hint { color: var(--fg-muted); }

/* ============================================================
   21. FOCUS & UTILITIES
   ============================================================ */

button,
button:focus { outline: none; }

button:focus-visible,
.svg-button:focus-visible,
.simple-button:focus-visible,
.switch-button:focus-visible,
.map-button:focus-visible,
.text-input:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring);
}

::selection { background: var(--accent); color: #fff; }

.side-menu .content > * { animation: fade-up var(--dur-3) var(--ease-out) both; }
.side-menu .content > *:nth-child(1) { animation-delay: 10ms; }
.side-menu .content > *:nth-child(2) { animation-delay: 30ms; }
.side-menu .content > *:nth-child(3) { animation-delay: 50ms; }
.side-menu .content > *:nth-child(4) { animation-delay: 70ms; }
.side-menu .content > *:nth-child(5) { animation-delay: 90ms; }
.side-menu .content > *:nth-child(6) { animation-delay: 110ms; }
.side-menu .content > *:nth-child(7) { animation-delay: 130ms; }
.side-menu .content > *:nth-child(8) { animation-delay: 150ms; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0);   }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}