@font-face {
  font-family: "EarlyGameBoy";
  src: url("./early-gameboy.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #485915;
  --fg: #0b0f06;
  --dim: #2f3b16;
  --accent: #1d260f;
  --cursor: #0b0f06;
}

body {
  margin: 0;
  height: 100vh;
  background: #017398;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family:
    "IBM Plex Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: underline;
}

.crt-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.crt-wrapper {
  position: relative;
  width: fit-content;
  height: fit-content;
  line-height: 0;
  max-width: 100vw;
  max-height: 100vh;
}

.crt-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  pointer-events: none;
}

.terminal-screen {
  position: absolute;

  /* JS will set dimensions and position dynamically */
  box-sizing: border-box;

  /* Force LTR direction for terminal */
  direction: ltr;

  background: var(--bg);
  color: var(--fg);

  line-height: 1.2;
  letter-spacing: 0.05em;
  font-family: "EarlyGameBoy", monospace;
  font-weight: normal;

  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;

  border-radius: 2px;
  box-shadow:
    inset 0 0 6px rgba(0, 0, 0, 0.3),
    inset 0 0 18px rgba(0, 0, 0, 0.25);

  text-shadow: 0 0 0.6px rgba(0, 0, 0, 0.25);
}

/* Terminal container - persistent */
#terminal-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* Music container - toggled via display */
#music-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.music-header {
  font-size: 0.8em;
  padding-bottom: 4px;
  color: var(--dim);
}

#music-iframe {
  flex: 1;
  border: none;
  background: #000;
}

/* LCD */
.terminal-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}

.terminal-output::-webkit-scrollbar {
  display: none;
}

.line {
  white-space: pre-wrap;
}

.dim {
  color: var(--dim);
}
.accent {
  color: var(--accent);
}

.input-line {
  display: flex;
  align-items: baseline;
  white-space: pre;
  font: inherit;
}

.prompt {
  color: var(--accent);
  flex-shrink: 0;
  margin-right: 0.5ch;
}

.input-wrapper {
  display: inline;
  position: relative;
  flex: 1;
}

/* Typed text + cursor live in same flow */
.input-display {
  display: inline;
  white-space: pre;
}

/* Cursor behaves like a glyph, not a box */
.cursor {
  color: var(--cursor);
  animation: blink 1.2s steps(1) infinite;
}

.hidden-input {
  position: fixed;

  /* MUST have real size for Android IME */
  width: 1px;
  height: 1.2em;

  /* Offscreen, but real */
  left: -1000px;
  top: 0;

  opacity: 0;
  pointer-events: none;

  /* Prevent RTL / IME heuristics */
  direction: ltr;
  text-align: left;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

@media (max-width: 768px) {
  :root {
    --bg: #282a36;
    --fg: #f8f8f2;
    --cursor: #ff79c6;
    --accent: #bd93f9;
    --dim: #6272a4;
  }

  body {
    background: var(--bg);
    align-items: flex-start;
  }

  .crt-container {
    display: block;
  }

  .crt-image {
    display: none;
  }

  .terminal-screen {
    position: static;
    transform: none;
    width: 100%;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    text-shadow: none;
    font-size: 14px;
    padding: 16px;
  }

  .terminal-screen::before {
    display: none;
  }
}
