/* ============================================
   Typing Kids Indonesia — Base styles
   Warm cream, pastel accents, Apple-quality polish
   ============================================ */

:root {
  --bg: #FFF6E9;
  --bg-soft: #FFF0DB;
  --card: #FFFFFF;
  --text: #3A2A1A;
  --text-soft: #6E5A44;
  --accent-blue: #A8D4F0;
  --accent-green: #A9D6BB;
  --accent-yellow: #FFE566;
  --accent-orange: #FFD4A8;
  --accent-pink: #FFB3A7;
  --accent-purple: #D4C4F0;
  --primary: #FFD94D;
  /* Brown — 5.3:1 on cream, passes WCAG AA for text (was #4A9FD8 at 2.9:1) */
  --primary-deep: #8A5A36;
  --shadow: 0 8px 32px rgba(58, 42, 26, 0.08);
  --shadow-soft: 0 4px 16px rgba(58, 42, 26, 0.06);
  --radius: 24px;
  --radius-sm: 16px;
  --font: 'Baloo 2', 'Nunito', system-ui, -apple-system, sans-serif;
  --letter-size: clamp(2rem, 6vw, 3.5rem);
  --image-size: clamp(160px, 28vw, 260px);
}

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

html {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  line-height: 1.4;
}

/* Background atmosphere — Poppu garden with soft cream scrim for readability */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background:
    linear-gradient(
      180deg,
      rgba(255, 246, 233, 0.72) 0%,
      rgba(255, 246, 233, 0.55) 45%,
      rgba(255, 246, 233, 0.68) 100%
    ),
    url('../assets/backgrounds/bg-garden.png') center / cover no-repeat,
    var(--bg);
}

.cloud {
  position: absolute;
  background: url('../assets/brand/decor/cloud.png') center / contain no-repeat;
  opacity: 0.85;
}

.cloud-1 {
  width: 150px;
  height: 100px;
  top: 10%;
  left: -160px;
  animation: cloud-drift 48s linear infinite;
}

.cloud-2 {
  width: 110px;
  height: 74px;
  top: 22%;
  left: -130px;
  animation: cloud-drift 62s linear infinite;
  animation-delay: -20s;
  opacity: 0.6;
}

.cloud-3 {
  width: 170px;
  height: 114px;
  top: 6%;
  left: -190px;
  animation: cloud-drift 55s linear infinite;
  animation-delay: -35s;
  opacity: 0.7;
}

.bird {
  position: absolute;
  width: 44px;
  height: 47px;
  top: 18%;
  left: -60px;
  opacity: 0.8;
  background: url('../assets/brand/decor/bird.png') center / contain no-repeat;
  animation: bird-fly 28s linear infinite;
}

.bird-2 {
  top: 28%;
  animation-duration: 36s;
  animation-delay: -12s;
  scale: 0.75;
}

/* App shell */
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  padding-top: max(1.5rem, env(safe-area-inset-top, 0px));
  padding-left: max(1.5rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.5rem, env(safe-area-inset-right, 0px));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

@media (min-width: 901px) {
  .app {
    /* Leave room for floating mute/help without covering title */
    padding-top: max(2rem, env(safe-area-inset-top, 0px));
  }
}

/* Prevent iOS double-tap zoom on UI */
button,
.osk-key,
.cat-btn,
.mode-btn,
.station-btn,
.length-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

/* Floating controls */
.mute-btn,
.help-btn,
.back-btn {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  z-index: 50;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
  font-family: var(--font);
  font-weight: 900;
  color: var(--primary-deep);
  touch-action: manipulation;
}

.back-btn {
  left: max(0.75rem, env(safe-area-inset-left, 0px));
  font-size: 1.5rem;
  line-height: 1;
}

.mute-btn {
  right: max(0.75rem, env(safe-area-inset-right, 0px));
}

.help-btn {
  right: calc(0.75rem + 52px + env(safe-area-inset-right, 0px));
  font-size: 1.25rem;
}

.mute-btn:hover,
.help-btn:hover,
.back-btn:hover {
  transform: scale(1.08);
}

.back-btn:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 3px;
}

/* In-game back (banner) — large tap target for kids */
.goal-top-row {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 0.15rem;
}

.btn-game-back {
  appearance: none;
  border: 2px solid #e8e0d5;
  background: var(--bg-soft);
  color: var(--primary-deep);
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
  transition: transform 0.12s ease, background 0.12s ease;
}

.btn-game-back:hover {
  background: #FFF3D1;
  border-color: var(--primary);
  transform: scale(1.03);
}

.btn-game-back:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 2px;
}

.mute-btn.is-muted {
  opacity: 0.85;
  background: #f0ebe3;
}

.mute-btn .mute-icon.hidden {
  display: none;
}

/* Parent summary on victory */
.parent-summary {
  text-align: left;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin: 0 0 1.25rem;
}

.parent-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-soft);
  margin-bottom: 0.5rem;
}

.parent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.parent-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.parent-list li:last-child {
  border-bottom: none;
}

.parent-k {
  color: var(--text-soft);
}

.parent-v {
  color: var(--text);
  font-weight: 800;
}

/* ---------- Start screen ---------- */
.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 520px;
  width: 100%;
  animation: fade-up 0.7s ease both;
}

.collection-bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  background: var(--card);
  border-radius: 999px;
  padding: 0.5rem 1.25rem;
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.25rem;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-soft);
}

.collection-rank {
  color: var(--primary-deep);
}

/* Poppu brand (light) */
.brand-mascot {
  width: auto;
  height: auto;
  margin-bottom: 0.35rem;
}

