:root {
  --app-height: 100dvh;
  --cream: #f5ddb0;
  --blue: #79c1ea;
  --card: #fbf3f1;
  --text: #1e5c9e;
  --shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
  --orange: #ff7a1f;
  --red: #ff3943;
  --green: #18a863;
  --white: #fff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: "Fredoka", system-ui, sans-serif;
  background: linear-gradient(180deg, #8ecbef 0%, #74bbe6 100%);
}

button,
a {
  font: inherit;
}

.lets-speak-app {
  min-height: 100svh;
  min-height: 100dvh;
  min-height: var(--app-height);
  display: grid;
  place-items: center;
}

.activity-shell {
  width: min(100vw, calc(var(--app-height) * 0.5625));
  height: 100svh;
  height: 100dvh;
  height: var(--app-height);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--cream);
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  justify-items: center;
  align-content: start;
  gap: clamp(10px, 1.8vh, 18px);
  padding: clamp(18px, 3vh, 30px) clamp(18px, 5vw, 34px) clamp(10px, 1.8vh, 16px);
  background: var(--cream);
  min-height: clamp(200px, 29svh, 286px);
  max-height: clamp(220px, 32svh, 300px);
}

.build-tools {
  position: absolute;
  top: clamp(10px, 1.4vh, 16px);
  right: clamp(10px, 3vw, 18px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.build-tag {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: rgba(30, 92, 158, 0.92);
  font-size: 12px;
  font-weight: 700;
}

.debug-jump-btn {
  min-height: 24px;
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(30, 92, 158, 0.9);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(30, 92, 158, 0.18);
}

.debug-jump-btn:active {
  transform: translateY(1px);
}

.manku-avatar {
  width: clamp(84px, 11.5vh, 112px);
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.18));
}

.prompt-text {
  margin: 0;
  color: var(--text);
  width: min(96%, 360px);
  min-height: clamp(82px, 11.5vh, 116px);
  max-height: clamp(104px, 15vh, 138px);
  overflow: hidden;
  font-size: clamp(24px, 3.25vh, 30px);
  line-height: 1.14;
  text-align: center;
  letter-spacing: 0;
  font-weight: 500;
  text-wrap: balance;
  transition: opacity 180ms ease, transform 180ms ease;
}

.practice-panel {
  display: grid;
  justify-items: center;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  align-content: stretch;
  gap: 0;
  padding: clamp(14px, 2vh, 18px) clamp(8px, 2.2vw, 12px) clamp(10px, 1.6vh, 14px);
  background: var(--blue);

  min-height: 0;
  overflow: hidden;
}

.art-card {
  width: min(99%, 430px);
  aspect-ratio: 1.18;
  flex: 0 0 auto;
  max-height: min(48vh, 372px);
  margin-bottom: clamp(14px, 2.2vh, 24px);
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  transition: transform 220ms ease, opacity 220ms ease, box-shadow 220ms ease;
}

.scene-image {
  position: absolute;
  inset: 0;
}

.art-card[data-mode="hidden"] {
  visibility: hidden;
  box-shadow: none;
  background: transparent;
}

.art-card[data-mode="title-card"] {
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0;
  overflow: visible;
  margin-bottom: clamp(10px, 1.6vh, 18px);
}

.art-card[data-mode="title-card"] .scene-image {
  padding: 0;
}

