:root {
  --bg: #030509;
  --ink: #ece7db;
  --dim: rgba(236, 231, 219, .58);
  --faint: rgba(236, 231, 219, .3);
  --line: rgba(236, 231, 219, .14);
  --amber: #ffb454;
  --ice: #9fd6ff;
  --ember: #ff6a3d;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pad: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); overflow: hidden; -webkit-text-size-adjust: 100%; }
body { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
::selection { background: rgba(255, 180, 84, .35); }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%); }
#grain { position: fixed; inset: -50%; width: 200%; height: 200%; pointer-events: none; z-index: 3; opacity: .045; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px; }

/* Cantos de visor */
.corner { position: fixed; width: 18px; height: 18px; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 1.2s ease .4s;
  border: 1px solid rgba(236, 231, 219, .28); }
.corner-tl { top: calc(12px + var(--safe-top)); left: 12px; border-right: 0; border-bottom: 0; }
.corner-tr { top: calc(12px + var(--safe-top)); right: 12px; border-left: 0; border-bottom: 0; }
.corner-bl { bottom: calc(12px + var(--safe-bottom)); left: 12px; border-right: 0; border-top: 0; }
.corner-br { bottom: calc(12px + var(--safe-bottom)); right: 12px; border-left: 0; border-top: 0; }
body.is-live .corner { opacity: 1; }

/* Rótulos projetados */
.lbl { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap;
  font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
  text-shadow: 0 1px 10px rgba(0,0,0,.95), 0 0 2px rgba(0,0,0,.9); padding-bottom: 16px; opacity: 0; will-change: transform, opacity; }
.lbl::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 1px; height: 10px; background: currentColor; opacity: .55; }
.lbl small { display: block; margin-top: 4px; font-weight: 400; letter-spacing: .03em; text-transform: none; color: var(--dim); }
.lbl-you { color: var(--amber); }
.lbl-other { color: var(--ice); }
.lbl-iss { color: #fff; }

/* Véu de abertura */
#veil { position: fixed; inset: 0; z-index: 30; background: #000; transition: background 2.6s ease, opacity 1.1s ease; cursor: pointer; }
#veil.is-clear { background: rgba(0,0,0,0); }
#veil.is-gone { opacity: 0; pointer-events: none; }
.veil-lines { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); width: min(92vw, 720px); }
.veil-line { position: absolute; left: 0; right: 0; top: 0; margin: 0; text-align: center;
  font: italic 400 clamp(28px, 4.6vw, 46px)/1.18 var(--serif); letter-spacing: -.005em; color: var(--ink);
  text-shadow: 0 2px 30px rgba(0,0,0,.9), 0 0 3px rgba(0,0,0,.8);
  opacity: 0; transform: translateY(10px); transition: opacity 1.3s ease, transform 1.3s ease; }
.veil-line.is-in { opacity: 1; transform: translateY(0); }
.veil-load { position: absolute; left: 0; right: 0; bottom: calc(44px + var(--safe-bottom)); text-align: center;
  font: 400 11px var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--faint); }
.veil-skip { position: absolute; right: calc(var(--pad) + 4px); bottom: calc(38px + var(--safe-bottom)); background: none; border: 0; padding: 10px;
  font: 400 11px var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--faint); cursor: pointer; opacity: 0; transition: opacity 1s ease 1.6s; }
#veil.is-clear .veil-skip { opacity: 1; }
.veil-skip:hover { color: var(--ink); }

/* HUD */
.hud { position: fixed; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 0 var(--pad); pointer-events: none; opacity: 0; transform: translateY(6px); transition: opacity 1.2s ease .2s, transform 1.2s ease .2s; }
.hud > * { pointer-events: auto; }
body.is-live .hud { opacity: 1; transform: none; }
.hud-top { top: calc(var(--pad) + var(--safe-top)); }
.hud-bottom { bottom: calc(var(--pad) + var(--safe-bottom)); align-items: flex-end; }

