:root {
  --c64-bg: #3B3BAE;
  --c64-border: #4A4AC8;
  --c64-text: #9C9CFF;
  --c64-dim: rgba(156, 156, 255, 0.55);
  --font-mono: "VT323", "Courier New", monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--c64-border);
  color: var(--c64-text);
  font-family: var(--font-mono);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.12) 3px
    ),
    radial-gradient(120% 90% at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.35) 100%);
}

.c64 {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: max(28px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: var(--c64-bg);
}

.c64-log {
  flex: 1 1 auto;
  overflow-y: auto;
  margin: 0;
  padding: 0 0 10px 0;
  font-family: var(--font-mono);
  font-size: clamp(19px, 4.6vw, 26px);
  line-height: 1.32;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--c64-text);
  text-shadow: 0 0 6px var(--c64-dim);
}

.c64-log::-webkit-scrollbar {
  width: 0;
}

.c64-portrait-wrap {
  margin: 10px 0 4px;
}

.c64-portrait {
  display: block;
  max-width: min(300px, 72vw);
  image-rendering: pixelated;
  border: 3px solid var(--c64-text);
  box-shadow: 0 0 0 3px var(--c64-bg), 0 0 20px var(--c64-dim);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.c64-portrait--visible {
  opacity: 1;
}

.c64-line {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.c64-prompt {
  font-size: clamp(19px, 4.6vw, 26px);
  line-height: 1;
  color: var(--c64-text);
  text-shadow: 0 0 6px var(--c64-dim);
}

.c64-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: clamp(19px, 4.6vw, 26px);
  letter-spacing: 0.02em;
  color: var(--c64-text);
  caret-color: var(--c64-text);
  text-shadow: 0 0 6px var(--c64-dim);
  text-transform: uppercase;
}

.c64-input::placeholder {
  color: var(--c64-dim);
}

.c64-input:disabled {
  opacity: 0.5;
}
