:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #0b1020;
  color: #e5edf7;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  margin: 0;
}

main {
  width: min(100%, 68rem);
  margin: 0 auto;
  padding: clamp(0.6rem, 2vw, 1.2rem);
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

header img {
  width: 5rem;
  height: auto;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.15rem, 4vw, 1.8rem);
}

header p,
.status {
  color: #b7c6d9;
}

.controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

button {
  min-width: 5rem;
  min-height: 2.4rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid #475569;
  border-radius: 0.45rem;
  background: #1e293b;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: #60a5fa;
  background: #263b59;
  outline: 2px solid #60a5fa;
  outline-offset: 1px;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

canvas {
  display: block;
  width: 100%;
  max-height: 29rem;
  aspect-ratio: 16 / 9;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  background: #0b1020;
}

.status {
  display: grid;
  gap: 0.32rem;
  margin-top: 0.55rem;
  font-size: 0.86rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.32rem;
}

.key {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0.2rem;
}

.key.required {
  border: 2px solid #60a5fa;
}

.key.newly {
  background: #0f766e;
}

.key.retained {
  background: #1e3a5f;
}

.key.evicted {
  border: 2px solid #fb7185;
}

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

@media (max-width: 36rem) {
  header img {
    display: none;
  }

  canvas {
    max-height: 18rem;
  }
}
