@font-face {
  font-family: "Pixelify Sans";
  src: url("/assets/fonts/pixelify-sans-600.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Barlow Condensed";
  src: url("/assets/fonts/barlow-condensed-400.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Barlow Condensed";
  src: url("/assets/fonts/barlow-condensed-600.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "Barlow Condensed", "Arial Narrow", ui-sans-serif, system-ui, sans-serif;
  background: #050d19;
  color: #dccfbf;
  --safe-x: max(3vw, env(safe-area-inset-left));
  --safe-y: max(3vh, env(safe-area-inset-top));
  --panel: #061425;
  --surface: #142634;
  --surface-teal: #053445;
  --line: #313946;
  --gold: #cb9a53;
  --teal-secondary: #1e565f;
  --mint: #339597;
  --live: #7f814f;
  --coral: #b05437;
  --window-ink: #041326;
  --window-highlight: #4b6470;
  --radius-window: 18px;
  --radius-hud: 10px;
  --radius-card: 8px;
  --radius-control: 6px;
  --window-shadow: inset 0 0 0 2px #050d19, inset 0 0 0 3px var(--window-highlight), 8px 8px 0 #02070d;
  --icon-font: "Segoe UI Symbol", "Noto Sans Symbols 2", sans-serif;
  --pixel-font: "Pixelify Sans", "Lucida Console", monospace;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #050d19; }
body { user-select: none; }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.tv-app { position: relative; width: 100%; height: 100%; background: #142634; isolation: isolate; }
#tv-canvas { display: block; width: 100%; height: 100%; cursor: grab; image-rendering: pixelated; touch-action: none; }
#tv-canvas.dragging { cursor: grabbing; }

.tv-app::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: #050d1926;
}

.tv-header {
  position: absolute;
  z-index: 4;
  top: var(--safe-y);
  left: var(--safe-x);
  right: var(--safe-x);
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.2vw, 26px);
  pointer-events: none;
}

.tv-brand { display: flex; align-items: center; gap: clamp(11px, 1vw, 20px); filter: drop-shadow(0 3px 14px #0008); }
.tv-brand-mark {
  display: grid;
  place-items: center;
  width: clamp(42px, 3.4vw, 70px);
  aspect-ratio: 1;
  border: 2px solid #e1b76e;
  border-radius: 2px;
  color: #050d19;
  background: var(--gold);
  font-weight: 950;
  font-size: clamp(14px, 1.1vw, 23px);
  letter-spacing: -0.05em;
}
.tv-brand > span:last-child { display: grid; }
.tv-brand strong { font-size: clamp(18px, 1.55vw, 32px); letter-spacing: -0.035em; line-height: 1; }
.tv-brand small { margin-top: 4px; color: #bad4d1; font-size: clamp(10px, 0.7vw, 15px); font-weight: 750; letter-spacing: 0.15em; text-transform: uppercase; }

.tv-live-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: clamp(7px, 0.55vw, 12px) clamp(11px, 0.8vw, 17px);
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  text-transform: uppercase;
  font-size: clamp(10px, 0.68vw, 14px);
  letter-spacing: 0.12em;
}
.tv-live-pill span { width: 8px; height: 8px; border-radius: 50%; background: #e7b25f; box-shadow: 0 0 14px currentColor; }
.tv-live-pill[data-state="online"] span { background: var(--live); }
.tv-live-pill[data-state="offline"] span { background: #e57468; }

.tv-environment {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: clamp(10px, 0.8vw, 17px);
  text-align: right;
  filter: drop-shadow(0 3px 14px #0008);
}
.tv-weather-icon { font-size: clamp(27px, 2.2vw, 46px); color: #f6d882; }
.tv-environment > span:last-child { display: grid; }
.tv-environment strong { font-size: clamp(20px, 1.8vw, 38px); line-height: 1; }
.tv-environment small { margin-top: 5px; color: #c9dad8; font-size: clamp(10px, 0.72vw, 16px); }

.tv-scene-card, .tv-overview-card {
  position: absolute;
  z-index: 4;
  left: var(--safe-x);
  bottom: clamp(120px, 14vh, 230px);
  max-width: min(740px, 48vw);
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px #050d19, 6px 6px 0 #020711;
  animation: tv-card-in 500ms cubic-bezier(.2, .8, .2, 1);
}

.tv-scene-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(16px, 1.45vw, 30px);
  align-items: center;
  min-width: min(620px, 44vw);
  padding: clamp(18px, 1.6vw, 34px);
  overflow: hidden;
}
.tv-avatar {
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  width: clamp(70px, 5.5vw, 116px);
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--avatar-color, #4f8b83);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.23);
  font-weight: 900;
  font-size: clamp(22px, 1.8vw, 38px);
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.06), 0 12px 30px #0004;
}
.tv-scene-copy { min-width: 0; }
.tv-scene-copy small, .tv-overview-card small { color: var(--gold); font-weight: 900; font-size: clamp(9px, 0.66vw, 14px); letter-spacing: 0.18em; }
.tv-scene-copy h1, .tv-overview-card h1 { margin: 5px 0 4px; font-size: clamp(25px, 2.3vw, 49px); line-height: 1.02; letter-spacing: -0.045em; }
.tv-scene-copy p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-resident-meta { color: #bdd0cf; font-size: clamp(11px, 0.82vw, 18px); }
.tv-resident-activity { margin-top: clamp(9px, 0.72vw, 15px) !important; font-size: clamp(14px, 1.08vw, 23px); font-weight: 760; }
.tv-resident-location { margin-top: 4px !important; color: #9ec1bd; font-size: clamp(11px, 0.78vw, 17px); }
.tv-scene-timer { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.08); }
.tv-scene-timer span { display: block; width: 100%; height: 100%; transform-origin: left; background: var(--mint); }

.tv-overview-card { padding: clamp(21px, 2vw, 42px); }
.tv-overview-card p { max-width: 590px; margin: 10px 0 0; color: #c4d6d4; font-size: clamp(12px, 0.92vw, 20px); line-height: 1.45; }

.tv-controls {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: var(--safe-y);
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  gap: clamp(7px, 0.55vw, 12px);
  padding: clamp(8px, 0.62vw, 13px);
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px #050d19, 5px 5px 0 #020711;
  transition: opacity 300ms, transform 300ms;
}
.tv-controls button {
  display: grid;
  place-items: center;
  gap: 4px;
  min-width: clamp(70px, 6.1vw, 126px);
  min-height: clamp(54px, 4.4vw, 91px);
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
}
.tv-controls button span { color: #d9e6e4; font-size: clamp(17px, 1.25vw, 27px); line-height: 1; }
.tv-controls button small { color: #b8cac8; font-size: clamp(9px, 0.62vw, 13px); font-weight: 760; white-space: nowrap; }
.tv-controls button:hover, .tv-controls button:focus-visible { outline: none; border-color: rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.1); }
.tv-controls button.active { background: rgba(98, 211, 179, 0.15); border-color: rgba(98, 211, 179, 0.35); }
.tv-controls button.active span, .tv-controls button.active small { color: #8ae2c8; }

.tv-key-help {
  position: absolute;
  z-index: 4;
  right: var(--safe-x);
  bottom: calc(var(--safe-y) + clamp(76px, 5.8vw, 118px));
  margin: 0;
  color: rgba(229, 240, 237, 0.7);
  font-size: clamp(9px, 0.62vw, 13px);
  text-shadow: 0 2px 10px #000;
  transition: opacity 300ms;
}

.controls-hidden .tv-controls { opacity: 0; transform: translate(-50%, 24px); pointer-events: none; }
.controls-hidden .tv-key-help { opacity: 0; }

.tv-loading, .tv-error {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  background: #050d19;
}
.tv-loading-mark {
  display: grid;
  place-items: center;
  width: clamp(80px, 7vw, 145px);
  aspect-ratio: 1;
  border-radius: 2px;
  color: #050d19;
  background: var(--gold);
  font-weight: 950;
  font-size: clamp(25px, 2vw, 44px);
  box-shadow: 0 25px 70px #0007;
}
.tv-loading small, .tv-error small { margin-top: 22px; color: var(--gold); font-weight: 900; letter-spacing: 0.22em; }
.tv-loading h1, .tv-error h1 { margin: 10px 0 20px; font-size: clamp(26px, 2.5vw, 52px); letter-spacing: -0.04em; }
.tv-loading-track { width: min(430px, 55vw); height: 5px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, 0.1); }
.tv-loading-track span { display: block; width: 8%; height: 100%; border-radius: inherit; background: var(--mint); transition: width 350ms ease; }
.tv-error p { color: #c5d5d3; font-size: clamp(13px, 1vw, 20px); }
.tv-error button { margin-top: 12px; padding: 14px 24px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255, 255, 255, 0.1); cursor: pointer; }
.is-ready .tv-loading { opacity: 0; pointer-events: none; transition: opacity 700ms ease; }

.tv-finder {
  width: min(820px, 74vw);
  max-height: min(760px, 76vh);
  padding: 0;
  color: #eff4ef;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px #050d19, 6px 6px 0 #020711;
}
.tv-finder::backdrop { background: #050d19e8; }
.tv-finder-heading { display: flex; align-items: center; padding: 25px 28px 17px; }
.tv-finder-heading span { display: grid; }
.tv-finder-heading small, .tv-favorites > small { color: var(--gold); font-size: 11px; font-weight: 900; letter-spacing: 0.17em; }
.tv-finder-heading strong { margin-top: 3px; font-size: 31px; letter-spacing: -0.035em; }
.tv-finder-heading button { margin-left: auto; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.07); font-size: 25px; cursor: pointer; }
.tv-finder > label { display: block; padding: 0 28px 20px; }
.tv-finder input { width: 100%; padding: 17px 19px; color: white; border: 1px solid var(--line); border-radius: 15px; outline: none; background: rgba(255, 255, 255, 0.08); font-size: 18px; }
.tv-finder input:focus { border-color: rgba(121, 217, 189, 0.7); box-shadow: 0 0 0 4px rgba(121, 217, 189, 0.1); }
.tv-favorites { padding: 0 28px 18px; }
.tv-favorites > div { display: flex; gap: 9px; margin-top: 9px; overflow-x: auto; }
.tv-search-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 0 28px 28px; overflow: auto; max-height: 430px; }
.tv-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 12px;
  color: inherit;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
}
.tv-result:hover, .tv-result:focus-visible { outline: none; border-color: rgba(121, 217, 189, 0.55); background: rgba(121, 217, 189, 0.1); }
.tv-result-avatar { display: grid; place-items: center; position: relative; overflow: hidden; width: 43px; height: 43px; border-radius: 2px; background: var(--avatar-color); color: white; font-style: normal; font-weight: 850; }
.tv-result > span:last-child { display: grid; min-width: 0; }
.tv-result strong, .tv-result small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-result small { margin-top: 3px; color: #a9c1be; }
.tv-favorites .tv-result { min-width: 230px; }

@keyframes tv-card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 900px) {
  .tv-live-pill, .tv-key-help { display: none; }
  .tv-scene-card, .tv-overview-card { left: 18px; right: 18px; bottom: 105px; max-width: none; min-width: 0; }
  .tv-controls { left: 12px; right: 12px; transform: none; overflow-x: auto; justify-content: flex-start; }
  .controls-hidden .tv-controls { transform: translateY(24px); }
  .tv-controls button { min-width: 74px; }
  .tv-search-results { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Ten-foot UI uses the same opaque, pixel-stepped Diego City components. */
.tv-brand-mark,
.tv-loading-mark {
  border-radius: 2px;
}

.tv-live-pill,
.tv-controls { border-radius: var(--radius-hud); }

.tv-scene-card,
.tv-overview-card,
.tv-finder { border-radius: var(--radius-window); }

.tv-controls button,
.tv-finder-heading button,
.tv-finder input,
.tv-error button { border-radius: var(--radius-control); }

.tv-result { border-radius: var(--radius-card); }

.tv-controls button > span:first-child,
.tv-finder-heading button {
  font-family: var(--icon-font);
  font-variant-emoji: text;
  text-shadow: none;
}

.tv-live-pill,
.tv-scene-card,
.tv-overview-card,
.tv-controls,
.tv-finder {
  border: 3px solid var(--teal-secondary);
  background: var(--window-ink);
  box-shadow: var(--window-shadow);
}

.tv-live-pill,
.tv-controls {
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px #050d19, 5px 5px 0 #020711;
}

.tv-controls button,
.tv-finder-heading button,
.tv-finder input,
.tv-result,
.tv-error button {
  border-color: var(--line);
  background: var(--surface);
}

.tv-controls button:hover,
.tv-controls button:focus-visible,
.tv-controls button.active,
.tv-result:hover,
.tv-result:focus-visible {
  border-color: var(--mint);
  background: var(--surface-teal);
  color: #dccfbf;
}

.tv-controls button:not(:disabled):active,
.tv-finder-heading button:not(:disabled):active,
.tv-result:not(:disabled):active,
.tv-error button:not(:disabled):active {
  border-color: var(--teal-secondary);
  transform: translate(1px, 1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.tv-scene-copy small,
.tv-overview-card small,
.tv-finder-heading small,
.tv-favorites > small,
.tv-loading small,
.tv-error small { color: var(--gold); }

.tv-scene-copy h1,
.tv-overview-card h1,
.tv-loading h1,
.tv-error h1,
.tv-finder-heading strong,
.tv-brand strong {
  font-family: var(--pixel-font);
  font-weight: 850;
  letter-spacing: 0.01em;
}

.tv-brand strong,
.tv-scene-copy small,
.tv-overview-card small,
.tv-finder-heading small,
.tv-favorites > small,
.tv-controls button small {
  font-family: var(--pixel-font);
}

.tv-controls button:focus-visible,
.tv-finder-heading button:focus-visible,
.tv-finder input:focus-visible,
.tv-result:focus-visible,
.tv-error button:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 3px;
}

.tv-scene-timer,
.tv-loading-track { border-radius: 0; background: var(--surface); }
.tv-scene-timer span,
.tv-loading-track span { border-radius: 0; background: var(--mint); }
.tv-result-avatar { border-radius: 2px; box-shadow: inset -2px -2px 0 #050d1966; }

.resident-portrait-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  background: var(--avatar-color, #142634);
  color: #fff;
  font-weight: 850;
}

.resident-portrait-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
