:root {
  --ink: #2b2340;
  --cream: #fffaf0;
  --paper: #fff3dc;
  --coral: #ff7a59;
  --teal: #2bb5a3;
  --blue: #2a6df5;
  --muted: #7a6f8f;
  --bad: #e8445a;
  --good: #23a86b;
  font: 15px/1.45 "Fredoka", ui-rounded, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; height: 100vh; background: #bfe8ff; }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }
.labels { position: absolute; inset: 0; }
.labels > div { pointer-events: none; }

/* ---------- sticker cards & buttons ---------- */
.card {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
}
button {
  font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
  background: #fff; border: 3px solid var(--ink); border-radius: 999px;
  padding: 6px 14px; box-shadow: 0 3px 0 var(--ink); transition: transform 0.08s, box-shadow 0.08s;
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--coral); color: #fff; }
button.danger { background: #ffd9de; }
button.active { background: var(--teal); color: #fff; }
.logo { font-weight: 700; font-size: 22px; letter-spacing: 0.3px; }
.logo span { color: var(--coral); }
.logo.big { font-size: 56px; line-height: 1; }

/* ---------- world HUD ---------- */
#brand { position: fixed; top: 16px; left: 16px; padding: 10px 16px; z-index: 5; }
#progress { font-size: 13px; color: var(--muted); }
#progress .dots { display: flex; gap: 5px; margin-top: 5px; }
#progress .dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: #e9e1d2; }
#minimap { position: fixed; top: 16px; right: 16px; width: 240px; height: 115px; z-index: 5; background: #bfe8ff; }
#hint { position: fixed; left: 16px; bottom: 18px; padding: 8px 14px; font-size: 13px; z-index: 5; }
#prompt {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 6;
  display: flex; gap: 10px; align-items: center; padding: 8px 18px 8px 8px; font-size: 16px;
  animation: bob 1.4s ease-in-out infinite;
}
#prompt kbd {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--coral); color: #fff; border: 2px solid var(--ink); font: 700 15px "Fredoka", sans-serif;
}
@keyframes bob { 50% { transform: translateX(-50%) translateY(-4px); } }

#dialog {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 8;
  width: min(560px, calc(100vw - 32px)); padding: 26px 22px 16px;
}
#dialog .who {
  position: absolute; top: -18px; left: 20px; padding: 3px 14px; border-radius: 999px;
  border: 3px solid var(--ink); color: #fff; font-weight: 700; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