.scene-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: none;
  display: block;
  padding: clamp(8px, 1.2vh, 12px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.mic-slot {
  width: 100%;
  min-height: 0;
  display: grid;
  justify-items: center;
  align-items: end;
  align-self: stretch;
  padding-top: 0;
  padding-bottom: clamp(12px, 1.8vh, 20px);
  margin-top: 0;
}

.mic-button {
  position: relative;
  width: clamp(148px, 19vh, 192px);
  height: clamp(148px, 19vh, 192px);
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.mic-shadow,
.mic-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 18px;
}

.mic-shadow {
  display: none;
}

.mic-face {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.mic-face::before {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 999px;
  background: rgba(24, 168, 99, 0);
  box-shadow: 0 0 0 0 rgba(24, 168, 99, 0);
  opacity: 0;
  transform: scale(0.84);
  transition: opacity 160ms ease, transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.mic-icon-image {
  position: relative;
  z-index: 1;
  display: block;
  width: 120%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.18));
  transition: transform 180ms ease, filter 180ms ease, opacity 180ms ease;
}

.mic-button:active .mic-icon-image {
  transform: translateY(4px);
}

.mic-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.status-strip {
  min-height: 38px;
  min-width: min(78%, 240px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: clamp(6px, 1vh, 10px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.96);
  font-size: clamp(13px, 1.8vh, 16px);
  font-weight: 600;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.listen-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
}

.practice-panel[data-state="listening"] .listen-dot {
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(255, 57, 67, 0.18);
  animation: pulse 0.85s infinite;
}

.practice-panel[data-state="correct"] .listen-dot {
  background: var(--green);
}

.practice-panel[data-state="try"] .listen-dot {
  background: #ffb43a;
}

.practice-panel[data-state="ready"] .status-strip {
  background: rgba(255, 255, 255, 0.16);
}

.practice-panel[data-state="listening"] .status-strip {
  background: rgba(24, 168, 99, 0.28);
  box-shadow: inset 0 0 0 1px rgba(175, 255, 214, 0.42), 0 10px 22px rgba(24, 168, 99, 0.18);
}

.practice-panel[data-state="listening"] .mic-face::before {
  background: rgba(24, 168, 99, 0.24);
  box-shadow:
    0 0 0 8px rgba(24, 168, 99, 0.16),
    0 0 34px 10px rgba(24, 168, 99, 0.35);
  opacity: 1;
  transform: scale(1);
  animation: micGlow 1s ease-in-out infinite;
}

.practice-panel[data-state="listening"] .mic-icon-image {
  transform: scale(1.06);
  filter:
    drop-shadow(0 0 16px rgba(24, 168, 99, 0.7))
    drop-shadow(0 12px 18px rgba(0, 0, 0, 0.16));
}

.practice-panel[data-state="correct"] .status-strip {
  background: rgba(24, 168, 99, 0.34);
  color: #effff6;
  box-shadow: inset 0 0 0 1px rgba(175, 255, 214, 0.38), 0 10px 22px rgba(24, 168, 99, 0.18);
  transform: scale(1.04);
}

.practice-panel[data-state="try"] .status-strip {
  background: rgba(255, 196, 58, 0.22);
  color: #fff8e4;
  box-shadow: inset 0 0 0 1px rgba(255, 225, 142, 0.24);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.35);
  }
}

@keyframes micGlow {
  0%,
  100% {
    box-shadow:
      0 0 0 8px rgba(24, 168, 99, 0.14),
      0 0 28px 8px rgba(24, 168, 99, 0.3);
  }

  50% {
    box-shadow:
      0 0 0 14px rgba(24, 168, 99, 0.08),
      0 0 40px 14px rgba(24, 168, 99, 0.46);
  }
}

.practice-panel[data-state="correct"] .art-card:not([data-mode="hidden"]) {
  transform: scale(1.015);
  box-shadow: 0 14px 30px rgba(24, 168, 99, 0.16);
}

.practice-panel[data-state="correct"] .mic-icon-image {
  transform: scale(1.05);
  filter: drop-shadow(0 12px 18px rgba(24, 168, 99, 0.18));
}

.bottom-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-items: center;
  background: #f5ddb0;
  min-height: clamp(82px, 12svh, 108px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-icon {
  border: 0;
  background: transparent;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.nav-icon-image {
  display: block;
  width: clamp(58px, 8.8vh, 88px);
  height: auto;
  max-height: clamp(58px, 8.8vh, 88px);
  object-fit: contain;
}

@media (max-width: 420px) {
  .activity-shell {
    width: 100vw;
  }

  .hero-panel {
    min-height: clamp(184px, 27svh, 254px);
    max-height: clamp(204px, 30svh, 270px);
  }

  .prompt-text {
    width: min(96%, 342px);
    min-height: clamp(78px, 11vh, 106px);
    max-height: clamp(96px, 14vh, 126px);
    font-size: clamp(23px, 3vh, 28px);
  }

  .art-card {
    width: 94%;
    max-height: 34vh;
    border-radius: 20px;
  }

  .mic-slot {
    padding-bottom: 14px;
  }

  .mic-button {
    width: clamp(100px, 13vh, 124px);
    height: clamp(100px, 13vh, 124px);
  }

  .bottom-bar {
    min-height: 88px;
  }
}

@media (max-height: 760px) {
  .hero-panel {
    min-height: clamp(184px, 28svh, 270px);
  }
}

@media (display-mode: standalone) and (max-width: 520px) {
  .activity-shell {
    width: min(100vw, calc(var(--app-height) * 0.5625));
    height: var(--app-height);
  }

  .bottom-bar {
    padding-bottom: max(env(safe-area-inset-bottom, 0), 6px);
  }
}
