@font-face {
  font-family: "VT323";
  src: url("/fonts/vt323-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --ink: #e7dfcb;
  --ink-dim: rgba(231, 223, 203, 0.62);
  --panel: rgba(15, 21, 25, 0.8);
  --line: rgba(231, 223, 203, 0.22);
  --font: "VT323", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #1d4f5a; overscroll-behavior: none;
}
* { box-sizing: border-box; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }

#view {
  display: block; width: 100vw; height: 100vh; height: 100dvh;
  image-rendering: pixelated; image-rendering: crisp-edges;
  cursor: crosshair; touch-action: none;
}
#view.panning { cursor: grabbing; }

.panel {
  position: fixed; color: var(--ink);
  font: 18px/1.25 var(--font);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px; padding: 8px 12px;
}

#hud { top: 14px; left: 14px; }
#hud h1 { margin: 0; font-size: 26px; line-height: 1; letter-spacing: 6px; font-weight: 400; }
#hud p { margin: 2px 0 0; color: var(--ink-dim); font-size: 17px; letter-spacing: 0.5px; }

#bottom {
  bottom: 14px; left: 0; right: 0; margin: 0 auto; width: max-content;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  max-width: min(96vw, 1220px);
}
.row { display: flex; gap: 5px; align-items: center; justify-content: center; flex-wrap: wrap; }

.btn {
  background: rgba(231, 223, 203, 0.07); color: var(--ink);
  border: 1px solid rgba(231, 223, 203, 0.3); border-radius: 2px;
  font: 18px/1 var(--font); letter-spacing: 0.5px;
  padding: 3px 9px 3px; cursor: pointer; touch-action: manipulation;
}
.btn:hover { border-color: rgba(231, 223, 203, 0.6); }
.btn:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
.btn.sel { background: var(--ink); color: #1d2a30; border-color: var(--ink); }

.sep { width: 1px; height: 16px; background: rgba(231, 223, 203, 0.25); margin: 0 3px; flex: 0 0 auto; }

#palette { display: inline-flex; gap: 5px; transition: opacity 0.15s; }
#palette.dim { opacity: 0.35; }
#palette button {
  width: 20px; height: 20px; padding: 0; cursor: pointer; flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.45); border-radius: 2px; outline: none;
}
#palette button.sel { box-shadow: 0 0 0 2px var(--ink); }

#help { top: 14px; right: 14px; width: 330px; display: none; }
#help.open { display: block; }
.help-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#help h2 { margin: 0; font-size: 20px; letter-spacing: 3px; font-weight: 400; }
#help dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 17px; line-height: 1.15; }
#help dt { color: var(--ink-dim); }
#help dd { margin: 0; }
#help .note { margin: 10px 0 0; color: var(--ink-dim); font-size: 16px; line-height: 1.15; }

#toast {
  position: fixed; top: 16px; left: 50%;
  transform: translate(-50%, -6px); opacity: 0;
  transition: opacity 0.2s, transform 0.2s; pointer-events: none;
  color: var(--ink); font: 19px var(--font); letter-spacing: 0.5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 6px 14px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  #hud { top: 8px; left: 8px; padding: 6px 10px; }
  #hud h1 { font-size: 22px; letter-spacing: 5px; }
  #hud .sub { display: none; }
  #bottom {
    left: 6px; right: 6px; bottom: calc(6px + env(safe-area-inset-bottom));
    width: auto; margin: 0; max-width: none; padding: 6px; align-items: stretch;
  }
  .row {
    flex-wrap: nowrap; justify-content: flex-start;
    overflow-x: auto; scrollbar-width: none; padding-bottom: 1px;
  }
  .row::-webkit-scrollbar { display: none; }
  .btn { flex: 0 0 auto; padding: 6px 11px; font-size: 19px; }
  #palette button { width: 26px; height: 26px; }
  #help { left: 8px; right: 8px; top: 8px; width: auto; max-height: 70vh; overflow-y: auto; }
}

/* 404 page */
body.lost { display: flex; align-items: center; justify-content: center; }
.lost-box { position: static; text-align: center; padding: 18px 26px; }
.lost-box h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: 6px; font-weight: 400; }
.lost-box p { margin: 4px 0; }
.lost-box a { color: #e6bd6a; }
