/* ==========================================================================
   CODIE JUNIOR: Official Codie.pro Design System
   Matches site brand aesthetics: Fredoka & Nunito fonts, rounded glass panels,
   soft gradients, playful animations, accessible oversized touch controls.
   STRICT REQUIREMENT: Guaranteed to fit inside 100vh without page scrollbar!
   ========================================================================== */

:root {
    --brand-blue: #4361EE;
    --brand-cyan: #4CC9F0;
    --brand-deep: #0F172A;
    --brand-gold: #F59E0B;
    --brand-gold-glow: #FDE047;
    --brand-green: #10B981;
    --brand-red: #EF4444;
    --brand-orange: #F97316;
    --brand-purple: #8B5CF6;
    --brand-card-bg: rgba(255, 255, 255, 0.94);
    --brand-border: #BAE6FD;
    --brand-shadow: 0 8px 24px rgba(2, 132, 199, 0.12);
    --brand-glow: 0 0 20px rgba(76, 201, 240, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body.junior-page {
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    max-height: 100dvh;
    max-height: calc(var(--vh, 1vh) * 100);
    overflow: hidden; /* STRICT: No page scrollbar! */
    overscroll-behavior: none;
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    background: #F0F9FF;
    color: var(--brand-deep);
    position: relative;
}

/* Background floating ambient blobs */
.junior-bg-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.junior-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
}

.blob-blue {
    width: 450px;
    height: 450px;
    background: #BAE6FD;
    top: -80px;
    left: -80px;
}

.blob-cyan {
    width: 400px;
    height: 400px;
    background: #E0F2FE;
    bottom: -60px;
    right: -60px;
}

.blob-amber {
    width: 280px;
    height: 280px;
    background: #FEF3C7;
    top: 40%;
    left: 55%;
}

/* ==========================================================================
   Navigation Bar (Shared for Map & Game)
   ========================================================================== */
.junior-navbar {
    height: 56px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    border-bottom: 2px solid var(--brand-border);
    box-shadow: 0 2px 10px rgba(2, 132, 199, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 50;
    position: relative;
    flex-shrink: 0;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-center {
    display: flex;
    align-items: center;
}

/* Logo Brand */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.nav-brand:hover {
    transform: scale(1.04);
}

.brand-avatar {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.brand-text {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 22px;
    color: #0369A1;
}

.brand-dot {
    color: var(--brand-cyan);
}

/* Action Buttons in Nav */
.junior-nav-btn {
    height: 40px;
    padding: 0 16px;
    border-radius: 20px;
    border: 2px solid var(--brand-border);
    background: white;
    color: #0369A1;
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    touch-action: manipulation;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.1);
    transition: all 0.15s ease;
}

.junior-nav-btn:hover {
    background: #E0F2FE;
    transform: translateY(-1px);
    border-color: #38BDF8;
}

.junior-nav-btn:active {
    transform: translateY(1px);
}

.junior-circle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--brand-border);
    background: white;
    color: #0369A1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.1);
    transition: all 0.15s ease;
}

.junior-circle-btn:hover {
    background: #E0F2FE;
    transform: translateY(-1px);
}

/* ==========================================================================
   Language Switcher Component (Clean, Self-Contained Dropdown)
   ========================================================================== */
.lang-switcher, .lang-switcher-slot {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.junior-navbar .lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px;
    background: white;
    border: 2px solid var(--brand-border);
    border-radius: 20px;
    color: #0369A1;
    cursor: pointer;
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    touch-action: manipulation;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.1);
    transition: all 0.15s ease;
}

.junior-navbar .lang-btn:hover {
    background: #E0F2FE;
    border-color: #38BDF8;
    transform: translateY(-1px);
}

.junior-navbar .lang-btn.open {
    background: #E0F2FE;
    border-color: #0284C7;
}

.junior-navbar .lang-icon-svg {
    width: 18px;
    height: 18px;
    color: #0284C7;
    flex-shrink: 0;
}

.junior-navbar .lang-code {
    font-size: 14px;
    letter-spacing: 0.5px;
}

.junior-navbar .lang-arrow {
    font-size: 11px;
    transition: transform 0.2s ease;
    margin-left: 2px;
}

.junior-navbar .lang-btn.open .lang-arrow {
    transform: rotate(180deg);
}

/* Dropdown Popup Menu */
.junior-navbar .lang-dropdown {
    display: none; /* STRICT: Always hidden until toggled! */
    position: absolute;
    top: calc(100% + 8px);
    left: auto;
    right: 0;
    transform: translateY(-6px);
    min-width: 155px;
    background: white;
    border: 2px solid var(--brand-border);
    backdrop-filter: blur(14px);
    border-radius: 16px;
    padding: 8px;
    z-index: 1000;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
}

[dir="rtl"] .junior-navbar .lang-dropdown {
    left: 0;
    right: auto;
}

.junior-navbar .lang-dropdown.show {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    animation: dropdownPop 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropdownPop {
    0% { transform: translateY(-8px) scale(0.96); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.lang-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: #0F172A;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.lang-option:hover {
    background: #E0F2FE;
    color: #0369A1;
}

.lang-option.active {
    background: #0284C7;
    color: white;
}

/* Stars Badges */
.map-stars-badge, .stars-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #FEF3C7;
    border: 2px solid #FDE047;
    padding: 4px 14px;
    border-radius: 18px;
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 15px;
    color: #B45309;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
}

.star-gold-icon {
    font-size: 20px;
    color: #F59E0B;
}

.level-indicator-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #E0F2FE;
    border: 2px solid #7DD3FC;
    padding: 4px 14px;
    border-radius: 18px;
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 15px;
    color: #0369A1;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ==========================================================================
   SCREEN 1: LEVEL MAP (64 Levels Grid)
   ========================================================================== */
.junior-map-screen {
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    max-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.map-main-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 16px 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.map-main-content::-webkit-scrollbar {
    width: 8px;
}
.map-main-content::-webkit-scrollbar-thumb {
    background: #BAE6FD;
    border-radius: 4px;
}

.map-title-wrap {
    text-align: center;
    margin-bottom: 14px;
}

.map-badge {
    display: inline-block;
    background: #E0F2FE;
    color: #0369A1;
    border: 1.5px solid #7DD3FC;
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 4px 14px;
    border-radius: 14px;
    margin-bottom: 6px;
}

.map-title {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 28px;
    color: #0369A1;
    margin-bottom: 4px;
}

.map-subtitle {
    font-size: 14px;
    color: #475569;
    font-weight: 600;
}

.map-grid-container {
    width: 100%;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    border-radius: 28px;
    border: 2px solid var(--brand-border);
    padding: 20px;
    box-shadow: var(--brand-shadow);
}

.junior-map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 14px;
    position: relative;
    padding: 8px 4px;
    background-image: radial-gradient(circle, #BAE6FD 18%, transparent 18%);
    background-size: 26px 26px;
    background-position: 0 0;
}

/* Individual Level Cards */
.junior-map-card {
    height: 84px;
    border-radius: 18px;
    border: 2.5px solid #E2E8F0;
    background: white;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06), inset 0 -2px 0 #E2E8F0;
    transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

/* Active current level on map with pulse and Codie Pin */
.junior-map-card.current-active {
    border-color: #0284C7 !important;
    background: linear-gradient(180deg, #FFFFFF 0%, #E0F2FE 100%) !important;
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.4), 0 8px 20px rgba(2, 132, 199, 0.25) !important;
    animation: activeMapCardPulse 2s infinite ease-in-out;
    z-index: 10;
}

@keyframes activeMapCardPulse {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35), 0 6px 14px rgba(2, 132, 199, 0.2);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.7), 0 10px 22px rgba(2, 132, 199, 0.35);
    }
}

