:root {
  color-scheme: dark;
  --background: #111214;
  --panel: #181a1e;
  --panel-border: #2a2d33;
  --text: #f5f7fa;
  --muted: #8b9099;
  --untyped: #737983;
  --error: #ff5d68;
  --accent: #b7bdc8;
  --progress: #eceff4;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.045), transparent 38rem),
    var(--background);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 32px;
}

.app-header,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-actions {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.control-picker {
  display: grid;
  gap: 6px;
}

.control-picker label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.control-select {
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 9px 34px 9px 14px;
  background-color: var(--background);
  color: var(--text);
  cursor: pointer;
}

.language-select {
  min-width: 132px;
}

.word-count-select {
  min-width: 112px;
}

.part-of-speech-select {
  min-width: 148px;
}

.frequency-select {
  min-width: 132px;
}

.control-select:hover,
.control-select:focus-visible {
  border-color: #4b5059;
}

.control-select:focus-visible,
.restart-button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: none;
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.restart-button {
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 10px 16px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.restart-button:hover {
  border-color: #4b5059;
  background: rgba(255, 255, 255, 0.04);
}

.restart-button:active {
  transform: translateY(1px);
}

.practice-card {
  position: relative;
  margin-top: 44px;
  padding: clamp(24px, 5vw, 48px);
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: rgba(24, 26, 30, 0.92);
  box-shadow: var(--shadow);
}

.progress-text {
  margin-bottom: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.word-viewport {
  min-height: 190px;
  margin: 52px 0 44px;
  overflow: hidden;
  cursor: text;
}

.word-area {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-end;
  gap: 24px 32px;
  min-height: 190px;
  padding: 8px 2px;
  outline: none;
}

.word-area.is-line-scrolling {
  will-change: transform;
}

.word-block {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 8px;
}

.word-block[hidden] {
  display: none;
}

.translation {
  align-self: stretch;
  max-width: 18rem;
  min-height: 1.35em;
  margin-bottom: 7px;
  color: #c5cad3;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  opacity: 0;
  text-align: center;
  transform: translateY(3px);
  transition:
    opacity 130ms ease,
    transform 130ms ease;
}

.word-block.completed .translation {
  opacity: 1;
  transform: translateY(0);
}

.word {
  position: relative;
  display: inline-flex;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(1.55rem, 4.5vw, 2.45rem);
  font-weight: 650;
  letter-spacing: 0.025em;
  line-height: 1.15;
}

.word-block.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.72);
  /*display: none;*/
}

.character {
  position: relative;
  color: var(--untyped);
  white-space: pre;
  transition: color 90ms ease;
}

.character.correct {
  color: var(--text);
}

.character.incorrect {
  color: var(--error);
}

.character.cursor::after {
  content: "";
  position: absolute;
  top: 0;
  left: -1px;
  width: 2px;
  height: 1.15em;
  background: var(--text);
  animation: blink 1s steps(1, end) infinite;
}

.word-end-cursor {
  width: 0;
}

.empty-bank-message {
  width: 100%;
  margin: auto 0;
  color: var(--muted);
  text-align: center;
}

.progress-track {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #2a2d33;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--progress);
  transition: width 180ms ease;
}

.typing-input {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.app-footer {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.82rem;
}

.app-footer span + span::before {
  content: "•";
  margin-right: 24px;
  color: #4f545d;
}

@keyframes blink {
  0%,
  48% {
    opacity: 1;
  }

  49%,
  100% {
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding-top: 28px;
  }

  .app-header {
    align-items: flex-start;
  }

  .app-header {
    flex-wrap: wrap;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .control-select {
    width: 100%;
    min-width: 0;
  }

  .restart-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .practice-card {
    margin-top: 28px;
  }

  .word-viewport {
    min-height: 250px;
    margin-top: 40px;
  }

  .word-area {
    gap: 20px 24px;
    min-height: 250px;
  }

  .app-footer span + span::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
