:root {
  --navy: #2B2D42;
  --yellow: #FFD166;
  --pink: #F72585;
  --blue: #4CC9F0;
  --green: #06D6A0;
  --bg-cream: #FFF8EE;
  --orange: #FF9F1C;
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Nunito', sans-serif;
  background-color: var(--bg-cream);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

.font-display {
  font-family: 'Fredoka', cursive, sans-serif;
}

.border-3 { border-width: 3px; }

.pt-safe { padding-top: calc(12px + env(safe-area-inset-top)); }
.pb-safe { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }

button, .sticker-card, .deck-tab, .mode-btn, .starter-chip {
  user-select: none;
  -webkit-user-select: none;
}

button:focus-visible,
.sticker-card:focus-visible,
.deck-tab:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

/* Deck tabs */
.deck-tab {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border-radius: 1rem;
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  border: 3px solid var(--navy);
  background: #fff;
  color: var(--navy);
  box-shadow: 0 5px 0 var(--navy);
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 48px;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s ease, color 0.15s ease;
}

.deck-tab.active {
  background: var(--green);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--navy);
}

.deck-tab:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--navy); }

.mode-btn {
  color: var(--navy);
  min-height: 40px;
}

.mode-btn.active {
  background-color: var(--pink) !important;
  color: #fff !important;
  box-shadow: 0 2px 0 var(--navy);
}

.brand-tagline {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 800;
  color: #4CC9F0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.35;
  white-space: normal;
}

.deck-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.35rem;
  padding: 6px 4px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: none;
}

.grid-scrim {
  background: rgba(255, 248, 238, 0.9);
  border-radius: 1.5rem;
  padding: 0.75rem;
  box-shadow: inset 0 0 0 1px rgba(43, 45, 66, 0.06);
}

/* Cards */
.sticker-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  gap: 0;
  min-height: 210px;
  padding: 0;
  border: 4px solid var(--navy);
  border-radius: 1.6rem;
  box-shadow: 0 8px 0 var(--navy), 0 16px 26px rgba(43, 45, 66, 0.18);
  background-color: var(--card-fill, #FFE7B3);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

.sticker-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 38%;
  background: linear-gradient(180deg, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
  border-top-left-radius: 1.4rem;
  border-top-right-radius: 1.4rem;
}

.sticker-card:active {
  transform: translateY(4px) scale(0.97);
  box-shadow: 0 4px 0 var(--navy), 0 8px 14px rgba(43, 45, 66, 0.12);
}

.card-art {
  flex: 1 1 auto;
  width: 100%;
  min-height: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 0.45rem 0.2rem;
  pointer-events: none;
  z-index: 1;
}

.card-photo {
  width: auto;
  height: auto;
  max-width: 88%;
  max-height: 128px;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 4px 0 rgba(43, 45, 66, 0.12));
}

.card-svg {
  width: 72%;
  max-width: 128px;
  height: auto;
  max-height: 128px;
}

.card-svg svg {
  width: 100%;
  height: 100%;
  max-height: 128px;
  display: block;
}

.card-emoji {
  font-size: 4.4rem;
  line-height: 1;
  filter: drop-shadow(0 3px 0 rgba(43, 45, 66, 0.12));
}

.card-label-bar {
  position: relative;
  z-index: 1;
  width: calc(100% - 14px);
  margin: 0 7px 8px;
  padding: 0.42rem 0.5rem 0.38rem;
  background: #FFFDF8;
  border-radius: 0.85rem;
  border: 2px solid rgba(43, 45, 66, 0.14);
  box-shadow: 0 2px 0 rgba(43, 45, 66, 0.06);
}

.card-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 0.92rem;
  line-height: 1.15;
  color: #2B2D42;
  letter-spacing: -0.02em;
  pointer-events: none;
}

.card-sub {
  margin-top: 0.12rem;
  font-size: 0.66rem;
  font-weight: 800;
  color: #2B2D42;
  opacity: 0.62;
  letter-spacing: 0.01em;
  pointer-events: none;
}

