@font-face {
  font-family: "PxPlus IBM VGA 8x16";
  src: url("../fonts/PxPlus_IBM_VGA_8x16.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  margin: 0;
  overflow-x: hidden;
}

body {
  --terminal-bg: #000000;
  --terminal-fg: #00ff66;
  --terminal-dim: #008f3a;
  background: var(--terminal-bg);
  color: var(--terminal-fg);
  font-family: "PxPlus IBM VGA 8x16", "Courier New", Courier, monospace;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  text-rendering: geometricPrecision;
}

body[data-display-mode="dos"] {
  --terminal-fg: #f2f2f2;
  --terminal-dim: #aaaaaa;
}

body[data-display-mode="amber"] {
  --terminal-fg: #ffb000;
  --terminal-dim: #b36b00;
}

.terminal {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  padding-bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--keyboard-padding, 0px));
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  user-select: text;
  -webkit-user-select: text;
  font-family: "PxPlus IBM VGA 8x16", "Courier New", Courier, monospace;
  line-height: 1;
  letter-spacing: 0;
}

.screen {
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}

.line {
  min-height: 1em;
}

.input-line {
  display: flex;
  gap: 8px;
  width: 100%;
}

.input-prompt.hidden {
  display: none;
}

.input-wrap {
  position: relative;
  display: inline-grid;
  flex: 1;
  min-width: 0;
}

#command-input {
  flex: 1;
  grid-area: 1 / 1;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--terminal-fg);
  caret-color: transparent;
  font: inherit;
  line-height: 1;
  letter-spacing: 0;
  touch-action: manipulation;
}

.cursor {
  grid-area: 1 / 1;
  align-self: baseline;
  width: 0.6em;
  height: 1em;
  background: currentColor;
  color: var(--terminal-fg);
  transform: translateX(var(--cursor-offset, 0ch));
  animation: cursor-blink 1s steps(1, end) infinite;
  pointer-events: none;
}

.input-wrap:focus-within .cursor {
  display: block;
}

.mobile-break-button {
  position: fixed;
  z-index: 50;
  right: calc(env(safe-area-inset-right, 0px) + 14px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--keyboard-padding, 0px) + 14px);
  min-width: 7ch;
  min-height: 2.2em;
  border: 1px solid #00ff66;
  border-radius: 0;
  padding: 0.3em 0.7ch;
  background: #000000;
  color: #00ff66;
  font: inherit;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: none;
  opacity: 0.82;
  touch-action: manipulation;
}

body[data-display-mode="amber"] .mobile-break-button {
  border-color: #ffb000;
  color: #ffb000;
}

body[data-display-mode="dos"] .mobile-break-button {
  border-color: #f2f2f2;
  color: #f2f2f2;
}

.mobile-break-button:active {
  opacity: 1;
}

.mobile-break-button.hidden {
  display: none;
}

@keyframes cursor-blink {
  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

::selection {
  background: var(--terminal-fg);
  color: var(--terminal-bg);
}

.basic-graphics {
  display: block;
  width: min(640px, 100%);
  height: auto;
  margin: 0.5rem 0;
  border: 1px solid var(--terminal-dim);
  background: #000000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .terminal {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
}

@media (forced-colors: active) {
  body {
    forced-color-adjust: none;
  }

  .cursor,
  .basic-graphics {
    border-color: currentColor;
  }
}
