/* joe.ag — a blocky town in first person. */

:root {
  --ink: #141414;
  --paper: #f3f0e6;
  --accent: #e8784b;
  --sky: #7fb2e5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--sky);
  color: var(--paper);
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

a { color: var(--paper); text-decoration: none; }
a:hover { text-decoration: underline; }

.shadow, .hud, .prompt, .toast, .tollbox { text-shadow: 1px 1px 0 var(--ink), -1px 1px 0 var(--ink), 1px -1px 0 var(--ink), -1px -1px 0 var(--ink); }

.hud {
  position: fixed; left: 0; right: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding: 12px 16px;
  pointer-events: none;
}
.hud a, .hud button { pointer-events: auto; }
.top { top: 0; align-items: flex-start; }
.bottom { bottom: 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.col { display: flex; flex-direction: column; gap: 2px; }
.col.right { text-align: right; }
.sub { font-size: 12px; opacity: 0.85; }
.links { display: flex; gap: 16px; flex-wrap: wrap; }
.ctls { display: flex; gap: 8px; }

.ctl {
  appearance: none;
  background: rgba(20, 20, 20, 0.55);
  border: 2px solid var(--paper);
  color: var(--paper);
  font: inherit; font-size: 12px;
  min-height: 34px; padding: 0 10px;
  cursor: pointer; text-shadow: none;
}
.ctl:hover { background: var(--paper); color: var(--ink); }
.ctl[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--ink); }

.crosshair {
  position: fixed; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; z-index: 3; pointer-events: none;
  background: linear-gradient(var(--paper), var(--paper)) center/2px 100% no-repeat, linear-gradient(var(--paper), var(--paper)) center/100% 2px no-repeat;
  mix-blend-mode: difference;
}

.prompt {
  position: fixed; left: 50%; top: 58%; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: rgba(20, 20, 20, 0.82);
  border: 2px solid var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  pointer-events: none; white-space: nowrap; max-width: 92vw;
}
.prompt[hidden] { display: none; }
.prompt b { font-weight: normal; }
.prompt i { font-style: normal; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; }
.key { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; background: var(--paper); color: var(--ink); font-weight: bold; text-shadow: none; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 4;
  padding: 8px 14px; background: rgba(20, 20, 20, 0.75); border: 2px solid var(--paper);
  max-width: 92vw; text-align: center; pointer-events: none;
}
.toast[hidden] { display: none; }
.tollbox { position: fixed; right: 16px; top: 64px; z-index: 3; font-size: 12px; color: #ffd166; pointer-events: none; }
.tollbox[hidden] { display: none; }

.hotbar { position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 3; display: flex; gap: 4px; }
.hotbar[hidden] { display: none; }
.slot { appearance: none; min-width: 44px; min-height: 44px; padding: 0 8px; background: rgba(20, 20, 20, 0.6); border: 2px solid rgba(243, 240, 230, 0.5); color: var(--paper); font: inherit; font-size: 11px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.slot b { font-size: 12px; color: var(--accent); }
.slot.on b { color: var(--paper); }
.slot.on { border-color: var(--accent); background: rgba(232, 120, 75, 0.35); }

.minimap { position: fixed; right: 16px; top: 90px; z-index: 3; width: 192px; height: 192px; border: 2px solid var(--paper); background: #111; image-rendering: pixelated; }
.minimap[hidden] { display: none; }

/* touch controls */
.touch { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.touch[hidden] { display: none; }
.stick { position: absolute; left: 24px; bottom: max(70px, calc(env(safe-area-inset-bottom) + 58px)); width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(243, 240, 230, 0.7); background: rgba(20, 20, 20, 0.25); pointer-events: auto; }
.knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(243, 240, 230, 0.8); }
.jump, .fire, .visit { position: absolute; right: 24px; appearance: none; border: 2px solid var(--paper); background: rgba(20, 20, 20, 0.5); color: var(--paper); font: inherit; font-size: 15px; pointer-events: auto; }
.jump { bottom: max(70px, calc(env(safe-area-inset-bottom) + 58px)); width: 72px; height: 72px; border-radius: 50%; }
.fire { right: 112px; bottom: max(70px, calc(env(safe-area-inset-bottom) + 58px)); width: 72px; height: 72px; border-radius: 50%; font-size: 14px; }
.visit { bottom: max(160px, calc(env(safe-area-inset-bottom) + 148px)); padding: 14px 22px; background: var(--paper); color: var(--ink); }
.visit[hidden] { display: none; }

.namefield { display: block; font-size: 12px; margin: 0 0 14px; opacity: 0.85; }
.namefield input, .book input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 2px solid var(--ink); background: #fff; color: var(--ink); font: inherit; font-size: 15px;
}
.bar { height: 6px; margin: 10px 0 0; background: rgba(20, 20, 20, 0.15); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.start:disabled { opacity: 0.6; cursor: wait; }
.start.small { width: auto; min-height: 44px; padding: 0 18px; font-size: 15px; }

.released {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 5;
  appearance: none; border: 2px solid var(--paper); background: rgba(20, 20, 20, 0.8); color: var(--paper);
  font: inherit; font-size: 13px; padding: 10px 14px; cursor: pointer; max-width: 92vw; text-align: center;
}
.released[hidden] { display: none; }

/* guestbook */
.book { position: fixed; inset: 0; z-index: 11; display: grid; place-items: center; background: rgba(20, 20, 20, 0.5); padding: 16px; }
.book[hidden] { display: none; }
.book form { width: min(440px, 100%); padding: 24px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.book h2 { margin: 0 0 6px; font-size: 24px; }
.book p { margin: 0 0 14px; line-height: 1.5; }
.book .row { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.book .ctl { background: none; color: var(--ink); border-color: var(--ink); min-height: 44px; font-size: 14px; }
.book .ctl:hover { background: var(--ink); color: var(--paper); }

/* start screen */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(20, 20, 20, 0.55); padding: 16px; overflow: auto; }
.overlay[hidden] { display: none; }
.card { width: min(480px, 100%); padding: 28px 28px 20px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.card h1 { margin: 0 0 8px; font-size: 40px; letter-spacing: -0.02em; }
.card p { margin: 0 0 18px; line-height: 1.5; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 22px; font-size: 13px; }
.keys dt { font-weight: bold; white-space: nowrap; }
.keys dd { margin: 0; }
.start { appearance: none; width: 100%; min-height: 52px; border: 3px solid var(--ink); background: var(--ink); color: var(--paper); font: inherit; font-size: 18px; cursor: pointer; }
.start:hover { background: #333; }
.fine { margin: 12px 0 0; font-size: 12px; opacity: 0.7; }

@media (hover: none) and (pointer: coarse) {
  .keys { display: none; }
  .crosshair { display: none; }
  .prompt .key { display: none; }
  .top { padding-top: max(12px, env(safe-area-inset-top)); }
  .bottom { flex-direction: column; align-items: flex-start; gap: 8px; top: 72px; bottom: auto; padding-top: 0; }
  .links { font-size: 13px; }
  .toast { top: 44%; }
  .hotbar { bottom: auto; top: 150px; left: 16px; right: 16px; transform: none; flex-wrap: wrap; justify-content: flex-start; }
  .slot { min-width: 40px; min-height: 40px; font-size: 10px; padding: 0 6px; }
  .minimap { top: auto; bottom: max(160px, calc(env(safe-area-inset-bottom) + 150px)); right: 16px; width: 128px; height: 128px; }
  .tollbox { top: auto; bottom: max(300px, calc(env(safe-area-inset-bottom) + 290px)); right: 16px; }
}