.brand-mascot img {
  width: clamp(100px, 22vw, 140px);
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 8px 16px rgba(61, 58, 53, 0.12));
  animation: float-soft 3.2s ease-in-out infinite;
}

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

.brand-host {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-deep);
  margin: -0.35rem 0 0.85rem;
}

.parent-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0.6rem 0 0.2rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.parent-links a {
  color: var(--text-soft);
  text-decoration: none;
}

.parent-links a:hover {
  color: var(--primary-deep);
  text-decoration: underline;
}

.victory-mascot {
  margin: 0 auto 0.35rem;
}

.victory-mascot img {
  width: clamp(90px, 18vw, 120px);
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 6px 14px rgba(61, 58, 53, 0.12));
  animation: letter-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* In-game corner host — small, non-blocking */
.game-screen {
  position: relative;
}

.game-mascot {
  position: absolute;
  top: 0.35rem;
  right: 0.25rem;
  width: clamp(48px, 10vw, 72px);
  height: auto;
  z-index: 4;
  pointer-events: none;
  opacity: 0.92;
  filter: drop-shadow(0 4px 10px rgba(61, 58, 53, 0.12));
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.game-mascot.is-cheer {
  animation: letter-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Friend companion — smaller, left of the Poppu host corner */
.game-companion {
  position: absolute;
  top: 0.5rem;
  right: clamp(3.2rem, 12vw, 4.6rem);
  width: clamp(36px, 8vw, 56px);
  height: auto;
  z-index: 4;
  pointer-events: none;
  opacity: 0.9;
  filter: drop-shadow(0 4px 10px rgba(61, 58, 53, 0.12));
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.game-companion.is-cheer {
  animation: letter-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Friend pose on world-map station cards */
.station-friend {
  width: clamp(40px, 9vw, 52px);
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(61, 58, 53, 0.14));
}

/* Friend jump pose beside Poppu on victory */
.victory-mascot {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0.4rem;
}

.victory-friend {
  width: clamp(56px, 13vw, 80px);
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(61, 58, 53, 0.12));
  animation: letter-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.game-screen.mode-hard .game-mascot {
  top: 0.25rem;
  opacity: 0.85;
}

@media (max-width: 600px) {
  .game-mascot {
    width: 44px;
    top: 0.15rem;
    right: 0.1rem;
  }

  .game-companion {
    width: 32px;
    top: 0.25rem;
    right: 2.7rem;
  }

  .goal-text {
    padding-right: 5.25rem;
  }
}

/* Mission length pick */
.length-pick {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.65rem 0 0.35rem;
  flex-wrap: wrap;
}

.length-btn {
  appearance: none;
  border: 2px solid #e8e0d5;
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
  min-height: 44px;
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
}

.length-btn.is-active {
  border-color: var(--primary);
  background: linear-gradient(145deg, #FFF3D1, #fff);
  color: var(--primary-deep);
  transform: scale(1.04);
}

/* Journey path */
.journey {
  position: relative;
  height: 36px;
  margin: 0.35rem 0 0.15rem;
}

.journey-track {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 0.35rem;
  position: relative;
}

.journey-track::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 4px;
  background: linear-gradient(90deg, #ffe566, #6cb4ee, #b8e6b8);
  border-radius: 999px;
  opacity: 0.55;
  z-index: 0;
}

.journey-node {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e0d8cc;
  z-index: 1;
  position: relative;
  transition: background 0.2s, transform 0.2s;
}

.journey-node.filled {
  background: #f4c430;
  box-shadow: 0 0 0 3px rgba(244, 196, 48, 0.35);
  transform: scale(1.15);
}

.journey-poppu {
  position: absolute;
  top: -8px;
  left: 0;
  width: 36px;
  height: auto;
  z-index: 2;
  transition: left 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.12));
  pointer-events: none;
}

/* Poppu bubble */
.poppu-bubble {
  background: #fff;
  border: 2px solid #ffe566;
  border-radius: 18px;
  padding: 0.45rem 0.85rem;
  margin: 0 0 0.65rem;
  max-width: 92%;
  box-shadow: var(--shadow-soft);
  position: relative;
  animation: fade-up 0.35s ease both;
}

.poppu-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 24px;
  border: 8px solid transparent;
  border-top-color: #ffe566;
}

.poppu-bubble.hidden {
  display: none !important;
}

.poppu-bubble-text {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary-deep);
}

/* Sticker book */
.sticker-book {
  width: 100%;
  max-width: 420px;
  margin: 0.5rem 0;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  padding: 0.35rem 0.85rem 0.75rem;
  text-align: left;
}

.sticker-book summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary-deep);
  padding: 0.4rem 0;
  list-style: none;
}

.sticker-book summary::-webkit-details-marker {
  display: none;
}

.sticker-hint {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-soft);
  margin: 0 0 0.5rem;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.45rem;
  max-height: 200px;
  overflow-y: auto;
}

.sticker-cell {
  appearance: none;
  border: 2px dashed #e8e0d5;
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 0.25rem;
  cursor: pointer;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  transition: transform 0.12s, border-color 0.15s;
}

.sticker-cell.is-on {
  border-style: solid;
  border-color: #ffe566;
  background: #fff;
}

.sticker-cell.is-on:hover {
  transform: scale(1.06);
}

