/* Original lettering and shared page colors. */
@font-face {
  font-family: Satisfaction;
  src: url('assets/satisfaction.ttf') format('truetype');
  font-display: swap;
}
:root {
  color-scheme: dark;
  font-family: Satisfaction, 'Courier New', monospace;
  font-synthesis: none;
  background: #000;
  color: #c0c0c0;
  --paper: #000;
  --ink: #c0c0c0;
  --bright: #fff;
  --line: #404040;
  --accent: #ffff00;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}

/* Fit the 4:3 screen to both available viewport height and page width. */
main {
  container-type: inline-size;
  width: min(1026px, calc(100% - 32px), max(386px, calc((100svh - 336px) * 4 / 3 + 2px)));
  margin: 0 auto;
  padding: 16px 0;
  font-size: 12px;
  line-height: 1.6;
}

/* Shared controls and keyboard focus treatment. */
button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 5px 8px;
  line-height: 1.4;
}
button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
button:disabled {
  cursor: wait;
  opacity: 0.6;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid #0ff;
  outline-offset: 3px;
}

/* Title and original-demo attribution. */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 54px;
  padding-bottom: 12px;
}
.identity {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
h1 {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: -1px;
  color: #0f0;
  margin: 0;
}
.identity span,
.edition {
  font-size: 8px;
  white-space: nowrap;
}
.edition {
  color: #0ff;
}

/* Chapter navigation and its hover/focus labels. */
.player {
  border: 1px solid var(--line);
}
.part-selector {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  min-height: 34px;
  background: #101010;
}
.part-label {
  font-size: 8px;
  padding: 0 12px;
  color: #808080;
}
nav {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1px;
}
nav button {
  border: 0;
  border-left: 1px solid #303030;
  padding: 8px 0;
  min-width: 0;
  font-size: 12px;
  color: #c0c0c0;
}
nav button:hover {
  background: #000080;
  color: #fff;
}
nav button[aria-current='true'] {
  color: #000;
  background: var(--accent);
}
nav button:is(:hover, :focus-visible)::after {
  content: attr(data-name);
  position: absolute;
  z-index: 3;
  top: 100%;
  left: 0;
  right: 0;
  padding: 4px 8px;
  background: #000080;
  color: #fff;
  text-align: left;
  font-size: 8px;
  pointer-events: none;
}

/* Pixel-preserving display, fullscreen sizing and initial playback overlay. */
.screen {
  position: relative;
  aspect-ratio: 4/3;
  display: grid;
  place-items: center;
  background: #000;
  isolation: isolate;
}
.screen canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.screen:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
}
.start {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  border: 0;
  background: #000c;
  color: #fff;
  padding: 24px;
  text-align: center;
}
.start[hidden] {
  display: none;
}
.start:hover {
  color: #fff;
}
.start-credit {
  font-size: 12px;
  color: #0f0;
}
#start-label {
  font-size: 16px;
  color: #ffff00;
  background: #000080;
  padding: 12px 16px;
}
.start small {
  font-size: 8px;
  color: #c0c0c0;
}

/* Playback buttons, chapter heading and audio controls. */
.transport {
  display: flex;
  align-items: center;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 10px 12px 8px;
}
.buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
#previous,
#next {
  width: 28px;
}
#play {
  color: #ffff00;
  min-width: 72px;
}
.now {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}
#part-number {
  color: #808080;
  font-size: 8px;
}
.now strong {
  font-weight: 400;
  color: #fff;
  white-space: nowrap;
  font-size: 10px;
}
.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
#mute {
  font-size: 8px;
  white-space: nowrap;
  min-width: 88px;
}
#mute[aria-pressed='true'] {
  color: #808080;
}
#fullscreen {
  font-size: 10px;
  white-space: nowrap;
}

/* Match the volume and seek sliders across browser engines. */
input[type='range'] {
  appearance: none;
  -webkit-appearance: none;
  height: 16px;
  margin: 0;
  cursor: pointer;
  background: transparent;
  border-radius: 0;
  accent-color: #ffff00;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  background: #404040;
}
input[type='range']::-moz-range-track {
  height: 4px;
  background: #404040;
}
input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 8px;
  height: 12px;
  margin-top: -4px;
  background: #ffff00;
  border: 0;
  border-radius: 0;
}
input[type='range']::-moz-range-thumb {
  width: 8px;
  height: 12px;
  background: #ffff00;
  border: 0;
  border-radius: 0;
}
#volume {
  width: 48px;
}

/* Timeline, per-scene hints and footer. */
.timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 8px;
  font-size: 8px;
  color: #c0c0c0;
}
.timeline input {
  flex: 1;
  min-width: 0;
}
.below {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 0;
  font-size: 8px;
  line-height: 1.8;
  min-height: 34px;
}
.below p {
  margin: 0;
  text-transform: uppercase;
}
.below label {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.below input {
  margin: 1px 0 0;
  accent-color: #ffff00;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 8px;
  color: #808080;
  border-top: 1px solid #303030;
  padding-top: 8px;
}
footer a {
  color: #c0c0c0;
  text-decoration: none;
  white-space: nowrap;
}
footer a:hover {
  color: #0ff;
}

/* Playback failures and fullscreen page behavior. */
#error {
  color: #ff0;
  border: 1px solid #f00;
  padding: 12px;
  font-size: 12px;
}
body:has(.screen:fullscreen) {
  overflow: hidden;
}

/* Viewport fallback and container-based player layouts. */
@media (max-width: 700px) {
  main {
    width: calc(100% - 24px);
    max-width: calc((100svh - 300px) * 4 / 3 + 2px);
    min-width: min(320px, calc(100% - 24px));
  }
}
@container (max-width:650px) {
  .edition {
    display: none;
  }
  .identity {
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }
  h1 {
    font-size: 16px;
    letter-spacing: 0;
  }
  .transport {
    gap: 12px;
    flex-wrap: wrap;
  }
  .audio-controls {
    width: 100%;
    justify-content: flex-end;
  }
  .now {
    margin-left: auto;
  }
  #volume {
    width: 64px;
  }
  .below {
    gap: 12px;
    min-height: 46px;
  }
  footer {
    flex-direction: column;
    gap: 8px;
    font-size: 8px;
  }
  .part-label {
    padding: 0 8px;
  }
  nav button {
    font-size: 10px;
    min-height: 32px;
  }
}
@container (max-width:340px) {
  .part-label {
    display: none;
  }
  .identity span {
    font-size: 7px;
  }
  .now strong {
    font-size: 8px;
  }
  .transport {
    gap: 6px;
    padding: 8px;
  }
  .below {
    gap: 8px;
  }
  footer span {
    max-width: 210px;
  }
}
