/* ============================================================
     SECTION 2: CSS - COMPLETE STYLESHEET
     ============================================================ */

  /* ---------- CSS Reset ---------- */
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
  }

  /* ---------- Root Variables ---------- */
  :root {
    --color-red:        #E63946;
    --color-yellow:     #FFD166;
    --color-blue:       #457B9D;
    --color-green:      #2DC653;
    --color-orange:     #F4A261;
    --color-purple:     #9B5DE5;
    --color-teal:       #2EC4B6;
    --bg-main:          #FFFBF0;
    --bg-card:          #FFFFFF;
    --bg-overlay:       rgba(0,0,0,0.18);
    --text-dark:        #2D2D2D;
    --text-light:       #FFFFFF;
    --font-display:     'Fredoka One', cursive;
    --font-body:        'Nunito', sans-serif;
    --radius-card:      20px;
    --radius-btn:       16px;
    --radius-zone:      28px;
    --shadow-card:      0 6px 20px rgba(0,0,0,0.12);
    --shadow-zone:      0 6px 20px rgba(0,0,0,0.15);
  }

  /* ---------- Body / Base ---------- */
  html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    color: var(--text-dark);
    background: var(--bg-main);
    animation: bgShift 20s ease-in-out infinite alternate;
  }

  @keyframes bgShift {
    0%   { background-color: #FFFBF0; }
    25%  { background-color: #FFF5E0; }
    50%  { background-color: #F0FFF5; }
    75%  { background-color: #F0F5FF; }
    100% { background-color: #FFF0FB; }
  }

  /* ---------- Screen System ---------- */
  #game-root {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .screen {
    position: absolute;
    top: 64px;               /* sit BELOW the fixed top bar (64px) */
    left: 0;
    width: 100%;
    height: calc(100% - 64px); /* band between top bar and bottom of root */
    display: none;
    flex-direction: column;
    align-items: center;
    padding-bottom: 140px;   /* room for the fixed 120px mascot bar + gap */
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
  }

  .screen.active {
    display: flex;
  }

  /* ---------- Top Bar ---------- */
  #top-bar {
    position: relative;
    z-index: 100;
    width: 100%;
    height: 64px;
    min-height: 64px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(8px);
    border-bottom: 2px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
  }

  #logo {
    font-family: var(--font-display);
    font-size: 24px;
    color: var(--color-purple);
    letter-spacing: 0.5px;
  }

  #star-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--color-purple);
    border-radius: 999px;
    padding: 6px 16px;
    font-family: var(--font-display);
    font-size: 22px;
    color: white;
  }

  #star-icon {
    display: inline-block;
    transition: transform 0.2s;
  }

  #star-icon.pop {
    animation: starPop 0.5s ease forwards;
  }

  #lang-toggle {
    min-width: 88px;
    min-height: 88px;
    border-radius: 999px;
    border: 2px solid var(--color-teal);
    background: white;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-dark);
    transition: background 0.2s, transform 0.1s;
  }

  #lang-toggle:active {
    transform: scale(0.95);
    background: var(--color-teal);
    color: white;
  }

  #lang-label-zh {
    color: var(--color-teal);
    font-weight: 900;
  }

  #lang-label-en {
    color: var(--text-dark);
    font-weight: 900;
  }

  #lang-toggle.zh-active #lang-label-zh {
    font-size: 18px;
    text-decoration: underline;
  }

  #lang-toggle.en-active #lang-label-en {
    font-size: 18px;
    text-decoration: underline;
  }

  /* ---------- Home Screen ---------- */
  #screen-home {
    justify-content: flex-start;
    align-items: center;
    padding-top: 20px;
  }

  #home-title {
    font-family: var(--font-display);
    font-size: 42px;
    color: var(--color-purple);
    text-align: center;
    margin-bottom: 24px;
    animation: slideUp 0.5s ease forwards;
  }

  #zone-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 0 20px;
    width: 100%;
    max-width: 680px;
    animation: fadeIn 0.6s ease 0.2s both;
  }

  .zone-btn {
    min-width: 180px;
    min-height: 180px;
    border-radius: var(--radius-zone);
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--shadow-zone);
    transition: transform 0.15s, box-shadow 0.15s;
    padding: 16px;
    color: white;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 20px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    will-change: transform;
  }

  .zone-btn:active {
    transform: scale(1.05);
    box-shadow: 0 10px 28px rgba(0,0,0,0.22);
    animation: bounce 0.35s ease;
  }

  #btn-zone-language {
    background: linear-gradient(135deg, #457B9D, #A8DADC);
  }

  #btn-zone-numbers {
    background: linear-gradient(135deg, #FFD166, #F4A261);
    color: var(--text-dark);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  }

  #btn-zone-logic {
    background: linear-gradient(135deg, #2DC653, #06A77D);
  }

  .zone-icon {
    font-size: 64px;
    line-height: 1;
  }

  .zone-label {
    font-size: 20px;
    text-align: center;
    line-height: 1.3;
  }

  /* ---------- Zone Screens ---------- */
  .zone-screen-inner {
    width: 100%;
    max-width: 700px;
    padding: 20px 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .zone-screen-title {
    font-family: var(--font-display);
    font-size: 36px;
    color: var(--color-purple);
    text-align: center;
  }

  .activity-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    width: 100%;
  }

  .activity-card-btn {
    min-width: 150px;
    min-height: 150px;
    border-radius: var(--radius-zone);
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: var(--shadow-card);
    background: white;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 18px;
    color: var(--text-dark);
    transition: transform 0.15s, box-shadow 0.15s;
    padding: 14px;
    text-align: center;
    line-height: 1.3;
  }

  .activity-card-btn:active {
    transform: scale(1.06);
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  }

  .activity-card-btn .act-icon {
    font-size: 52px;
    line-height: 1;
  }

  /* Language zone accent */
  #screen-zone-language .activity-card-btn { border-top: 5px solid var(--color-blue); }
  /* Numbers zone accent */
  #screen-zone-numbers .activity-card-btn  { border-top: 5px solid var(--color-yellow); }
  /* Logic zone accent */
  #screen-zone-logic .activity-card-btn    { border-top: 5px solid var(--color-green); }

  /* ---------- Big-Kids gating ---------- */
  .activity-card-btn.is-gated { position: relative; }
  .bigkid-chip {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #9B5DE5;
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 900;
    padding: 3px 8px;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    line-height: 1.1;
  }

  /* ---------- Parent Gate overlay ---------- */
  #parent-gate-overlay {
    position: fixed;
    inset: 0;
    background: rgba(40,30,60,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 11000;
    padding: 20px;
  }
  #parent-gate-overlay.visible { display: flex; }
  #parent-gate-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    padding: 26px 28px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    font-family: 'Nunito', sans-serif;
  }
  #parent-gate-emoji { font-size: 52px; line-height: 1; }
  #parent-gate-title {
    font-family: 'Fredoka One', 'Nunito', sans-serif;
    font-size: 26px;
    color: #9B5DE5;
    margin: 8px 0 4px;
  }
  #parent-gate-sub { font-size: 15px; color: #555; font-weight: 700; margin-bottom: 14px; }
  #parent-gate-question {
    font-size: 32px;
    font-weight: 900;
    color: #2D2D2D;
    margin: 6px 0 14px;
  }
  #parent-gate-choices {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
  }
  .parent-gate-choice {
    min-width: 72px;
    min-height: 72px;
    border-radius: 16px;
    border: 3px solid #2EC4B6;
    background: #fff;
    font-size: 28px;
    font-weight: 900;
    color: #2D2D2D;
    cursor: pointer;
    transition: transform 0.12s, background 0.15s;
    font-family: 'Nunito', sans-serif;
  }
  .parent-gate-choice:active { transform: scale(0.93); }
  .parent-gate-choice.parent-gate-wrong {
    background: #FFE0E0;
    border-color: #E63946;
    animation: shake 0.4s ease;
  }
  #parent-gate-cancel {
    min-height: 56px;
    padding: 0 24px;
    border-radius: 16px;
    border: none;
    background: #EDE7F6;
    color: #6A4BAA;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
  }
  #parent-gate-cancel:active { transform: scale(0.95); }

  /* ---------- Settings (gear) button ---------- */
  #settings-btn {
    min-width: 52px;
    min-height: 52px;
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0.08);
    background: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.12s, background 0.15s;
  }
  #settings-btn:active { transform: scale(0.92) rotate(40deg); background: #f0f0f0; }

  /* ---------- Settings overlay ---------- */
  #settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(40,30,60,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 11000;
    padding: 20px;
  }
  #settings-overlay.visible { display: flex; }
  #settings-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    padding: 24px 26px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    font-family: 'Nunito', sans-serif;
    max-height: 90vh;
    overflow-y: auto;
  }
  #settings-emoji { font-size: 48px; line-height: 1; }
  #settings-title {
    font-family: 'Fredoka One', 'Nunito', sans-serif;
    font-size: 26px;
    color: #9B5DE5;
    margin: 6px 0 18px;
  }
  .settings-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 18px;
    text-align: left;
  }
  .settings-label {
    font-size: 17px;
    font-weight: 900;
    color: #2D2D2D;
  }
  .settings-seg {
    display: flex;
    gap: 8px;
  }
  .seg-btn {
    flex: 1;
    min-height: 56px;
    border-radius: 14px;
    border: 3px solid #ddd;
    background: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 900;
    color: #777;
    cursor: pointer;
    transition: transform 0.12s, background 0.15s, border-color 0.15s, color 0.15s;
  }
  .seg-btn:active { transform: scale(0.95); }
  .seg-btn.active {
    background: #2EC4B6;
    border-color: #2EC4B6;
    color: #fff;
  }
  #settings-reset {
    width: 100%;
    min-height: 52px;
    border-radius: 14px;
    border: 3px solid #E63946;
    background: #fff;
    color: #E63946;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
    margin-bottom: 12px;
    transition: transform 0.12s, background 0.15s, color 0.15s;
  }
  #settings-reset:active { transform: scale(0.97); }
  #settings-reset.confirm {
    background: #E63946;
    color: #fff;
    animation: shake 0.4s ease;
  }
  #settings-done {
    width: 100%;
    min-height: 60px;
    border-radius: 16px;
    border: none;
    background: #9B5DE5;
    color: #fff;
    font-family: 'Fredoka One', 'Nunito', sans-serif;
    font-size: 22px;
    cursor: pointer;
    transition: transform 0.12s;
  }
  #settings-done:active { transform: scale(0.96); }

  /* ---------- Back Button (clear labeled pill) ---------- */
  .btn-back {
    align-self: flex-start;
    min-width: 120px;
    min-height: 88px;
    padding: 0 20px;
    border-radius: 999px;
    border: 3px solid rgba(0,0,0,0.08);
    background: var(--color-yellow, #FFD166);
    box-shadow: var(--shadow-card);
    font-size: 30px;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.12s, filter 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 0 0 16px;
    color: #3a2a1a;
    font-family: 'Nunito', sans-serif;
  }

  .btn-back .btn-back-arrow { font-size: 26px; line-height: 1; }
  .btn-back .btn-back-icon  { font-size: 30px; line-height: 1; }
  .btn-back .btn-back-label { font-size: 24px; font-weight: 900; }

  .btn-back:active {
    transform: scale(0.94);
    filter: brightness(0.96);
  }

  /* ---------- Activity Screen ---------- */
  #screen-activity {
    padding-top: 0;
    align-items: stretch;
  }

  #activity-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 16px;
    overflow-y: auto;
  }

  /* ---------- Tap Targets ---------- */
  .tap-target {
    min-width: 88px;
    min-height: 88px;
    border-radius: var(--radius-btn);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px;
    font-size: 24px;
    background: white;
    box-shadow: var(--shadow-card);
    transition: transform 0.12s;
  }

  .tap-target:active {
    transform: scale(0.94);
  }

  /* ---------- Choice Chips ---------- */
  .choice-chip {
    min-width: 100px;
    min-height: 88px;
    border-radius: 14px;
    border: 3px solid transparent;
    background: white;
    box-shadow: var(--shadow-card);
    font-family: var(--font-display);
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: transform 0.12s, border-color 0.15s;
  }

  .choice-chip:active {
    transform: scale(0.94);
  }

  .choices-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin: 16px 0;
  }

  /* ---------- Activity Card Surface ---------- */
  .activity-card {
    min-width: 120px;
    min-height: 120px;
    border-radius: var(--radius-card);
    padding: 16px;
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  /* ---------- Mascot Bar ---------- */
  #mascot-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(8px);
    border-top: 2px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 200;
  }

  /* ---------- CSS Hedgehog ---------- */
  #mascot {
    position: relative;
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    animation: mascotFloat 3s ease-in-out infinite;
    will-change: transform;
  }

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

  #mascot::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10px;
    width: 70px;
    height: 50px;
    background: #8B6914;
    border-radius: 50% 50% 40% 40%;
  }

  .spine {
    position: absolute;
    bottom: 28px;
    width: 8px;
    height: 22px;
    background: #4A3000;
    border-radius: 4px 4px 0 0;
    transform-origin: bottom center;
  }

  .spine:nth-child(1) { left: 22px; transform: rotate(-20deg); }
  .spine:nth-child(2) { left: 38px; transform: rotate(0deg); }
  .spine:nth-child(3) { left: 54px; transform: rotate(20deg); }

  .mascot-face {
    position: absolute;
    bottom: 14px;
    left: 14px;
    width: 36px;
    height: 28px;
    background: #F5C07A;
    border-radius: 50%;
  }

  .mascot-eye {
    position: absolute;
    top: 8px;
    width: 7px;
    height: 7px;
    background: #2D2D2D;
    border-radius: 50%;
  }

  .mascot-eye.left  { left: 8px; }
  .mascot-eye.right { left: 20px; }

  .mascot-nose {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 5px;
    background: var(--color-red);
    border-radius: 50%;
  }

  #mascot.celebrate-mascot {
    animation: wiggle 0.4s ease infinite;
  }

  /* ---------- Speech Bubble ---------- */
  #speech-bubble {
    flex: 1;
    background: white;
    border-radius: 16px;
    padding: 12px 18px;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 18px;
    color: var(--text-dark);
    box-shadow: var(--shadow-card);
    position: relative;
    min-height: 56px;
    display: flex;
    align-items: center;
    line-height: 1.4;
    transition: opacity 0.2s;
  }

  #speech-bubble::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right-color: white;
    border-left: none;
  }

  /* ---------- Celebration Screen ---------- */
  #screen-celebrate {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #FFD166 0%, #F4A261 50%, #9B5DE5 100%);
  }

  #celebrate-content {
    text-align: center;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }

  #celebrate-message {
    font-family: var(--font-display);
    font-size: 44px;
    color: white;
    text-shadow: 0 3px 10px rgba(0,0,0,0.25);
    padding: 0 20px;
    animation: celebrate 0.6s ease forwards;
  }

  #confetti-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
  }

  #btn-next {
    min-width: 180px;
    min-height: 64px;
    border-radius: 999px;
    border: none;
    background: white;
    font-family: var(--font-display);
    font-size: 26px;
    color: var(--color-purple);
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    transition: transform 0.15s;
    z-index: 2;
  }

  #btn-next:active {
    transform: scale(0.95);
  }

  /* ---------- Key Display Overlay ---------- */
  #key-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-family: var(--font-display);
    color: white;
    text-shadow: 0 4px 20px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 9999;
    background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
    border-radius: 32px;
    padding: 20px 40px;
    opacity: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform 0.1s, opacity 0.1s;
  }
  #key-display .kd-char  { font-size: clamp(90px, 22vw, 180px); line-height: 1; }
  #key-display .kd-emoji { font-size: clamp(60px, 16vw, 120px); line-height: 1; }
  #key-display .kd-word  { font-size: clamp(28px, 7vw, 56px); line-height: 1.1; }
  #key-display.has-extra { padding: 24px 48px; }

  /* ---------- Cursor sparkle trail (mouse / trackpad delight) ---------- */
  .cursor-spark {
    position: fixed;
    pointer-events: none;
    z-index: 9500;
    font-size: 22px;
    will-change: transform, opacity;
    animation: cursor-spark-fade 0.8s ease-out forwards;
  }
  @keyframes cursor-spark-fade {
    0%   { transform: translate(-50%, -50%) scale(0.4) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%, -120%) scale(1.1) rotate(40deg); opacity: 0; }
  }

  /* ---------- Hover affordance (mouse devices only) ---------- */
  @media (hover: hover) and (pointer: fine) {
    .zone-btn:hover, .activity-card-btn:hover, .choice-chip:hover,
    .tap-target:hover, .seg-btn:hover, .nc-nav-btn:hover, .mode-btn:hover,
    .btn-back:hover, #lang-toggle:hover, #settings-btn:hover {
      transform: scale(1.06);
      box-shadow: 0 8px 24px rgba(155,93,229,0.35);
      filter: brightness(1.03);
    }
    .choice-chip:hover, .activity-card-btn:hover {
      outline: 4px solid rgba(155,93,229,0.45);
      outline-offset: 2px;
    }
  }

  /* ---------- Keyboard-navigation highlight (mouse-free play) ---------- */
  .kbd-focus {
    outline: 5px solid var(--color-purple, #9B5DE5) !important;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(155,93,229,0.25) !important;
    border-radius: 14px;
    animation: pulse-glow 1.2s ease-in-out infinite;
  }

  #key-display.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.95;
    animation: keyPop 0.6s ease forwards;
  }

  /* ---------- All Keyframe Animations ---------- */

  @keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  @keyframes slideUp {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  @keyframes bounce {
    0%,100% { transform: scale(1); }
    40%      { transform: scale(0.88); }
    70%      { transform: scale(1.06); }
  }

  /* bounce-back, celebrate, correct-glow, star-collect, idle-nudge, confetti-fall, wiggle
     defined in activity module CSS block below — removing duplicates from block 1 */

  @keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }

  @keyframes pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1); }
  }

  @keyframes starPop {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.5) rotate(20deg); }
    60%  { transform: scale(0.9) rotate(-10deg); }
    100% { transform: scale(1) rotate(0); }
  }

  @keyframes keyPop {
    0%   { transform: translate(-50%, -50%) scale(0.7); opacity: 1; }
    40%  { transform: translate(-50%, -50%) scale(1.1); }
    70%  { transform: translate(-50%, -50%) scale(0.95); }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  }

  /* ---------- Feedback State Classes ---------- */
  .is-correct {
    animation: correct-glow 0.5s ease forwards;
    border-color: var(--color-yellow) !important;
  }

  .is-wrong {
    animation: bounce-back 0.4s ease forwards;
  }

  .is-celebrating {
    animation: celebrate 0.6s ease forwards;
  }

  /* ---------- Tap Pulse Feedback ---------- */
  .zone-btn:active, .activity-card-btn:active, .choice-chip:active {
    transform: scale(0.92);
    transition: transform 0.08s ease;
  }

  /* ---------- Context Menu / Selection Prevention ---------- */
  * {
    -webkit-touch-callout: none;
  }

  img {
    pointer-events: none;
    draggable: false;
  }

  /* ---------- Scrollbar (minimal) ---------- */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(155,93,229,0.3); border-radius: 4px; }

  /* ---------- Responsive (768px+) ---------- */
  @media (min-width: 768px) {
    #zone-buttons {
      gap: 28px;
    }
    .zone-btn {
      min-width: 180px;
      min-height: 180px;
    }
    .zone-icon {
      font-size: 62px;
    }
    .zone-label {
      font-size: 19px;
    }
    #home-title {
      font-size: 52px;
    }
    .activity-card-btn {
      min-width: 160px;
      min-height: 160px;
    }
    .choice-chip {
      min-width: 120px;
      min-height: 100px;
      font-size: 36px;
    }
  }

  
