:root {
  color-scheme: dark;
  --background: #050600;
  --panel: #0b0c05;
  --yellow: #f2e94e;
  --dim-yellow: #aaa337;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--background);
  color: var(--yellow);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.terminal {
  width: min(100%, 880px);
  min-height: min(620px, calc(100vh - 64px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #37360f;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 100px #0009, 0 0 45px #f2e94e08;
}

.terminal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid #29280d;
  background: #0e0f07;
  color: var(--dim-yellow);
  font-size: 11px;
  letter-spacing: .08em;
}

.terminal-actions { display: flex; align-items: center; gap: 8px; }
.terminal-actions button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 6px;
  border: 1px solid #a94d44;
  border-radius: 50%;
  background: #572c25;
  color: #ffc1a9;
  cursor: pointer;
}
#terminal-close:hover { background: #863d32; }
.terminal-actions button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 4px; }
.terminal-actions svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
#terminal-maximize { border-color: #686522; background: #302f12; color: var(--yellow); }
#terminal-maximize:hover { background: #48451b; }
.restore-icon, #terminal-maximize[aria-pressed="true"] .maximize-icon { display: none; }
#terminal-maximize[aria-pressed="true"] .restore-icon { display: inline; }
.terminal.terminal-maximized {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.terminal-maximized .terminal-bar { flex-shrink: 0; }
.terminal-maximized .terminal-screen { min-height: 0; }
.terminal-mark { color: var(--yellow); }

.terminal-screen {
  flex: 1;
  min-height: 480px;
  padding: 32px;
  overflow-y: auto;
  cursor: text;
}

.motd { margin-bottom: 28px; color: var(--dim-yellow); }
.motd p { margin: 0; }
.motd .welcome { margin-bottom: 8px; color: var(--yellow); font-size: 17px; font-weight: 700; }
.motd-hint { margin-top: 12px !important; }
.motd-hint span { color: var(--yellow); }
.terminal-output { display: flex; flex-direction: column; gap: 4px; }
.command-line, .output-line { overflow-wrap: anywhere; }
.command-line { color: var(--yellow); }
.command-line .prompt { color: var(--dim-yellow); }
.output-line { color: var(--dim-yellow); white-space: pre-wrap; }
.prompt-line { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.prompt { flex: 0 0 auto; color: var(--yellow); }
#terminal-input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--yellow);
  caret-color: var(--yellow);
  font: inherit;
}
.prompt-cursor { display: none; }

html.terminal-closed { color-scheme: light; background: #eee9f8; }
.terminal-closed body { background: #eee9f8; color: #352a4b; font-family: system-ui, sans-serif; }
.crash-screen { width: min(100%, 560px); padding-block: 48px; overflow-wrap: anywhere; }
.crash-icon {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin-bottom: 32px;
  border: 2px solid #796390;
  border-radius: 20px;
  background: #f5d978;
  color: #796390;
  font: 32px "SFMono-Regular", Consolas, monospace;
  transform: rotate(-6deg);
}
.crash-eyebrow { color: #796390; font-size: 11px; font-weight: 600; letter-spacing: .16em; }
.crash-screen h1 { margin: 8px 0 16px; font-size: clamp(40px, 8vw, 60px); line-height: 1.1; letter-spacing: -.04em; }
.crash-screen h1:focus { outline: none; }
.crash-screen p { margin-block: 12px; }
.crash-screen .crash-hint { color: #655477; }

@keyframes blink { to { visibility: hidden; } }

@media (max-width: 600px) {
  body { padding: 12px; font-size: 13px; }
  .terminal { min-height: calc(100vh - 24px); border-radius: 5px; }
  .terminal-screen { min-height: 0; padding: 22px 16px; }
  .terminal-bar { padding-inline: 15px; }
  .prompt-line { flex-wrap: wrap; gap: 4px 8px; }
  .prompt { max-width: 100%; }
  #terminal-input { flex: 1 1 100%; }
  .prompt-cursor { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