.sticker-cell img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.sticker-cell .sticker-name {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sticker-cell.is-off {
  opacity: 0.45;
  filter: grayscale(0.8);
  cursor: default;
}

.sticker-toast {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 248, 240, 0.92);
  border-radius: var(--radius);
  z-index: 8;
  animation: letter-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sticker-toast.hidden {
  display: none !important;
}

.sticker-toast img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.12));
}

.sticker-toast-text {
  margin-top: 0.5rem;
  font-weight: 900;
  color: var(--primary-deep);
  font-size: 1.1rem;
}

/* Friendship */
.friendship-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: #e17055;
  background: #fff5f0;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

/* World map */
.world-map {
  width: 100%;
  max-width: 440px;
  margin: 0.35rem 0 0.85rem;
  padding: 0.75rem 0.85rem 0.9rem;
  background:
    linear-gradient(160deg, rgba(255, 246, 233, 0.82), rgba(255, 246, 233, 0.72)),
    url('../assets/backgrounds/worldmap.png') center / cover no-repeat;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border: 2px solid rgba(138, 90, 42, 0.35);
}

.world-map-title {
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--primary-deep);
  margin: 0 0 0.55rem;
  text-align: center;
}

.world-stations {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.station-btn {
  appearance: none;
  border: 2px solid #e8e0d5;
  background: #fff;
  border-radius: 16px;
  padding: 0.55rem 0.35rem;
  cursor: pointer;
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-height: 96px;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}

.station-btn:hover {
  transform: translateY(-2px);
}

.station-btn.is-active {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(138, 90, 42, 0.35);
  background: linear-gradient(160deg, #fff, #FFF3D1);
}

.station-emoji {
  font-size: 1.55rem;
  line-height: 1;
}

.station-name {
  font-weight: 900;
  font-size: 0.72rem;
  color: var(--text);
  text-align: center;
  line-height: 1.15;
}

.station-desc {
  font-weight: 700;
  font-size: 0.65rem;
  color: var(--text-soft);
  text-align: center;
}

.victory-friendship {
  font-weight: 800;
  font-size: 1rem;
  color: #e17055;
  margin: 0.15rem 0 0.5rem;
  min-height: 1.3em;
}

@media (max-width: 480px) {
  .world-stations {
    grid-template-columns: 1fr;
  }
  .station-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.65rem;
    min-height: 56px;
    padding: 0.5rem 0.85rem;
    text-align: left;
  }
  .station-friend {
    width: 34px;
  }
  .station-name,
  .station-desc {
    text-align: left;
  }
}

.collection-streak {
  color: #e17055;
  font-size: 0.85rem;
}

/* Daily mission card */
.daily-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(145deg, #fff9e8, #fff);
  border: 2px solid #ffe566;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem 1rem;
  margin: 0.75rem 0 0.5rem;
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.daily-card.is-done {
  border-color: var(--accent-green);
  background: linear-gradient(145deg, #f0faf0, #fff);
}

.daily-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.daily-title {
  font-weight: 900;
  font-size: 1rem;
  color: var(--primary-deep);
  margin: 0;
}

.daily-badge {
  font-size: 1rem;
}

.daily-desc {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-soft);
  margin: 0.35rem 0 0.65rem;
}

.btn-daily {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.95rem;
  color: #3d3a35;
  background: linear-gradient(145deg, #ffe566, #ffd43b);
  padding: 0.55rem 1.25rem;
  border-radius: 999px;
  min-height: 44px;
  box-shadow: 0 4px 12px rgba(244, 196, 48, 0.35);
  transition: transform 0.15s ease;
}

.btn-daily:hover:not(:disabled) {
  transform: scale(1.04);
}

.btn-daily:disabled {
  opacity: 0.75;
  cursor: default;
  background: var(--accent-green);
  box-shadow: none;
}

/* Classroom panel */
.class-panel {
  width: 100%;
  max-width: 420px;
  margin: 0.5rem 0 0.75rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  text-align: left;
  padding: 0.35rem 0.85rem 0.65rem;
}

.class-panel summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary-deep);
  padding: 0.4rem 0;
  list-style: none;
}

.class-panel summary::-webkit-details-marker {
  display: none;
}

.class-body {
  padding-bottom: 0.35rem;
}

.class-active {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text);
  margin: 0.25rem 0 0.5rem;
}

.class-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.class-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  border: 2px solid #e8e0d5;
  border-radius: 12px;
  padding: 0.45rem 0.6rem;
  background: var(--bg-soft);
  color: var(--text);
}

.class-input:focus {
  outline: none;
  border-color: var(--primary);
}

.class-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.btn-sm {
  min-height: 40px !important;
  padding: 0.45rem 0.9rem !important;
  font-size: 0.85rem !important;
}

.class-msg {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-deep);
  min-height: 1.2em;
  margin-top: 0.4rem;
  text-align: center;
}

/* Combo badge */
.combo-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: linear-gradient(145deg, #ff9f7a, #ff6b6b);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
  vertical-align: middle;
}

.combo-badge.combo-pop {
  animation: letter-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Easy: dim typed letters in full word */
.word-full .wf-letter {
  display: inline-block;
  transition: opacity 0.2s ease, color 0.2s ease, transform 0.2s ease;
  min-width: 0.55em;
}

.word-full .wf-letter.is-done {
  opacity: 0.35;
  color: var(--text-soft);
}

.word-full .wf-letter.is-current {
  color: var(--primary-deep);
  transform: scale(1.12);
  text-shadow: 0 2px 0 rgba(138, 90, 42, 0.2);
}

.share-msg {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-deep);
  min-height: 1.2em;
  margin-top: 0.5rem;
}