/* ═══ ACTIVITY MODULE CSS ═══ */
    /* ═══ ANIMATIONS ═══ */
    /* bounce-back, celebrate, correct-glow — defined in full below; removed compact duplicates */
    @keyframes star-collect  { 0%{transform:translateY(0) scale(1);opacity:1} 100%{transform:translateY(-80px) scale(1.6);opacity:0} }
    @keyframes idle-nudge    { 0%,100%{transform:translateX(0)} 30%{transform:translateX(6px)} 60%{transform:translateX(-6px)} }
    @keyframes confetti-fall { 0%{transform:translateY(-20px) rotate(0deg);opacity:1} 100%{transform:translateY(100vh) rotate(720deg);opacity:0} }
    @keyframes wiggle        { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-8deg)} 75%{transform:rotate(8deg)} }
    @keyframes pop-in        { 0%{transform:scale(0);opacity:0} 70%{transform:scale(1.15)} 100%{transform:scale(1);opacity:1} }
    @keyframes emoji-appear  { 0%{transform:scale(0) rotate(-20deg);opacity:0} 80%{transform:scale(1.1) rotate(3deg)} 100%{transform:scale(1) rotate(0);opacity:1} }
    @keyframes card-flip     { 0%{transform:rotateY(0)} 100%{transform:rotateY(180deg)} }
    @keyframes slide-to-bucket { 0%{transform:translate(0,0) scale(1)} 100%{transform:translate(var(--tx),var(--ty)) scale(0.4);opacity:0} }
    @keyframes shake          { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-8px)} 40%,80%{transform:translateX(8px)} }
    @keyframes pulse-glow     { 0%,100%{box-shadow:0 0 0 0 rgba(255,209,102,0.6)} 50%{box-shadow:0 0 0 10px rgba(255,209,102,0)} }

    /* ═══ LAYOUT ═══ */
    #game-root {
      display: flex;
      flex-direction: column;
      height: 100vh;
      max-width: 680px;
      margin: 0 auto;
      position: relative;
    }

    /* TOP BAR */
    #top-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 64px;
      padding: 0 16px;
      background: var(--bg-card);
      box-shadow: 0 2px 8px rgba(0,0,0,0.08);
      z-index: 100;
      flex-shrink: 0;
    }
    #logo {
      font-family: 'Fredoka One', cursive;
      font-size: 24px;
      color: var(--color-purple);
    }
    #star-counter {
      background: var(--color-purple);
      border-radius: 999px;
      padding: 6px 16px;
      font-family: 'Fredoka One', cursive;
      font-size: 24px;
      color: white;
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 80px;
      justify-content: center;
    }
    #star-icon { display: inline-block; transition: transform 0.2s; }
    #lang-toggle {
      min-width: 88px; min-height: 88px;
      border-radius: 999px;
      background: #f0f0f0;
      font-family: 'Nunito', sans-serif;
      font-weight: 900;
      font-size: 15px;
      padding: 6px 14px;
      border: 2px solid #ddd;
      transition: all 0.2s;
    }
    #lang-toggle:active { background: #e0e0e0; }
    #lang-label-zh { color: #2EC4B6; }

    /* SCREENS */
    .screen { display: none; flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px; }
    .screen.active { display: flex; flex-direction: column; }

    /* ZONE SELECTION */
    #screen-zone-select {
      align-items: center;
      justify-content: center;
      gap: 20px;
    }
    #zone-select-title {
      font-family: 'Fredoka One', cursive;
      font-size: 32px;
      color: var(--text-dark);
      text-align: center;
      margin-bottom: 8px;
    }
    .zone-buttons-grid {
      display: flex;
      gap: 20px;
      flex-wrap: wrap;
      justify-content: center;
    }
    .zone-btn {
      min-width: 160px; min-height: 160px;
      border-radius: 28px;
      box-shadow: 0 6px 20px rgba(0,0,0,0.15);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 10px;
      transition: transform 0.15s, box-shadow 0.15s;
      font-family: 'Nunito', sans-serif;
      font-weight: 900;
      font-size: 18px;
      color: white;
      text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }
    .zone-btn:active { transform: scale(1.05); }
    #btn-zone-numbers { background: linear-gradient(135deg, #FFD166, #F4A261); color: #2D2D2D; }
    #btn-zone-logic   { background: linear-gradient(135deg, #2DC653, #06A77D); }
    .zone-icon { font-size: 52px; line-height: 1; }

    /* ACTIVITY LIST SCREEN */
    #screen-activity-list {
      flex-direction: column;
      gap: 12px;
    }
    .activity-list-header {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 8px;
    }
    .activity-list-title {
      font-family: 'Fredoka One', cursive;
      font-size: 28px;
    }
    .activity-grid {
      display: flex;
      flex-direction: column;
      gap: 14px;
    }
    .activity-card-btn {
      background: var(--bg-card);
      border-radius: 20px;
      padding: 18px 20px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
      display: flex;
      align-items: center;
      gap: 16px;
      text-align: left;
      transition: transform 0.15s, box-shadow 0.15s;
      width: 100%;
      min-height: 88px;
    }
    .activity-card-btn:active { transform: scale(0.98); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
    .activity-card-icon { font-size: 40px; flex-shrink: 0; }
    .activity-card-info { flex: 1; }
    .activity-card-name {
      font-family: 'Fredoka One', cursive;
      font-size: 28px;
      color: var(--text-dark);
    }
    .activity-card-desc {
      font-size: 20px;
      color: #555;
      font-weight: 700;
      margin-top: 2px;
    }
    .activity-card-stars {
      font-size: 20px;
      color: var(--color-purple);
      font-weight: 900;
      margin-top: 4px;
    }

    /* ACTIVITY SCREEN */
    #screen-activity {
      flex-direction: column;
    }
    .activity-header {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 16px;
      flex-shrink: 0;
    }
    #btn-back {
      min-width: 120px; min-height: 88px;
      border-radius: 999px;
      background: var(--color-yellow, #FFD166);
      box-shadow: var(--shadow-card);
      font-size: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      flex-shrink: 0;
    }
    .activity-title {
      font-family: 'Fredoka One', cursive;
      font-size: 26px;
      color: var(--text-dark);
    }
    #activity-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      animation: swooshIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }
    @keyframes swooshIn {
      from { transform: translateX(40px); opacity: 0; }
      to   { transform: translateX(0); opacity: 1; }
    }

    /* MASCOT BAR */
    #mascot-bar {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 16px;
      background: var(--bg-card);
      box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
      min-height: 80px;
      flex-shrink: 0;
    }
    #mascot {
      position: relative;
      width: 60px;
      height: 60px;
      flex-shrink: 0;
    }
    #mascot::before {
      content: '';
      position: absolute;
      bottom: 0; left: 6px;
      width: 48px; height: 34px;
      background: #8B6914;
      border-radius: 50% 50% 40% 40%;
    }
    .spine {
      position: absolute;
      bottom: 20px;
      width: 6px; height: 16px;
      background: #4A3000;
      border-radius: 4px 4px 0 0;
      transform-origin: bottom center;
    }
    .spine:nth-child(1) { left: 14px; transform: rotate(-20deg); }
    .spine:nth-child(2) { left: 24px; transform: rotate(0deg); }
    .spine:nth-child(3) { left: 34px; transform: rotate(20deg); }
    .mascot-face {
      position: absolute;
      bottom: 9px; left: 8px;
      width: 26px; height: 20px;
      background: #F5C07A;
      border-radius: 50%;
    }
    .mascot-eye {
      position: absolute;
      top: 5px;
      width: 5px; height: 5px;
      background: #2D2D2D;
      border-radius: 50%;
    }
    .mascot-eye.left  { left: 5px; }
    .mascot-eye.right { left: 14px; }
    .mascot-nose {
      position: absolute;
      bottom: 4px; left: 50%;
      transform: translateX(-50%);
      width: 6px; height: 4px;
      background: var(--color-red);
      border-radius: 50%;
    }
    #speech-bubble {
      flex: 1;
      background: #f9f9f9;
      border-radius: 16px;
      padding: 10px 14px;
      font-size: 20px;
      font-weight: 700;
      color: var(--text-dark);
      min-height: 56px;
      display: flex;
      align-items: center;
      border: 2px solid #eee;
      line-height: 1.4;
    }

    /* ═══ SHARED COMPONENT STYLES ═══ */
    .tap-target {
      min-width: 88px; min-height: 88px;
      border-radius: 16px;
      margin: 10px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .choices-row {
      display: flex;
      gap: 24px;
      flex-wrap: wrap;
      justify-content: center;
      margin-top: 16px;
    }
    .choice-chip {
      min-width: 120px; min-height: 110px;
      border-radius: 14px;
      background: var(--bg-card);
      box-shadow: 0 4px 12px rgba(0,0,0,0.12);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      font-family: 'Fredoka One', cursive;
      font-size: 32px;
      transition: transform 0.15s;
      padding: 10px;
    }
    .choice-chip:active { transform: scale(0.95); }
    .choice-chip.correct-glow { animation: correct-glow 0.6s ease-in-out; }
    .choice-chip.bounce-back  { animation: bounce-back 0.5s ease-in-out; }
    .choice-chip.selected {
      border: 3px solid var(--color-yellow);
      box-shadow: 0 0 0 3px var(--color-yellow);
    }
    .prompt-text {
      font-family: 'Nunito', sans-serif;
      font-weight: 700;
      font-size: 28px;
      text-align: center;
      margin: 12px 0;
      color: var(--text-dark);
    }
    .progress-bar-wrap {
      background: #eee;
      border-radius: 999px;
      height: 10px;
      width: 100%;
      margin: 8px 0;
      overflow: hidden;
    }
    .progress-bar-fill {
      height: 100%;
      border-radius: 999px;
      background: linear-gradient(90deg, var(--color-yellow), var(--color-orange));
      transition: width 0.4s ease;
    }
    .round-counter {
      font-weight: 900;
      font-size: 22px;
      color: #888;
      text-align: right;
      margin-bottom: 4px;
    }

    /* ═══ ACTIVITY: COUNTING ═══ */
    #act-counting {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
    }
    #nc-number-display {
      font-family: 'Fredoka One', cursive;
      font-size: 100px;
      line-height: 1;
      color: var(--color-orange);
      text-shadow: 3px 3px 0 rgba(0,0,0,0.08);
    }
    #nc-word-display {
      font-family: 'Fredoka One', cursive;
      font-size: 28px;
      color: var(--text-dark);
    }
    #nc-word-zh {
      font-family: 'Fredoka One', cursive;
      font-size: 28px;
      color: #2EC4B6;
    }
    #nc-emoji-field {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 8px;
      min-height: 80px;
      padding: 12px;
      background: rgba(255,255,255,0.7);
      border-radius: 20px;
      width: 100%;
      max-width: 400px;
    }
    .nc-emoji-item {
      font-size: 44px;
      opacity: 0;
      transform: scale(0) rotate(-20deg);
      transition: all 0.3s ease;
      display: inline-block;
    }
    .nc-emoji-item.shown {
      opacity: 1;
      transform: scale(1) rotate(0);
    }
    .nc-emoji-item.counted {
      animation: wiggle 0.4s ease;
      filter: drop-shadow(0 0 8px var(--color-yellow));
    }
    #nc-count-btn {
      background: linear-gradient(135deg, var(--color-yellow), var(--color-orange));
      border-radius: 20px;
      padding: 14px 28px;
      font-family: 'Fredoka One', cursive;
      font-size: 22px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      margin-top: 4px;
    }
    .nc-nav-row {
      display: flex;
      gap: 20px;
      align-items: center;
      margin-top: 8px;
    }
    .nc-nav-btn {
      min-width: 88px; min-height: 88px;
      border-radius: 50%;
      background: var(--bg-card);
      box-shadow: 0 4px 12px rgba(0,0,0,0.12);
      font-size: 26px;
      display: flex; align-items: center; justify-content: center;
    }
    #nc-choices { margin-top: 10px; }

    /* ═══ ACTIVITY: SHAPES ═══ */
    #act-shapes {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
    }
    #ss-mode-row {
      display: flex;
      gap: 12px;
      margin-bottom: 4px;
    }
    .mode-btn {
      padding: 10px 24px;
      border-radius: 999px;
      font-family: 'Fredoka One', cursive;
      font-size: 18px;
      background: #eee;
      color: #666;
      transition: all 0.2s;
    }
    .mode-btn.active {
      background: var(--color-blue);
      color: white;
      box-shadow: 0 3px 10px rgba(69,123,157,0.4);
    }
    #ss-shape-display {
      width: 140px; height: 140px;
      display: flex; align-items: center; justify-content: center;
      margin: 8px auto;
    }
    .css-shape { display: inline-block; }
    #ss-shape-name {
      font-family: 'Fredoka One', cursive;
      font-size: 32px;
      color: var(--text-dark);
      text-align: center;
    }
    #ss-shape-name-zh {
      font-family: 'Fredoka One', cursive;
      font-size: 28px;
      color: #2EC4B6;
      text-align: center;
    }
    #ss-speak-btn {
      background: var(--color-blue);
      color: white;
      border-radius: 14px;
      padding: 10px 20px;
      font-family: 'Fredoka One', cursive;
      font-size: 18px;
    }
    #ss-choices { gap: 10px; }
    .shape-choice-chip {
      min-width: 88px; min-height: 88px;
      border-radius: 14px;
      background: var(--bg-card);
      box-shadow: 0 4px 12px rgba(0,0,0,0.12);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 8px;
      transition: transform 0.15s;
    }
    .shape-choice-chip:active { transform: scale(0.95); }
    .shape-choice-label {
      font-family: 'Fredoka One', cursive;
      font-size: 22px;
      color: var(--text-dark);
    }

    /* ═══ ACTIVITY: COLORS ═══ */
    #act-colors {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
    }
    #cl-circle {
      width: 140px; height: 140px;
      border-radius: 50%;
      box-shadow: 0 8px 24px rgba(0,0,0,0.18);
      transition: background-color 0.4s ease;
      margin: 8px auto;
    }
    #cl-color-name {
      font-family: 'Fredoka One', cursive;
      font-size: 36px;
      color: var(--text-dark);
    }
    #cl-color-name-zh {
      font-family: 'Fredoka One', cursive;
      font-size: 28px;
      color: #2EC4B6;
    }
    #cl-object {
      font-size: 52px;
      margin: 4px 0;
    }
    #cl-mode-row { display: flex; gap: 12px; margin-bottom: 4px; }
    #cl-mix-section {
      display: flex;
      align-items: center;
      gap: 16px;
      padding: 16px;
      background: rgba(255,255,255,0.8);
      border-radius: 20px;
      flex-wrap: wrap;
      justify-content: center;
    }
    .mix-circle {
      width: 70px; height: 70px;
      border-radius: 50%;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      flex-shrink: 0;
    }
    #mix-plus, #mix-equals {
      font-family: 'Fredoka One', cursive;
      font-size: 32px;
      color: var(--text-dark);
    }
    #mix-result {
      width: 70px; height: 70px;
      border-radius: 50%;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      flex-shrink: 0;
      transition: background-color 0.6s ease;
    }
    #mix-label {
      font-family: 'Fredoka One', cursive;
      font-size: 18px;
      color: var(--text-dark);
      text-align: center;
      width: 100%;
    }
    #cl-nav-row { display: flex; gap: 20px; margin-top: 4px; }

    /* ═══ ACTIVITY: PATTERNS ═══ */
    #act-patterns {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 14px;
    }
    #pc-sequence {
      display: flex;
      gap: 10px;
      align-items: center;
      justify-content: center;
      flex-wrap: wrap;
      padding: 14px;
      background: rgba(255,255,255,0.8);
      border-radius: 20px;
      width: 100%;
    }
    .seq-tile {
      width: 88px; height: 88px;
      border-radius: 12px;
      background: var(--bg-card);
      box-shadow: 0 3px 8px rgba(0,0,0,0.1);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 34px;
      flex-shrink: 0;
    }
    .seq-tile.question-card {
      background: linear-gradient(135deg, #a8edea, #fed6e3);
      cursor: pointer;
      font-family: 'Fredoka One', cursive;
      font-size: 28px;
      color: var(--text-dark);
      animation: pulse-glow 2s infinite;
    }
    .seq-tile.pulse-hint {
      animation: wiggle 0.6s ease-in-out infinite;
    }
    #pc-hint {
      font-size: 20px;
      color: #888;
      font-weight: 700;
      text-align: center;
      font-style: italic;
    }

    /* ═══ ACTIVITY: MEMORY ═══ */
    #act-memory {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
    }
    #mf-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 10px;
      width: 100%;
      max-width: 400px;
    }
    .mf-card {
      aspect-ratio: 1;
      border-radius: 14px;
      background: linear-gradient(135deg, #667eea, #764ba2);
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 32px;
      cursor: pointer;
      position: relative;
      transform-style: preserve-3d;
      transition: transform 0.5s ease;
    }
    .mf-card.flipped { transform: rotateY(180deg); }
    .mf-card.matched {
      background: linear-gradient(135deg, var(--color-green), #06A77D) !important;
      transform: rotateY(180deg) scale(0.95);
      cursor: default;
    }
    .mf-card-back, .mf-card-front {
      position: absolute;
      width: 100%; height: 100%;
      border-radius: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      backface-visibility: hidden;
      -webkit-backface-visibility: hidden;
    }
    .mf-card-back {
      background: linear-gradient(135deg, #667eea, #764ba2);
      font-size: 28px;
      color: white;
    }
    .mf-card-front {
      background: var(--bg-card);
      font-size: 36px;
      transform: rotateY(180deg);
    }
    .mf-card.matched .mf-card-front {
      background: linear-gradient(135deg, var(--color-green), #06A77D);
    }
    #mf-score {
      font-family: 'Fredoka One', cursive;
      font-size: 22px;
      color: var(--text-dark);
    }
    #mf-flips {
      font-size: 18px;
      color: #888;
      font-weight: 700;
    }

    /* ═══ ACTIVITY: SEQUENCES ═══ */
    #act-sequences {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 14px;
    }
    #sb-sequence {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 16px;
      background: rgba(255,255,255,0.8);
      border-radius: 20px;
      flex-wrap: wrap;
      justify-content: center;
      width: 100%;
    }
    .sb-item {
      font-family: 'Fredoka One', cursive;
      font-size: 22px;
      padding: 10px 14px;
      background: var(--bg-card);
      border-radius: 12px;
      box-shadow: 0 3px 8px rgba(0,0,0,0.1);
      white-space: nowrap;
    }
    .sb-arrow {
      font-size: 24px;
      color: #ccc;
    }
    .sb-question {
      font-family: 'Fredoka One', cursive;
      font-size: 28px;
      padding: 12px 18px;
      background: linear-gradient(135deg, #a8edea, #fed6e3);
      border-radius: 12px;
      box-shadow: 0 3px 8px rgba(0,0,0,0.1);
      animation: pulse-glow 2s infinite;
    }
    #sb-hint-btn {
      background: var(--color-yellow);
      border-radius: 14px;
      padding: 10px 20px;
      font-family: 'Fredoka One', cursive;
      font-size: 18px;
      box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    }

    /* ═══ ACTIVITY: SORTING ═══ */
    #act-sorting {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    #sort-title {
      font-family: 'Fredoka One', cursive;
      font-size: 24px;
      text-align: center;
      color: var(--text-dark);
    }
    #sort-items-area {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      justify-content: center;
      padding: 14px;
      background: rgba(255,255,255,0.7);
      border-radius: 20px;
      min-height: 80px;
    }
    .sort-item {
      font-size: 44px;
      width: 88px; height: 88px;
      border-radius: 12px;
      background: var(--bg-card);
      box-shadow: 0 3px 10px rgba(0,0,0,0.1);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.2s;
      flex-shrink: 0;
    }
    .sort-item.selected {
      border: 3px solid var(--color-yellow);
      box-shadow: 0 0 0 3px var(--color-yellow);
      transform: scale(1.1);
    }
    .sort-item.shake { animation: shake 0.4s ease; }
    #sort-buckets-area {
      display: flex;
      gap: 12px;
      justify-content: center;
      flex-wrap: wrap;
    }
    .sort-bucket {
      border-radius: 20px;
      border: 3px solid;
      min-width: 120px;
      min-height: 110px;
      padding: 10px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      transition: transform 0.15s;
      flex: 1;
      max-width: 160px;
    }
    .sort-bucket:active { transform: scale(0.97); }
    .sort-bucket.highlight {
      box-shadow: 0 0 0 4px var(--color-yellow);
      animation: bucket-pulse 0.8s ease 2;
    }
    @keyframes bucket-pulse {
      0%,100% { transform: scale(1); }
      50% { transform: scale(1.08); border-color: #ffd700; }
    }
    .sort-bucket-label {
      font-family: 'Fredoka One', cursive;
      font-size: 24px;
      color: var(--text-dark);
      text-align: center;
    }
    .sort-bucket-items {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      justify-content: center;
    }
    .sort-bucket-item {
      font-size: 24px;
      animation: pop-in 0.3s ease forwards;
    }
    #sort-progress {
      font-family: 'Fredoka One', cursive;
      font-size: 18px;
      text-align: center;
      color: var(--text-dark);
    }
    #sort-challenge-nav {
      display: flex;
      gap: 10px;
      justify-content: center;
      flex-wrap: wrap;
      margin-top: 4px;
    }
    .challenge-btn {
      padding: 8px 18px;
      border-radius: 999px;
      font-family: 'Fredoka One', cursive;
      font-size: 16px;
      background: #eee;
      color: #666;
    }
    .challenge-btn.active {
      background: var(--color-green);
      color: white;
    }

    /* ═══ CELEBRATION OVERLAY ═══ */
    #celebrate-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: var(--bg-overlay);
      z-index: 500;
      align-items: center;
      justify-content: center;
      flex-direction: column;
    }
    #celebrate-overlay.active { display: flex; }
    #celebrate-box {
      background: var(--bg-card);
      border-radius: 28px;
      padding: 32px;
      text-align: center;
      box-shadow: 0 12px 40px rgba(0,0,0,0.2);
      animation: celebrate 0.5s ease forwards;
      max-width: 320px;
      width: 90%;
    }
    #celebrate-msg {
      font-family: 'Fredoka One', cursive;
      font-size: 32px;
      color: var(--text-dark);
      margin-bottom: 10px;
    }
    #celebrate-sub {
      font-size: 18px;
      font-weight: 700;
      color: #666;
      margin-bottom: 20px;
    }
    #btn-celebrate-ok {
      background: linear-gradient(135deg, var(--color-green), #06A77D);
      color: white;
      border-radius: 16px;
      padding: 14px 32px;
      font-family: 'Fredoka One', cursive;
      font-size: 22px;
      box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    }
    #confetti-layer {
      position: fixed;
      inset: 0;
      pointer-events: none;
      z-index: 499;
    }
    .confetti-piece {
      position: absolute;
      width: 10px; height: 10px;
      border-radius: 2px;
      animation: confetti-fall linear forwards;
    }

    /* ═══ RESPONSIVE ═══ */
    @media (max-height: 700px) {
      #nc-number-display { font-size: 72px; }
      .nc-emoji-item { font-size: 36px; }
      #cl-circle, #ss-shape-display { width: 100px; height: 100px; }
    }
    @media (min-width: 600px) {
      #zone-select-title { font-size: 40px; }
    }

  /* ════════════════════════════════════════════════════════════════════
     UNIFIED RESPONSIVE LAYOUT (authoritative)
     Earlier in this stylesheet, #game-root / #top-bar / .screen /
     #mascot-bar were each defined TWICE with conflicting models: one set
     used position:absolute/fixed, the other used flexbox. The leftover
     absolute .screen + fixed #mascot-bar forced the page to overflow so
     the top/bottom had to be scrolled into view. The rules below come last,
     so they win the cascade and collapse everything into ONE flex column
     that fills the viewport — no page scrolling; only the activity content
     area scrolls when a single activity is genuinely too tall.
     ════════════════════════════════════════════════════════════════════ */
  html, body { height: 100%; min-height: 100%; overflow: hidden; }

  #game-root {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 680px;
    height: 100vh;     /* fallback for old browsers */
    height: 100dvh;    /* tracks dynamic mobile browser chrome */
    margin: 0 auto;
    overflow: hidden;
  }

  #top-bar {
    position: relative;
    top: auto; left: auto;
    flex: 0 0 auto;
    height: 60px;
    min-height: 60px;
    z-index: 100;
  }
  /* Top-bar controls must fit the 60px bar (the 88px toddler tap-size is for
     in-activity buttons, not the persistent header). */
  #top-bar #lang-toggle,
  #top-bar #settings-btn {
    min-height: 48px; height: 48px;
    min-width: 48px;
  }
  #top-bar #lang-toggle { width: auto; padding: 0 12px; font-size: 14px; }
  #logo { font-size: clamp(18px, 5vw, 24px); }

  .screen {
    position: relative;        /* was absolute — the overlap culprit */
    top: auto; left: auto;
    width: 100%;
    height: auto;
    flex: 1 1 auto;
    min-height: 0;             /* let the flex child shrink so it can scroll inside */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 16px;   /* no longer reserving 140px for a fixed mascot */
  }

  #mascot-bar {
    position: relative;        /* was fixed — now sits in normal flow */
    bottom: auto; left: auto;
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    min-height: 72px;
  }

  /* Home screen scales to the viewport so the title + 3 zones always fit. */
  #screen-home { justify-content: center; align-items: center; gap: clamp(10px, 2.5vh, 22px); padding-top: 0; }
  #home-title  { font-size: clamp(26px, 7vw, 46px); margin-bottom: clamp(6px, 2vh, 18px); }
  #zone-buttons { gap: clamp(12px, 3vw, 24px); }
  .zone-btn {
    min-width: clamp(116px, 38vw, 180px);
    min-height: clamp(104px, 21vh, 180px);
    padding: clamp(8px, 2vh, 16px);
  }
  .zone-icon  { font-size: clamp(38px, 9vw, 64px); }
  .zone-label { font-size: clamp(14px, 3.6vw, 20px); }

  /* Zone (activity-picker) screens: scale headings + keep cards tappable. */
  .zone-screen-inner { padding-top: 8px; gap: clamp(10px, 2vh, 16px); }
  .zone-screen-title { font-size: clamp(24px, 6vw, 36px); }

  /* Shorter windows: tighten the mascot bar so play area keeps priority. */
  @media (max-height: 640px) {
    #mascot-bar { min-height: 60px; }
    #mascot { width: 50px; height: 50px; }
    #speech-bubble { font-size: 16px; min-height: 44px; }
  }

