@font-face {
  font-family: "Clay Prestige Elite";
  src: url("fonts/PrestigeEliteStd-Bd.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: block;
}

:root {
  --terminal-font-size: 16px;
  --ink: #ffb000;
  --ink-dim: #a66f00;
  --ink-bright: #ffd166;
  --paper: #080602;
  --panel: #100b03;
  --scrollbar-reserve: 1rem;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Clay Prestige Elite", "Courier New", monospace;
  font-style: normal;
  font-weight: 700;
  font-synthesis: none;
}

button,
select,
input {
  font: inherit;
  font-style: inherit;
}

button,
select {
  min-height: 2.25rem;
  border: 1px solid var(--ink-dim);
  border-radius: 0;
  color: var(--ink);
  background: var(--panel);
}

button {
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

button:hover:not(:disabled),
select:hover {
  border-color: var(--ink);
  color: var(--ink-bright);
  background: #181004;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

:focus-visible {
  outline: 2px solid var(--ink-bright);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.5rem;
  color: var(--paper);
  background: var(--ink-bright);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  width: min(100%, 92rem);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.masthead,
.control-deck,
.save-state,
.diagnostics {
  width: min(
    100%,
    calc(80ch + 3rem + var(--scrollbar-reserve))
  );
}

.masthead {
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  font-size: var(--terminal-font-size);
}

.masthead h1 {
  margin: 0;
  font-size: 1.25em;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow,
.runtime-state {
  margin: 0 0 0.35rem;
  color: var(--ink-dim);
  font-size: 0.75em;
}

.terminal-scroll {
  width: 100%;
  overflow-x: auto;
  padding: 0.35rem 0 0.6rem;
}

.terminal {
  width: calc(80ch + 3rem + var(--scrollbar-reserve));
  min-width: calc(80ch + 3rem + var(--scrollbar-reserve));
  height: clamp(34rem, 72vh, 52rem);
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--ink-dim);
  background: var(--paper);
  font-size: var(--terminal-font-size);
  line-height: 1.4;
}

.font-pending .terminal {
  visibility: hidden;
}

.font-ready .terminal,
.font-error .terminal {
  visibility: visible;
}

#terminal-output {
  width: calc(80ch + var(--scrollbar-reserve));
  min-width: calc(80ch + var(--scrollbar-reserve));
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: var(--ink-dim) var(--paper);
  scrollbar-gutter: stable;
}

#transcript,
#history-text,
#diagnostic-text {
  white-space: pre-wrap;
  overflow-wrap: normal;
}

#transcript {
  width: 80ch;
  min-height: 100%;
  margin: 0;
  color: inherit;
  font: inherit;
}

#command-form {
  display: flex;
  width: 80ch;
  padding-top: 0.8rem;
  gap: 1ch;
  border-top: 1px solid var(--ink-dim);
}

#command {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--ink-dim);
  border-radius: 0;
  outline-offset: 4px;
  color: var(--ink-bright);
  background: transparent;
  caret-color: var(--ink-bright);
}

.control-deck {
  margin: 0.75rem auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  font-size: 0.9rem;
}

.control-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.save-state,
.diagnostics {
  margin: 0.65rem auto 0;
  color: var(--ink-dim);
  font-size: 0.82rem;
}

.diagnostics pre {
  padding: 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--ink-dim);
  background: var(--paper);
}

dialog {
  width: min(92vw, calc(80ch + 5rem));
  max-height: 86vh;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: inherit;
  font-style: inherit;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.88);
}

.dialog-header,
.history-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
}

.history-nav {
  margin: 0.75rem 0;
}

#history-text {
  width: 80ch;
  max-width: 100%;
  min-height: 20rem;
  max-height: 58vh;
  margin: 0;
  padding: 1rem;
  overflow: auto;
  border: 1px solid var(--ink-dim);
  background: var(--paper);
  font-size: var(--terminal-font-size);
  line-height: 1.4;
}

#unsupported-device {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 2rem;
  color: var(--ink);
  background: var(--paper);
}

#unsupported-device > div {
  width: min(100%, 34rem);
  border: 1px solid var(--ink-dim);
  padding: 1.5rem;
}

#unsupported-device h1 {
  margin: 0 0 1rem;
  color: var(--ink-bright);
  font-size: 1.4rem;
  font-weight: 700;
}

#unsupported-device p:last-child {
  margin-bottom: 0;
  line-height: 1.5;
}

.mobile-device .shell,
.mobile-device .skip-link {
  display: none;
}

.mobile-device #unsupported-device {
  display: grid;
}

noscript {
  display: block;
  width: min(100%, 40rem);
  margin: 2rem auto;
  border: 1px solid var(--ink);
  padding: 1rem;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 48rem) {
  .shell {
    padding: 0.75rem;
  }

  .masthead {
    align-items: start;
    flex-direction: column;
  }

  .terminal {
    margin-left: 0;
  }

  .control-deck {
    justify-content: start;
  }
}

@media (max-width: 699px) and (pointer: coarse) {
  .shell,
  .skip-link {
    display: none;
  }

  #unsupported-device {
    display: grid;
  }
}

@media (forced-colors: active) {
  body,
  .terminal,
  #history-text,
  dialog {
    color: CanvasText;
    background: Canvas;
  }
}