.mission-title {
  font-size: 0.95rem !important;
  font-weight: 800 !important;
  color: var(--primary-deep) !important;
  margin-bottom: 0.25rem !important;
}

.mission-goal {
  font-size: 1.2rem !important;
  color: var(--text) !important;
  font-weight: 800 !important;
  margin-bottom: 0.75rem !important;
}

.mission-preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 0.85rem;
}

.preview-star {
  color: #A98B62;
  font-size: 1.15rem;
}

.mode-pick {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 1.25rem;
}

.mode-pick-3 {
  gap: 0.5rem;
}

.mode-pick-3 .mode-btn {
  padding: 0.75rem 0.35rem;
}

.mode-pick-3 .mode-desc {
  font-size: 0.72rem;
  line-height: 1.2;
}

/* Language toggle */
.lang-pick {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.lang-btn {
  appearance: none;
  border: 2px solid transparent;
  background: var(--card);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.lang-btn:hover {
  transform: translateY(-1px);
}

.lang-btn.is-active {
  border-color: var(--primary);
  background: linear-gradient(145deg, #FFF3D1, #fff);
  color: var(--primary-deep);
}

.pick-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-soft);
  margin: 0 0 0.5rem;
  width: 100%;
  text-align: left;
}

.cat-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  width: 100%;
  margin-bottom: 1.25rem;
  justify-content: center;
}

.cat-btn {
  appearance: none;
  border: 2px solid transparent;
  background: var(--card);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.cat-btn:hover {
  transform: translateY(-1px);
}

.cat-btn.is-active {
  border-color: var(--primary);
  background: linear-gradient(145deg, #FFF3D1, #fff);
  color: var(--primary-deep);
}

.cat-emoji {
  font-size: 1rem;
}

/* Full word (Easy + Medium) — whole word, not one letter */
.word-full {
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 900;
  color: var(--text);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0.25rem 0 0.85rem;
  text-align: center;
  min-height: 1.2em;
}

.word-full.hidden {
  display: none !important;
}

.word-full.word-full-pop {
  animation: letter-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Big single letter — Easy only; force-hide if mode-medium/hard */
.game-screen.mode-medium #target-block,
.game-screen.mode-hard #target-block {
  display: none !important;
}

.game-screen.mode-medium #kb-hint {
  display: none !important;
}

/* Hard timer */
.timer-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-weight: 800;
  color: var(--primary-deep);
  font-size: 1rem;
}

.timer-wrap.is-urgent {
  color: #e17055;
  animation: glow-pulse 0.8s ease-in-out infinite;
}

.timer-value {
  font-size: 1.35rem;
  font-weight: 900;
  min-width: 1.5em;
  text-align: center;
}

.timer-unit {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* Tutorial overlay */
.tutorial {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 248, 240, 0.88);
  backdrop-filter: blur(6px);
  padding: 1.25rem;
}

.tutorial.hidden {
  display: none;
}

.tutorial-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: fade-up 0.4s ease both;
}

.tutorial-step {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.tutorial-card h2 {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.tutorial-body {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 1.25rem;
  line-height: 1.45;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.tut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e0d8cc;
}

.tut-dot.is-on {
  background: var(--primary);
  transform: scale(1.2);
}

.tutorial-skip {
  margin-top: 0.65rem;
  min-height: 44px;
  font-size: 0.95rem;
}

/* Parental gate overlay */
.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 248, 240, 0.88);
  backdrop-filter: blur(6px);
  padding: 1.25rem;
}

.gate-overlay.hidden {
  display: none;
}

.gate-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: fade-up 0.4s ease both;
}

.gate-card h2 {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.gate-instruction {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 1rem;
  line-height: 1.45;
}

.gate-question {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
  margin: 0 0 1rem;
}

.gate-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.gate-answer {
  min-height: 56px;
  font-size: 1.25rem;
  font-weight: 900;
}

.gate-msg {
  min-height: 1.4rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-deep);
  margin: 0 0 0.5rem;
}

.gate-close {
  min-height: 44px;
  font-size: 0.95rem;
}

.mode-btn {
  flex: 1;
  appearance: none;
  border: 3px solid transparent;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  padding: 0.85rem 0.5rem;
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.mode-btn:hover {
  transform: translateY(-2px);
}

.mode-btn.is-active {
  border-color: var(--primary);
  background: linear-gradient(145deg, #FFF3D1, #fff);
  box-shadow: 0 4px 16px rgba(138, 90, 42, 0.25);
}

.mode-emoji {
  font-size: 1.5rem;
}

.mode-name {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
}

.mode-desc {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.logo-mark {
  width: 100px;
  height: 100px;
  border-radius: 28px;
  background: linear-gradient(145deg, var(--accent-yellow), var(--accent-orange));
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin-bottom: 1.5rem;
  animation: float-gentle 3.5s ease-in-out infinite;
}

.logo-mark svg {
  width: 64px;
  height: 64px;
}

.start-screen h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.start-screen .subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 2rem;
}

.start-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 2rem;
  width: 100%;
  margin-bottom: 1.75rem;
}

.start-card p {
  font-size: 1.05rem;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.start-card .hint {
  font-size: 0.95rem;
  color: var(--primary-deep);
  font-weight: 700;
}

.btn-start {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 800;
  color: #3A2A1A;
  background: linear-gradient(145deg, var(--accent-yellow), var(--primary));
  padding: 1.1rem 3.5rem;
  border-radius: 999px;
  box-shadow:
    0 8px 24px rgba(138, 90, 42, 0.35),
    0 2px 0 rgba(255, 255, 255, 0.25) inset;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 64px;
  min-width: 200px;
}

.btn-start:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 28px rgba(138, 90, 42, 0.4);
}

.btn-start:active {
  transform: translateY(1px) scale(0.98);
}

.btn-start:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 4px;
}

