@font-face {
  font-family: "Pixelify Sans";
  src: url("/pixelify.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --ink: #1b1a22;
  --panel: #2a2838;
  --panel-hi: #3b3850;
  --panel-lo: #19171f;
  --paper: #f3e9cf;
  --dim: #a9a2ba;
  --gold: #ffd23f;
  --gold-lo: #c99a1c;
  --gold-hi: #fff0a8;
  --red: #ff6b5e;
  --edge: max(10px, env(safe-area-inset-top));
  --below: calc(var(--edge) + 50px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: #4b5674;
  color: var(--paper);
  font: 16px/1.35 "Pixelify Sans", ui-monospace, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

#board { position: fixed; left: 0; top: 0; display: block; image-rendering: pixelated; touch-action: none; cursor: pointer; }
#board.grab { cursor: grabbing; }

.panel {
  background: var(--panel);
  border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 var(--panel-hi), inset -2px -2px 0 var(--panel-lo), 4px 4px 0 rgba(0, 0, 0, .4);
}
.dim { color: var(--dim); }
.dim b { color: var(--paper); font-weight: 600; }
button { font: inherit; }

.px {
  color: var(--ink);
  background: var(--gold);
  border: 2px solid var(--ink);
  padding: 6px 12px 7px;
  cursor: pointer;
  box-shadow: inset -2px -3px 0 var(--gold-lo), inset 2px 2px 0 var(--gold-hi), 3px 3px 0 var(--ink);
}
.px:active { transform: translate(2px, 2px); box-shadow: inset 2px 2px 0 var(--gold-lo), 1px 1px 0 var(--ink); }
.px:disabled { opacity: .6; cursor: default; }
.px.dark { color: var(--paper); background: #45415c; box-shadow: inset -2px -3px 0 #2d2a3d, inset 2px 2px 0 #625d80, 3px 3px 0 var(--ink); }
.px.dark:active { box-shadow: inset 2px 2px 0 #2d2a3d, 1px 1px 0 var(--ink); }
.px.small { padding: 2px 9px 3px; }
.link { background: none; border: 0; padding: 0; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link:hover { color: var(--paper); }

/* corners */
#hud-tl {
  position: fixed; top: var(--edge); left: max(10px, env(safe-area-inset-left));
  display: flex; align-items: baseline; gap: 12px; padding: 5px 12px 7px;
}
.logo { font-size: 19px; font-weight: 700; }
#coords { min-width: 9ch; font-variant-numeric: tabular-nums; }
#help-btn { text-decoration: none; border: 2px solid var(--dim); width: 22px; height: 22px; line-height: 16px; text-align: center; align-self: center; }

#hud-tr { position: fixed; top: var(--edge); right: max(10px, env(safe-area-inset-right)); padding: 5px 8px 6px 12px; }
.acct { display: flex; align-items: center; gap: 10px; min-height: 28px; }
#me-name { color: var(--gold); font-weight: 600; }

#hud-bl { position: fixed; left: max(10px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); }
#hud-br {
  position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 12px;
}
#nearest { font-size: 18px; padding: 9px 15px 11px; }
.zoom { display: flex; flex-direction: column; gap: 8px; }
.zoom .px { width: 42px; padding: 3px 0 6px; font-size: 22px; line-height: 1; }

#feed {
  position: fixed; top: var(--below); left: max(10px, env(safe-area-inset-left));
  margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px;
}
#feed li { width: fit-content; padding: 2px 8px 3px; font-size: 14px; background: rgba(27, 26, 34, .86); cursor: pointer; transition: opacity .7s; }
#feed li b { color: #ff9a90; font-weight: 600; }
#feed li.fade { opacity: 0; }

#tip {
  position: fixed; z-index: 30; pointer-events: none; white-space: nowrap;
  padding: 2px 8px 4px; font-size: 15px; background: var(--ink); border: 2px solid #000;
}
#tip b { color: var(--gold); font-weight: 600; }
#toast {
  position: fixed; z-index: 40; top: calc(var(--below) + 2px); left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 7px 14px 9px; text-align: center;
  background: var(--ink); border: 2px solid #000; box-shadow: 4px 4px 0 rgba(0, 0, 0, .4);
}
#net {
  position: fixed; z-index: 40; bottom: max(70px, calc(env(safe-area-inset-bottom) + 56px)); left: 50%; transform: translateX(-50%);
  padding: 4px 12px 6px; background: #7a5a12; border: 2px solid var(--ink); font-size: 15px;
}

