/* ============================================================
   PIXEL WILDS — HUD / chrome
   The world itself is a low-res canvas scaled up with
   image-rendering:pixelated; this layer stays crisp.
   ============================================================ */

:root {
  --ink: #070b09;
  --paper: #e9e3cf;
  --paper-dim: rgba(233, 227, 207, 0.62);
  --moss: #2c4a35;
  --gold: #c9a227;
  --red: #a61c26;
  --blue: #003366;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #060a08;
  color: var(--paper);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

[hidden] { display: none !important; }

/* ---------- the world canvas ---------- */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
}

/* ---------- screen effects ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; }
.fx-scan {
  background: repeating-linear-gradient(to bottom,
      rgba(0, 0, 0, 0.14) 0px, rgba(0, 0, 0, 0.14) 1px,
      rgba(0, 0, 0, 0) 1px, rgba(0, 0, 0, 0) 3px);
  opacity: 0.55;
  mix-blend-mode: multiply;
}
.fx-vignette {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 40%, rgba(4, 8, 6, 0.5) 100%),
    linear-gradient(to bottom, rgba(4, 8, 6, 0.35), rgba(0, 0, 0, 0) 22%, rgba(0, 0, 0, 0) 78%, rgba(4, 8, 6, 0.42));
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
}
.hud-top {
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(12px, 2vw, 22px) clamp(14px, 2.4vw, 28px);
}
.hud-bottom {
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(12px, 2vw, 22px) clamp(14px, 2.4vw, 28px) clamp(14px, 2.2vw, 26px);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  color: var(--gold);
  font-size: 20px;
  line-height: 1;
  text-decoration: none;
  display: inline-block;
  filter: drop-shadow(0 0 6px rgba(201, 162, 39, 0.55));
  animation: pulse 3.4s ease-in-out infinite;
}
.brand-mark:focus-visible { outline: 1px solid var(--gold); outline-offset: 3px; }
.brand-text h1 {
  margin: 0;
  font-size: clamp(13px, 1.35vw, 17px);
  letter-spacing: 0.32em;
  font-weight: 700;
  text-transform: uppercase;
}
.brand-text p {
  margin: 4px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

/* local wall clock — the valley's sky is driven by it */
.clock {
  display: block;
  margin-top: 3px;
  color: rgba(233, 227, 207, 0.55);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.nav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; pointer-events: auto; }
.nav button {
  appearance: none;
  background: rgba(8, 14, 10, 0.55);
  border: 1px solid rgba(233, 227, 207, 0.26);
  color: var(--paper);
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 7px 11px 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
  backdrop-filter: blur(3px);
}
.nav button:hover,
.nav button:focus-visible {
  background: rgba(201, 162, 39, 0.16);
  border-color: var(--gold);
  color: #fff6d8;
  outline: none;
}
.nav button:active { transform: translateY(1px); }
.nav .lang-btn {
  border-color: rgba(201, 162, 39, 0.45);
  color: #e8d9a8;
  letter-spacing: 0.08em;
  min-width: 44px;
}
.nav .lang-btn:hover {
  background: rgba(201, 162, 39, 0.18);
  border-color: var(--gold);
  color: #fff6d8;
}

.zone {
  position: fixed;
  top: clamp(62px, 8.4vh, 84px);
  left: clamp(14px, 2.4vw, 28px);
  z-index: 5;
  padding: 5px 12px 4px;
  background: rgba(7, 11, 9, 0.62);
  border: 1px solid rgba(233, 227, 207, 0.16);
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(233, 227, 207, 0.72);
  pointer-events: none;
  transition: color 0.3s, letter-spacing 0.3s, border-color 0.3s;
  white-space: nowrap;
  backdrop-filter: blur(3px);
}
.zone.on { color: var(--gold); letter-spacing: 0.42em; border-color: rgba(201, 162, 39, 0.5); }