.start-footer {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-soft);
  font-weight: 600;
}

/* ---------- Game screen ---------- */
.game-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 720px;
  min-height: min(90vh, 800px);
  animation: fade-up 0.45s ease both;
}

/* Session goal / star chase */
.goal-banner {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.goal-text {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  /* Keep the remaining-stars line clear of the corner mascots */
  padding-right: clamp(5.5rem, 16vw, 9rem);
}

.goal-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.goal-remaining {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-deep);
}

.star-track {
  display: flex;
  justify-content: space-between;
  gap: 0.2rem;
}

.star-slot {
  flex: 1;
  text-align: center;
  line-height: 1;
  transition: transform 0.2s ease;
}

/* Poppu gold star icon — dim/grayscale until earned */
.star-icon {
  width: clamp(1.15rem, 4vw, 1.6rem);
  height: auto;
  vertical-align: middle;
  opacity: 0.28;
  filter: grayscale(1);
  transition: opacity 0.2s ease, filter 0.2s ease, transform 0.2s ease;
}

.star-slot.filled .star-icon,
.victory-star .star-icon,
.target-letter.done .star-icon {
  opacity: 1;
  filter: grayscale(0) drop-shadow(0 2px 6px rgba(255, 217, 77, 0.5));
}

.target-letter.done .star-icon {
  width: clamp(2.6rem, 9vw, 3.6rem);
}

.star-slot.star-pop {
  animation: letter-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.goal-count {
  text-align: center;
  font-weight: 900;
  font-size: 1rem;
  color: var(--text);
}

/* Top bar */
.top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-soft);
}

.progress-track {
  height: 14px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-green), var(--primary));
  transition: width 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-chip {
  background: var(--card);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
  color: var(--primary-deep);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.score-chip .star-icon {
  color: #F4C430;
}

/* Main card */
.game-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: visible;
}

/* Invisible focus trap for reliable keyboard capture */
.key-catcher {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  caret-color: transparent;
  color: transparent;
  background: transparent;
  z-index: -1;
  /* ≥16px prevents iOS auto-zoom on focus */
  font-size: 16px;
}

.image-wrap {
  position: relative;
  width: var(--image-size);
  height: calc(var(--image-size) + 28px);
  margin-bottom: 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 28px;
}

.image-wrap::before {
  content: '';
  position: absolute;
  width: 110%;
  height: 110%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--bg-soft) 0%, transparent 70%);
  z-index: 0;
}

#word-image {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: var(--image-size);
  max-height: var(--image-size);
  /* Icons: show whole picture (not cropped photos) */
  object-fit: contain;
  object-position: center;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(61, 58, 53, 0.1);
  padding: 0.5rem;
  user-select: none;
  -webkit-user-drag: none;
  cursor: pointer;
}

/* Solid color swatches: full block of one color only */
#word-image[src*="merah.png"],
#word-image[src*="biru.png"],
#word-image[src*="hijau.png"],
#word-image[src*="kuning.png"],
#word-image[src*="putih.png"],
#word-image[src*="hitam.png"],
#word-image[src*="ungu.png"],
#word-image[src*="pink.png"],
#word-image[src*="oranye.png"],
#word-image[src*="coklat.png"] {
  object-fit: fill;
  padding: 0;
  background: transparent;
}

.word-label {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 800;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  pointer-events: none;
  white-space: nowrap;
}

.word-label.is-hidden {
  display: none;
}

.word-label.label-reveal {
  animation: fade-up 0.4s ease both;
}

.speak-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 5;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid #fff;
  cursor: pointer;
  background: linear-gradient(145deg, var(--accent-yellow), var(--primary));
  box-shadow: 0 6px 16px rgba(138, 90, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3A2A1A;
  transition: transform 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

.speak-btn:hover {
  transform: scale(1.1);
}

.speak-btn:active {
  transform: scale(0.92);
}

.speak-btn:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 2px;
}

.speak-btn svg {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

/* Big target letter to type */
.target-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1rem;
  user-select: none;
}

.target-hint {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 0.4rem;
}

.target-letter {
  width: clamp(4.5rem, 14vw, 6rem);
  height: clamp(4.5rem, 14vw, 6rem);
  border-radius: 20px;
  background: linear-gradient(145deg, #FFF3D1, #FFE9A8);
  border: 3px solid var(--primary);
  box-shadow:
    0 0 0 6px rgba(138, 90, 42, 0.2),
    0 8px 24px rgba(138, 90, 42, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.5rem, 10vw, 3.75rem);
  font-weight: 900;
  color: var(--primary-deep);
  animation: glow-pulse 1.6s ease-in-out infinite;
  cursor: default;
}

.target-letter.done {
  background: linear-gradient(145deg, var(--accent-green), #9DD99D);
  border-color: #7CB87C;
  color: #2D5A2D;
  animation: none;
}

.target-letter.target-pop {
  animation: letter-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), glow-pulse 1.6s ease-in-out 0.4s infinite;
}

/* Letter slots — display only, not buttons */
.word-slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(0.4rem, 1.5vw, 0.75rem);
  margin-bottom: 1.25rem;
  min-height: calc(var(--letter-size) + 1rem);
  padding: 0.25rem;
  cursor: default;
}

