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

html {
  font-family: "DejaVu Sans Mono", monospace;
  font-size: 15px;
  background: #282a36;
  color: #f8f8f2;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

#root {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 70ch;
  padding: 3rem 1rem;
}

#root > * + * {
  margin-top: 3rem;
}

#root > footer {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  text-align: center;
  color: #6272a4;
  padding: 2rem 0;
}

#root > footer > * + * {
  margin-top: 2rem;
}

a,
a:hover,
a:visited {
  color: inherit;
}

p {
  text-align: justify;
  hyphens: auto;
}

button {
  background: inherit;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:hover,
button:focus {
  background: #44475a;
  outline: none;
}

button svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.space-out {
  letter-spacing: 0.3rem;
  word-spacing: -0.3rem;
  margin: 0 0.25rem;
}

#github-link {
  display: flex;
  position: fixed;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  background: #44475a;
  transform: translate(60px, -60px) rotate(45deg);
  overflow: hidden;
  z-index: 1000;
}

#github-link a {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: rotate(-45deg) translate(-25px, 25px);
}

#github-link svg {
  width: 32px;
  height: 32px;
  fill: #f8f8f2;
}

#welcome > * + * {
  margin-top: 0.5rem;
  text-align: justify;
}

#practice {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#practice > * + * {
  margin-top: 4rem;
}

#practice > section {
  width: 100%;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  height: 2.75rem;
  padding: 0.5rem;
  border: 2px solid #44475a;
}

#practice > section > div {
  flex: 1;
  text-align: center;
  height: 1.6rem;
  line-height: 1.5rem;
}

/* Hidden rather than removed when the timer is off, so the layout stays put. */
#practice > .timer-bar {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
}

#practice > .timer-bar.off {
  visibility: hidden;
}

#practice > .timer-bar > div {
  width: 100%;
  height: 100%;
  background: #ff5555;
}

#practice > section.given {
  margin-top: 0.5rem;
  border-bottom: none;
  border-radius: 0.5rem 0.5rem 0 0;
}

#practice > section.typed {
  position: relative;
  overflow: hidden;
  background: #343746;
  margin-top: 0;
  border-radius: 0 0 0.5rem 0.5rem;
}

#practice > section.typed > input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

#practice .count {
  font-weight: 700;
}

#practice > section.given > .hl {
  background: #44475a;
}

#practice > section.typed > .hl {
  background: #f8f8f2;
  color: #282a36;
}

#practice > section > .err {
  background: #ff5555;
  color: #282a36;
}

/* Typed after the timer ran out, so not counted. */
#practice > section.typed > .late {
  color: #6272a4;
}

#practice > section.given > .hl.expired {
  background: #ff5555;
  color: #282a36;
}

#practice .weights {
  display: flex;
  justify-content: space-between;
  margin-top: 0;
  padding-top: 4rem;
  width: 320px;
  position: relative;
}

#practice .weights > div {
  display: flex;
  flex-direction: column;
  border: 2px solid #44475a;
  border-radius: 0.3rem;
  min-width: 4.5rem;
}

#practice .weights .chars {
  font-style: italic;
  padding: 0.4rem 0.5rem;
  text-align: center;
}

#practice .weights > div .weight {
  display: flex;
  border-top: 2px solid #44475a;
  background: #343746;
}

#practice .weights > div .weight > * {
  display: flex;
  justify-content: center;
  align-items: center;
}

#practice .weights > div .weight > * + * {
  border-left: 2px solid #44475a;
}

#practice .weights > div .weight > span {
  flex: 1;
}

#practice .weights > div .weight > span::before {
  content: "x";
}

#practice .weights .controls {
  display: flex;
  flex-direction: column;
}

#practice .weights .controls > * {
  padding: 0.3rem;
}

#practice .weights .controls > * + * {
  border-top: 2px solid #44475a;
}

#practice .weights > .lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

#finger-chart {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#finger-chart > .toggle,
#practice .session button {
  border: 2px solid #44475a;
  border-radius: 0.3rem;
  height: 1.6rem;
  line-height: 1.35rem;
  padding: 0 0.5rem;
  background: #343746;
}

