@font-face {
  font-family: 'PetMe64';
  src: local('Pet Me 64'), local('PetMe64'), local('Pet Me 2Y'),
       local('C64 Pro Mono'), local('C64 Pro'),
       url('fonts/PetMe64.woff2') format('woff2'),
       url('fonts/PetMe64.ttf')  format('truetype');
  font-display: swap;
}
:root {
  --c64-blue:       #352879; 
  --c64-lightblue:  #7070ff;
  --c64-white:      #ffffff;
  --c64-video:      #a0a0ff;
  --c64-cyan:       #6abfc6;
  --c64-yellow:     #d5d58a;
  --c64-red:        #ff7c70;
  --room:           #14141f;
  --case:           #2a2a38;

  --font-stack: 'PetMe64', 'Press Start 2P', 'C64 Pro Mono',
                ui-monospace, 'Courier New', monospace;
  --fs: 16px;
  --lh: 1.35;

  --border-color: var(--c64-lightblue);

  --screen-w: min(96vw, 940px);
  --bezel: clamp(10px, 2.4vw, 30px);
  --glow: 0 0 6px rgba(160, 160, 255, .38);
}

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

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.5vh, 18px);
  padding: clamp(8px, 2vh, 28px) 0;
  background:
    radial-gradient(ellipse at 50% 0%, #23233a 0%, var(--room) 70%);
  color: var(--c64-video);
  font-family: var(--font-stack);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  overflow: hidden;
  cursor: default;
}

#metrics {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  font-family: var(--font-stack);
  font-size: 100px;
  left: -9999px;
  top: -9999px;
}

.monitor {
  width: var(--screen-w);
  padding: clamp(8px, 1.4vw, 16px);
  background: linear-gradient(180deg, #34344a, var(--case));
  border-radius: 14px;
  box-shadow:
    0 0 0 1px #4a4a63,
    0 18px 45px rgba(0, 0, 0, .65),
    inset 0 1px 0 rgba(255, 255, 255, .06);
}

.screen {
  position: relative;
  padding: var(--bezel);
  background: var(--border-color);
  border-radius: 6px;
  transition: background-color .12s steps(1);
  overflow: hidden;
}

.screen.is-loading { animation: driveFlash .28s steps(1) infinite; }
@keyframes driveFlash {
  0%,  49% { background: var(--border-color); }
  50%, 99% { background: var(--c64-blue); }
}

.crt {
  position: relative;
  height: min(70vh, 620px);
  min-height: 300px;
  background: var(--c64-blue);
  overflow: hidden;
}

.terminal {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 41ch;
  margin: 0 auto;
  padding: 0 .5ch;
  font-size: var(--fs);
  line-height: var(--lh);
  text-shadow: var(--glow);
}

.view { display: none; flex-direction: column; height: 100%; min-height: 0; }
.view.is-active { display: flex; }

.hdr {
  flex: 0 0 auto;
  padding: .55em 0 .45em;
  border-bottom: 2px solid var(--c64-lightblue);
}

.hdr__status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1ch;
  color: var(--c64-video);
  font-size: .82em;
}

.hdr__logo {
  margin-top: .35em;
  text-align: center;
  color: var(--c64-white);
  letter-spacing: 0;
  white-space: pre;
  text-shadow: 0 0 8px rgba(255, 255, 255, .5);
}

.hdr__logo b { color: var(--c64-lightblue); text-shadow: none; }

.hdr__hint {
  text-align: center;
  color: var(--c64-cyan);
  font-size: .78em;
  margin-top: .25em;
}

.out {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .7em 0;
  scrollbar-width: thin;
  scrollbar-color: var(--c64-lightblue) var(--c64-blue);
  overscroll-behavior: contain;
}

.out::-webkit-scrollbar { width: 6px; }
.out::-webkit-scrollbar-track { background: var(--c64-blue); }
.out::-webkit-scrollbar-thumb { background: var(--c64-lightblue); }

.ln {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  min-height: 1em;
}

.ln--sys    { color: var(--c64-video); }
.ln--bright { color: var(--c64-white); }
.ln--echo   { color: var(--c64-white); }
.ln--key    { color: var(--c64-cyan); }
.ln--warn   { color: var(--c64-yellow); }
.ln--err    { color: var(--c64-red); }
.ln--rem    { color: var(--c64-video); opacity: .85; }
.ln--center { text-align: center; }

.ln--logo {
  color: var(--c64-white);
  line-height: 1.05;
  white-space: pre;
  overflow-wrap: normal;
  letter-spacing: 0;
  word-spacing: 0;
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: 'liga' 0, 'clig' 0, 'calt' 0;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

.ln--pal { white-space: pre; letter-spacing: 0; }

.swatch { text-shadow: none; }

.prompt {
  position: relative;
  flex: 0 0 auto;
  padding: .5em 0 .3em;
  border-top: 2px solid var(--c64-lightblue);
  color: var(--c64-white);
  cursor: text;
}

.prompt__line { white-space: pre-wrap; overflow-wrap: break-word; }
.prompt__sigil { color: var(--c64-lightblue); }

.prompt__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  outline: none;
  -webkit-appearance: none;
}

.cursor {
  display: inline-block;
  width: 1ch;
  background: var(--c64-white);
  color: var(--c64-blue);
  animation: blink 1s steps(1) infinite;
  text-shadow: none;
  vertical-align: baseline;
}

.cursor::before { content: '\00a0'; }
.cursor.is-off { animation: none; opacity: 0; }

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

.prompt.is-busy .cursor { animation-duration: .25s; }

#bootView .out { padding-top: 1em; }

.deck {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2ch;
  width: var(--screen-w);
  padding: 0 4px;
  color: #6b6b8c;
  font-family: var(--font-stack);
  font-size: clamp(8px, 1.1vw, 11px);
  letter-spacing: .08em;
  text-align: center;
}

.led {
  width: .7em;
  height: .7em;
  border-radius: 50%;
  background: var(--c64-red);
  box-shadow: 0 0 7px var(--c64-red);
  flex: 0 0 auto;
}

.deck__hint { color: #8686ad; }
.deck__hint[hidden] { display: none; }

.crt__fx {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.crt__fx::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, .16) 0 1px,
    rgba(0, 0, 0, 0)   1px 3px
  );
}

.crt__fx::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 42%,
      rgba(255, 255, 255, .05) 0%,
      rgba(0, 0, 0, 0) 45%),
    radial-gradient(ellipse at 50% 50%,
      rgba(0, 0, 0, 0) 55%,
      rgba(0, 0, 0, .35) 100%);
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .screen.is-loading { animation: none; }
}

@media (max-width: 620px) {
  :root { --screen-w: 100vw; --bezel: 8px; }
  body { padding: 0; justify-content: flex-start; gap: 6px; }
  .monitor { border-radius: 0; padding: 6px; }
  .crt { height: calc(100vh - 92px); height: calc(100dvh - 92px); }
  .hdr__status { font-size: .78em; }
}

@media (max-height: 460px) {
  .crt { height: 78vh; min-height: 200px; }
  .hdr__hint { display: none; }
}
