:root {
  color-scheme: dark;
  --base: #090c10;
  --panel: #12171d;
  --edge: #303942;
  --text: #e3edf8;
  --dim: #a1b3c9;
  --blue: #8bc6eb;
  font:
    15px/1.45 "Segoe UI",
    Roboto,
    sans-serif;
  color: var(--text);
  background: var(--base);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  background: #202832;
  border: 1px solid #33485e;
  border-radius: 2px;
  padding: 0.47rem 0.85rem;
  cursor: pointer;
}
button:hover,
button:focus-visible {
  background: #2b3b4b;
  border-color: var(--blue);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
button.primary {
  color: #082338;
  background: var(--blue);
  border-color: transparent;
  font-weight: 650;
}
button.danger {
  color: #ffaaa3;
}
button.link {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding-left: 0;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 1.75rem;
}
h2 {
  font-size: 1.12rem;
}
h3 {
  font-size: 1rem;
  margin: 1.1rem 0 0.55rem;
}
small,
p {
  color: var(--dim);
}
p:empty {
  display: none;
}
.brand {
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  font-weight: 680;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
}
.brandmark {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
#auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  grid-template-rows: 1fr auto;
  background-color: #0a0e12;
  background-image:
    linear-gradient(#151c23 1px, transparent 1px),
    linear-gradient(90deg, #151c23 1px, transparent 1px);
  background-size: 48px 48px;
}
.auth-card,
dialog,
.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 2px;
  box-shadow: 4px 4px 0 #070a0d;
}
.auth-card {
  width: min(100%, 390px);
  border-top: 3px solid #87bada;
  padding: 2rem;
}
#auth footer {
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.55;
  color: #9daab4;
  margin-top: 1.3rem;
}
.auth-card h1 {
  margin: 1.8rem 0 1.1rem;
}
.auth-card .link {
  margin-top: 0.7rem;
}
form {
  display: grid;
  gap: 0.85rem;
}
form label {
  display: grid;
  gap: 0.28rem;
  color: var(--dim);
  font-size: 0.87rem;
}
input:not([type="checkbox"]),
textarea,
select {
  width: 100%;
  border: 1px solid var(--edge);
  background: #0b1015;
  padding: 0.55rem 0.65rem;
  border-radius: 2px;
  color: var(--text);
}
input[type="color"] {
  height: 2.55rem;
}
input[type="checkbox"] {
  accent-color: var(--blue);
  width: 1rem;
  height: 1rem;
}
#workspace {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
header {
  min-height: 3.7rem;
  background: #10151b;
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: center;
  gap: 1.3rem;
  padding: 0.5rem 1rem;
}
.world {
  color: var(--dim);
}
.header-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}
#mapframe {
  position: relative;
  min-height: 0;
  flex: 1;
  background: #0b1420;
  overflow: hidden;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
canvas.drawing {
  cursor: crosshair;
}
.overlay,
.panel,
.statusbar,
#crosshair {
  position: absolute;
}
.tools {
  top: 12px;
  left: 12px;
}
.panel {
  top: 60px;
  left: 12px;
  padding: 1rem;
  width: min(230px, calc(100% - 85px));
  max-height: calc(100% - 130px);
  overflow: auto;
}
.panel h2 {
  margin-bottom: 0.55rem;
}
.panel label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  overflow-wrap: anywhere;
}
.player-toggle {
  border-top: 1px solid var(--edge);
  margin-top: 0.5rem;
}
.panel button {
  width: 100%;
  margin-top: 0.6rem;
}
.nav {
  right: 12px;
  top: 12px;
  display: grid;
  gap: 0.3rem;
}
.nav button {
  width: 42px;
  height: 42px;
  font-size: 1.35rem;
  line-height: 1;
}
.statusbar {
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 1rem;
  align-items: center;
  background: #0a1422e8;
  padding: 0.35rem 0.8rem;
  color: var(--dim);
  font-size: 0.8rem;
  pointer-events: none;
}
.statusbar #coords {
  color: var(--text);
  font:
    0.84rem Consolas,
    monospace;
}
.statusbar #progress {
  margin-left: auto;
}
dialog {
  color: var(--text);
  padding: 1.15rem;
  width: min(440px, calc(100% - 22px));
  max-height: 90dvh;
  overflow: auto;
}
dialog::backdrop {
  background: #050a12aa;
}
.dialog-head,
.actions,
.pair {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dialog-head {
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.dialog-head button {
  font-size: 1.2rem;
  padding: 0.15rem 0.6rem;
}
.actions {
  flex-wrap: wrap;
}
.pair label {
  flex: 1;
}
#detail-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 1rem 0;
}
#draw-controls {
  bottom: 2.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--edge);
  padding: 0.6rem;
  border-radius: 2px;
  display: flex;
  gap: 0.35rem;
  align-items: center;
  max-width: 95%;
  width: max-content;
  flex-wrap: wrap;
}
.statusbar span {
  white-space: nowrap;
}
#toast {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: #233951;
  border: 1px solid #55728d;
  padding: 0.65rem 1rem;
  border-radius: 2px;
  max-width: 92vw;
  pointer-events: none;
}
#crosshair {
  display: none;
  pointer-events: none;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#fff, #fff) center/2px 100% no-repeat,
    linear-gradient(#fff, #fff) center/100% 2px no-repeat;
  filter: drop-shadow(0 1px 2px #000);
}
@media (pointer: coarse) {
  #crosshair {
    display: block;
  }
}
@media (max-width: 600px) {
  header {
    padding: 0.45rem 0.6rem;
    gap: 0.4rem;
  }
  .world {
    display: none;
  }
  .brand {
    font-size: 1rem;
  }
  .header-actions button {
    padding: 0.35rem 0.55rem;
  }
  .statusbar {
    gap: 0.4rem;
    font-size: 0.7rem;
  }
  .statusbar #progress {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .panel {
    width: 190px;
  }
  .auth-card {
    padding: 1.4rem;
  }
  #draw-controls span {
    width: 100%;
    font-size: 0.8rem;
  }
}
