@font-face {
  font-family: 'Pixel5x5';
  src: url('../fonts/5x5_pixel_fixed.ttf') format('truetype');
  font-display: swap;
}


@font-face {
    font-family: 'Edit Undo BRK';
    src: url('../fonts/EditUndoBRK.woff2') format('woff2'),
        url('../fonts/EditUndoBRK.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}


html,
body {
  margin: 0;
  height: 100%;
  background: #03040b;
  color: #c7fff8;
  font-family: 'Edit Undo BRK', monospace;
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
}

.hidden {
  display: none;
}

#device {
  position: relative;
  width: 800px;
  height: 480px;
  image-rendering: pixelated;
  background: #000 url('../img/background.png') center / 100% 100% no-repeat;
}

#screen {
  width: 800px;
  height: 480px;
  display: block;
  image-rendering: pixelated;
}

#modeControls {
  position: absolute;
  left: 512px;
  top: 4px;
  display: grid;
  grid-template-columns: 50px 50px;
  gap: 4px;
  z-index: 3;
}

#overlayToggles {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: 44px 44px;
  gap: 6px;
  z-index: 3;
}

.mode-button {
  appearance: none;
  width: 50px;
  height: 30px;
  padding: 0;
  border: 2px solid #000;
  border-radius: 0;
  background: #555;
  display: grid;
  place-items: center;
  image-rendering: pixelated;
}

.mode-button.is-active {
  background: #36f4ff;
}

.mode-button img {
  display: block;
  width: 22px;
  image-rendering: pixelated;
}

.mode-toggle {
  width: 44px;
  background: #1b1f2a;
}

.mode-toggle.is-active {
  background: #263447;
  border-color: #36f4ff;
}

.mode-toggle img {
  width: 20px;
  filter: grayscale(1) contrast(1.2);
}

.mode-toggle.is-active img {
  filter: none;
}

.viewerPage {
  place-items: stretch;
  width: 100vw;
  height: 100vh;
}

#viewerDevice {
  position: relative;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  background: #000;
  overflow: hidden;
}

#viewerScreen {
  width: 100vw;
  height: 100vh;
  display: block;
}

.viewerLayerToggles {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 8px;
  z-index: 6;
}

.layerToggleBtn {
  appearance: none;
  width: 46px;
  height: 46px;
  border: 1px solid #2f4e5c;
  border-radius: 0;
  background: rgba(10, 15, 28, 0.92);
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.layerToggleBtn img {
  max-width: 24px;
  max-height: 24px;
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
  filter: grayscale(1) contrast(1.2);
}

.layerToggleBtn.is-on {
  border-color: #36f4ff;
  background: rgba(15, 27, 43, 0.95);
}

.layerToggleBtn.is-on img {
  filter: none;
}

.viewerDetails {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(340px, calc(100vw - 36px));
  padding: 16px 18px 18px;
  border: 0;
  background: #050611;
  color: #c7fff8;
  z-index: 5;
}

.viewerDetails h1 {
  margin: 0 38px 14px 0;
  color: #ff4fd8;
  font: 22px 'Edit Undo BRK', monospace;
  overflow-wrap: anywhere;
}

.viewerDetails dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.viewerDetails div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.viewerDetails dt {
  color: #617b88;
  font: 13px 'Edit Undo BRK', monospace;
}

.viewerDetails dd {
  margin: 0;
  color: #c7fff8;
  font: 16px 'Edit Undo BRK', monospace;
  overflow-wrap: anywhere;
}

.viewerDetailsAction {
  appearance: none;
  width: 100%;
  height: 32px;
  margin-top: 14px;
  border: 1px solid #2f4e5c;
  border-radius: 0;
  background: #101b2b;
  color: #c7fff8;
  font: 13px 'Edit Undo BRK', monospace;
  cursor: pointer;
}

.viewerDetailsClose {
  appearance: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #36f4ff;
  font: bold 18px 'Edit Undo BRK', monospace;
  line-height: 26px;
  text-align: center;
}

.viewerControls {
  position: absolute;
  top: 16px;
  left: 16px;
  width: min(420px, calc(100vw - 32px));
  padding: 12px;
  background: rgba(5, 6, 17, 0.94);
  color: #c7fff8;
  z-index: 5;
}

.viewerControlsRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.viewerControlsCompact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.viewerControls input[type='search'],
.viewerControls button,
.viewerControls .fileImportBtn {
  appearance: none;
  border: 1px solid #2f4e5c;
  border-radius: 0;
  background: #0a0f1c;
  color: #c7fff8;
  font: 13px 'Edit Undo BRK', monospace;
  padding: 6px 8px;
  height: 32px;
  box-sizing: border-box;
}

.viewerControls button,
.viewerControls .fileImportBtn {
  background: #101b2b;
  text-align: center;
  cursor: pointer;
}

.viewerControls input[type='search']::placeholder {
  color: #617b88;
}

#importSyncFile {
  display: none;
}

