.terminal {
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 900px;
  margin: 0 auto;
  min-height: calc(100vh - var(--topbar-h) - 4rem);
  display: flex;
  flex-direction: column;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.terminal-dots span:nth-child(1) { background: #ff5f57; }
.terminal-dots span:nth-child(2) { background: #febc2e; }
.terminal-dots span:nth-child(3) { background: #28c840; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.35);
}

.terminal-output {
  flex: 1;
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--terminal-text);
  background: var(--terminal-bg);
  overflow-y: auto;
  max-height: calc(100vh - var(--topbar-h) - 8rem);
}

.terminal-line {
  margin-bottom: 0.15rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.terminal-line.command {
  color: var(--terminal-prompt);
}

.terminal-line.error {
  color: var(--danger);
}

.terminal-line.success {
  color: var(--success);
}

.creeper-face {
  display: inline-block;
  line-height: 1.1;
  color: #7ef07e;
}

.terminal-line.info {
  color: #60a5fa;
}

.terminal-line.banner {
  color: #a78bfa;
  white-space: pre;
  font-family: var(--font-ascii);
  font-size: 0.75rem;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.terminal-line.neofetch {
  white-space: pre;
  font-family: var(--font-ascii);
  font-size: 0.78rem;
  line-height: 1.35;
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--terminal-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.terminal-input-line .prompt {
  font-family: var(--font-mono);
  color: var(--terminal-prompt);
  font-weight: 700;
  user-select: none;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--terminal-text);
  caret-color: var(--terminal-prompt);
}

#terminal-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#terminal-input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.cowsay pre {
  margin: 0;
  color: var(--terminal-text);
  line-height: 1.3;
}

.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--terminal-prompt);
  animation: cursorBlink 1s step-end infinite;
  vertical-align: text-bottom;
}

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

@media (max-width: 768px) {
  /* The terminal is the whole point of this view, so on a phone it gets
     as much of the screen as possible while still leaving room for the
     bottom nav and the input line itself. */
  .terminal-wrap {
    min-height: auto;
    padding: 0.5rem;
  }

  .terminal-output {
    font-size: 0.75rem;
    padding: 0.75rem;
    line-height: 1.5;
    max-height: calc(100vh - var(--topbar-h) - 12rem);
    /* Long unbroken command output (paths, URLs) would otherwise force
       horizontal scrolling of the entire page on a narrow screen. */
    overflow-wrap: break-word;
    word-break: break-word;
    -webkit-overflow-scrolling: touch;
  }

  .terminal-input-line {
    padding: 0.6rem 0.75rem;
  }

  #terminal-input {
    /* Anything under 16px makes iOS Safari auto-zoom the whole page on
       focus, which is disorienting and hard to undo. */
    font-size: 16px;
    min-height: 24px;
  }

  /* The ASCII banner is ~60 characters wide — far more than a phone can
     show at normal size. Scaled down so the whole word fits rather than
     being cut off mid-letter, with horizontal scroll as a fallback for
     anything still too wide (box-drawing art in some command output). */
  .terminal-line.banner {
    font-size: 0.42rem;
    line-height: 1.15;
    overflow-x: auto;
  }

  .terminal-output pre,
  .terminal-output .ascii {
    overflow-x: auto;
    font-size: 0.62rem;
  }
}

/* Hidden Snake game overlay */
.snake-overlay {
  position: fixed;
  inset: 0;
  z-index: 10002;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}

.snake-canvas {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  image-rendering: pixelated;
}

.snake-hint {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

/* Hidden school calculator — deliberately separate from the desktop apps. */
.school-calculator { position: fixed; z-index: 10002; inset: 0; display: grid; place-items: center; padding: 1.25rem; background: rgba(0, 0, 0, 0.88); backdrop-filter: blur(6px); }
.school-calculator__shell { width: min(100%, 440px); overflow: hidden; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; box-shadow: 0 24px 70px rgba(0,0,0,.65); background: rgb(25,25,25); color: white; font-family: var(--font-mono); }
.school-calculator header { display: flex; justify-content: space-between; align-items: center; padding: .7rem .9rem; color: rgba(255,255,255,.58); font-size: .72rem; }
.school-calculator header button { width: 1.9rem; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-size: 1.35rem; cursor: pointer; }
.school-calculator output { display: block; min-height: 7.5rem; padding: 1.1rem 1.3rem; box-sizing: border-box; overflow-wrap: anywhere; background: rgb(60,60,60); color: cornsilk; text-align: right; font-size: clamp(2rem, 8vw, 3.5rem); }
.school-calculator__keys { display: grid; grid-template-columns: repeat(4,1fr); gap: 1px; background: rgb(25,25,25); }
.school-calculator__keys button { min-height: 4rem; border: 0; background: rgb(100,78,31); color: white; font: 1.4rem var(--font-mono); cursor: pointer; }
.school-calculator__keys button:hover, .school-calculator__keys button:focus-visible { background: rgb(18,167,87); outline: 2px solid white; outline-offset: -2px; }
.school-calculator__keys .operator { background: coral; }.school-calculator__keys .equals { background: blue; }.school-calculator__keys .danger { background: crimson; }
.school-calculator__keys .danger:hover, .school-calculator__keys .danger:focus-visible { background: darkred; }
.school-calculator__shell p { margin: 0; padding: .8rem; color: rgba(255,255,255,.46); text-align: center; font-size: .67rem; }