/* panels */
#lb, #help {
  position: fixed; z-index: 20; left: max(10px, env(safe-area-inset-left));
  width: min(330px, calc(100vw - 20px)); overflow: auto; padding: 12px 16px 16px;
}
#lb { bottom: max(66px, calc(env(safe-area-inset-bottom) + 52px)); max-height: calc(100dvh - 150px); }
#lb .head { display: flex; justify-content: space-between; align-items: baseline; }
#lb h2, #help h2 { margin: 0; font-size: 20px; }
#lb h3 { margin: 14px 0 4px; font-size: 15px; font-weight: 600; color: var(--gold); }
#lb ol { margin: 0; padding: 0; list-style: none; }
#lb li { display: flex; gap: 10px; padding: 3px 0 4px; border-bottom: 2px solid #34314a; font-size: 15px; }
#lb li .r { width: 2.4ch; color: var(--dim); text-align: right; }
#lb li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#lb li .v { font-variant-numeric: tabular-nums; }
#lb li.me .n, #lb li.me .v { color: var(--gold); }
#lb li.empty { color: var(--dim); border: 0; }
#lb .totals { margin: 14px 0 0; font-size: 14px; }

#help { top: var(--below); max-height: calc(100dvh - 160px); }
#help p { margin: 8px 0; }
#help ul { margin: 8px 0; padding-left: 18px; }
#help li { margin: 5px 0; }
#help .dim { font-size: 14px; }
#help .px { margin-top: 6px; }

/* death */
#dead { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(52, 12, 14, .74); }
#dead .box { width: min(360px, 100%); padding: 22px 24px 24px; text-align: center; }
#dead-art { display: block; width: 64px; height: 64px; margin: 0 auto 12px; image-rendering: pixelated; }
#dead h1 { margin: 0; font-size: 54px; line-height: 1; font-weight: 700; color: var(--red); text-shadow: 4px 4px 0 var(--ink); }
#dead p { margin: 12px 0 0; color: var(--dim); }
#dead .count { margin: 10px 0 16px; font-size: 46px; color: var(--gold); font-variant-numeric: tabular-nums; }
#dead-bar {
  position: fixed; z-index: 45; top: var(--below); left: 50%; transform: translateX(-50%);
  padding: 5px 14px 7px; background: #8a2620; border: 2px solid var(--ink); box-shadow: 4px 4px 0 rgba(0, 0, 0, .4);
}
#dead-bar b { color: var(--gold); font-variant-numeric: tabular-nums; }

/* sign in */
dialog#auth { width: min(340px, calc(100vw - 32px)); padding: 16px 18px 18px; color: var(--paper); }
dialog::backdrop { background: rgba(10, 10, 16, .6); }
.tabs { display: flex; gap: 6px; }
.tab { flex: 1; padding: 6px 0 8px; color: var(--dim); background: var(--panel-lo); border: 2px solid var(--ink); cursor: pointer; }
.tab.on { color: var(--paper); background: var(--panel-hi); }
.note { margin: 12px 0 4px; font-size: 14px; }
label { display: block; margin-top: 10px; font-size: 14px; color: var(--dim); }
input {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px;
  font: inherit; font-size: 16px; color: var(--paper); background: var(--ink);
  border: 2px solid #000; border-radius: 0; outline: none; user-select: text;
}
input:focus { border-color: var(--gold); }
.error { margin: 10px 0 0; font-size: 14px; color: #ff9a90; }
.row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

@media (max-width: 640px) {
  #coords, .wide { display: none; }
  .logo { font-size: 17px; }
  #hud-tl { gap: 9px; padding: 4px 10px 6px; }
  .acct { gap: 8px; font-size: 15px; }
  #nearest { font-size: 17px; }
}
@media (max-width: 480px) {
  :root { --below: calc(var(--edge) + 92px); }
  #hud-tr { top: calc(var(--edge) + 44px); left: max(10px, env(safe-area-inset-left)); right: auto; }
}