#dialog p { margin: 0 0 12px; font-size: 16px; }
#dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- labels in the 3D world ---------- */
.sign-label, .npc-label {
  background: var(--cream); border: 2px solid var(--ink); border-radius: 10px; padding: 2px 10px;
  text-align: center; box-shadow: 0 3px 0 var(--ink); white-space: nowrap; transition: opacity 0.3s;
}
.sign-label b, .xr-label b { display: block; font-size: 14px; }
.sign-label small, .xr-label small { display: block; font-size: 11px; color: var(--muted); }
.npc-label { font-size: 12px; padding: 0 8px; }
.bubble { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 2px solid var(--ink); background: #fff; }
.bubble.bad { background: var(--bad); color: #fff; }
.xr-label { background: var(--blue); color: #fff; border: 2px solid #fff; border-radius: 8px; padding: 2px 8px; text-align: center; white-space: nowrap; }
.xr-label small { color: #d6e6ff; }
body:not(.xray) .xr-label { display: none; }

/* ---------- zone panels ---------- */
.panel { position: fixed; top: 16px; z-index: 6; padding: 14px 16px; overflow-y: auto; max-height: calc(100vh - 32px); }
#zone-left { left: 16px; width: 330px; }
#zone-right { right: 16px; width: 380px; top: auto; bottom: 16px; }
.panel h2 { margin: 0; font-size: 24px; }
.panel h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.panel h3 small { text-transform: none; letter-spacing: 0; }
.zone-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--paper); border: 2px solid var(--ink); }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { padding: 3px 9px; font-size: 13px; box-shadow: 0 2px 0 var(--ink); border-width: 2px; }
.story { margin: 12px 0; padding: 10px 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; }
.story h4 { margin: 0 0 4px; font-size: 17px; }
.story p { margin: 4px 0; }
.story .tech { color: var(--muted); }
.story ul { margin: 4px 0; padding-left: 18px; font-size: 13px; }
.story a { color: var(--blue); font-weight: 600; }
.pros li::marker { content: "+ "; color: var(--good); font-weight: 700; }
.cons li::marker { content: "− "; color: var(--bad); font-weight: 700; }
.xray-btn { width: 100%; background: #dbe8ff; }
.xray-btn.active { background: var(--blue); color: #fff; }
.panel .danger { width: 100%; margin-top: 10px; }
.exit { width: 100%; margin-top: 14px; }

.slider { display: block; margin: 8px 0; }
.slider .row { display: flex; justify-content: space-between; font-weight: 500; }
.slider output { color: var(--coral); font-weight: 700; }
.slider input { width: 100%; accent-color: var(--coral); }
.slider small, .toggle { color: var(--muted); font-size: 13px; }
.toggle { display: flex; gap: 8px; align-items: center; margin: 10px 0 0; cursor: pointer; }

.metrics { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.metrics th, .metrics td { padding: 4px; text-align: right; border-bottom: 2px dashed #e6dcc8; white-space: nowrap; }
.metrics tbody th { text-align: left; font-weight: 500; color: var(--muted); }
.metrics td.bad { color: var(--bad); font-weight: 700; }
.legend { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.legend i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); }
.asks { display: flex; flex-direction: column; gap: 6px; }
.asks button { text-align: left; font-size: 13px; padding: 4px 12px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
.ask-form { display: flex; gap: 6px; margin-top: 8px; }
.ask-form input { flex: 1; min-width: 0; font: inherit; padding: 5px 12px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; }
.question { margin: 0; font-weight: 600; font-size: 16px; }
.answer-card { margin: 10px 0; padding: 8px 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; }
.answer-card .who { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.answer-card p { margin: 4px 0 2px; font-size: 16px; }
.answer-card small { color: var(--muted); }
.verdict { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 2px solid var(--ink); background: #fff; white-space: nowrap; }
.verdict.good { background: #d7f5e5; color: var(--good); }
.verdict.bad { background: #ffd9de; color: var(--bad); }
.hits th { font-weight: 500; }
.prompt { margin: 0; padding: 8px 10px; background: #1d2a4d; color: #d6e6ff; border-radius: 10px; font: 12px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.bubble.answer { max-width: 240px; font-size: 13px; padding: 4px 12px; border-radius: 14px; text-align: center; }
.hint-x { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
body.xray .hint-x { display: none; }

#tour-btn { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 7; }
#tourbar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 7;
  width: min(560px, calc(100vw - 760px)); min-width: 340px; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
#tourbar p { margin: 0; font-size: 16px; }
#tourbar .count { color: var(--muted); font-size: 12px; font-weight: 600; }
#tourbar .actions { display: flex; gap: 6px; justify-content: flex-end; }
#tourbar .ghost { box-shadow: none; border-color: transparent; background: transparent; }

/* ---------- intro & fade ---------- */
#intro {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: linear-gradient(transparent 45%, rgba(255, 243, 220, 0.85));
  transition: opacity 0.8s, visibility 0.8s;
}
#intro.gone { opacity: 0; visibility: hidden; }
.intro-card { text-align: center; max-width: 520px; padding: 20px; margin-top: 52vh; }
.intro-card p { font-size: 19px; margin: 12px 0 20px; text-shadow: 0 1px 0 #fff; }
.intro-card small { display: block; margin-top: 12px; color: var(--muted); }
button.big { font-size: 20px; padding: 10px 26px; }
#fade { position: fixed; inset: 0; z-index: 30; background: var(--cream); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
#fade.on { opacity: 1; }

@media (max-width: 900px) {
  #hint, #zone-right { display: none; }
  #zone-left { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 45vh; border-radius: 18px 18px 0 0; }
  #tourbar { width: calc(100vw - 24px); min-width: 0; bottom: calc(45vh + 10px); }
  #minimap { width: 160px; height: 77px; }
  .logo.big { font-size: 40px; }
}