.letter-slot {
  font-size: var(--letter-size);
  font-weight: 800;
  width: clamp(2.5rem, 7vw, 3.75rem);
  height: clamp(3rem, 8vw, 4.25rem);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  letter-spacing: 0;
  pointer-events: auto;
  transition:
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.2s ease,
    box-shadow 0.2s ease,
    color 0.15s ease;
}

.slot-dash {
  display: block;
  width: 40%;
  height: 4px;
  border-radius: 2px;
  background: #C8C0B4;
}

.letter-slot.empty {
  color: #C8C0B4;
}

.letter-slot.current {
  background: linear-gradient(145deg, #FFF3D1, #FFE9A8);
  color: var(--primary-deep);
  box-shadow:
    0 0 0 3px rgba(138, 90, 42, 0.45),
    0 4px 12px rgba(138, 90, 42, 0.2);
  animation: glow-pulse 1.6s ease-in-out infinite;
}

.letter-slot.current .slot-dash {
  background: var(--primary-deep);
  opacity: 0.55;
}

.letter-slot.filled {
  background: linear-gradient(145deg, var(--accent-green), #9DD99D);
  color: #2D5A2D;
  box-shadow: 0 4px 12px rgba(155, 200, 155, 0.35);
}

.letter-slot.pop {
  animation: letter-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.encouragement {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 700;
  color: var(--text-soft);
  text-align: center;
  min-height: 1.6em;
}

/* Praise overlay */
.praise-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 248, 240, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 5;
  border-radius: var(--radius);
}

.praise-overlay.visible {
  opacity: 1;
}

.praise-text {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 900;
  color: var(--primary-deep);
  text-shadow: 0 4px 20px rgba(138, 90, 42, 0.3);
  animation: praise-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* FX canvas */
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* Keyboard hint strip */
.kb-hint {
  margin-top: 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-soft);
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kb-hint kbd {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 2px 0 #E0D8CC;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text);
}

/* ---------- Milestone toast ---------- */
.milestone-toast {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 248, 240, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.milestone-toast.visible {
  opacity: 1;
}

.milestone-toast.hidden {
  display: none;
}

.milestone-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2.5rem;
  text-align: center;
  animation: praise-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90vw;
}

.milestone-trophy {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.milestone-title {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 900;
  color: var(--primary-deep);
}

.milestone-sub {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-top: 0.35rem;
}

/* ---------- Victory screen ---------- */
.victory-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 520px;
  animation: fade-up 0.5s ease both;
}

.victory-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.75rem, 4vw, 2.5rem);
  width: 100%;
  text-align: center;
}

.victory-trophy {
  font-size: 4rem;
  line-height: 1;
  animation: float-gentle 2.5s ease-in-out infinite;
}

.victory-card h2 {
  font-size: clamp(2rem, 7vw, 2.75rem);
  font-weight: 900;
  color: var(--primary-deep);
  margin: 0.5rem 0 0.25rem;
}

.victory-sub {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 1rem;
}

.victory-stars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem;
  margin-bottom: 1.25rem;
}

.victory-star {
  animation: letter-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.victory-star .star-icon {
  width: 1.5rem;
}

.victory-stats {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  flex: 1;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-val {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text);
}

.stat-lbl {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-soft);
}

.victory-next {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-deep);
  margin-bottom: 1.25rem;
  min-height: 1.4em;
}

.victory-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.btn-secondary {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-soft);
  background: var(--bg-soft);
  padding: 0.85rem 2rem;
  border-radius: 999px;
  min-height: 52px;
  transition: transform 0.15s ease;
}

.btn-secondary:hover {
  transform: scale(1.03);
  color: var(--text);
}

.btn-secondary:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 3px;
}

/* Mode layouts */
.game-screen.mode-hard .game-card {
  padding-top: clamp(2rem, 5vw, 3rem);
  padding-bottom: clamp(2rem, 5vw, 3rem);
}

.game-screen.mode-hard .image-wrap {
  --image-size: clamp(200px, 36vw, 300px);
  width: var(--image-size);
  height: calc(var(--image-size) + 28px);
  margin-bottom: 1.25rem;
}

.kb-hint-hard {
  font-weight: 700;
  color: var(--primary-deep);
}