.brand h1 { margin: 0; font: italic 400 38px/1 var(--serif); letter-spacing: -.02em; color: var(--ink); }
.brand span { display: block; margin-top: 6px; font: 400 10px var(--mono); letter-spacing: .26em; text-transform: uppercase; color: var(--dim); }

.controls { display: flex; gap: 6px; }
.btn { appearance: none; cursor: pointer; font: 500 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
  background: rgba(3, 5, 9, .38); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; min-height: 36px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: color .2s, border-color .2s, background .2s, transform .1s; }
.btn:hover { color: var(--ink); border-color: rgba(236, 231, 219, .4); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 1px solid var(--amber); outline-offset: 2px; }
.btn.is-on { color: var(--amber); border-color: rgba(255, 180, 84, .55); }
.btn-icon { min-width: 36px; padding: 0; }
.btn-primary { color: #1a1206; background: var(--amber); border-color: var(--amber); }
.btn-primary:hover { color: #1a1206; background: #ffc36f; border-color: #ffc36f; }
.btn[disabled] { opacity: .5; cursor: default; }

.status { font: 400 12px/1.7 var(--mono); color: var(--ink); }
.status-place { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.status-time { color: var(--dim); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.dot-amber { background: var(--amber); box-shadow: 0 0 10px rgba(255, 180, 84, .8); }
.dot-amber.dot-soft { box-shadow: none; opacity: .8; }
.dot-ice { background: var(--ice); box-shadow: 0 0 10px rgba(159, 214, 255, .8); }

.stats { text-align: right; font: 400 12px/1.7 var(--mono); color: var(--ink); }
.stats > div { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.stats-visit { color: var(--dim); }

.hint { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); white-space: nowrap;
  font: italic 400 17px var(--serif); color: var(--dim); opacity: 0; transition: opacity 1s ease; pointer-events: none; }
.hint.is-in { opacity: 1; }

/* Feed de acontecimentos */
.feed { position: fixed; left: var(--pad); bottom: calc(var(--pad) + var(--safe-bottom) + 66px); z-index: 5; display: flex; flex-direction: column; gap: 6px; pointer-events: none; max-width: min(72vw, 420px); }
.feed-item { display: flex; align-items: baseline; gap: 8px; font: 400 11px/1.5 var(--mono); color: var(--dim);
  opacity: 0; transform: translateX(-8px); transition: opacity .6s ease, transform .6s ease; }
.feed-item.is-in { opacity: 1; transform: none; }
.feed-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--dim); flex: 0 0 auto; position: relative; top: -1px; }
.feed-join .feed-dot { background: var(--ice); box-shadow: 0 0 8px rgba(159, 214, 255, .9); }
.feed-join { color: var(--ink); }
.feed-mark .feed-dot { background: var(--amber); box-shadow: 0 0 8px rgba(255, 180, 84, .9); }
.feed-mark { color: var(--ink); }
.feed-quake .feed-dot { background: var(--ember); box-shadow: 0 0 8px rgba(255, 106, 61, .9); }
.feed-iss .feed-dot { background: #fff; box-shadow: 0 0 8px rgba(255,255,255,.9); }
.feed-iss { color: var(--ink); }

/* Tooltip */
.tip { position: fixed; left: 0; top: 0; z-index: 8; max-width: 300px; padding: 12px 14px 12px; pointer-events: none;
  background: rgba(6, 9, 16, .84); border: 1px solid var(--line); border-radius: 6px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  opacity: 0; transform: translateY(4px); transition: opacity .18s ease, transform .18s ease; will-change: left, top; }
.tip.is-open { opacity: 1; transform: none; pointer-events: auto; }
.tip-text { font: 400 17px/1.32 var(--serif); color: var(--ink); overflow-wrap: anywhere; }
.tip-title { font: 500 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink); }
.tip-title.is-quake { color: var(--ember); }
.tip-title.is-you { color: var(--amber); }
.tip-title.is-other { color: var(--ice); }
.tip-meta { margin-top: 8px; font: 400 11px/1.55 var(--mono); color: var(--dim); }
.tip-claude { color: #fff0c2; }
.tip-actions { display: flex; gap: 12px; margin-top: 10px; }
.tip-btn { background: none; border: 0; padding: 0; cursor: pointer; font: 500 10px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--amber); }
.tip-btn:hover { color: #ffd08a; }
.tip-btn.is-muted { color: var(--dim); }

/* Folhas (composer / sobre) */
.sheet { position: fixed; left: 50%; bottom: calc(var(--pad) + var(--safe-bottom)); z-index: 10; width: min(480px, calc(100vw - 2 * var(--pad)));
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; }
.sheet.is-open { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.sheet-inner { background: rgba(6, 9, 16, .9); border: 1px solid var(--line); border-radius: 10px; padding: 18px 18px 14px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sheet h2 { margin: 0; font: italic 400 24px/1.1 var(--serif); letter-spacing: -.01em; }
.sheet-coords { font: 400 11px var(--mono); color: var(--dim); white-space: nowrap; }
.sheet textarea { display: block; width: 100%; resize: none; border: 0; border-bottom: 1px solid rgba(236, 231, 219, .25); background: transparent; color: var(--ink);
  font: 400 19px/1.35 var(--serif); padding: 4px 0 10px; outline: none; caret-color: var(--amber); }
.sheet textarea::placeholder { color: rgba(236, 231, 219, .35); font-style: italic; }
.sheet textarea:focus { border-bottom-color: var(--amber); }
.sheet-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.sheet-count { font: 400 11px var(--mono); color: var(--faint); }
.sheet-error { flex: 1 1 auto; font: 400 11px var(--mono); color: var(--ember); min-width: 0; }
.sheet-actions { display: flex; gap: 6px; margin-left: auto; }
.sheet-about p { margin: 0 0 12px; font: 400 15px/1.5 var(--serif); color: var(--ink); }
.sheet-about h2 { margin-bottom: 12px; }
.sheet-about .about-credit { font: 400 11px/1.6 var(--mono); color: var(--dim); margin-top: 16px; }
.sheet-about .about-credit em { color: var(--amber); font-style: normal; }
.sheet-about .btn { margin-top: 6px; }

.nowebgl[hidden] { display: none; }
.nowebgl { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; background: var(--bg); }
.nowebgl p { margin: 0 0 10px; font: italic 400 26px/1.3 var(--serif); max-width: 26ch; }
.nowebgl .nowebgl-sub { font: 400 12px var(--mono); color: var(--dim); }

@media (max-width: 720px) {
  :root { --pad: 16px; }
  body { font-size: 11px; }
  .brand h1 { font-size: 32px; }
  .btn { padding: 0 11px; min-height: 40px; letter-spacing: .1em; }
  .btn-icon { min-width: 40px; }
  .hud-bottom { flex-direction: column; align-items: flex-start; gap: 4px; }
  .status, .stats { font-size: 11px; line-height: 1.6; }
  .stats { text-align: left; display: flex; flex-wrap: wrap; gap: 0 14px; }
  .stats > div { justify-content: flex-start; }
  .stats-visit { display: none !important; }
  .st-coords { display: none; }
  .hint { display: none; }
  .feed { bottom: calc(var(--pad) + var(--safe-bottom) + 76px); max-width: calc(100vw - 2 * var(--pad)); }
  .feed-item { font-size: 10.5px; }
  .tip { max-width: min(300px, calc(100vw - 32px)); }
  .sheet { width: calc(100vw - 2 * var(--pad)); }
  .sheet h2 { font-size: 22px; }
  .sheet-coords { display: none; }
  .veil-lines { top: 16%; }
}

@media (max-width: 420px) {
  .stats > div:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .veil-line, .hud, .feed-item, .tip, .sheet, .corner { transition-duration: .01s; }
}
