:root {
  --bg0: #050506;
  --bg1: #0b0c10;
  --ink: #e8eaef;
  --muted: #8b90a0;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #6ea8ff;
  --panel: rgba(10, 12, 16, 0.88);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --font-display: "Segoe UI", "Trebuchet MS", sans-serif;
  --font-body: "Segoe UI", "Trebuchet MS", sans-serif;
  --map-void: #000000;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--bg0);
}

.shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.login-brand .brand-logo {
  width: 4.25rem;
  height: 4.25rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.brand p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.controls label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.controls select,
.controls button {
  min-width: 10rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.75);
  color: var(--ink);
  padding: 0 0.75rem;
  font: inherit;
}

.controls button {
  min-width: 4.5rem;
  cursor: pointer;
  background: #151821;
}

.controls button:hover {
  border-color: rgba(110, 168, 255, 0.55);
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  min-height: 0;
  overflow: hidden;
}

.map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  background: var(--map-void);
  image-rendering: pixelated;
}

#map.selecting {
  cursor: crosshair;
}

#map:active {
  cursor: grabbing;
}

.hud {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  padding: 0.65rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-width: 9.5rem;
  max-width: min(16rem, calc(100% - 1.5rem));
  font-size: 0.82rem;
  line-height: 1.4;
  pointer-events: none;
}

