* { margin: 0; padding: 0; box-sizing: border-box; }

/* TI-99/4A TMS9918A-inspired palette */
:root {
  --fg:      #222222;
  --fg-dim:  #555555;
  --fg-hi:   #111111;
  --fg-warn: #333333;
  --fg-err:  #1a1a1a;
  --fg-gold: #222222;
  --fg-good: #333333;
  --bg:      #5EDC78;
  --rule:    #2a2a2a;
  --glow:    rgba(0,0,0,0.08);
}

/* ── Base (mobile-first) ────────────────────────────────────────────────── */
html, body {
  height: 100%;
  background: #111116;
  font-family: 'VT323', 'Courier New', Courier, monospace;
  font-size: 18px;
  color: var(--fg);
}

/* ── Monitor — full-bleed on mobile ─────────────────────────────────────── */
#monitor {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: #252528;
  padding: 10px 10px 8px;
}

/* ── CRT screen — fills remaining space ─────────────────────────────────── */
#screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 4px;
  padding: 14px 12px 0;
  box-shadow:
    inset 0 0 0 1px #000,
    inset 3px 3px 14px rgba(0,0,0,0.5),
    inset -3px -3px 14px rgba(0,0,0,0.5);
}

/* Red screen on loss */
#screen.loss {
  background: #cc1a00;
}

/* ── Bezel label ─────────────────────────────────────────────────────────── */
#bezel-label {
  margin-top: 8px;
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: #444;
  text-transform: uppercase;
  user-select: none;
}

/* ── Terminal content layout ─────────────────────────────────────────────── */
#wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#out {
  flex: 1;
  line-height: 1.65;
  padding-bottom: 8px;
  text-shadow: 0 0 7px var(--glow);
  overflow-x: hidden;   /* clips long rule lines on narrow screens */
}

/* ── Output line classes ─────────────────────────────────────────────────── */
.ln   { display: block; white-space: pre-wrap; word-break: break-word; }
.dim  { color: var(--fg-dim); }
.hi   { color: var(--fg-hi); }
.warn { color: var(--fg-warn); }
.err  { color: var(--fg-err); }
.gold { color: var(--fg-gold); }
.good { color: var(--fg-good); }
.echo { color: var(--fg-dim); font-style: italic; }

/* ── Input bar ───────────────────────────────────────────────────────────── */
#bar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  /* respect iOS home-bar safe area */
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

#pmt {
  color: var(--fg-hi);
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

#inp {
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  /* 16px minimum prevents iOS auto-zoom on focus */
  font-size: max(16px, 1em);
  flex: 1;
  caret-color: var(--fg-hi);
  min-width: 0;
  text-shadow: 0 0 7px var(--glow);
}

/* ── Desktop (≥ 640px) ───────────────────────────────────────────────────── */
@media (min-width: 640px) {
  html, body {
    font-size: 20px;
  }

  #monitor {
    max-width: 760px;
    margin: 28px auto 40px;
    min-height: auto;
    padding: 22px 22px 14px;
    border-radius: 14px 14px 10px 10px;
    box-shadow:
      0 0 0 2px #111,
      0 10px 50px rgba(0,0,0,0.85),
      inset 0 1px 0 rgba(255,255,255,0.07),
      inset 0 -1px 0 rgba(0,0,0,0.4);
  }

  #screen {
    padding: 18px 16px 0;
    box-shadow:
      inset 0 0 80px rgba(0,200,80,0.05),
      inset 0 0 0 1px #000,
      inset 4px 4px 20px rgba(0,0,0,0.6),
      inset -4px -4px 20px rgba(0,0,0,0.6);
  }

  #bezel-label {
    margin-top: 12px;
    font-size: 13px;
    letter-spacing: 2px;
  }
}
