:root {
  color-scheme: dark;
  --ink: #05010f;
  --ink-2: #0d0420;
  --magenta: #ff2a6d;
  --cyan: #05d9e8;
  --yellow: #f9f002;
  --red: #ff2b3a;
  --text: #f4f1ff;
  --muted: rgba(234, 226, 255, 0.84);
  --panel: rgba(5, 1, 15, 0.74);
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --mono: "Share Tech Mono", ui-monospace, "DejaVu Sans Mono", monospace;
  --ca: -0.6px 0 rgba(255, 42, 109, 0.45), 0.6px 0 rgba(5, 217, 232, 0.45), 0 0 6px rgba(5, 1, 15, 0.95), 0 1px 2px rgba(5, 1, 15, 0.9);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--text);
  font-family: var(--display);
  -webkit-tap-highlight-color: transparent;
}
p, dl, dd { margin: 0; }

#cena {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  background: var(--ink);
}
#cena:focus { outline: none; }
#cena:focus-visible { outline: 2px solid var(--yellow); outline-offset: -2px; }

.vinheta, .scan { position: fixed; inset: 0; pointer-events: none; }
.vinheta { background: radial-gradient(ellipse 90% 80% at 50% 45%, transparent 55%, rgba(5, 1, 15, 0.7) 100%); }
.scan {
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.07) 2px 3px);
  overflow: hidden;
}
.scan::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: -20%;
  height: 18%;
  background: linear-gradient(to bottom, transparent, rgba(180, 220, 255, 0.05), transparent);
  animation: rolo 7s linear infinite;
}
@keyframes rolo { to { transform: translateY(700%); } }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 18px;
  display: grid;
  gap: 8px;
  pointer-events: none;
  text-transform: uppercase;
  text-shadow: var(--ca);
  background: linear-gradient(to bottom, rgba(5, 1, 15, 0.92) 0%, rgba(5, 1, 15, 0.7) 65%, rgba(5, 1, 15, 0));
  transition: opacity 0.3s;
}
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hud-id { display: grid; gap: 2px; }
.net {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 7px;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulso 1.6s ease-in-out infinite;
}
@keyframes pulso { 50% { opacity: 0.25; } }
.loc { font-size: 13px; letter-spacing: 0.12em; color: var(--muted); font-weight: 500; }
.warn { font-size: 13px; letter-spacing: 0.14em; color: var(--red); font-weight: 700; }
.warn span { animation: pulso 1s steps(2, jump-none) infinite; }
.hud-clock { text-align: right; }
.time {
  font-family: var(--mono);
  font-size: clamp(22px, 6.4vw, 34px);
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.date { font-size: 13px; letter-spacing: 0.14em; color: var(--muted); margin-top: 4px; font-weight: 500; }

.hud-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.hud-stats > div { display: grid; gap: 1px; }
.hud-stats dt { font-size: 12px; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.hud-stats dt span { color: var(--yellow); }
.hud-stats dd {
  font-family: var(--mono);
  font-size: clamp(15px, 4.2vw, 19px);
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
  min-height: 20px;
  display: flex;
  align-items: flex-end;
}
.bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 17px; }
.bars i { width: 4px; background: rgba(226, 216, 255, 0.18); }
.bars i:nth-child(1) { height: 5px; }
.bars i:nth-child(2) { height: 8px; }
.bars i:nth-child(3) { height: 11px; }
.bars i:nth-child(4) { height: 14px; }
.bars i:nth-child(5) { height: 17px; }
.bars i.on { background: var(--cyan); box-shadow: 0 0 6px rgba(5, 217, 232, 0.7); }

.hud.glitch { animation: falha 0.28s steps(4) 1; }
@keyframes falha {
  0% { transform: translate(0); text-shadow: -3px 0 var(--magenta), 3px 0 var(--cyan); }
  30% { transform: translate(-4px, 1px); clip-path: inset(10% 0 40% 0); }
  60% { transform: translate(3px, -1px); clip-path: inset(50% 0 5% 0); }
  100% { transform: translate(0); clip-path: none; }
}

/* ---------- dica ---------- */
.dica {
  position: fixed;
  left: 16px; right: 76px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 112px);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.4;
  color: var(--text);
  text-shadow: var(--ca), 0 0 12px rgba(5, 1, 15, 0.9);
  pointer-events: none;
  transition: opacity 0.8s;
}
.dica.fora { opacity: 0; }

/* ---------- controlos e notícias ---------- */
.bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  pointer-events: none;
}
.controls {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px;
  pointer-events: auto;
}
.controls button {
  appearance: none;
  min-height: 48px;
  min-width: 84px;
  padding: 6px 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  font-family: var(--display);
  color: var(--text);
  background: var(--panel);
  border: 1px solid rgba(5, 217, 232, 0.5);
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  cursor: pointer;
  text-shadow: var(--ca);
  touch-action: manipulation;
}
.controls button span { font-size: 12px; font-weight: 600; letter-spacing: 0.18em; color: var(--muted); }
.controls button b { font-size: 16px; font-weight: 700; letter-spacing: 0.1em; color: var(--yellow); }
.controls button[aria-pressed="true"] b { color: var(--cyan); }
.controls button:hover { background: rgba(26, 4, 51, 0.85); }
.controls button:active { transform: translateY(1px); }
.controls button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

.ticker {
  height: 36px;
  overflow: hidden;
  background: rgba(5, 1, 15, 0.94);
  border-top: 1px solid rgba(255, 42, 109, 0.55);
  display: flex;
  align-items: center;
  transition: opacity 0.3s;
}
.ticker-track {
  display: flex;
  width: max-content;
  animation: noticias var(--dur, 150s) linear infinite;
}
.ticker .run {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-right: 16px;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}
.ticker .tag {
  background: var(--magenta);
  color: var(--ink);
  padding: 3px 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-shadow: none;
}
.ticker i { font-style: normal; color: var(--magenta); font-size: 10px; }
@keyframes noticias { to { transform: translateX(-50%); } }

/* ---------- zoom ---------- */
.zoom {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 108px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}
.zoom button {
  appearance: none;
  width: 48px;
  height: 48px;
  padding: 0;
  font-family: var(--display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
  background: var(--panel);
  border: 1px solid rgba(5, 217, 232, 0.5);
  cursor: pointer;
  touch-action: manipulation;
}
.zoom #zoom-nivel {
  height: 34px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--yellow);
  border-color: rgba(249, 240, 2, 0.4);
}
.zoom button:disabled { opacity: 0.35; cursor: default; }
.zoom button:not(:disabled):hover { background: rgba(26, 4, 51, 0.85); }
.zoom button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
body.com-zoom #cena { cursor: grab; }
body.com-zoom #cena:active { cursor: grabbing; }

body.sem-painel .hud,
body.sem-painel .ticker { opacity: 0; }

.noscript { position: fixed; inset: auto 16px 50% 16px; text-align: center; font-size: 18px; }

@media (min-width: 720px) {
  .hud { padding-inline: 24px; }
  .controls { padding-inline: 24px; }
  .net { font-size: 14px; }
  .hud-stats { gap: 28px; }
  .dica { bottom: calc(env(safe-area-inset-bottom, 0px) + 116px); left: 88px; right: 88px; }
  .zoom { right: 24px; top: 50%; bottom: auto; transform: translateY(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .scan::after, .dot, .warn span { animation: none; }
  .ticker-track { animation-duration: calc(var(--dur, 150s) * 2.5); }
  .hud.glitch { animation: none; }
}