#finger-chart > .toggle:hover,
#finger-chart > .toggle:focus,
#practice .session button:hover:enabled,
#practice .session button:focus:enabled {
  background: #44475a;
}

#practice .session button:disabled {
  opacity: 0.4;
  cursor: default;
}

#practice .session {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#practice .session > * + * {
  margin-top: 1rem;
}

#practice .session .actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#practice .session .hardcore {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

#practice .session .hardcore input {
  accent-color: #ff5555;
  cursor: pointer;
}

#practice .session .timer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#practice .session .timer input {
  width: 4.5ch;
  height: 1.6rem;
  padding: 0 0.3rem;
  border: 2px solid #44475a;
  border-radius: 0.3rem;
  background: #343746;
  color: inherit;
  font: inherit;
  text-align: right;
  -moz-appearance: textfield;
  appearance: textfield;
}

#practice .session .timer input::-webkit-inner-spin-button,
#practice .session .timer input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#practice .session .timer input:focus {
  outline: none;
  background: #44475a;
}

#practice .session .status {
  color: #6272a4;
  min-height: 1.2em;
}

#finger-chart.off > .chart {
  display: none;
}

#finger-chart > .chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  border: 2px solid #44475a;
  border-radius: 0.5rem;
}

#finger-chart .keyboard {
  width: 100%;
}

#finger-chart .keyboard .row {
  display: flex;
}

/* Key widths are in units of a standard key; every row adds up to 15. */
#finger-chart .keyboard .key {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: calc(var(--w) / 15 * 100%);
  height: 2.5rem;
  border: 2px solid transparent;
  border-radius: 0.4rem;
  background: var(--c);
  background-clip: padding-box;
  color: #282a36;
  line-height: 1;
}

#finger-chart .keyboard .key .shift {
  font-size: 0.75rem;
  opacity: 0.6;
}

#finger-chart .keyboard .key.named {
  font-size: 0.8rem;
  font-style: italic;
}

#finger-chart .fingertips {
  width: 220px;
  margin-top: 1rem;
}

#finger-chart .fingertips circle {
  fill: var(--c);
}

/* Finger colors (Dracula palette). */
#finger-chart .lp,
#finger-chart .rp {
  --c: #bd93f9;
}

#finger-chart .lr,
#finger-chart .rr {
  --c: #ff79c6;
}

#finger-chart .lm,
#finger-chart .rm {
  --c: #ffb86c;
}

#finger-chart .li {
  --c: #50fa7b;
}

#finger-chart .ri {
  --c: #8be9fd;
}

#finger-chart .lt,
#finger-chart .rt {
  --c: #f1fa8c;
}

#stats > * + * {
  margin-top: 1.5rem;
}

#stats h2 {
  font-size: 1.25rem;
}

#stats .summary {
  color: #6272a4;
}

#stats .legend {
  display: flex;
  gap: 1.5rem;
  color: #6272a4;
}

#stats .legend span::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.5rem;
  border-radius: 0.2rem;
  vertical-align: -0.05rem;
}

#stats .legend .normal::before {
  background: #bd93f9;
}

#stats .legend .hardcore::before {
  background: #ff5555;
}

#stats .chart {
  width: 100%;
}

#stats .chart svg {
  display: block;
  font-family: inherit;
}

#stats summary {
  cursor: pointer;
  color: #6272a4;
}

#stats table {
  margin-top: 0.75rem;
  border-collapse: collapse;
}

#stats th,
#stats td {
  padding: 0.25rem 1rem 0.25rem 0;
  text-align: left;
  font-weight: normal;
}

#stats th {
  color: #6272a4;
}

#stats .tooltip {
  display: none;
  position: fixed;
  pointer-events: none;
  padding: 0.3rem 0.5rem;
  border: 2px solid #44475a;
  border-radius: 0.3rem;
  background: #343746;
  white-space: nowrap;
  z-index: 10;
}