.hud span {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.hud .muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.legend {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.legend i.lg {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.35rem;
  vertical-align: -0.05rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend i.new { background: var(--chunk-new, #e0567a); }
.legend i.old { background: var(--chunk-old, #2f6fd4); }
.legend i.old-untouched { background: var(--chunk-old-untouched, #9b4dff); }
.legend i.modern {
  background: color-mix(in srgb, var(--chunk-modern, #1a2230) 35%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chunk-modern, #1a2230) 70%, white);
}
.legend i.portal-nether { background: var(--portal-nether, #9b4dff); }
.legend i.portal-end { background: var(--portal-end, #1ce0c8); }

.controls .check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  height: 2.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.controls .check input {
  width: 1rem;
  height: 1rem;
}

.side-panel {
  position: relative;
  width: auto;
  height: 100%;
  padding: 0.7rem;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  pointer-events: auto;
  min-height: 0;
  overflow: hidden;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
}

.players-section {
  flex: 1 1 42%;
  min-height: 6rem;
}

.chat-section {
  flex: 1 1 58%;
  min-height: 8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.settings-list {
  display: grid;
  gap: 0.3rem;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
}

.set-row input {
  width: 1rem;
  height: 1rem;
}

.hidden {
  display: none !important;
}

.settings-sub {
  margin: 0.55rem 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.color-settings {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.chunk-opacity-row {
  margin: 0.15rem 0 0.1rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: rgba(0, 0, 0, 0.18);
}

.color-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--ink);
}

.color-row input[type="color"] {
  width: 2.25rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.portal-settings {
  display: grid;
  gap: 0.35rem;
  margin: -0.15rem 0 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: rgba(0, 0, 0, 0.18);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.35rem 0.65rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--ink);
}

.range-row > span {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: var(--muted);
}

.range-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent, #7cbc6a);
}

.range-row output {
  min-width: 1.75rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.range-row.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.setting-hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
}

.admin-section {
  display: none;
}

.admin-body {
  min-height: 100%;
  overflow: auto;
  background: var(--bg0);
}

.admin-page {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.admin-page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.admin-card-grow {
  min-height: 12rem;
}

.admin-card h2,
.admin-card-head h2 {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.admin-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.75);
  color: var(--ink);
  padding: 0.45rem 0.55rem;
  font: inherit;
}

.admin-form button {
  border: 1px solid var(--line);
  background: #151821;
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  font: inherit;
  cursor: pointer;
}

.admin-form button:hover {
  border-color: rgba(110, 168, 255, 0.55);
}

.admin-msg {
  margin-top: 0.35rem;
  font-size: 0.78rem;
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.admin-user-list {
  max-height: none;
}

.user-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.55);
}

.user-list .empty-row {
  justify-content: center;
  color: var(--muted);
}

.user-row-main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.user-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.user-row-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.user-item {
  display: grid;
  gap: 0.55rem;
}

.user-item.editing {
  border-color: rgba(110, 168, 255, 0.45);
}

.user-edit-panel {
  border-top: 1px solid var(--line);
  padding-top: 0.55rem;
}

.user-edit-form {
  display: grid;
  gap: 0.55rem;
}

.user-edit-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.user-edit-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.75);
  color: var(--ink);
  padding: 0.45rem 0.55rem;
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
}

.user-edit-form input:disabled {
  opacity: 0.7;
}

.user-edit-actions {
  display: flex;
  gap: 0.4rem;
}

.field-hint {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.ghost-btn,
.save-btn {
  border: 1px solid var(--line);
  background: #151821;
  color: var(--ink);
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-btn:hover,
.save-btn:hover {
  border-color: rgba(110, 168, 255, 0.55);
}

.save-btn {
  border-color: rgba(110, 168, 255, 0.45);
  background: #1a2230;
}

.danger-btn {
  border: 1px solid rgba(240, 120, 120, 0.35);
  background: rgba(80, 24, 24, 0.55);
  color: #f0c0c0;
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
}

.danger-btn:hover {
  border-color: rgba(240, 120, 120, 0.75);
}

.muted.small {
  font-size: 0.75rem;
}

.user-list .tag-admin {
  color: var(--accent);
  font-size: 0.72rem;
}

.panel-section h2 {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.players-panel {
  display: none;
}

.players-list,
.chat-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 0;
  flex: 1;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.chat-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.75);
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  font: inherit;
}

.chat-form button {
  border: 1px solid var(--line);
  background: rgba(30, 48, 36, 0.9);
  color: var(--ink);
  padding: 0.5rem 0.75rem;
  font: inherit;
  cursor: pointer;
}

.player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.65);
  color: var(--ink);
  padding: 0.45rem 0.5rem;
  font: inherit;
}

.player-row.following {
  border-color: rgba(110, 168, 255, 0.75);
}

.player-jump {
  display: grid;
  gap: 0.12rem;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  cursor: pointer;
  min-width: 0;
}

.player-row strong {
  font-size: 0.92rem;
}

.player-row span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.follow-btn {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: #151821;
  color: var(--ink);
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  min-width: 4.6rem;
  touch-action: manipulation;
  user-select: none;
}

.follow-btn:hover {
  border-color: rgba(110, 168, 255, 0.55);
}

.follow-btn.active {
  border-color: rgba(110, 168, 255, 0.85);
  background: #1a2230;
}

.player-row.self {
  border-color: rgba(110, 168, 255, 0.45);
}

.player-row:hover {
  border-color: rgba(110, 168, 255, 0.55);
}

.players-list .empty,
.chat-list .empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.35rem 0.15rem;
}

.chat-row {
  border: 1px solid rgba(180, 210, 180, 0.12);
  background: rgba(8, 14, 10, 0.55);
  padding: 0.45rem 0.55rem;
  border-radius: 2px;
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.2rem;
}

.chat-meta strong {
  font-size: 0.82rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-meta time {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.chat-text {
  font-size: 0.84rem;
  line-height: 1.35;
  word-break: break-word;
  color: var(--ink);
}

.controls .goto {
  display: grid;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.controls .goto input {
  width: 8.5rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.75);
  color: var(--ink);
  padding: 0 0.65rem;
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
}

.controls button.ghost {
  background: rgba(8, 14, 10, 0.55);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  background: #151821;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.btn-link:hover {
  border-color: rgba(110, 168, 255, 0.55);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(18rem, 92vw);
  height: 100%;
  z-index: 40;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transform: translateX(100%);
  transition: transform 0.24s ease;
  overflow: auto;
}

.settings-drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.drawer-head h2 {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.drawer-close {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.75);
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.drawer-close:hover {
  border-color: rgba(110, 168, 255, 0.55);
}

.dim-tabs {
  display: flex;
  gap: 0.35rem;
}

.dim-tab {
  min-width: 0 !important;
  height: 2.25rem;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.75);
  color: var(--ink);
  padding: 0 0.85rem;
  font: inherit;
  cursor: pointer;
}

.dim-tab.active {
  border-color: rgba(110, 168, 255, 0.65);
  background: #1a2230;
}

.login-body {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 1.25rem;
  background: #050508 url("/lootmap-login-bg.png") center center / cover no-repeat fixed;
  overflow: hidden;
}

.login-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 80% at 50% 42%, rgba(5, 5, 8, 0.08) 0%, rgba(5, 5, 8, 0.55) 52%, rgba(5, 5, 8, 0.88) 100%);
  pointer-events: none;
  z-index: 0;
}

.login-body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 5, 8, 0.25) 0%, rgba(5, 5, 8, 0.45) 100%);
  pointer-events: none;
  z-index: 0;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(100%, 24rem);
  margin-top: min(14vh, 7rem);
  display: grid;
  gap: 0.9rem;
  padding: 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(18, 20, 26, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.login-brand {
  margin-bottom: 0.35rem;
}

.login-card label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-card input {
  height: 2.4rem;
  border: 1px solid var(--line);
  background: rgba(8, 14, 10, 0.75);
  color: var(--ink);
  padding: 0 0.75rem;
  font: inherit;
}

.login-card button {
  height: 2.5rem;
  border: 1px solid rgba(110, 168, 255, 0.45);
  background: #1a2230;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.auth-tab {
  min-width: 0 !important;
  height: 2.2rem !important;
  border: 1px solid var(--line) !important;
  background: rgba(8, 14, 10, 0.65) !important;
  color: var(--muted) !important;
}

.auth-tab.active {
  border-color: rgba(124, 188, 106, 0.7) !important;
  background: linear-gradient(180deg, rgba(124, 188, 106, 0.28), rgba(40, 70, 45, 0.45)) !important;
  color: var(--ink) !important;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: 0;
}

.login-error {
  margin: 0;
  color: #f0a0a0;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
}

@media (max-width: 900px) {
  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(10rem, 32vh);
  }

  .side-panel {
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .top {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    align-items: stretch;
  }

  .dim-tabs {
    width: 100%;
  }

  .dim-tab {
    flex: 1;
  }

  .controls .goto input {
    width: 100%;
  }
}
