:root {
  --accent: #367a92;
  --accent-dark: #28596a;
  --wash: #afd7e3;
}

.blend-stage {
  width: min(100%, 680px);
}

.word-card {
  position: relative;
  display: grid;
  overflow: hidden;
  width: 100%;
  height: clamp(230px, 36dvh, 320px);
  min-height: 0;
  align-content: center;
  justify-items: center;
  padding: 32px 22px 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.3)),
    var(--wash);
  box-shadow: var(--shadow);
}

.word-card::before,
.word-card::after {
  position: absolute;
  border: 2px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 50%;
  content: "";
}

.word-card::before {
  top: -58px;
  right: -34px;
  width: 138px;
  height: 138px;
}

.word-card::after {
  bottom: -48px;
  left: -37px;
  width: 110px;
  height: 110px;
}

.word-display {
  z-index: 1;
  display: flex;
  width: 100%;
  min-height: 0.9em;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3.5vw, 22px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: "Comic Neue", "Comic Sans MS", "Chalkboard SE", cursive;
  font-size: clamp(6.2rem, 29vw, 11rem);
  font-variant-ligatures: none;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.8;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.word-display:active {
  transform: scale(0.98);
}

.word-display:disabled {
  cursor: wait;
  opacity: 1;
}

.sound-letter {
  position: relative;
  display: inline-block;
  min-width: 0.54em;
  border-radius: 0.16em;
  transform-origin: center bottom;
  transition:
    color 180ms ease,
    transform 230ms cubic-bezier(0.2, 0.85, 0.35, 1.2),
    background 180ms ease,
    box-shadow 180ms ease;
}

.sound-letter.is-active {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 24px rgba(40, 89, 106, 0.13);
  color: var(--accent-dark);
  transform: translateY(-8px) scale(1.08);
}

.word-card.is-changing .word-display {
  animation: word-pop 300ms cubic-bezier(0.2, 0.85, 0.35, 1.15);
}

.word-card.is-whole-word .sound-letter {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 20px rgba(40, 89, 106, 0.1);
  color: var(--accent-dark);
  transform: translateY(-4px);
}

.blend-swoop {
  position: relative;
  z-index: 1;
  overflow: hidden;
  width: min(72%, 330px);
  height: 22px;
  margin-top: 19px;
  border-bottom: 4px solid color-mix(in srgb, var(--accent-dark) 64%, transparent);
  border-radius: 0 0 50% 50%;
  opacity: 0.55;
}

.swoop-dot {
  position: absolute;
  bottom: -1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-dark);
  opacity: 0;
}

.word-card.is-reading .swoop-dot {
  opacity: 1;
  animation: sweep-across var(--sweep-duration, 2.4s) linear forwards;
}

.sound-trail {
  z-index: 1;
  display: flex;
  min-height: 32px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 13px;
  color: color-mix(in srgb, var(--ink) 58%, var(--accent));
  font-size: clamp(0.77rem, 2.8vw, 0.9rem);
  font-weight: 800;
}

.trail-sound,
.trail-word,
.trail-arrow {
  transition: color 160ms ease, transform 160ms ease, background 160ms ease;
}

.trail-sound,
.trail-word {
  padding: 5px 8px;
  border-radius: 999px;
}

.trail-arrow {
  padding-inline: 1px;
  opacity: 0.5;
}

.trail-sound.is-active,
.trail-word.is-active {
  background: rgba(255, 255, 255, 0.74);
  color: var(--accent-dark);
  transform: scale(1.08);
}

.audio-status {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.blend-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.help-button,
.next-button {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 22px;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.help-button {
  border: 2px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  background: var(--surface);
  color: var(--accent-dark);
}

.next-button {
  border: 2px solid var(--accent-dark);
  background: var(--accent-dark);
  color: white;
}

.help-button:hover,
.next-button:hover {
  transform: translateY(-2px);
}

.help-button:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--wash) 22%, white);
}

.next-button:hover {
  background: color-mix(in srgb, var(--accent-dark) 90%, black);
}

.help-button:active,
.next-button:active {
  transform: scale(0.98);
}

.help-button:disabled,
.next-button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.help-icon,
.next-arrow {
  flex: none;
  font-size: 1.45rem;
}

.help-button strong,
.next-button strong {
  font-size: 0.91rem;
  font-weight: 800;
}

.next-arrow {
  margin-left: 5px;
  transition: transform 160ms ease;
}

.next-button:hover .next-arrow {
  transform: translateX(3px);
}

@keyframes word-pop {
  0% { opacity: 0; transform: scale(0.72) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes sweep-across {
  0% { left: 1px; }
  100% { left: calc(100% - 13px); }
}

@media (min-width: 700px) {
  .word-card {
    height: clamp(300px, 40dvh, 390px);
    min-height: 0;
    border-radius: 42px;
    padding: 38px 30px 29px;
  }

  .blend-controls { gap: 14px; }

  .help-button,
  .next-button {
    min-height: 80px;
    border-radius: 25px;
  }
}

@media (max-height: 690px) {
  .word-card {
    height: clamp(205px, 34dvh, 230px);
    min-height: 0;
    padding-block: 24px 18px;
  }

  .word-display {
    font-size: clamp(5.2rem, 22vh, 8.5rem);
  }

  .blend-swoop { margin-top: 12px; }
  .sound-trail { margin-top: 8px; }
  .help-button,
  .next-button { min-height: 62px; }
}
