:root {
  --pink-soft: #fce7f3;
  --pink: #f472b6;
  --pink-deep: #db2777;
  --purple-light: #e9d5ff;
  --purple: #a855f7;
  --purple-deep: #7c3aed;
  --blue-light: #dbeafe;
  --blue: #3b82f6;
  --blue-deep: #2563eb;
  --ink: #1e1b4b;
  --white: #ffffff;
  --glass: rgba(255, 255, 255, 0.65);
  /* Finger colors (touch typing) */
  --f-lp: #f472b6;
  --f-lr: #c084fc;
  --f-lm: #a78bfa;
  --f-li: #818cf8;
  --f-ri: #6366f1;
  --f-rm: #60a5fa;
  --f-rr: #38bdf8;
  --f-rp: #ec4899;
  --f-thumb: #94a3b8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(145deg, #fdf2f8 0%, #ede9fe 45%, #dbeafe 100%);
  background-attachment: fixed;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

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

.brand-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.25);
  padding: 6px;
}

.brand h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--pink-deep), var(--purple-deep), var(--blue-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand p {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  opacity: 0.85;
}

.card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 12px 40px rgba(99, 102, 241, 0.12);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: var(--purple-deep);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.stats span {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink-soft), var(--purple-light));
}

.text-display {
  font-size: 1.35rem;
  line-height: 1.85;
  letter-spacing: 0.02em;
  min-height: 5.5rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: var(--white);
  border: 2px solid var(--purple-light);
}

.text-display .done {
  color: #94a3b8;
}

.text-display .current {
  background: linear-gradient(transparent 60%, rgba(244, 114, 182, 0.45) 60%);
  border-radius: 4px;
  padding: 0 2px;
  margin: 0 -2px;
}

.text-display .wrong {
  background: rgba(239, 68, 68, 0.25);
  border-radius: 4px;
}

.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.focus-hint {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--purple-deep);
}

.focus-hint.auto-advance-hint {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

button.primary {
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: var(--white);
  background: linear-gradient(135deg, var(--pink), var(--purple), var(--blue));
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(59, 130, 246, 0.35);
}

button.primary:active {
  transform: translateY(0);
}

/* Keyboard */
.keyboard-wrap {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.keyboard-wrap h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: center;
  user-select: none;
  min-width: min(100%, 68rem);
}

.kb-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: nowrap;
}

.key {
  min-width: 3.5rem;
  height: 3.5rem;
  padding: 0.15rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 0 rgba(30, 27, 75, 0.12);
  transition: transform 0.1s ease, box-shadow 0.1s ease, outline 0.1s;
}

.key .finger-label {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-top: 0.05rem;
}

.key.wide-1 {
  min-width: 4.75rem;
}
.key.wide-2 {
  min-width: 6.25rem;
}
.key.wide-3 {
  min-width: 8rem;
}
.key.wide-space {
  min-width: 22rem;
}

.key.f-lp {
  background: linear-gradient(180deg, #fbcfe8, var(--f-lp));
}
.key.f-lr {
  background: linear-gradient(180deg, #e9d5ff, var(--f-lr));
}
.key.f-lm {
  background: linear-gradient(180deg, #ddd6fe, var(--f-lm));
}
.key.f-li {
  background: linear-gradient(180deg, #c7d2fe, var(--f-li));
}
.key.f-ri {
  background: linear-gradient(180deg, #bfdbfe, var(--f-ri));
}
.key.f-rm {
  background: linear-gradient(180deg, #bae6fd, var(--f-rm));
}
.key.f-rr {
  background: linear-gradient(180deg, #e0f2fe, var(--f-rr));
}
.key.f-rp {
  background: linear-gradient(180deg, #fce7f3, var(--f-rp));
}
.key.f-thumb {
  background: linear-gradient(180deg, #e2e8f0, var(--f-thumb));
}

.key.next {
  outline: 3px solid var(--blue-deep);
  outline-offset: 2px;
  transform: scale(1.08);
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35);
}

.key.pressed {
  transform: scale(0.95);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend i {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(30, 27, 75, 0.2);
}

@media (max-width: 720px) {
  .text-display {
    font-size: 1.1rem;
  }
  .keyboard {
    min-width: 0;
  }
  .kb-row {
    flex-wrap: wrap;
  }
  .key {
    min-width: 2.65rem;
    height: 2.85rem;
    font-size: 0.82rem;
  }
  .key .finger-label {
    font-size: 0.62rem;
  }
  .key.wide-space {
    min-width: 14rem;
  }
  .key.wide-1 {
    min-width: 3.5rem;
  }
  .key.wide-2 {
    min-width: 4.5rem;
  }
  .key.wide-3 {
    min-width: 5.5rem;
  }
}
