:root {
  --bg: #000;
  --fg: #33ff66;
  --fg-dim: #1aa53a;
  --font-stack: 'VT323', 'Courier Prime', 'Lucida Console', 'Consolas', monospace;
  --font-size: clamp(14px, 3.5vw, 20px);
  --line-height: 1.25;
  --srs-line-height: 1.4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-stack);
  font-size: var(--font-size);
  line-height: var(--line-height);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  cursor: text;
}

#terminal {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 0.5rem;
  overflow: hidden;
}

#output {
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  overflow: auto;
  white-space: pre;
  font-family: inherit;
  font-size: inherit;
  color: var(--fg);
  scrollbar-width: thin;
  scrollbar-color: var(--fg-dim) transparent;
}

#output::-webkit-scrollbar { width: 6px; }
#output::-webkit-scrollbar-thumb { background: var(--fg-dim); }

#output.awaiting-input::after {
  content: '\2588';
  display: inline-block;
  color: var(--fg);
  animation: blink 1.05s steps(1) infinite;
}

.srs-frame {
  margin: 0.5em 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--fg);
  white-space: pre;
  line-height: var(--srs-line-height);
}

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

/* Hidden input — captures keystrokes (incl. hardware keyboards / IME on toggle),
   live characters echo into #output via teletype sync. With the on-screen keypad
   handling phone input, the input is collapsed to 1x1 so it never intercepts taps. */
#prompt {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
  margin: 0;
  padding: 0;
  border: 0;
}

#cursor { display: none; }

#cmd {
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: transparent;
  caret-color: transparent;
  font-family: inherit;
  font-size: inherit;
  text-transform: uppercase;
  opacity: 0;
}

/* On-screen keypad — docked at the bottom of #terminal */
#keypad {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px 2px 2px;
  margin-top: 4px;
  border-top: 1px solid var(--fg-dim);
}

.kp-key {
  background: #001a00;
  color: var(--fg);
  border: 1px solid var(--fg-dim);
  padding: 12px 0;
  font-family: var(--font-stack);
  font-size: var(--font-size);
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
  line-height: 1;
}

.kp-key:active,
.kp-key:focus {
  background: var(--fg-dim);
  color: #000;
  outline: 0;
}

/* The control glyphs (⌫ ⌦ ⌨) have lighter ink than letters in most
   monospaced fonts, so size them up and use a glyph-rich fallback. */
.kp-back,
.kp-kbd {
  font-size: 1.6em;
  font-family: 'Apple Symbols', 'Segoe UI Symbol', 'Noto Sans Symbols', system-ui, sans-serif;
  line-height: 0.9;
}