.prompt {
  position: fixed;
  left: 50%;
  bottom: clamp(92px, 15vh, 132px);
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px 8px 9px;
  background: rgba(8, 14, 10, 0.72);
  border: 1px solid rgba(201, 162, 39, 0.55);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f4ecd6;
  pointer-events: none;
  animation: rise 0.28s ease-out both;
  backdrop-filter: blur(3px);
}

.dialogue {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: min(560px, 62vw);
  padding: 9px 13px 10px 9px;
  background: rgba(8, 14, 10, 0.66);
  border: 1px solid rgba(233, 227, 207, 0.2);
  border-left: 2px solid var(--gold);
  backdrop-filter: blur(3px);
}
.dialogue .tag {
  flex: none;
  background: var(--gold);
  color: #1a1408;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 3px 6px 2px;
}
.dialogue p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgba(233, 227, 207, 0.88);
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(233, 227, 207, 0.5);
}
.keys li { display: flex; align-items: center; gap: 6px; }

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 2px 5px 1px;
  border: 1px solid rgba(233, 227, 207, 0.35);
  border-bottom-width: 2px;
  background: rgba(233, 227, 207, 0.07);
  color: #f4ecd6;
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-align: center;
}

/* ---------- critter name chips ---------- */
#tags { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.tag-critter {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 3px 8px 2px;
  background: rgba(7, 11, 9, 0.78);
  border: 1px solid rgba(201, 162, 39, 0.5);
  color: #f2e6c8;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s linear;
  will-change: opacity, left, top;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
}

/* ---------- section panel ---------- */
.panel-wrap {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 6, 0.55);
  backdrop-filter: blur(2px);
  animation: fade 0.2s ease-out both;
}
.panel {
  position: relative;
  width: min(540px, 94vw);
  max-height: min(76vh, 620px);
  overflow: auto;
  padding: clamp(20px, 3vw, 30px) clamp(20px, 3vw, 32px) clamp(22px, 3vw, 30px);
  background:
    linear-gradient(160deg, rgba(201, 162, 39, 0.07), rgba(0, 0, 0, 0) 42%),
    #10140f;
  border: 1px solid rgba(233, 227, 207, 0.28);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  animation: pop 0.26s cubic-bezier(0.2, 0.9, 0.25, 1) both;
  scrollbar-width: thin;
}
.panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--gold) 55%, var(--blue));
}
.panel-kicker {
  font-size: 9.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}
