@font-face {
  font-family: "Signifier";
  src: local("Signifier");
  font-style: normal;
  font-weight: 300 400;
}

:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --text: #1a1a1a;
  --muted: #888888;
  --quiet: #b0b0b0;
  --red: #d84f4f;
  --syntax-attribute: var(--text);
  --syntax-comment: #6b6b6b;
  --syntax-constant: #2d7f3e;
  --syntax-function: var(--text);
  --syntax-keyword: #3b5bdb;
  --syntax-module: var(--text);
  --syntax-number: #2d7f3e;
  --syntax-operator: var(--text);
  --syntax-property: var(--text);
  --syntax-punctuation: var(--text);
  --syntax-string: #2d7f3e;
  --syntax-tag: var(--text);
  --syntax-type: var(--text);
  --syntax-variable: var(--text);
  font-family: "Signifier", ui-serif, Georgia, serif;
  font-style: normal;
  font-weight: 300;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121212;
    --text: #e0e0e0;
    --muted: #666666;
    --quiet: #555555;
    --red: #ff6b6b;
    --syntax-attribute: var(--text);
    --syntax-comment: #666666;
    --syntax-constant: #98c379;
    --syntax-function: var(--text);
    --syntax-keyword: #7aa2f7;
    --syntax-module: var(--text);
    --syntax-number: #98c379;
    --syntax-operator: var(--text);
    --syntax-property: var(--text);
    --syntax-punctuation: var(--text);
    --syntax-string: #98c379;
    --syntax-tag: var(--text);
    --syntax-type: var(--text);
    --syntax-variable: var(--text);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-style: normal;
}

button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-style: normal;
  padding: 0;
}

button:hover,
button.selected {
  color: var(--text);
}

.shell {
  --content-width: 82rem;
  --rail-min: 9rem;
  display: grid;
  grid-template-rows: auto 1fr;
  width: calc(100vw - 2rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vh, 4rem) 0;
  outline: none;
}

.topline {
  display: grid;
  grid-template-columns: minmax(var(--rail-min), 1fr) minmax(0, var(--content-width)) minmax(
      var(--rail-min),
      1fr
    );
  color: var(--muted);
  font-family:
    "Berkeley Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  font-style: normal;
}

.layouts {
  display: flex;
  flex-wrap: wrap;
  grid-column: 2;
  grid-row: 1;
  gap: 1.25rem;
  justify-content: flex-start;
}

.levels {
  display: grid;
  gap: 0.25rem;
  justify-content: start;
}

.level {
  display: grid;
  grid-template-columns: 2ch minmax(4.5rem, 1fr);
  column-gap: 1.6rem;
  width: 9rem;
}

.level-number {
  text-align: left;
}

.level-name {
  text-align: right;
}

.stats {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.stage {
  display: grid;
  grid-template-columns: minmax(var(--rail-min), 1fr) minmax(0, var(--content-width)) minmax(
      var(--rail-min),
      1fr
    );
  align-items: center;
  width: 100%;
  min-height: 0;
}

.sidebar {
  grid-column: 1;
  align-self: center;
  justify-self: center;
  font-family:
    "Berkeley Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
}

.rail {
  display: block;
  grid-column: 3;
}

.practice-window {
  grid-column: 2;
  align-self: center;
  height: calc(1.45em * 8);
  overflow: hidden;
  scroll-behavior: smooth;
  font-family:
    "Berkeley Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: clamp(1.55rem, 3.15vw, 3.15rem);
  line-height: 1.45;
}

.word-stream {
  position: relative;
  max-width: 100%;
  margin: 0;
  color: var(--quiet);
  overflow-wrap: normal;
  padding: 0 0 calc(1.45em * 4);
  text-align: justify;
  white-space: normal;
  word-break: normal;
}

.char {
  display: inline;
}

.char.space {
  display: inline;
}

.char.typed {
  color: var(--text);
}

.char.future {
  color: var(--quiet);
}

.char.current {
  position: relative;
}

.typing-cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 1ch;
  height: 0.055em;
  background: var(--quiet);
  content: "";
  pointer-events: none;
  transition:
    transform 90ms ease-out,
    width 90ms ease-out,
    background-color 90ms ease-out;
}

.char.current.wrong,
.practice-window.blocked .char.current {
  color: var(--red);
}

.practice-window.blocked .typing-cursor {
  background: var(--red);
}

.practice-window.syntax-highlighting {
  height: calc(1.45em * 12);
  font-size: clamp(1rem, 1.55vw, 1.45rem);
  line-height: 1.45;
}

.practice-window.syntax-highlighting .word-stream {
  overflow-wrap: normal;
  tab-size: 2;
  text-align: left;
  white-space: break-spaces;
}

.practice-window.syntax-highlighting .char.typed.syntax-attribute {
  color: var(--syntax-attribute);
}

.practice-window.syntax-highlighting .char.typed.syntax-comment {
  color: var(--syntax-comment);
  font-style: italic;
}

.practice-window.syntax-highlighting .char.typed.syntax-constant {
  color: var(--syntax-constant);
}

.practice-window.syntax-highlighting .char.typed.syntax-function {
  color: var(--syntax-function);
}

.practice-window.syntax-highlighting .char.typed.syntax-keyword {
  color: var(--syntax-keyword);
}

.practice-window.syntax-highlighting .char.typed.syntax-module {
  color: var(--syntax-module);
}

.practice-window.syntax-highlighting .char.typed.syntax-number {
  color: var(--syntax-number);
}

.practice-window.syntax-highlighting .char.typed.syntax-operator {
  color: var(--syntax-operator);
}

.practice-window.syntax-highlighting .char.typed.syntax-property {
  color: var(--syntax-property);
}

.practice-window.syntax-highlighting .char.typed.syntax-punctuation {
  color: var(--syntax-punctuation);
}

.practice-window.syntax-highlighting .char.typed.syntax-string {
  color: var(--syntax-string);
}

.practice-window.syntax-highlighting .char.typed.syntax-tag {
  color: var(--syntax-tag);
}

.practice-window.syntax-highlighting .char.typed.syntax-type {
  color: var(--syntax-type);
}

.practice-window.syntax-highlighting .char.typed.syntax-variable {
  color: var(--syntax-variable);
}

.practice-window.syntax-highlighting .char.current.wrong,
.practice-window.syntax-highlighting.blocked .char.current {
  color: var(--red);
}

@media (max-width: 1040px) {
  .shell {
    width: min(var(--content-width), calc(100vw - 2rem));
  }

  .topline {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
  }

  .stage {
    grid-template-columns: minmax(0, var(--content-width));
    align-content: center;
    justify-content: stretch;
    row-gap: 2rem;
  }

  .sidebar,
  .practice-window {
    grid-column: 1;
  }

  .sidebar {
    justify-self: start;
  }

  .levels {
    grid-template-columns: repeat(3, max-content);
    column-gap: 1.5rem;
  }

  .rail {
    display: none;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 1.25rem, 42rem);
    padding-top: 2rem;
  }

  .topline {
    align-items: start;
    gap: 1rem;
  }

  .practice-window {
    height: calc(1.48em * 7);
    font-size: clamp(1.45rem, 6vw, 2.35rem);
    line-height: 1.48;
  }

  .practice-window.syntax-highlighting {
    height: calc(1.45em * 10);
    font-size: clamp(0.95rem, 3.8vw, 1.3rem);
    line-height: 1.45;
  }

  .word-stream {
    max-width: 100%;
  }
}