/* Responsive */
@media (max-width: 600px) {
  .app {
    padding: 0.75rem;
    padding-top: max(3.5rem, calc(env(safe-area-inset-top, 0px) + 3rem));
    justify-content: flex-start;
  }

  .start-screen {
    max-width: 100%;
    padding-bottom: 1.5rem;
  }

  .brand-mascot img {
    width: clamp(80px, 28vw, 110px);
  }

  h1#app-title {
    font-size: clamp(1.45rem, 7vw, 1.85rem);
    padding: 0 0.5rem;
  }

  .collection-bar {
    width: 100%;
    max-width: 100%;
    border-radius: 18px;
    gap: 0.4rem 0.65rem;
    font-size: 0.8rem;
    padding: 0.55rem 0.75rem;
    justify-content: center;
  }

  .friendship-chip {
    font-size: 0.75rem;
  }

  .world-map {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .mission-row {
    max-width: 100%;
    flex-direction: column;
  }

  .mission-row .daily-card {
    flex: 1 1 auto;
    width: 100%;
  }

  .start-card,
  .sticker-book,
  .parent-dash,
  .class-panel {
    max-width: 100%;
  }

  .mode-pick-4 {
    max-width: 100%;
  }

  .game-screen {
    min-height: auto;
    max-width: 100%;
    width: 100%;
    padding-bottom: 0.5rem;
  }

  .goal-banner {
    padding: 0.65rem 0.75rem;
  }

  .star-track {
    gap: 0.1rem;
  }

  .star-slot .star-icon {
    width: clamp(0.95rem, 4.5vw, 1.25rem);
  }

  .journey {
    height: 32px;
  }

  .journey-poppu {
    width: 30px;
    top: -6px;
  }

  .game-card {
    padding: 1rem 0.85rem 1.15rem;
    width: 100%;
  }

  .top-bar {
    flex-wrap: wrap;
  }

  .speak-btn {
    width: 44px;
    height: 44px;
  }

  .target-letter {
    font-size: clamp(2.5rem, 16vw, 3.5rem);
  }

  .word-full {
    font-size: clamp(1.25rem, 6vw, 1.75rem);
    letter-spacing: 0.08em;
  }

  .word-slots {
    gap: 0.35rem;
  }

  .letter-slot {
    min-width: 2rem;
    font-size: 1.15rem;
  }

  .kb-hint,
  .kb-hint-hard {
    font-size: 0.85rem;
    padding: 0 0.5rem;
    text-align: center;
  }

  .mute-btn,
  .help-btn,
  .back-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .help-btn {
    right: calc(0.5rem + 48px + env(safe-area-inset-right, 0px));
  }

  .victory-card {
    padding: 1.25rem 1rem;
    max-width: 100%;
  }

  .victory-actions {
    width: 100%;
  }

  .victory-actions .btn-start,
  .victory-actions .btn-secondary {
    width: 100%;
    max-width: 100%;
  }

  /* Finger guide less useful / crowded on tiny screens */
  .osk-finger {
    display: none;
  }
}

@media (min-width: 1366px) {
  .game-screen {
    max-width: 780px;
  }
}

@media (min-width: 1920px) {
  :root {
    --image-size: 280px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .cloud,
  .bird {
    animation: none !important;
  }
}

/* ========== v1.7 improvements ========== */
.mission-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  width: 100%;
  max-width: 420px;
  justify-content: center;
}

.mission-row .daily-card {
  flex: 1 1 180px;
  margin: 0;
  max-width: none;
}

.weekly-card {
  border-color: #a8d4f0;
  background: linear-gradient(145deg, #eef7fc, #fff);
}

.btn-weekly {
  background: linear-gradient(145deg, #c9e8d4, var(--accent-green)) !important;
  box-shadow: 0 4px 12px rgba(138, 90, 42, 0.25) !important;
}

.mode-pick-4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  width: 100%;
  max-width: 420px;
}

.mode-pick-4 .mode-btn {
  min-height: 72px;
}

/* Parent dash */
.parent-dash {
  width: 100%;
  max-width: 420px;
  margin: 0.5rem 0;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  padding: 0.35rem 0.85rem 0.65rem;
  text-align: left;
}

.parent-dash summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary-deep);
  padding: 0.4rem 0;
  list-style: none;
}

.parent-dash summary::-webkit-details-marker { display: none; }

.parent-dash-list {
  list-style: none;
  margin: 0.35rem 0;
  padding: 0;
}

.parent-dash-list li {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.2rem 0;
}

.mastery-title, .badges-title, .a11y-title {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 0.55rem 0 0.25rem;
}

.mastery-line {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin: 0 0 0.35rem;
}

.badges-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--bg-soft);
  color: var(--text-soft);
}

.badge-chip.is-on {
  background: linear-gradient(145deg, #ffe566, #fff3c4);
  color: var(--text);
}

.badge-chip.is-off {
  opacity: 0.4;
  filter: grayscale(0.6);
}

.badge-name {
  max-width: 7em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.a11y-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.a11y-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.class-name-input {
  width: 100%;
  margin-bottom: 0.5rem;
  letter-spacing: normal !important;
  text-transform: none !important;
  text-align: left !important;
  padding-left: 0.75rem !important;
}

.class-board {
  margin: 0.35rem 0;
  padding-left: 1.25rem;
  font-weight: 700;
  font-size: 0.85rem;
}

.class-board li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0;
}

.class-board-title {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 0.4rem 0 0;
}

/* On-screen keyboard */
.osk {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0.75rem auto 0.25rem;
  padding: 0.65rem 0.4rem 0.85rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  touch-action: manipulation;
  user-select: none;
}

.osk-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}

.osk-row {
  display: flex;
  gap: 0.28rem;
  justify-content: center;
}

.osk-row-mid { padding-left: 0.6rem; }
.osk-row-bot { padding-left: 1.4rem; }

.osk-key {
  appearance: none;
  border: 2px solid #e8e0d5;
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  font-weight: 900;
  font-size: clamp(0.85rem, 2.8vw, 1.05rem);
  min-width: clamp(1.65rem, 7.2vw, 2.55rem);
  min-height: clamp(2.2rem, 9vw, 2.85rem);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 0 #e0d8cc;
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
  touch-action: manipulation;
}

.osk-key:active,
.osk-key.is-pressed {
  transform: translateY(2px);
  box-shadow: none;
}