/* Portfolio polish: a wider play surface and clearer product identity. */
html,
body {
  background: #eaf5ff;
}

#game-root {
  background-color: #f8fbff;
  background-image:
    linear-gradient(#d9e8f4 1px, transparent 1px),
    linear-gradient(90deg, #d9e8f4 1px, transparent 1px);
  background-size: 42px 42px;
  box-shadow: 0 0 0 1px rgba(49, 66, 84, 0.08), 0 24px 80px rgba(43, 62, 80, 0.16);
  max-width: 1120px;
  margin: 0 auto;
}

#top-bar {
  background: rgba(255, 255, 255, 0.96);
  border-bottom-color: #dfe9f1;
  padding: 0 24px;
}

#logo {
  align-items: center;
  display: flex;
  gap: 10px;
}

#logo img {
  height: 36px;
  width: 36px;
}

#screen-home {
  background: rgba(248, 251, 255, 0.86);
}

#home-title {
  color: #3c2e83;
  font-size: clamp(32px, 5vw, 54px);
  margin-bottom: 18px;
}

#zone-buttons {
  align-items: stretch;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 940px;
  width: calc(100% - 48px);
}

.zone-btn {
  min-height: clamp(180px, 28vh, 250px);
  min-width: 0;
  padding: 22px 16px;
}

