:root {
  --bg-a: #f6f4ec;
  --bg-b: #d7efe6;
  --ink: #1f2a2a;
  --muted: #4f6762;
  --card: #fffdf8;
  --line: #c8d9d1;
  --accent: #0f766e;
  --accent-strong: #0a5a54;
  --alert: #9f1d35;
  --ok: #14532d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Century Gothic", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: linear-gradient(130deg, var(--bg-a), var(--bg-b));
  overflow-x: hidden;
}

.bg-circle {
  position: fixed;
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
}

.bg-circle-a {
  width: 32rem;
  height: 32rem;
  left: -8rem;
  top: -10rem;
  background: radial-gradient(circle, #ffd0a8 0%, transparent 68%);
}

.bg-circle-b {
  width: 30rem;
  height: 30rem;
  right: -8rem;
  bottom: -11rem;
  background: radial-gradient(circle, #9ed8d6 0%, transparent 65%);
}

.app-shell {
  width: min(72rem, 96vw);
  margin: 1.5rem auto;
  position: relative;
  z-index: 1;
}

.screen {
  display: none;
  animation: lift 240ms ease;
}

.screen.active {
  display: block;
}

@keyframes lift {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.2rem);
}

h2 {
  font-size: 1.2rem;
}

.subtitle {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 8px 24px #17312914;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}

label {
  font-weight: 600;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.6rem 0.7rem;
  background: #fffcf4;
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 0.7rem;
  padding: 0.65rem 0.9rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost:hover:not(:disabled) {
  background: #ffffffb7;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.saved-lists {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 22rem;
  overflow-y: auto;
}

.saved-lists li {
  border: 1px solid var(--line);
  background: #ffffffbc;
  border-radius: 0.65rem;
  padding: 0.55rem 0.7rem;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: start;
}

.list-main {
  min-width: 0;
}

.list-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.list-select-wrap input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

.list-actions {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

.small-btn {
  padding: 0.35rem 0.55rem;
  border-radius: 0.55rem;
  font-size: 0.86rem;
}

.saved-lists .list-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.setup-row {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: auto minmax(7rem, 9rem) auto auto;
  gap: 0.6rem;
  align-items: end;
}

#selected-count {
  margin: 0;
  align-self: center;
}

.message {
  margin: 0.2rem 0 0;
  min-height: 1.2rem;
  font-weight: 600;
}

.message.error {
  color: var(--alert);
}

.message.success {
  color: var(--ok);
}

#practice-screen {
  min-height: min(88vh, 700px);
  position: relative;
}

.practice-top {
  display: flex;
  justify-content: center;
  margin-top: 0.8rem;
}

.start-btn {
  font-size: 1.15rem;
  padding-inline: 2rem;
  min-width: 11rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(1rem, 8vh);
}

.start-btn:hover:not(:disabled),
.start-btn:focus-visible:not(:disabled) {
  transform: translateX(-50%) translateY(-1px);
}

.back-btn {
  position: absolute;
  top: 0.7rem;
  left: 0;
}

.practice-center {
  min-height: min(72vh, 560px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 1rem;
}

#word-display {
  font-size: clamp(2rem, 10vw, 5.5rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: 0.03em;
  min-height: 1.3em;
  max-width: 92%;
}

.next-btn {
  min-width: 11rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(1rem, 8vh);
}

.next-btn:hover:not(:disabled),
.next-btn:focus-visible:not(:disabled) {
  transform: translateX(-50%) translateY(-1px);
}

@media (max-width: 860px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .setup-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .back-btn {
    position: absolute;
    top: 0.5rem;
    left: 0;
    margin-bottom: 0;
  }

  .practice-top {
    margin-top: 0;
  }

  .next-btn {
    bottom: 2rem;
  }

  .start-btn {
    bottom: 2rem;
  }
}