.map-codie-pin {
    position: absolute;
    top: -24px;
    right: -10px;
    width: 44px;
    height: 44px;
    z-index: 20;
    filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.3));
    animation: mapPinBob 1.6s infinite ease-in-out;
    pointer-events: none;
}

@keyframes mapPinBob {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-8px) rotate(5deg);
    }
}

.m-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.m-level-num {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 24px;
    color: #0F172A;
}

.m-stars-row {
    display: flex;
    gap: 2px;
    font-size: 13px;
    color: #E2E8F0;
}

.m-star.active {
    color: #F59E0B;
}

.lock-icon {
    font-size: 20px;
    color: #94A3B8;
}

.junior-map-card.unlocked {
    border-color: #38BDF8;
    background: linear-gradient(180deg, #FFFFFF 0%, #F0F9FF 100%);
}

.junior-map-card.unlocked:hover {
    transform: translateY(-4px) scale(1.04);
    border-color: #0284C7;
    box-shadow: 0 10px 18px rgba(2, 132, 199, 0.2), inset 0 -2px 0 #BAE6FD;
}

.junior-map-card.perfect {
    border-color: #FBBF24;
    background: linear-gradient(180deg, #FEFCE8 0%, #FEF3C7 100%);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.15), inset 0 -2px 0 #FDE047;
}

.junior-map-card.locked {
    background: #F8FAFC;
    opacity: 0.55;
    cursor: not-allowed;
}

/* ==========================================================================
   SCREEN 2: IN-GAME WORKSPACE & BOARD
   ========================================================================== */
.junior-game-screen {
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    max-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.junior-workspace-layout {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    padding: 8px 12px;
    gap: 10px;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    align-items: stretch;
    overflow: hidden;
}

/* Common Panels */
.junior-panel {
    background: var(--brand-card-bg);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    border: 2px solid var(--brand-border);
    box-shadow: var(--brand-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.panel-header-title {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 13px;
    color: #0369A1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    text-align: center;
}

/* ==========================================================================
   1. Commands Panel (Left) - Interactive D-Pad & Jump Buttons
   ========================================================================== */
.commands-panel {
    width: 236px;
    flex-shrink: 0;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
}

.commands-panel::-webkit-scrollbar {
    width: 4px;
}
.commands-panel::-webkit-scrollbar-thumb {
    background: #BAE6FD;
    border-radius: 4px;
}

/* D-Pad Wrapper & Unified Cross Housing */
.dpad-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 4px;
}

.dpad-container {
    display: grid;
    grid-template-columns: 54px 62px 54px;
    grid-template-rows: 54px 62px 54px;
    gap: 4px;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 6px;
    background: #E2E8F0;
    border-radius: 36px;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12), inset 0 2px 4px rgba(255, 255, 255, 0.7);
    border: 3px solid #CBD5E1;
}

.dpad-btn {
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    touch-action: manipulation;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12), inset 0 2px 0 rgba(255, 255, 255, 0.4);
    transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.12s ease;
}

.dpad-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.06);
}

.dpad-btn:active {
    transform: scale(0.96) translateY(2px);
    border-bottom-width: 2px !important;
}

.dpad-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.5);
}