@media (min-width: 640px) {
  .brand-tagline { font-size: 0.7rem; letter-spacing: 0.14em; }
  .grid-scrim { padding: 1rem; border-radius: 1.75rem; }
  .sticker-card { min-height: 248px; }
  .card-art { min-height: 148px; }
  .card-photo { max-height: 152px; }
  .card-svg { max-width: 152px; max-height: 152px; }
  .card-svg svg { max-height: 152px; }
  .card-emoji { font-size: 5.1rem; }
  .card-label { font-size: 1.08rem; }
}

/* Sentence builder */
.starter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 3px solid var(--navy);
  background: var(--yellow);
  color: var(--navy);
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: 0 3px 0 var(--navy);
}

.starter-chip:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--navy);
}

.sentence-strip {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  background: #fff;
  border: 4px solid var(--navy);
  border-radius: 1.25rem;
  padding: 0.5rem;
  box-shadow: 0 5px 0 var(--navy);
  min-height: 72px;
}

.sentence-chips {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  min-width: 0;
}

.sentence-placeholder {
  color: var(--navy);
  opacity: 0.4;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 0 0.4rem;
}

.sent-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 64px;
  padding: 0.25rem 0.4rem;
  border-radius: 0.85rem;
  border: 3px solid var(--navy);
  background: #FFF8EE;
  box-shadow: 0 3px 0 var(--navy);
  flex-shrink: 0;
}

.sent-chip-starter { background: var(--yellow); }

.sent-emoji { font-size: 1.35rem; line-height: 1; }
.sent-svg { width: 28px; height: 28px; }
.sent-svg svg { width: 100%; height: 100%; display: block; }
.sent-word {
  font-family: 'Fredoka', cursive, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 0.1rem;
}

.sentence-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
}

.strip-btn {
  min-height: 36px;
  min-width: 64px;
  border-radius: 0.75rem;
  border: 3px solid var(--navy);
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  box-shadow: 0 2px 0 var(--navy);
}

.strip-btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--navy); }

.strip-play { background: var(--green); color: #fff; }
.strip-clear { background: #fff; color: var(--navy); }

.sentence-preview {
  margin-top: 0.4rem;
  text-align: center;
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--pink);
  min-height: 1.25rem;
}

/* Toast */
.speech-toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(92vw, 420px);
  padding: 0.7rem 1.2rem;
  background: #fff;
  color: var(--navy);
  border: 4px solid var(--navy);
  border-radius: 999px;
  box-shadow: 0 6px 0 var(--navy);
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  text-align: center;
  pointer-events: none;
}

/* Settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #F3EEE4;
  padding: 0.75rem;
  border-radius: 1rem;
  border: 2px solid rgba(43, 45, 66, 0.12);
}

.setting-label {
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--navy);
}

.visual-btn {
  padding: 0.3rem 0.65rem;
  border-radius: 0.75rem;
  font-size: 0.72rem;
  font-weight: 800;
  border: 2px solid var(--navy);
  background: #fff;
  color: var(--navy);
  min-height: 32px;
}

.visual-btn.is-on,
.visual-btn.active {
  background: var(--pink);
  color: #fff;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 2px solid var(--navy);
  background: #E8E4DA;
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.45;
}

.badge-pill.is-on {
  background: var(--yellow);
  opacity: 1;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  flex-shrink: 0;
}

.live-dot.is-speaking {
  background: var(--pink);
  box-shadow: 0 0 0 6px rgba(247, 37, 133, 0.18);
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.hidden { display: none !important; }

@keyframes popIn {
  0% { transform: scale(0.84); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.animate-pop-in { animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg) scale(0.98); }
  75% { transform: rotate(8deg) scale(0.98); }
}

.animate-wiggle { animation: wiggle 0.4s ease-in-out; }

@keyframes bounceSoft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.bounce-soft { animation: bounceSoft 1.6s cubic-bezier(0.34, 1.56, 0.64, 1) infinite; }

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

.float-blob { animation: floaty 8s ease-in-out infinite; }
.delay-2 { animation-delay: 1.4s; }
.delay-3 { animation-delay: 2.6s; }

@media (prefers-reduced-motion: reduce) {
  .bounce-soft, .float-blob, .animate-pop-in, .animate-wiggle { animation: none; }
}

@media (min-width: 900px) {
  .sticker-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 0 var(--navy), 0 20px 30px rgba(43, 45, 66, 0.2);
  }
}