:root {
  --mc-dirt: #5a3a22;
  --mc-gold: #ffd83d;
  --mc-heart: #ff5555;
  --mc-stone: #6f6f6f;
  --mc-stone-hi: #a0a0a0;
  --mc-stone-lo: #3a3a3a;
  --mc-select: #8a8a8a;
  --mc-paper: #f8f8f8;
  --mc-shadow: #3f3f3f;
  --map-bg: #1a2740;
  color-scheme: dark;
  accent-color: #6f6f6f;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #111;
  color: var(--mc-paper);
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
  image-rendering: pixelated;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.45);
}

::selection {
  background: #6f6f6f;
  color: #fff;
}

button, a {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.45);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button:focus, a:focus { outline: none; }
button:focus-visible {
  outline: 2px solid #8a8a8a;
  outline-offset: 1px;
}
body.mc {
  display: flex;
  flex-direction: column;
}

.logo,
.player-bar,
.corner {
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  isolation: isolate;
}

.logo {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 2000;
  line-height: 0;
  pointer-events: auto;
}
.logo img {
  display: block;
  height: 56px;
  width: auto;
  image-rendering: auto;
  transform: translateZ(0);
}
.logo:hover { opacity: 0.92; }

.player-bar {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(78vw, 560px);
  max-height: 96px;
  overflow-y: auto;
  overflow-x: hidden;
}
.player-bar.crowded .player-head {
  width: 32px;
  height: 32px;
}
.player-head {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid #000;
  background: var(--mc-stone);
  box-shadow: 2px 2px 0 #0008;
  cursor: pointer;
  image-rendering: pixelated;
  overflow: hidden;
}
.player-head img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.player-head:hover { outline: 2px solid var(--mc-gold); outline-offset: 0; }

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  z-index: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--map-bg);
  touch-action: none;
  overflow: hidden;
}

body[data-world="overworld"] { --map-bg: #1a2740; }
body[data-world="nether"],
body[data-world="nether_roof"] { --map-bg: #1a0808; }
body[data-world="end"] { --map-bg: #0c0814; }

.corner {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.corner > * { pointer-events: auto; }

.world-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.world-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 156px;
}
.world-menu-btn {
  min-height: 44px;
  min-width: 156px;
  padding: 0 0.7rem;
  background: var(--mc-stone);
  color: #fff;
  border: 2px solid #000;
  font: inherit;
  font-size: 16px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: 1px 1px 0 var(--mc-shadow);
  box-shadow: inset 2px 2px 0 var(--mc-stone-hi), inset -2px -2px 0 var(--mc-stone-lo);
  cursor: pointer;
  text-align: left;
}
.world-menu-btn + .world-menu-btn { border-top-width: 0; }
.world-menu-btn:hover,
.world-menu-btn[aria-pressed="true"] { background: var(--mc-select); }

.world-stack,
.zoom-stack {
  display: flex;
  flex-direction: column;
}
.world-stack .corner-btn + .corner-btn,
.zoom-stack .corner-btn + .corner-btn {
  border-top-width: 0;
}

.corner-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: var(--mc-stone);
  color: #fff;
  border: 2px solid #000;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  text-shadow: 1px 1px 0 var(--mc-shadow);
  box-shadow: inset 2px 2px 0 var(--mc-stone-hi), inset -2px -2px 0 var(--mc-stone-lo);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.corner-btn:hover,
.corner-btn[aria-expanded="true"],
.corner-btn[aria-pressed="true"] { background: var(--mc-select); }
.corner-btn:disabled { opacity: 0.45; cursor: default; }
#zoom-in, #zoom-out { font-size: 20px; }

.world-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  display: block;
  pointer-events: none;
}

.leaflet-container {
  background: var(--map-bg);
  font: inherit;
  overflow: hidden;
  z-index: 0;
}
.leaflet-container img.leaflet-tile {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: 1px solid transparent;
}
.leaflet-container .leaflet-tile-container img.leaflet-tile {
  margin: -1px;
}
.leaflet-control-zoom { display: none !important; }

.player-face-icon {
  background: none !important;
  border: none !important;
}
.player-face {
  width: 24px;
  height: 24px;
  border: 2px solid #000;
  background: var(--mc-stone);
  box-shadow: 1px 1px 0 #0008;
  overflow: hidden;
  image-rendering: pixelated;
}
.player-face img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

@media (max-width: 720px) {
  .logo img { height: 44px; }
  .player-head { width: 40px; height: 40px; }
  .world-menu { min-width: 160px; }
  .world-menu-btn { min-width: 160px; }
}