.dpad-btn .material-symbols-rounded {
    font-size: 32px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

/* Direction Colors & Borders */
.dpad-up {
    grid-column: 2;
    grid-row: 1;
    width: 62px;
    height: 52px;
    background: linear-gradient(180deg, #34D399, #059669);
    border-bottom: 4px solid #047857;
    color: white;
}

.dpad-down {
    grid-column: 2;
    grid-row: 3;
    width: 62px;
    height: 52px;
    background: linear-gradient(180deg, #A78BFA, #7C3AED);
    border-bottom: 4px solid #6D28D9;
    color: white;
}

.dpad-left {
    grid-column: 1;
    grid-row: 2;
    width: 52px;
    height: 62px;
    background: linear-gradient(180deg, #38BDF8, #0284C7);
    border-bottom: 4px solid #0369A1;
    color: white;
}

.dpad-right {
    grid-column: 3;
    grid-row: 2;
    width: 52px;
    height: 62px;
    background: linear-gradient(180deg, #FB923C, #EA580C);
    border-bottom: 4px solid #C2410C;
    color: white;
}

/* D-Pad Center: Interactive Reactive Robot Head */
.dpad-center-robot {
    grid-column: 2;
    grid-row: 2;
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    pointer-events: none;
    z-index: 5;
}

.dpad-head-svg {
    width: 58px;
    height: 58px;
    display: block;
}

.head-pupil {
    transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dynamic Gaze Reaction when Arrows Hovered/Pressed */
.dpad-center-robot.look-up .head-pupil {
    transform: translate(0, -3.2px);
}
.dpad-center-robot.look-down .head-pupil {
    transform: translate(0, 3.2px);
}
.dpad-center-robot.look-left .head-pupil {
    transform: translate(-3.2px, 0);
}
.dpad-center-robot.look-right .head-pupil {
    transform: translate(3.2px, 0);
}

/* Idle eye blink for D-Pad robot */
.dpad-center-robot:not(.look-up):not(.look-down):not(.look-left):not(.look-right) .head-eye {
    animation: codieEyeBlink 3.8s infinite ease-in-out;
    transform-origin: 30px 33px;
}

/* ==========================================================================
   Jump Buttons Container (under D-Pad)
   ========================================================================== */
.jump-buttons-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    width: 100%;
    margin-top: 14px;
    position: relative;
}

.junior-jump-btn {
    width: 88px;
    height: 76px;
    border-radius: 22px;
    border: none;
    background: linear-gradient(135deg, #F472B6, #EC4899);
    border-bottom: 4px solid #DB2777;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.45);
    transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease;
}

.junior-jump-btn:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 20px rgba(236, 72, 153, 0.45);
}

.junior-jump-btn:active {
    transform: scale(0.96) translateY(2px);
    border-bottom-width: 2px;
}

.jump-btn-icon-svg {
    width: 72px;
    height: 64px;
    display: block;
}

/* ==========================================================================
   Radial Mini-Menu (Petals / Fan Direction Picker for Jump)
   - Zero Blur: Student clearly sees the map and character!
   - 210x210px Spacious Layout with 56px Petals for Easy Finger Taps!
   - Stable Hover: No translation offsets to prevent jitter/dropping!
   ========================================================================== */
.jump-radial-menu {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.jump-radial-menu.open {
    display: block !important;
    opacity: 1;
    pointer-events: auto;
}

/* Ultra-light overlay with ZERO BLUR so board is 100% visible */
.radial-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.08);
    backdrop-filter: none;
    z-index: 1;
}

.radial-petals-wrap {
    position: absolute;
    z-index: 2;
    width: 210px;
    height: 210px;
    transform: translate(-50%, -50%) scale(0.5);
    transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jump-radial-menu.open .radial-petals-wrap {
    transform: translate(-50%, -50%) scale(1);
}

/* Big 56x56px Direction Petals */
.radial-petal {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    touch-action: manipulation;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    transform: scale(1);
    transform-origin: center center;
    transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.16s ease, filter 0.16s ease;
}

/* Scales up on hover without moving or shaking! */
.radial-petal:hover {
    transform: scale(1.18);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
    filter: brightness(1.08);
}

.radial-petal:active {
    transform: scale(0.95);
}

.radial-petal .material-symbols-rounded {
    font-size: 32px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

/* Exact coordinate positioning: center is 105px, offset is (105 - 28) = 77px */
.petal-up {
    position: absolute;
    top: 4px;
    left: 77px;
    background: linear-gradient(180deg, #34D399, #059669);
}

.petal-right {
    position: absolute;
    top: 77px;
    right: 4px;
    background: linear-gradient(180deg, #FB923C, #EA580C);
}

.petal-down {
    position: absolute;
    bottom: 4px;
    left: 77px;
    background: linear-gradient(180deg, #A78BFA, #7C3AED);
}

.petal-left {
    position: absolute;
    top: 77px;
    left: 4px;
    background: linear-gradient(180deg, #38BDF8, #0284C7);
}

.radial-center-badge {
    position: absolute;
    top: 80px;
    left: 80px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #E11D48;
    border: 3px solid #FDE047;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    box-sizing: border-box;
}

.radial-dots-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ==========================================================================
   2. Program Conveyor Panel (Middle) - Top-down chain & Bottom Controls
   ========================================================================== */
.conveyor-panel {
    width: 205px;
    flex-shrink: 0;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

/* Slots Scroll Area - Scrollable for long programs, never pushes controls off! */
.slots-scroll-area {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    -webkit-overflow-scrolling: touch;
}

.slots-scroll-area::-webkit-scrollbar {
    width: 5px;
}
.slots-scroll-area::-webkit-scrollbar-thumb {
    background: #BAE6FD;
    border-radius: 4px;
}

.slots-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    align-items: center;
}

/* High Contrast, Touch-Friendly Program Slots */
.junior-slot {
    width: 160px;
    height: 58px;
    border-radius: 18px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
    touch-action: manipulation;
}

.junior-slot.empty {
    border: 2.5px dashed #94A3B8;
    background: rgba(241, 245, 249, 0.85);
}

.slot-number {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 20px;
    color: #94A3B8;
}

.junior-slot.drag-over {
    border-color: #0284C7;
    background: #E0F2FE;
    transform: scale(1.05);
}

.junior-slot.filled {
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12), inset 0 2px 0 rgba(255, 255, 255, 0.35);
    cursor: pointer;
}

/* Arrow Block Fills */
.junior-slot.block-right {
    background: linear-gradient(135deg, #FB923C, #EA580C);
    border-bottom: 4px solid #C2410C;
}

.junior-slot.block-left {
    background: linear-gradient(135deg, #38BDF8, #0284C7);
    border-bottom: 4px solid #0369A1;
}

.junior-slot.block-up {
    background: linear-gradient(135deg, #34D399, #059669);
    border-bottom: 4px solid #047857;
}

.junior-slot.block-down {
    background: linear-gradient(135deg, #A78BFA, #7C3AED);
    border-bottom: 4px solid #6D28D9;
}

/* Jump Block Fill - Candy Pink distinct from purple! */
.junior-slot.block-jump {
    height: 58px;
    background: linear-gradient(135deg, #F472B6, #EC4899);
    border-bottom: 4px solid #DB2777;
}

.junior-slot .block-icon-svg {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

.junior-slot .jump-svg {
    width: 116px;
    height: 46px;
}

.junior-slot.filled .slot-remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #EF4444;
    color: white;
    border: 2px solid white;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    z-index: 10;
    transition: transform 0.1s ease;
}

.junior-slot.filled .slot-remove-btn:hover {
    transform: scale(1.15);
    background: #DC2626;
}

.junior-slot.executing {
    box-shadow: 0 0 0 4px #F59E0B, 0 0 20px #FBBF24 !important;
    transform: scale(1.06) !important;
    z-index: 10;
}

/* Compact slots for levels with 7+ commands */
.slots-compact .junior-slot {
    height: 48px;
    width: 154px;
}
.slots-compact .junior-slot.block-jump {
    height: 48px;
}
.slots-compact .junior-slot .block-icon-svg {
    width: 40px;
    height: 40px;
}
.slots-compact .junior-slot .jump-svg {
    width: 104px;
    height: 40px;
}

/* ==========================================================================
   Bottom Controls Bar (Reset, Big PLAY, Trash)
   Positioned at the bottom of the Commands Panel on the left!
   ========================================================================== */
.commands-bottom-bar,
.conveyor-bottom-bar {
    width: 100%;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 10px;
    border-top: 2px dashed #BAE6FD;
    flex-shrink: 0;
}

/* Big Primary PLAY Button with Optical Centering */
.junior-btn {
    touch-action: manipulation;
}

.junior-btn.btn-play-large {
    flex: 1;
    min-width: 80px;
    height: 48px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #10B981, #059669);
    border-bottom: 4px solid #047857;
    color: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.4);
    transition: transform 0.12s ease;
}

.junior-btn.btn-play-large .play-icon {
    font-size: 26px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    margin-top: -1px;
}

.junior-btn.btn-play-large .btn-play-text {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 16px;
    line-height: 1;
    display: inline-block;
    padding-top: 1px;
    letter-spacing: 0.5px;
}

.junior-btn.btn-play-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.junior-btn.btn-play-large:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.junior-btn.btn-play-large.is-running {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    border-bottom-color: #991B1B;
    animation: runPulse 1.2s infinite alternate ease-in-out;
}

@keyframes runPulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.03); filter: brightness(1.12); }
}

/* Compact Round Reset Button */
.junior-btn.btn-reset {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #FBBF24, #F59E0B);
    border-bottom: 3px solid #B45309;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.4);
    transition: transform 0.12s ease;
    flex-shrink: 0;
}

.junior-btn.btn-reset .material-symbols-rounded {
    font-size: 24px;
}

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

.junior-btn.btn-reset:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

/* Compact Round Trash Button */
.junior-btn.btn-trash {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid #FCA5A5;
    background: #FEE2E2;
    color: #DC2626;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.12);
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.junior-btn.btn-trash .material-symbols-rounded {
    font-size: 22px;
}

.junior-btn.btn-trash:hover {
    background: #FCA5A5;
    color: #991B1B;
}

/* ==========================================================================
   3. Stage Board Panel (Right) - Fills Available Space Without Waste!
   ========================================================================== */
.stage-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 8px;
    background: radial-gradient(circle at 50% 30%, #F0F9FF 0%, #E0F2FE 55%, #DCFCE7 100%);
    border: 2px solid var(--brand-border);
}

.board-canvas-holder {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.junior-board {
    position: relative;
    box-sizing: content-box;
    background: #68C53C;
    border-radius: 28px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18), inset 0 2px 4px rgba(255, 255, 255, 0.35);
    overflow: hidden;
    border: 5px solid #4ADE80;
    transition: width 0.15s ease, height 0.15s ease;
}

.junior-cell {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.junior-tile-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.junior-obstacle {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 5;
}

.junior-bush-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.junior-star-item {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 6;
}

.junior-star-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.star-spinning {
    animation: starFloat 3s infinite ease-in-out;
    transform-origin: 40px 40px;
}

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

.star-collecting {
    animation: collectStarPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes collectStarPop {
    0% { transform: scale(1) translateY(0); opacity: 1; }
    50% { transform: scale(1.6) translateY(-24px); opacity: 0.9; }
    100% { transform: scale(0.1) translateY(-48px); opacity: 0; }
}

/* ==========================================================================
   Finish Super Battery Animations (Living Finish Beacon)
   ========================================================================== */
.junior-goal {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 7;
}

.junior-battery-svg {
    width: 100%;
    height: 100%;
    display: block;
    animation: batteryFloat 2.4s infinite ease-in-out;
}

.junior-goal.goal-activated .junior-battery-svg {
    animation: batteryCollect 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes batteryCollect {
    0% { transform: scale(1); opacity: 1; filter: brightness(1); }
    40% { transform: scale(1.25); opacity: 1; filter: brightness(1.6) drop-shadow(0 0 14px #FDE047); }
    100% { transform: scale(0.2); opacity: 0; filter: brightness(1.8); }
}

@keyframes batteryFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.05); }
}

.battery-halo {
    animation: batteryHaloPulse 2s infinite ease-in-out;
    transform-origin: 40px 45px;
}

@keyframes batteryHaloPulse {
    0%, 100% { transform: scale(0.92); opacity: 0.55; }
    50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 14px #FDE047); }
}

.battery-core {
    animation: batteryCoreGlow 1.8s infinite alternate ease-in-out;
}

@keyframes batteryCoreGlow {
    0% { opacity: 0.85; filter: brightness(1); }
    100% { opacity: 1; filter: brightness(1.25); }
}

.battery-bolt {
    animation: batteryBoltFlash 1.2s infinite ease-in-out;
    transform-origin: 40px 41px;
}

@keyframes batteryBoltFlash {
    0%, 100% { filter: drop-shadow(0 0 2px #FDE047); transform: scale(1); }
    50% { filter: drop-shadow(0 0 10px #F59E0B) drop-shadow(0 0 16px #38BDF8); transform: scale(1.08); }
}

.battery-sparkle {
    animation: batterySparkleTwinkle 1.6s infinite ease-in-out;
    transform-origin: 40px 40px;
}
.battery-sparkle.s-1 { animation-delay: 0s; }
.battery-sparkle.s-2 { animation-delay: 0.8s; }

@keyframes batterySparkleTwinkle {
    0%, 100% { transform: scale(0.7) rotate(0deg); opacity: 0.4; }
    50% { transform: scale(1.25) rotate(45deg); opacity: 1; }
}

/* ==========================================================================
   Baby Codie Character - Living Eyes (Blinking & Looking Around)
   ========================================================================== */
.junior-character {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20;
    pointer-events: none;
    will-change: transform;
}

.junior-codie-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Natural Blinking Animation */
.junior-codie-svg.state-idle .codie-eye,
.junior-codie-svg.state-walk .codie-eye {
    animation: codieEyeBlink 3.8s infinite ease-in-out;
    transform-origin: 40px 48px;
}

@keyframes codieEyeBlink {
    0%, 93%, 97%, 100% {
        transform: scaleY(1);
    }
    95% {
        transform: scaleY(0.06);
    }
}

/* Curious Looking-Around Animation for Eyes */
.junior-codie-svg.state-idle .eye-pupil-group {
    animation: codiePupilLookAround 5.5s infinite ease-in-out;
}

@keyframes codiePupilLookAround {
    0%, 15% {
        transform: translate(0, 0);
    }
    22%, 38% {
        transform: translate(-2.6px, -0.4px); /* Glance slightly left */
    }
    48%, 64% {
        transform: translate(2.6px, 0px);    /* Glance slightly right */
    }
    72%, 100% {
        transform: translate(0, 0);          /* Look straight */
    }
}

/* Antenna Breathing Bob */
.junior-codie-svg.state-idle .codie-antenna {
    animation: antennaBob 2.6s infinite ease-in-out;
    transform-origin: 40px 25px;
}

@keyframes antennaBob {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(3deg); }
}

/* Ground Shadow Element (Keeps 3D ground contact during jumps) */
.junior-ground-shadow {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 15;
    pointer-events: none;
    will-change: transform, opacity;
}
.junior-ground-shadow .shadow-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Character Jumping Dynamics (Squash, Stretch, & Landing) */
.junior-character.jump-crouch .junior-codie-svg {
    transform-origin: center bottom;
    transform: scale(1.18, 0.76) !important;
    transition: transform 0.12s ease-in;
}

.junior-character.jump-stretch .junior-codie-svg {
    transform-origin: center bottom;
    transform: scale(0.84, 1.24) !important;
}

.junior-character.jump-land .junior-codie-svg {
    transform-origin: center bottom;
    animation: jumpLandingBounce 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes jumpLandingBounce {
    0% { transform: scale(1.3, 0.7); }
    40% { transform: scale(0.9, 1.12); }
    75% { transform: scale(1.06, 0.95); }
    100% { transform: scale(1, 1); }
}

/* Character Walking Waddle / Track Movement */
.junior-character.is-walking .junior-codie-svg {
    animation: codieWalkBob 0.22s infinite alternate ease-in-out;
    transform-origin: center bottom;
}

@keyframes codieWalkBob {
    0% { transform: translateY(0px) rotate(-3deg); }
    100% { transform: translateY(-5px) rotate(3deg); }
}

/* Hide internal sprite shadow while airborne so external ground shadow provides real 3D depth */
.junior-character.is-jumping .codie-shadow {
    opacity: 0 !important;
}

/* ==========================================================================
   Big Touch Jump Picker Modal (Designed for Tablets & Mobile Phones)
   ========================================================================== */
.junior-jump-modal-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.junior-jump-modal-overlay.visible {
    display: flex !important;
}

.jump-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
}

.jump-modal-card {
    position: relative;
    z-index: 10;
    background: white;
    border-radius: 36px;
    padding: 24px 28px;
    width: 90%;
    max-width: 440px;
    max-height: 94vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 4px solid #8B5CF6;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jump-modal-header {
    margin-bottom: 20px;
}

.jump-modal-title {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 26px;
    color: #6D28D9;
}

.jump-modal-section {
    width: 100%;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.jump-section-label {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 16px;
    color: #334155;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Direction Choice: 4 Huge Chunky Buttons (62x62px) */
.jump-dirs-row {
    display: flex;
    gap: 14px;
    justify-content: center;
    width: 100%;
}

.jump-big-dir-btn {
    width: 62px;
    height: 62px;
    border-radius: 20px;
    border: 3px solid #E2E8F0;
    background: #F8FAFC;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jump-big-dir-btn .material-symbols-rounded {
    font-size: 34px;
}

.jump-big-dir-btn:hover {
    transform: translateY(-2px) scale(1.05);
    border-color: #A78BFA;
    background: #F3E8FF;
}

.jump-big-dir-btn.active {
    background: linear-gradient(135deg, #8B5CF6, #6D28D9);
    border-color: #FDE047;
    color: white;
    transform: scale(1.08);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
}

/* Distance Choice: 2 Huge Chunky Buttons (110x68px) */
.jump-dists-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    width: 100%;
}

.jump-big-dist-btn {
    flex: 1;
    max-width: 150px;
    height: 68px;
    border-radius: 22px;
    border: 3px solid #E2E8F0;
    background: #F8FAFC;
    color: #334155;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jump-big-dist-btn .dist-num {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 24px;
    line-height: 1;
}

.jump-big-dist-btn .dist-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 1px;
}

.jump-big-dist-btn .dist-dots {
    font-size: 10px;
    color: #94A3B8;
    letter-spacing: 2px;
}

.jump-big-dist-btn:hover {
    transform: translateY(-2px) scale(1.04);
    border-color: #38BDF8;
    background: #E0F2FE;
}

.jump-big-dist-btn.active {
    background: linear-gradient(135deg, #38BDF8, #0284C7);
    border-color: #FDE047;
    color: white;
    transform: scale(1.06);
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35);
}

.jump-big-dist-btn.active .dist-dots {
    color: #FDE047;
}

/* Confirm Button */
.jump-modal-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 6px;
}

.jump-confirm-btn {
    width: 100%;
    height: 54px;
    border-radius: 20px;
    border: none;
    background: linear-gradient(135deg, #10B981, #059669);
    border-bottom: 4px solid #047857;
    color: white;
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
    transition: transform 0.15s ease;
}

.jump-confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45);
}

.jump-confirm-btn:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

/* Victory Modals */
.junior-dialogs-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 0;
}

.junior-dialogs-overlay.visible {
    display: flex;
}

.junior-modal-backdrop {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
}

.junior-victory-dialog {
    position: relative;
    z-index: 1000;
    background: linear-gradient(180deg, #FFFFFF 0%, #FEF9C3 100%);
    border-radius: 40px;
    padding: 34px 40px 26px;
    width: 92%;
    max-width: 440px;
    box-shadow: 0 25px 60px rgba(245, 158, 11, 0.4), 0 12px 30px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 5px solid #FDE047;
    animation: modalPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: visible;
}

@keyframes modalPop {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.junior-confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 999;
}

.victory-ribbon-badge {
    position: absolute;
    top: -20px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 14px;
    letter-spacing: 1px;
    padding: 6px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
    border: 3px solid #FEF08A;
    text-transform: uppercase;
}

.victory-title {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 34px;
    background: linear-gradient(135deg, #F59E0B, #EA580C);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(245, 158, 11, 0.25));
    margin-top: 8px;
    letter-spacing: 0.5px;
}

.victory-stars-row {
    display: flex;
    gap: 16px;
    margin: 16px 0 14px;
}

.v-star {
    width: 68px;
    height: 68px;
    opacity: 0.25;
    filter: grayscale(1);
    transform: scale(0.85);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.v-star.earned {
    opacity: 1;
    filter: none;
    transform: scale(1);
    animation: starBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.v-star.star-1.earned { animation-delay: 0.1s; }
.v-star.star-2.earned { animation-delay: 0.3s; }
.v-star.star-3.earned { animation-delay: 0.5s; }

@keyframes starBounce {
    0% { transform: scale(0.2); }
    70% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.victory-codie-avatar {
    width: 105px;
    height: 105px;
    margin-bottom: 18px;
    animation: victoryCodieCheer 0.6s infinite alternate cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes victoryCodieCheer {
    0% { transform: translateY(0px) rotate(-3deg) scale(1); }
    100% { transform: translateY(-10px) rotate(3deg) scale(1.06); }
}

.victory-buttons {
    display: flex;
    gap: 14px;
    width: 100%;
    justify-content: center;
}

.v-btn {
    border-radius: 22px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease;
}

.v-btn-replay {
    width: 64px;
    height: 64px;
    background: #F3F4F6;
    color: #4B5563;
    border: 2px solid #D1D5DB;
}

.v-btn-replay .material-symbols-rounded {
    font-size: 34px;
}

.v-btn-share {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #38BDF8, #0284C7);
    border-bottom: 4px solid #0369A1;
    color: #ffffff;
    flex-shrink: 0;
}

.v-btn-share .material-symbols-rounded {
    font-size: 30px;
}

.v-btn-next {
    flex: 1;
    height: 64px;
    background: linear-gradient(135deg, #10B981, #059669);
    border-bottom: 4px solid #047857;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 24px;
    letter-spacing: 0.5px;
    padding: 0 20px;
}

.v-btn-next .material-symbols-rounded {
    font-size: 38px;
}

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

.v-btn:active {
    transform: translateY(2px);
}

/* ==========================================================================
   Target Cell Glow, Landing Dust Puffs & Floating Stars
   ========================================================================== */
.cell-target-active {
    z-index: 2;
}

.cell-target-active::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 3.5px #FDE047, 0 0 16px rgba(253, 224, 71, 0.8);
    animation: targetCellPulse 0.45s ease-in-out infinite alternate;
}

@keyframes targetCellPulse {
    0% { filter: brightness(1.02); }
    100% { filter: brightness(1.25); }
}

/* Landing Dust Puffs */
.junior-landing-dust {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 45;
}

.dust-puff {
    position: absolute;
    width: 22px;
    height: 14px;
    background: rgba(241, 245, 249, 0.9);
    border: 1.5px solid #CBD5E1;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.3);
}

.dust-puff-left {
    animation: dustPuffLeft 0.5s cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
}

.dust-puff-right {
    animation: dustPuffRight 0.5s cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
}

@keyframes dustPuffLeft {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0.95;
    }
    60% {
        transform: translate(calc(-50% - 18px), calc(-50% - 6px)) scale(1.15);
        opacity: 0.75;
    }
    100% {
        transform: translate(calc(-50% - 28px), calc(-50% - 12px)) scale(1.4);
        opacity: 0;
    }
}

@keyframes dustPuffRight {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0.95;
    }
    60% {
        transform: translate(calc(-50% + 18px), calc(-50% - 6px)) scale(1.15);
        opacity: 0.75;
    }
    100% {
        transform: translate(calc(-50% + 28px), calc(-50% - 12px)) scale(1.4);
        opacity: 0;
    }
}

/* Floating Star Collected */
.junior-floating-star {
    position: absolute;
    width: 36px;
    height: 36px;
    pointer-events: none;
    z-index: 55;
    filter: drop-shadow(0 2px 8px rgba(245, 158, 11, 0.6));
    animation: starSparkleGlow 0.35s ease-in-out infinite alternate;
}

@keyframes starSparkleGlow {
    0% { filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.6)); }
    100% { filter: drop-shadow(0 0 16px rgba(254, 240, 138, 0.95)); }
}

/* ==========================================================================
   Responsive Adaptations (Narrow / Mobile Viewports)
   Guarantees ZERO body scrollbars, everything fits in 100dvh / --vh
   ========================================================================== */
/* Portrait Viewports (Mobile & Tablet in Portrait) */
@media (max-width: 850px) and (orientation: portrait), (max-width: 680px) and (min-height: 541px) {
    .junior-navbar {
        height: 46px;
        padding: 0 8px;
        gap: 6px;
    }

    .nav-left, .nav-right {
        gap: 6px;
        min-width: 0;
    }

    .junior-navbar .brand-avatar {
        width: 26px;
        height: 26px;
    }

    .game-nav .brand-text {
        display: none;
    }

    .brand-text {
        font-size: 18px;
    }

    .junior-nav-btn {
        height: 34px;
        padding: 0 10px;
        font-size: 13px;
        border-radius: 17px;
        gap: 5px;
    }

    .level-indicator-pill, .stars-pill, .map-stars-badge {
        height: 34px;
        padding: 0 10px;
        font-size: 13px;
        gap: 4px;
    }

    .star-gold-icon {
        font-size: 17px;
    }

    .junior-navbar .lang-btn {
        height: 34px;
        padding: 0 10px;
        font-size: 13px;
        gap: 4px;
    }

    .junior-navbar .lang-icon-svg {
        width: 16px;
        height: 16px;
    }

    .junior-navbar .lang-code {
        font-size: 12px;
    }

    .junior-circle-btn {
        width: 34px;
        height: 34px;
    }

    .junior-circle-btn .material-symbols-rounded {
        font-size: 20px;
    }

    .junior-workspace-layout {
        flex-direction: column;
        padding: 5px 6px max(6px, env(safe-area-inset-bottom));
        gap: 5px;
        height: auto;
        max-height: none;
    }

    /* 1. Board Stage in upper area, flexing to fill space */
    .stage-panel {
        order: 1;
        flex: 1 1 0;
        min-height: 0;
        width: 100%;
        padding: 4px;
        border-radius: 18px;
    }

    /* 2. Conveyor row right under the board */
    .conveyor-panel {
        order: 2;
        width: 100%;
        height: auto;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        border-radius: 16px;
        padding: 2px 6px;
        overflow: hidden;
    }

    .conveyor-panel .panel-header-title {
        display: none;
    }

    .slots-scroll-area {
        flex: 1;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px 4px 6px;
        touch-action: pan-x;
        scrollbar-width: thin;
    }

    .slots-scroll-area::-webkit-scrollbar {
        height: 4px;
        width: 0;
    }

    .slots-list {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: max-content;
        min-width: 100%;
    }

    .junior-slot,
    .slots-compact .junior-slot {
        width: 58px;
        height: 46px;
        border-radius: 13px;
    }

    .junior-slot.block-jump,
    .slots-compact .junior-slot.block-jump {
        width: 84px;
        height: 46px;
    }

    .junior-slot .block-icon-svg,
    .slots-compact .junior-slot .block-icon-svg {
        width: 30px;
        height: 30px;
    }

    .junior-slot .jump-svg,
    .slots-compact .junior-slot .jump-svg {
        width: 74px;
        height: 34px;
    }

    .slot-number {
        font-size: 17px;
    }

    .junior-slot.filled .slot-remove-btn {
        width: 20px;
        height: 20px;
        font-size: 13px;
        top: -6px;
        right: -5px;
    }

    /* 3. Thumb-zone Commands Panel at bottom: 2-column CSS Grid (D-Pad left, Jumps + Controls right) */
    .commands-panel {
        order: 3;
        width: 100%;
        height: auto;
        max-height: none;
        flex: 0 0 auto;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-items: center;
        align-content: center;
        column-gap: 10px;
        row-gap: 8px;
        border-radius: 20px;
        padding: 8px 10px;
        overflow: visible;
    }

    .commands-panel .panel-header-title {
        display: none;
    }

    .commands-panel.no-jumps {
        grid-template-rows: 1fr;
    }

    .dpad-wrapper {
        grid-column: 1;
        grid-row: 1 / span 2;
        width: auto;
        margin-top: 0;
    }

    .commands-panel.no-jumps .dpad-wrapper {
        grid-row: 1;
    }

    .dpad-container {
        grid-template-columns: 40px 46px 40px;
        grid-template-rows: 40px 46px 40px;
        gap: 3px;
        padding: 4px;
        border-radius: 24px;
        border-width: 2px;
    }

    .dpad-btn {
        border-radius: 14px;
    }

    .dpad-up, .dpad-down {
        width: 46px;
        height: 38px;
    }
    .dpad-left, .dpad-right {
        width: 38px;
        height: 46px;
    }

    .dpad-center-robot {
        width: 46px;
        height: 46px;
    }
    .dpad-head-svg {
        width: 42px;
        height: 42px;
    }

    .dpad-btn .material-symbols-rounded {
        font-size: 24px;
    }

    .jump-buttons-container {
        grid-column: 2;
        grid-row: 1;
        margin-top: 0;
        gap: 8px;
        width: 100%;
        justify-content: stretch;
        align-items: center;
    }

    .junior-jump-btn {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        height: 58px;
        border-radius: 16px;
        padding: 4px;
    }

    .jump-btn-icon-svg {
        width: 52px;
        height: 44px;
        max-width: 100%;
        max-height: 100%;
    }

    .commands-bottom-bar,
    .conveyor-bottom-bar {
        grid-column: 2;
        grid-row: 2;
        width: 100%;
        margin: 0;
        padding: 0;
        border-top: none;
        gap: 6px;
        justify-content: stretch;
    }

    .commands-panel.no-jumps .commands-bottom-bar {
        grid-row: 1;
        align-self: center;
    }

    .junior-btn.btn-play-large {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        height: 50px;
        border-radius: 14px;
        padding: 0 8px;
        gap: 4px;
    }

    .junior-btn.btn-play-large .play-icon {
        font-size: 28px;
    }

    .junior-btn.btn-play-large .btn-play-text {
        font-size: 14px;
    }

    .junior-btn.btn-reset, .junior-btn.btn-trash {
        width: 46px;
        height: 50px;
        border-radius: 14px;
    }

    .commands-panel.no-jumps .junior-btn.btn-play-large {
        height: 56px;
    }

    .commands-panel.no-jumps .junior-btn.btn-reset,
    .commands-panel.no-jumps .junior-btn.btn-trash {
        width: 50px;
        height: 56px;
    }

    .map-title {
        font-size: 22px;
    }

    .junior-map-grid {
        grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
        gap: 10px;
    }
}

/* Smartphone Refinements (<=520px) */
@media (max-width: 520px) {
    .game-nav .btn-map-toggle {
        width: 34px;
        padding: 0;
        justify-content: center;
    }

    .game-nav .btn-map-toggle .btn-text {
        display: none;
    }

    .junior-map-screen .btn-exit {
        width: 36px;
        padding: 0;
        justify-content: center;
    }

    .junior-map-screen .btn-exit .btn-text {
        display: none;
    }

    .map-main-content {
        padding: 10px 8px 16px;
    }

    .map-title-wrap {
        margin-bottom: 10px;
    }

    .map-title {
        font-size: 20px;
    }

    .map-subtitle {
        font-size: 12px;
    }

    .map-grid-container {
        padding: 12px 10px;
        border-radius: 20px;
    }

    .junior-map-grid {
        grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
        gap: 9px;
    }

    .junior-map-card {
        height: 74px;
        border-radius: 15px;
    }

    .m-level-num {
        font-size: 21px;
    }

    .map-codie-pin {
        width: 36px;
        height: 36px;
        top: -18px;
        right: -6px;
    }

    .junior-victory-dialog {
        padding: 26px 20px 20px;
        border-radius: 30px;
        margin: auto;
        overflow: visible;
    }

    .victory-title {
        font-size: 26px;
    }

    .victory-stars-row {
        gap: 12px;
        margin: 12px 0 10px;
    }

    .v-star {
        width: 54px;
        height: 54px;
    }

    .victory-codie-avatar {
        width: 84px;
        height: 84px;
        margin-bottom: 14px;
    }

    .v-btn-replay,
    .v-btn-share {
        width: 54px;
        height: 54px;
    }

    .v-btn-share .material-symbols-rounded {
        font-size: 26px;
    }

    .v-btn-next {
        height: 54px;
        font-size: 20px;
    }
}

@media (max-width: 460px) {
    .junior-btn.btn-play-large .btn-play-text {
        display: none;
    }
}

/* Narrow Phones (<=390px, e.g. 360px Android) */
@media (max-width: 390px) {
    .junior-navbar {
        height: 44px;
        padding: 0 6px;
        gap: 4px;
    }

    .nav-left, .nav-right {
        gap: 4px;
    }

    .junior-navbar .brand-avatar {
        width: 24px;
        height: 24px;
    }

    .junior-nav-btn {
        height: 32px;
        font-size: 12px;
    }

    .game-nav .btn-map-toggle {
        width: 32px;
    }

    .level-indicator-pill, .stars-pill, .map-stars-badge {
        height: 32px;
        padding: 0 8px;
        font-size: 12px;
        gap: 3px;
    }

    .star-gold-icon {
        font-size: 15px;
    }

    .junior-navbar .lang-btn {
        height: 32px;
        padding: 0 8px;
        gap: 3px;
    }

    .junior-navbar .lang-arrow {
        display: none;
    }

    .junior-circle-btn {
        width: 32px;
        height: 32px;
    }

    .commands-panel {
        padding: 6px 8px;
        column-gap: 8px;
        row-gap: 6px;
        border-radius: 18px;
    }

    .dpad-container {
        grid-template-columns: 36px 42px 36px;
        grid-template-rows: 36px 42px 36px;
        gap: 3px;
        padding: 4px;
        border-radius: 22px;
    }

    .dpad-up, .dpad-down {
        width: 42px;
        height: 34px;
    }
    .dpad-left, .dpad-right {
        width: 34px;
        height: 42px;
    }

    .dpad-center-robot {
        width: 42px;
        height: 42px;
    }
    .dpad-head-svg {
        width: 38px;
        height: 38px;
    }

    .dpad-btn .material-symbols-rounded {
        font-size: 22px;
    }

    .jump-buttons-container {
        gap: 6px;
    }

    .junior-jump-btn {
        height: 52px;
        border-radius: 14px;
    }

    .jump-btn-icon-svg {
        width: 46px;
        height: 40px;
    }

    .commands-bottom-bar,
    .conveyor-bottom-bar {
        gap: 5px;
    }

    .junior-btn.btn-play-large {
        height: 46px;
        border-radius: 13px;
    }

    .junior-btn.btn-reset, .junior-btn.btn-trash {
        width: 42px;
        height: 46px;
        border-radius: 13px;
    }

    .commands-panel.no-jumps .junior-btn.btn-play-large {
        height: 52px;
    }

    .commands-panel.no-jumps .junior-btn.btn-reset,
    .commands-panel.no-jumps .junior-btn.btn-trash {
        width: 46px;
        height: 52px;
    }

    .junior-slot,
    .slots-compact .junior-slot {
        width: 52px;
        height: 44px;
    }

    .junior-slot.block-jump,
    .slots-compact .junior-slot.block-jump {
        width: 76px;
        height: 44px;
    }

    .junior-slot .jump-svg,
    .slots-compact .junior-slot .jump-svg {
        width: 66px;
        height: 32px;
    }

    .radial-petals-wrap {
        width: 190px;
        height: 190px;
    }

    .radial-petal {
        width: 50px;
        height: 50px;
    }

    .radial-petal .material-symbols-rounded {
        font-size: 28px;
    }

    .petal-up {
        top: 4px;
        left: 70px;
    }

    .petal-down {
        bottom: 4px;
        left: 70px;
    }

    .petal-left {
        top: 70px;
        left: 4px;
    }

    .petal-right {
        top: 70px;
        right: 4px;
    }

    .radial-center-badge {
        top: 72px;
        left: 72px;
        width: 46px;
        height: 46px;
    }
}

/* Short Portrait Phones (e.g. 360x640, iPhone SE with browser bars) */
@media (max-width: 680px) and (max-height: 660px) and (orientation: portrait) {
    .junior-workspace-layout {
        padding: 4px 5px;
        gap: 4px;
    }

    .commands-panel {
        padding: 6px 8px;
        row-gap: 6px;
    }

    .dpad-container {
        grid-template-columns: 34px 40px 34px;
        grid-template-rows: 34px 40px 34px;
    }

    .dpad-up, .dpad-down {
        width: 40px;
        height: 32px;
    }
    .dpad-left, .dpad-right {
        width: 32px;
        height: 40px;
    }

    .dpad-center-robot {
        width: 40px;
        height: 40px;
    }
    .dpad-head-svg {
        width: 36px;
        height: 36px;
    }

    .junior-jump-btn {
        height: 48px;
    }

    .junior-btn.btn-play-large {
        height: 44px;
    }

    .junior-btn.btn-reset, .junior-btn.btn-trash {
        width: 40px;
        height: 44px;
    }

    .junior-slot,
    .slots-compact .junior-slot,
    .junior-slot.block-jump,
    .slots-compact .junior-slot.block-jump {
        height: 42px;
    }
}

/* Landscape Viewports on Small Screens (Mobile Phones in Landscape) */
@media (orientation: landscape) and (max-height: 540px) {
    .junior-navbar {
        height: 42px;
        padding: 0 10px;
    }

    .brand-text {
        font-size: 17px;
    }

    .junior-nav-btn {
        height: 34px;
        padding: 0 10px;
        font-size: 13px;
    }

    .junior-circle-btn,
    .junior-navbar .lang-btn {
        height: 34px;
        padding: 0 10px;
    }

    .junior-circle-btn {
        width: 34px;
        padding: 0;
    }

    .map-stars-badge, .stars-pill, .level-indicator-pill {
        padding: 2px 10px;
        font-size: 13px;
    }

    .junior-workspace-layout {
        flex-direction: row;
        padding: 4px 6px;
        gap: 6px;
        height: auto;
        max-height: none;
    }

    /* Commands Panel on Left */
    .commands-panel {
        width: 165px;
        padding: 6px 4px;
        border-radius: 16px;
    }

    .commands-panel .panel-header-title {
        font-size: 11px;
        margin-bottom: 2px;
    }

    .dpad-container {
        grid-template-columns: 38px 44px 38px;
        grid-template-rows: 38px 44px 38px;
        padding: 3px;
        border-radius: 22px;
    }

    .dpad-up, .dpad-down {
        width: 44px;
        height: 36px;
    }
    .dpad-left, .dpad-right {
        width: 36px;
        height: 44px;
    }

    .dpad-center-robot {
        width: 44px;
        height: 44px;
    }
    .dpad-head-svg {
        width: 40px;
        height: 40px;
    }

    .dpad-btn .material-symbols-rounded {
        font-size: 22px;
    }

    .jump-buttons-container {
        margin-top: 6px;
        gap: 8px;
    }

    .junior-jump-btn {
        width: 58px;
        height: 48px;
        border-radius: 14px;
    }

    .jump-btn-icon-svg {
        width: 44px;
        height: 38px;
    }

    /* Conveyor in Middle */
    .conveyor-panel {
        width: 145px;
        padding: 6px 4px;
        border-radius: 16px;
    }

    .conveyor-panel .panel-header-title {
        font-size: 11px;
        margin-bottom: 2px;
    }

    .slots-scroll-area {
        padding: 4px;
    }

    .slots-list {
        gap: 5px;
    }

    .junior-slot {
        width: 120px;
        height: 44px;
        border-radius: 12px;
    }

    .slots-compact .junior-slot,
    .slots-compact .junior-slot.block-jump {
        width: 120px;
        height: 38px;
    }

    .junior-slot .block-icon-svg {
        width: 32px;
        height: 32px;
    }

    .slots-compact .junior-slot .block-icon-svg {
        width: 28px;
        height: 28px;
    }

    .junior-slot .jump-svg {
        width: 100px;
        height: 38px;
    }

    .slots-compact .junior-slot .jump-svg {
        width: 92px;
        height: 32px;
    }

    .conveyor-bottom-bar {
        padding-top: 4px;
        gap: 4px;
    }

    .junior-btn.btn-play-large {
        flex: 1;
        min-width: 52px;
        height: 36px;
        border-radius: 12px;
        font-size: 13px;
        padding: 0 4px;
    }
    .junior-btn.btn-play-large .btn-play-text {
        display: none;
    }
    .junior-btn.btn-play-large .play-icon {
        font-size: 20px;
    }

    .junior-btn.btn-reset, .junior-btn.btn-trash {
        width: 34px;
        height: 34px;
        border-radius: 50%;
    }
    .junior-btn.btn-reset .material-symbols-rounded,
    .junior-btn.btn-trash .material-symbols-rounded {
        font-size: 18px;
    }

    /* Stage on Right taking maximum room */
    .stage-panel {
        padding: 4px;
        border-radius: 16px;
    }

    .junior-victory-dialog {
        margin: auto;
        overflow: visible;
        padding: 20px 24px 16px;
        border-radius: 28px;
    }

    .victory-title {
        font-size: 24px;
    }

    .victory-stars-row {
        margin: 8px 0;
        gap: 10px;
    }

    .v-star {
        width: 48px;
        height: 48px;
    }

    .victory-codie-avatar {
        width: 72px;
        height: 72px;
        margin-bottom: 10px;
    }

    .v-btn-replay,
    .v-btn-share {
        width: 48px;
        height: 48px;
    }

    .v-btn-share .material-symbols-rounded {
        font-size: 22px;
    }

    .v-btn-next {
        height: 48px;
        font-size: 18px;
    }
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 660px) {
    .game-nav .brand-text {
        display: none;
    }
}