#viewerControlsStatus {
  margin: 2px 0 0;
  color: #8bc0d3;
  font: 12px 'Edit Undo BRK', monospace;
  min-height: 14px;
}

.viewerSearchResults {
  display: grid;
  gap: 4px;
  max-height: min(260px, calc(100vh - 150px));
  margin: -2px 0 8px;
  overflow: auto;
}

.viewerSearchResults.hidden {
  display: none;
}

.viewerSearchResultBtn {
  appearance: none;
  width: 100%;
  min-height: 34px;
  border: 1px solid #2f4e5c;
  border-radius: 0;
  background: #0a0f1c;
  color: #c7fff8;
  font: 13px 'Edit Undo BRK', monospace;
  text-align: left;
  padding: 5px 8px;
  cursor: pointer;
}

.viewerSearchResultBtn strong,
.viewerSearchResultBtn span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewerSearchResultBtn span {
  margin-top: 3px;
  color: #8bc0d3;
  font-size: 11px;
}

#locateBtn {
  appearance: none;
  position: absolute;
  right: 190px;
  top: 400px;
  width: 38px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #36f4ff;
  font: bold 36px 'Edit Undo BRK', monospace;
  line-height: 22px;
  text-align: center;
  z-index: 3;
  image-rendering: pixelated;
}

#locateBtn:active {
  color: #ff4fd8;
  transform: translate(1px, 1px);
}

body.pi35Page {
  display: block;
  width: 480px;
  height: 320px;
  overflow: hidden;
}

body.pi35Page,
body.pi35Page * {
  cursor: none !important;
}

body.pi35Page #device {
  position: fixed;
  left: 0;
  top: 0;
  width: 480px;
  height: 320px;
  background: #000 url('../img/background-35.png') center / 100% 100% no-repeat;
  transform: translate(var(--app-offset-x, 0px), var(--app-offset-y, 0px));
  transform-origin: top left;
}

body.pi35Page #screen {
  width: 480px;
  height: 320px;
}

body.pi35Page #modeControls {
  left: 261px;
  top: 6px;
  grid-template-columns: 46px 46px;
  gap: 4px;
}

body.pi35Page #overlayToggles {
  right: 6px;
  bottom: 6px;
  grid-template-columns: 40px 40px;
  gap: 4px;
}

body.pi35Page .mode-button {
  width: 46px;
  height: 28px;
}

body.pi35Page .mode-button img {
  width: 20px;
}

body.pi35Page .mode-toggle {
  width: 40px;
}

body.pi35Page .mode-toggle img {
  width: 18px;
}

body.pi35Page #locateBtn {
  left: 237px;
  right: auto;
  top: 7px;
  width: 30px;
  height: 24px;
  font-size: 28px;
  line-height: 22px;
}

#phoneNote {
  position: fixed;
  top: 8px;
  left: 8px;
  right: 8px;
  text-align: center;
  font: 12px 'Edit Undo BRK', monospace;
  color: #617b88;
  z-index: 4;
  text-transform: uppercase;
}

@media (max-width: 840px),
(max-height: 520px) {
  body:not(.pi35Page) {
    place-items: start center;
  }

  body:not(.pi35Page) #device {
    transform-origin: top center;
    transform: scale(min(calc(100vw / 800), calc(100vh / 480)));
  }
}

@media (max-width: 500px),
(max-height: 340px) {
  body.pi35Page #device {
    transform-origin: top left;
    transform: translate(var(--app-offset-x, 0px), var(--app-offset-y, 0px));
  }
}