.zone-icon {
  font-size: clamp(54px, 7vw, 82px);
}

.zone-label {
  font-size: clamp(17px, 2vw, 23px);
}

#btn-zone-language {
  background: #4f83a7;
}

#btn-zone-numbers {
  background: #ffd166;
}

#btn-zone-logic {
  background: #41b968;
}

#settings-btn {
  color: #4b5660;
  font-size: 25px;
}

#mascot-bar {
  background: rgba(255, 255, 255, 0.97);
  border-top-color: #dfe9f1;
}

@media (max-width: 760px) {
  #game-root {
    box-shadow: none;
  }

  #top-bar {
    padding: 0 12px;
  }

  #logo {
    font-size: 19px;
  }

  #logo img {
    height: 30px;
    width: 30px;
  }

  #zone-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: calc(100% - 24px);
  }

  #btn-zone-logic {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc(50% - 6px);
  }

  .zone-btn {
    min-height: clamp(112px, 20vh, 170px);
  }
}

@media (max-width: 430px) {
  #top-bar {
    gap: 7px;
  }

  #logo,
  #star-counter,
  #lang-toggle,
  #settings-btn {
    flex-shrink: 0;
  }

  #logo {
    font-size: 16px;
    gap: 7px;
    white-space: nowrap;
  }

  #logo img {
    height: 28px;
    width: 28px;
  }

  #star-counter {
    font-size: 18px;
    padding-inline: 10px;
  }

  #lang-toggle {
    min-width: 70px;
  }

  #lang-toggle span {
    white-space: nowrap;
  }

  #settings-btn {
    min-width: 48px;
  }

  #home-title {
    font-size: 30px;
  }

  .zone-icon {
    font-size: 46px;
  }
}

