:root {
  color-scheme: dark;
  --ink: #f4ecdf;
  --muted: #d9cbb8;
  --green: #2fbe62;
  --green-ink: #06210f;
  --panel: rgba(22, 16, 12, 0.88);
  --line: rgba(244, 236, 223, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #140e0c;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  touch-action: none;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#hud { position: fixed; inset: 0; pointer-events: none; }

#hud button, #joy, #talk article, #talk .backdrop, #gamebar { pointer-events: auto; }

.brand {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand strong {
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 20px;
  letter-spacing: 0.16em;
  font-weight: 700;
}

.brand span { color: var(--green); }

.brand em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

#hint, #status, #prompt {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  text-align: center;
  max-width: min(640px, 92vw);
}

#hint {
  bottom: max(18px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

#prompt {
  bottom: 52px;
  background: rgba(20, 14, 12, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
}

#status {
  top: 72px;
  background: rgba(90, 28, 24, 0.92);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
}

#vr, #reset {
  position: absolute;
  border: 0;
  cursor: pointer;
  font: inherit;
}

#vr {
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  background: var(--green);
  color: var(--green-ink);
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 16px;
}

#vr:disabled { opacity: 0.55; }

#reset {
  top: max(64px, calc(env(safe-area-inset-top) + 52px));
  right: max(16px, env(safe-area-inset-right));
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 8px;
}

#reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border: 1.5px solid rgba(244, 236, 223, 0.85);
  border-radius: 50%;
  display: none;
}

body.locked #reticle, body.coarse #reticle { display: block; }

#joy {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(244, 236, 223, 0.12);
  border: 2px solid rgba(244, 236, 223, 0.28);
}

#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(47, 190, 98, 0.85);
}

#gamebar {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}

.game-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#game-slot canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  background: #000;
  border-radius: 8px;
}

#game-help { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

#game-exit, #talk-go, #talk-close, #flip-l, #flip-r {
  font: inherit;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

#game-exit, #talk-close, #flip-l, #flip-r {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

#talk-go, #flip-r {
  background: var(--green);
  color: var(--green-ink);
  border: 0;
  font-weight: 700;
}

#pin-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

#talk {
  position: absolute;
  inset: 0;
}

#talk .backdrop { position: absolute; inset: 0; background: rgba(8, 6, 4, 0.35); }

#talk article {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

#talk .role {
  margin: 0;
  color: var(--green);
  letter-spacing: 0.14em;
  font-size: 12px;
  text-transform: uppercase;
}

#talk h2 {
  font-family: Palatino, Georgia, serif;
  font-size: 36px;
  margin: 4px 0 8px;
}

#talk-blurb { margin: 0 0 12px; line-height: 1.45; }

#talk .url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #b7e7c6;
  word-break: break-all;
}

#talk .note { color: var(--muted); font-size: 13px; }

#talk .row { display: flex; gap: 8px; margin-top: 8px; }

body.vr #hud { display: none; }

@media (max-width: 720px) {
  #hint { bottom: 150px; }
  #gamebar { left: 12px; right: 12px; width: auto; }
  #prompt { bottom: 168px; }
}