.osk-key.is-target {
  border-color: var(--primary);
  background: linear-gradient(145deg, #FFF3D1, #fff);
  color: var(--primary-deep);
  box-shadow: 0 0 0 3px rgba(138, 90, 42, 0.35);
  transform: scale(1.08);
  z-index: 1;
}

.osk-key.is-ok {
  background: #b8e6b8 !important;
  border-color: #5b8c5a !important;
}

.osk-key.is-bad {
  background: #ffc4d6 !important;
  border-color: #e17055 !important;
}

.osk-finger {
  position: absolute;
  font-size: 1.35rem;
  pointer-events: none;
  transform: translate(-50%, -100%);
  opacity: 0;
  transition: left 0.25s ease, top 0.25s ease, opacity 0.2s ease;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
  animation: finger-bounce 0.9s ease-in-out infinite;
}

.osk-finger.is-on { opacity: 1; }

@keyframes finger-bounce {
  0%, 100% { transform: translate(-50%, -100%); }
  50% { transform: translate(-50%, calc(-100% - 6px)); }
}

/* Speak pulse */
.speak-btn.is-speaking,
.image-wrap.is-speaking #word-image {
  animation: glow-pulse 0.7s ease-in-out infinite;
}

.speak-btn.is-speaking {
  box-shadow: 0 0 0 4px rgba(138, 90, 42, 0.45);
}

/* Letters mode: bigger target */
.game-screen.mode-letters #target-letter {
  font-size: clamp(3.5rem, 14vw, 5.5rem);
}

.game-screen.mode-letters .image-wrap.hidden {
  display: none !important;
}

/* Achievement toast */
.ach-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--card);
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 800;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90vw;
}

.ach-toast.visible {
  transform: translateX(-50%) translateY(0);
}

.ach-toast.hidden { display: none; }
.ach-toast.visible.hidden { display: flex; }

.ach-toast-emoji { font-size: 1.6rem; }
.ach-toast-title { font-size: 0.75rem; color: var(--text-soft); margin: 0; }
.ach-toast-name { font-size: 1rem; color: var(--primary-deep); margin: 0; }

/* A11y */
html.a11y-contrast {
  --bg: #fff;
  --text: #000;
  --text-soft: #222;
  --card: #fff;
  --primary: #005a9e;
  --primary-deep: #003d6b;
}

html.a11y-contrast body {
  background: #fff;
  color: #000;
}

/* Keep text on the accent-yellow → primary gradient readable: the gradient's
   yellow end stays light in high-contrast mode, so use solid primary + white. */
html.a11y-contrast .btn-start,
html.a11y-contrast .speak-btn {
  color: #fff;
  background: var(--primary);
}

html.a11y-large {
  font-size: 112%;
}

html.a11y-large .osk-key {
  min-height: 3rem;
}

/* Touch / tablet polish */
@media (max-width: 900px) {
  .btn-start {
    min-height: 64px;
    font-size: 1.2rem;
    width: min(100%, 100%);
    max-width: 420px;
  }

  .osk {
    position: sticky;
    bottom: 0;
    z-index: 6;
    max-width: 100%;
    margin-top: 0.5rem;
    margin-bottom: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(61, 58, 53, 0.08);
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  }

  .osk-row-mid {
    padding-left: 0.35rem;
  }

  .osk-row-bot {
    padding-left: 0.85rem;
  }

  .osk-key {
    min-width: clamp(1.7rem, 8.2vw, 2.4rem);
    min-height: clamp(2.5rem, 10vw, 3rem);
    font-size: clamp(0.9rem, 3.2vw, 1.1rem);
    border-width: 1.5px;
  }

  /* Game layout: image a bit smaller so OSK fits above fold */
  :root {
    --image-size: clamp(120px, 32vw, 200px);
  }

  .game-mascot {
    width: 40px;
    top: 0.1rem;
    right: 0.05rem;
    opacity: 0.88;
  }

  .game-companion {
    width: 30px;
    top: 0.2rem;
    right: 2.5rem;
    opacity: 0.85;
  }

  .poppu-bubble {
    max-width: 100%;
    font-size: 0.9rem;
  }

  .poppu-bubble-text {
    font-size: 0.9rem;
  }
}

@media (max-width: 600px) {
  .mode-pick-4 {
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 100%;
  }

  .mode-pick-4 .mode-btn {
    min-height: 68px;
    padding: 0.5rem 0.35rem;
  }

  .mode-pick-4 .mode-desc {
    font-size: 0.68rem;
  }

  .osk {
    /* Full-bleed: escape .app's 0.75rem side padding to buy key width */
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    width: calc(100% + 1.5rem);
    max-width: none;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
  }

  .osk-row {
    /* Rows are shrink-wrapped by .osk-rows' align-items: center; stretch
       them so keys can grow to fill the full width */
    align-self: stretch;
    gap: 0.14rem;
  }

  .osk-key {
    /* Grow to fill the row (10 keys worst case), capped so wide rows
       don't stretch keys past a comfortable size */
    flex: 1 1 0;
    min-width: 0;
    max-width: 2.3rem;
    min-height: 2.75rem;
    padding: 0;
  }

  .collection-bar {
    gap: 0.45rem;
    font-size: 0.8rem;
  }

  .length-pick {
    width: 100%;
  }

  .length-btn {
    flex: 1;
    min-width: 0;
  }

  .cat-pick {
    justify-content: center;
  }

  .cat-btn {
    min-height: 44px;
  }
}

/* Landscape phones — keep OSK usable */
@media (max-height: 480px) and (orientation: landscape) {
  .brand-mascot img {
    width: 64px;
  }

  .game-screen .goal-banner {
    padding: 0.4rem 0.6rem;
  }

  .journey {
    display: none;
  }

  .game-mascot {
    display: none;
  }

  .game-companion {
    display: none;
  }

  :root {
    --image-size: 88px;
  }

  .osk-key {
    min-height: 2.2rem;
  }
}

/* Safe area extras */
@supports (padding: env(safe-area-inset-bottom)) {
  .app {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}
