:root {
  --ink: #1a2433;
  --muted: #5c6b7a;
  --paper: #f7f3eb;
  --accent: #0d6e6e;
  --accent-deep: #094f4f;
  --wrong: #9b2c2c;
  --ok: #1f6b3a;
  --line: rgba(26, 36, 51, 0.12);
  --shadow: 0 12px 36px rgba(26, 36, 51, 0.1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: "Source Sans 3", system-ui, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--paper);
}

body {
  padding-bottom: 0;
}

body.in-practice {
  padding-bottom: calc(5.5rem + var(--safe-b));
}

.home-header {
  margin-bottom: 1.25rem;
}

.score-hud {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: center;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.score-main {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.score-pts {
  font-family: Fraunces, Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-deep);
  line-height: 1;
}

.score-pts-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
}

.score-meta {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
}

.score-bar {
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(13, 110, 110, 0.12);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #2a9d8f);
  border-radius: inherit;
  transition: width 0.45s ease;
}

.score-next {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.score-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(13, 110, 110, 0.1);
  color: var(--accent-deep);
  font-weight: 700;
  font-size: 0.9rem;
  position: relative;
}

.score-chip[hidden] {
  display: none !important;
}

.score-chip-sep {
  opacity: 0.45;
}

.score-plus {
  position: absolute;
  right: -0.2rem;
  top: -0.85rem;
  color: #d4a017;
  font-weight: 800;
  font-size: 1rem;
  animation: scorePop 1.1s ease forwards;
  pointer-events: none;
}

.score-plus[hidden] {
  display: none !important;
}