.panel-title {
  margin: 8px 0 0;
  font-size: clamp(19px, 2.4vw, 25px);
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: #f6efd9;
}
.panel-rule {
  height: 1px;
  margin: 16px 0 15px;
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.75), rgba(233, 227, 207, 0.08));
}
.panel p {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.75;
  color: rgba(233, 227, 207, 0.84);
}
.panel-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}
.panel-list li {
  position: relative;
  padding-left: 16px;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgba(233, 227, 207, 0.74);
}
.panel-list li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--gold);
}
.panel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}
.panel-links a {
  padding: 8px 13px 7px;
  border: 1px solid rgba(201, 162, 39, 0.5);
  color: #f6efd9;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.panel-links a:hover { background: rgba(201, 162, 39, 0.15); border-color: var(--gold); }
.panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid rgba(233, 227, 207, 0.22);
  color: rgba(233, 227, 207, 0.7);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.panel-close:hover { color: #fff; border-color: var(--gold); }

/* ---------- boot ---------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: #070b09;
  transition: opacity 0.7s ease, visibility 0.7s;
}
.boot.gone { opacity: 0; visibility: hidden; }
.boot-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(233, 227, 207, 0.7);
}
.boot-dot {
  width: 7px;
  height: 7px;
  background: var(--gold);
  animation: pulse 1s steps(2, end) infinite;
}
.boot.failed .boot-inner { color: #ff9a8a; letter-spacing: 0.1em; text-transform: none; }

/* dim the in-world HUD while a panel is open */
body.panel-open .hud-bottom,
body.panel-open .zone,
body.panel-open .prompt {
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

/* ---------- animation ---------- */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 700px) {
  .hud-top {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  }
  .brand-text p { display: none; }
  .nav { justify-content: space-between; gap: 5px; }
  .nav button {
    flex: 1;
    padding: 9px 4px 8px;
    font-size: 9px;
    letter-spacing: 0.1em;
    background: rgba(7, 11, 9, 0.78);
    border-color: rgba(233, 227, 207, 0.3);
  }
  .zone { display: none; }
  .keys { display: none; }
  .dialogue { max-width: none; width: 100%; }
  .dialogue p { font-size: 11px; }
  .hud-bottom { padding: 12px 12px max(14px, env(safe-area-inset-bottom)); }
  .prompt { bottom: max(84px, calc(env(safe-area-inset-bottom) + 74px)); font-size: 10px; }
  .panel { padding: 22px 18px 24px; max-height: 82vh; }
}
/* ---------- touch / tablet controls ---------- */
.touch-ui {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  pointer-events: none;
  transition: opacity 0.2s;
}
body.is-touch .touch-ui { display: block; }
body.panel-open .touch-ui { opacity: 0; pointer-events: none; }
body.is-touch .keys { display: none; }
body.is-touch .prompt { display: none; }

/* lift the LOG bar clear of the stick and the action button.
   the stick is the tallest control, so its column sets the clearance. */
body.is-touch .hud-bottom {
  bottom: calc(var(--ctl-rise, 150px) + env(safe-area-inset-bottom));
}

.stick {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 18px));
  width: 118px;
  height: 118px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  background: radial-gradient(circle at 50% 50%, rgba(233, 227, 207, 0.07), rgba(7, 11, 9, 0.55));
  border: 1px solid rgba(233, 227, 207, 0.26);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.45);
}
.stick-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  height: 62%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px dashed rgba(233, 227, 207, 0.16);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #f2ecd8, #a89f83 72%, #6d6752);
  border: 1px solid rgba(11, 20, 16, 0.6);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.06s linear;
}

.act {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(30px, calc(env(safe-area-inset-bottom) + 26px));
  width: 78px;
  height: 78px;
  border-radius: 50%;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  touch-action: manipulation;
  color: #0b1410;
  background: radial-gradient(circle at 38% 30%, #f6e7a8, #c9a227 78%);
  border: 2px solid rgba(11, 20, 16, 0.55);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  font: inherit;
  transition: transform 0.1s, opacity 0.15s;
}
.act:active { transform: scale(0.94); }
.act-glyph { font-weight: 800; font-size: 15px; line-height: 1; letter-spacing: 0.04em; }
.act-label { font-size: 8px; font-weight: 700; letter-spacing: 0.14em; opacity: 0.75; }
.act.off,
.act:disabled {
  opacity: 0.3;
  pointer-events: none;
  background: radial-gradient(circle at 38% 30%, #cfc9b4, #8c8877 78%);
}

@media (max-width: 700px) {
  body.is-touch { --ctl-rise: 136px; }
  .online { top: calc(max(10px, env(safe-area-inset-top)) + 96px); }
  .stick { width: 104px; height: 104px; left: max(14px, env(safe-area-inset-left)); }
  .stick-knob { width: 44px; height: 44px; }
  .act { width: 68px; height: 68px; }
  .act-glyph { font-size: 13px; }
  .act-label { font-size: 7px; }
}


/* ---------- other visitors ---------- */
.tag-visitor {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 3px 8px 2px;
  background: rgba(7, 11, 9, 0.82);
  border: 1px solid rgba(233, 227, 207, 0.45);
  color: #f2e6c8;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s linear;
  will-change: opacity, left, top;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
}
.tag-visitor::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 1px;
  height: 4px;
  background: rgba(233, 227, 207, 0.45);
}

.online {
  position: fixed;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 3px 10px 2px;
  background: rgba(7, 11, 9, 0.72);
  border: 1px solid rgba(99, 183, 106, 0.55);
  color: #bfe3c2;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  animation: fade 0.3s ease-out;
}
.online::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 6px;
  border-radius: 50%;
  background: #63b76a;
  vertical-align: 1px;
  animation: pulse 2.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}