@keyframes scorePop {
  0% { opacity: 0; transform: translateY(6px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateY(-14px) scale(1); }
}

.index-list {
  display: grid;
  gap: 0.7rem;
}

.index-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem 0.95rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.index-card:active {
  transform: scale(0.99);
}

.index-num {
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
}

.index-body {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.index-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.index-blurb {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.index-meta {
  font-size: 0.78rem;
  color: var(--accent-deep);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.index-arrow {
  color: var(--accent);
  font-size: 1.2rem;
}

.voices-note {
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.install-btn {
  display: block;
  width: 100%;
  margin: 1rem 0 0;
  min-height: 3.1rem;
  font: inherit;
  font-weight: 700;
  font-size: 1.02rem;
  border-radius: 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.install-btn[hidden] {
  display: none !important;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  margin: 0 0 0.75rem;
  padding: 0.35rem 0.2rem;
  border: 0;
  background: transparent;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.question {
  margin: 0 0 0.9rem;
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.4;
}

.speak-hint {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.vocab-box {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.vocab-box[hidden] {
  display: none !important;
}

.vocab-dir {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vocab-prompt {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.45rem, 6vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.vocab-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.vocab-input {
  font: inherit;
  font-size: 1.05rem;
  min-height: 3.1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  width: 100%;
  resize: vertical;
  line-height: 1.45;
}

.vocab-prompt.sentence {
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
}

.stars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
  margin-top: 0.25rem;
}

.stars[hidden] {
  display: none !important;
}

.star {
  font-size: 1.35rem;
  color: rgba(26, 36, 51, 0.18);
  line-height: 1;
}

.star.on {
  color: #d4a017;
}

.stars-num {
  margin-left: 0.45rem;
  font-weight: 700;
  color: var(--accent-deep);
  font-size: 0.95rem;
}

.model-trans {
  margin: 0.35rem 0 0;
  padding: 0.75rem 0.85rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--muted);
  background: rgba(13, 110, 110, 0.06);
  border-radius: 12px;
  border: 1px solid rgba(13, 110, 110, 0.12);
}

.model-trans[hidden] {
  display: none !important;
}

.vocab-input:focus {
  outline: 2px solid rgba(13, 110, 110, 0.35);
  border-color: var(--accent);
}

.vocab-check {
  width: 100%;
  min-height: 3.1rem;
  font: inherit;
  font-weight: 600;
  font-size: 1.02rem;
  border-radius: 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.vocab-check:disabled {
  opacity: 0.7;
}

.listen-inline {
  width: 100%;
  min-height: 3.2rem;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  border-radius: 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  margin: 0.15rem 0 0.35rem;
}

.listen-inline[hidden] {
  display: none !important;
}

.listen-inline:active {
  background: var(--accent-deep);
}

body.mode-vocab:not(.mode-translate) .player,
body.mode-vocab:not(.mode-translate) #btn-play,
body.mode-vocab:not(.mode-translate) #btn-replay {
  display: none !important;
}

body.mode-translate .vocab-prompt.is-hidden {
  filter: blur(6px);
  user-select: none;
  color: transparent;
  text-shadow: 0 0 12px rgba(26, 36, 51, 0.35);
  background: rgba(26, 36, 51, 0.06);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
}

body.mode-translate .vocab-prompt.is-hidden::before {
  content: "🎧 Escucha el audio (el texto se revela al comprobar)";
  display: block;
  color: var(--muted);
  text-shadow: none;
  filter: none;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

/* En móvil, el dock sí muestra Escuchar en translate */
body.mode-translate #btn-play[hidden],
body.mode-translate #btn-replay[hidden] {
  display: none !important;
}

.match-board {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.match-col {
  display: grid;
  gap: 0.5rem;
}

.match-item {
  font: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  text-align: left;
  min-height: 3rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.match-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 110, 110, 0.22);
}

.match-item.ok {
  border-color: var(--ok);
  background: #eef8f1;
  color: var(--ok);
}

.match-item.bad {
  border-color: var(--wrong);
  background: #fdf0f0;
}

.dock[hidden] {
  display: none !important;
}


.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(700px 380px at 8% -8%, rgba(13, 110, 110, 0.16), transparent 60%),
    radial-gradient(520px 320px at 100% 0%, rgba(180, 120, 60, 0.1), transparent 55%),
    linear-gradient(180deg, #efe8da 0%, var(--paper) 48%, #e8eef0 100%);
  z-index: -1;
}

main {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: calc(1rem + var(--safe-t)) 1rem 1.5rem;
}

.brand {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--accent-deep);
}

h1 {
  margin: 0.25rem 0 0.2rem;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.55rem, 6.5vw, 2.2rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.card-practice {
  margin-top: 1.15rem;
  padding: 1.1rem 1rem 1.15rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.progress {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hint {
  margin: 0.55rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.player {
  display: none; /* botones van al dock móvil */
}

.choices {
  display: grid;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.choice-label {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.choice {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  min-height: 3.1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.choice:active:not(:disabled) {
  transform: scale(0.98);
}

.choice.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 110, 110, 0.22);
}

.choice.ok {
  border-color: var(--ok);
  background: #eef8f1;
  color: var(--ok);
}

.choice.bad {
  border-color: var(--wrong);
  background: #fdf0f0;
  color: var(--wrong);
}

.choice:disabled {
  cursor: default;
}

.sentence {
  margin: 0.35rem 0 0.85rem;
  padding: 0.9rem 0.95rem;
  font-size: 1.05rem;
  line-height: 1.55;
  background: rgba(13, 110, 110, 0.08);
  border-radius: 12px;
  border: 1px solid rgba(13, 110, 110, 0.18);
  word-break: break-word;
}

.sentence mark {
  background: rgba(31, 107, 58, 0.22);
  color: var(--ok);
  font-weight: 700;
  padding: 0 0.12em;
  border-radius: 4px;
}

.actions {
  display: none; /* next va al dock */
}

.feedback {
  min-height: 1.35rem;
  margin: 0.35rem 0 0;
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.35;
}

.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--wrong); }

.dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.15rem;
  padding: 0.25rem;
}

.dots button {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 0;
  background: rgba(26, 36, 51, 0.2);
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}

.dots button.active { background: var(--accent); }
.dots button.done { background: var(--ok); }

/* Dock fijo abajo: fácil con el pulgar */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0.65rem 0.85rem calc(0.65rem + var(--safe-b));
  background: rgba(247, 243, 235, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.dock-inner {
  width: min(640px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.dock .btn {
  width: 100%;
  min-height: 3.1rem;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.dock .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  grid-column: 1 / -1;
}

.dock .btn.primary:active { background: var(--accent-deep); }

.dock .btn[hidden] { display: none !important; }

.dock.has-next {
  grid-template-columns: 1fr 1fr;
}

.dock.has-next .btn.primary {
  grid-column: auto;
}

@media (min-width: 640px) {
  body { padding-bottom: 0; }

  main {
    padding: 2.25rem 1.25rem 3rem;
  }

  .card-practice {
    margin-top: 1.6rem;
    padding: 1.45rem 1.35rem 1.3rem;
    border-radius: 18px;
  }

  .player,
  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 1rem;
  }

  .btn {
    font: inherit;
    font-weight: 600;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 0.65rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    min-height: 2.75rem;
  }

  .btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .btn.ghost { background: transparent; }

  .choice-row {
    grid-template-columns: 1fr 1fr;
  }

  .choice {
    text-align: center;
  }

  .match-board {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .dock { display: none; }
}
