/* ============================================
   BEAR FACTORY - Storybook Pop-Up Aesthetic
   ============================================ */

:root {
    /* Warm Storybook Palette */
    --cream: #FDF6E3;
    --cream-dark: #F5E6C8;
    --paper-white: #FFFEF9;

    --honey: #F5A623;
    --honey-dark: #D4881A;
    --honey-glow: #FFD980;

    --bear-brown: #8B5A2B;
    --bear-dark: #6B4423;
    --wood: #A0522D;
    --wood-light: #C4824A;

    --forest: #4A7C59;
    --forest-dark: #3A5F47;
    --mint: #A8D5BA;

    --candy-pink: #E85D75;
    --candy-pink-dark: #C94A5F;
    --blush: #FFD4DC;

    --sky: #87CEEB;
    --sky-light: #B8E0F0;

    --charcoal: #2C3E50;
    --slate: #546E7A;

    /* Shadows & Effects */
    --shadow-soft: 0 4px 12px rgba(139, 90, 43, 0.15);
    --shadow-medium: 0 8px 24px rgba(139, 90, 43, 0.2);
    --shadow-deep: 0 16px 48px rgba(139, 90, 43, 0.25);
    --shadow-inset: inset 0 2px 8px rgba(0, 0, 0, 0.1);

    /* Typography */
    --font-display: 'Baloo 2', cursive;
    --font-body: 'Nunito', sans-serif;

    /* Transitions */
    --bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Base & Reset
   ============================================ */

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-drag: none;
}

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

body {
    font-family: var(--font-body);
    background: linear-gradient(180deg, var(--sky-light) 0%, var(--cream) 40%, var(--cream-dark) 100%);
    color: var(--charcoal);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ============================================
   Paper Texture Overlay
   ============================================ */

.paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* ============================================
   Floating Clouds
   ============================================ */

.bg-clouds {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 40%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.cloud {
    position: absolute;
    background: white;
    border-radius: 100px;
    opacity: 0.8;
    filter: blur(2px);
}

.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: white;
    border-radius: 50%;
}

.cloud-1 {
    width: 120px;
    height: 40px;
    top: 15%;
    left: 10%;
    animation: float-cloud 20s ease-in-out infinite;
}

.cloud-1::before {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 20px;
}

.cloud-1::after {
    width: 35px;
    height: 35px;
    top: -15px;
    left: 55px;
}

.cloud-2 {
    width: 150px;
    height: 50px;
    top: 8%;
    right: 15%;
    animation: float-cloud 25s ease-in-out infinite reverse;
    animation-delay: -5s;
}

.cloud-2::before {
    width: 60px;
    height: 60px;
    top: -30px;
    left: 30px;
}

.cloud-2::after {
    width: 45px;
    height: 45px;
    top: -20px;
    left: 80px;
}

.cloud-3 {
    width: 100px;
    height: 35px;
    top: 20%;
    left: 50%;
    animation: float-cloud 18s ease-in-out infinite;
    animation-delay: -10s;
}

.cloud-3::before {
    width: 40px;
    height: 40px;
    top: -20px;
    left: 15px;
}

.cloud-3::after {
    width: 30px;
    height: 30px;
    top: -12px;
    left: 50px;
}

@keyframes float-cloud {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(30px); }
}

/* ============================================
   Game Container
   ============================================ */

#game-container {
    position: relative;
    width: 100%;
    max-width: 1100px;
    height: 100vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    z-index: 1;
    padding: 0.8rem;
}

/* Decorative Factory Pipes */
.deco-pipes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.pipe {
    position: absolute;
    width: 20px;
    background: linear-gradient(90deg, var(--slate) 0%, #6B7B8A 50%, var(--slate) 100%);
    border-radius: 10px;
}

.pipe-left {
    left: 30px;
    top: 150px;
    height: 200px;
}

.pipe-right {
    right: 30px;
    top: 100px;
    height: 250px;
}

.pipe::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -5px;
    width: 30px;
    height: 20px;
    background: var(--slate);
    border-radius: 5px;
}

/* ============================================
   Top Bar / HUD
   ============================================ */

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    gap: 1rem;
    z-index: 50;
    flex-shrink: 0;
}

.title-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--paper-white);
    padding: 0.6rem 1.5rem;
    border-radius: 50px;
    border: 4px solid var(--bear-brown);
    box-shadow:
        4px 4px 0 var(--bear-dark),
        var(--shadow-soft);
    transform: rotate(-2deg);
    transition: transform 0.3s var(--bounce);
}

.title-badge:hover {
    transform: rotate(0deg) scale(1.02);
}

.badge-icon {
    font-size: 1.8rem;
}

.game-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--bear-brown);
    margin: 0;
    text-shadow: 2px 2px 0 var(--honey-glow);
}

.difficulty-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--paper-white);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    border: 3px solid var(--forest);
    box-shadow: 3px 3px 0 var(--forest-dark);
}

.diff-label {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--forest);
    font-weight: 700;
}

.game-select {
    font-family: var(--font-display);
    font-size: 1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    border: 2px solid var(--forest);
    background: var(--mint);
    color: var(--forest-dark);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s var(--smooth);
}

.game-select:hover {
    background: var(--forest);
    color: white;
}

.game-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--honey-glow);
}

#score-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--honey) 0%, var(--honey-dark) 100%);
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    border: 3px solid var(--bear-brown);
    box-shadow:
        3px 3px 0 var(--bear-dark),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

/* Audio Toggle Button */
.audio-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--paper-white);
    border: 3px solid var(--forest);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s var(--bounce);
    box-shadow: 3px 3px 0 var(--forest-dark);
}

.audio-btn:hover {
    transform: scale(1.1);
    background: var(--mint);
}

.audio-btn:active {
    transform: scale(0.95);
    box-shadow: 1px 1px 0 var(--forest-dark);
}

.audio-btn.muted {
    background: var(--cream-dark);
    border-color: var(--slate);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
}

.audio-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.score-icon {
    font-size: 1.4rem;
    animation: pulse-star 2s ease-in-out infinite;
}

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

.score-value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    color: white;
    text-shadow: 2px 2px 0 var(--bear-dark);
}

.score-label {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--paper-white);
    font-weight: 700;
}

/* ============================================
   Main Stage
   ============================================ */

#stage {
    flex: 1;
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem 1rem;
    min-height: 0;
    overflow: visible;
}

/* ============================================
   Order Panel (Left Sidebar)
   ============================================ */

#order-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    width: 220px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

#bear-character {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bear-glow {
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, var(--honey-glow) 0%, transparent 70%);
    border-radius: 50%;
    animation: glow-pulse 3s ease-in-out infinite;
    z-index: 0;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

#bear-avatar {
    position: relative;
    width: 85px;
    height: 85px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFE4B5 0%, #DEB887 100%);
    border: 4px solid var(--paper-white);
    box-shadow:
        0 0 0 3px var(--bear-brown),
        var(--shadow-medium);
    overflow: hidden;
    animation: bear-bob 4s ease-in-out infinite;
    z-index: 1;
}

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

#bear-avatar img {
    width: 110%;
    height: 110%;
    object-fit: cover;
    transform: translate(-5%, -5%);
}

.bear-name-tag {
    margin-top: 0.3rem;
    background: var(--bear-brown);
    color: white;
    padding: 0.2rem 0.8rem;
    border-radius: 15px;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: 2px 2px 0 var(--bear-dark);
}

#order-ticket {
    background: var(--paper-white);
    border-radius: 20px;
    border: 4px solid var(--honey);
    box-shadow:
        6px 6px 0 var(--honey-dark),
        var(--shadow-soft);
    overflow: hidden;
    width: 100%;
    transform: rotate(1deg);
    transition: transform 0.3s var(--bounce);
}

#order-ticket:hover {
    transform: rotate(0deg) scale(1.02);
}

.ticket-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, var(--honey) 0%, var(--honey-dark) 100%);
    padding: 0.4rem;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 0 var(--bear-dark);
}

.ticket-icon {
    font-size: 1.2rem;
}

.ticket-body {
    padding: 0.6rem 0.5rem;
    text-align: center;
}

#order-text {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    line-height: 1.6;
}

.order-num.highlight {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--candy-pink);
    background: var(--blush);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    border: 2px dashed var(--candy-pink);
    display: inline-block;
    animation: number-bounce 0.6s var(--bounce);
}

@keyframes number-bounce {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.order-unit {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--charcoal);
}

.order-times {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--honey-dark);
    font-weight: 800;
    margin: 0 0.1rem;
}

.order-equals {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--forest);
    font-weight: 800;
    margin: 0 0.1rem;
}

.order-result {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--forest);
    font-weight: 800;
    background: var(--mint);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

#ship-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.6rem;
    background: linear-gradient(135deg, var(--forest) 0%, var(--forest-dark) 100%);
    color: white;
    border: none;
    border-radius: 0 0 16px 16px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s var(--smooth);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

#ship-btn:hover {
    background: linear-gradient(135deg, #5A9F6D 0%, var(--forest) 100%);
    transform: scale(1.02);
}

#ship-btn:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 1.4rem;
}

/* ============================================
   Conveyor Zone
   ============================================ */

#conveyor-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.3) 0%,
        rgba(255, 255, 255, 0.1) 100%);
    border-radius: 30px;
    border: 5px solid var(--paper-white);
    box-shadow:
        inset 0 0 30px rgba(255, 255, 255, 0.5),
        var(--shadow-medium);
    overflow: hidden;
}

/* Decorative Frame Corners */
.conveyor-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.frame-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 6px solid var(--wood);
    border-radius: 8px;
}

.frame-tl { top: 15px; left: 15px; border-right: none; border-bottom: none; }
.frame-tr { top: 15px; right: 15px; border-left: none; border-bottom: none; }
.frame-bl { bottom: 15px; left: 15px; border-right: none; border-top: none; }
.frame-br { bottom: 15px; right: 15px; border-left: none; border-top: none; }

/* Conveyor Belt */
#conveyor-belt {
    position: absolute;
    bottom: 30px;
    left: 5%;
    width: 90%;
    height: 80px;
    z-index: 2;
}

.belt-track {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 50px;
    background: repeating-linear-gradient(
        90deg,
        #5D4E37 0px,
        #5D4E37 40px,
        #4A3F2E 40px,
        #4A3F2E 80px
    );
    border-radius: 10px;
    border: 4px solid #3D3426;
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.3),
        inset 0 -5px 0 rgba(0, 0, 0, 0.2);
    animation: belt-scroll 2s linear infinite;
}

@keyframes belt-scroll {
    from { background-position: 0 0; }
    to { background-position: -80px 0; }
}

.belt-rollers {
    position: absolute;
    bottom: 45px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 0 20px;
}

.roller {
    width: 25px;
    height: 25px;
    background: radial-gradient(circle at 30% 30%, #8B8B8B, #5A5A5A);
    border-radius: 50%;
    border: 3px solid #4A4A4A;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    animation: roller-spin 1s linear infinite;
}

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

/* Active Crates Area */
#active-crates {
    position: relative;
    width: 100%;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    padding: 20px 15px;
    padding-bottom: 110px;
    z-index: 10;
    flex-wrap: wrap;
}

.zone-hint {
    position: absolute;
    bottom: 95px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--slate);
    box-shadow: var(--shadow-soft);
    z-index: 5;
    animation: hint-pulse 3s ease-in-out infinite;
}

@keyframes hint-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Placed Crates */
.placed-crate {
    width: 130px;
    height: 120px;
    background-image: url('assets/crate.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s var(--bounce);
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.25));
    animation: crate-land 0.4s var(--bounce);
    overflow: visible;
    margin-bottom: 18px; /* Space for stepper */
}

@keyframes crate-land {
    0% { transform: translateY(-50px) scale(0.8); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.placed-crate:hover {
    transform: scale(1.1) translateY(-8px);
    filter: drop-shadow(0 15px 20px rgba(0, 0, 0, 0.3));
}

/* Crate Contents - Grid Apple Layout */
.crate-contents {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 85px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
    align-items: center;
    justify-items: center;
    pointer-events: none;
}

.packed-apple {
    width: 32px;
    height: 32px;
    background-image: url('assets/apple.png');
    background-size: 160%;
    background-repeat: no-repeat;
    background-position: center 55%;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
    animation: apple-drop 0.3s var(--bounce);
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.15s var(--bounce);
}

@keyframes apple-drop {
    0% { transform: translateY(-20px) scale(0.5); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.packed-apple:hover {
    transform: scale(1.2);
    z-index: 10;
}

/* Crate Stepper Controls */
.crate-stepper {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--paper-white);
    padding: 3px 6px;
    border-radius: 20px;
    border: 2px solid var(--candy-pink);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 20;
}

.stepper-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s var(--bounce);
}

.stepper-btn.minus {
    background: var(--blush);
    color: var(--candy-pink);
}

.stepper-btn.plus {
    background: var(--mint);
    color: var(--forest);
}

.stepper-btn:hover {
    transform: scale(1.15);
}

.stepper-btn:active {
    transform: scale(0.95);
}

.stepper-count {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--charcoal);
    min-width: 24px;
    text-align: center;
}

/* Quick Fill Button */
.quick-fill-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: var(--honey);
    border: 2px solid var(--honey-dark);
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s var(--bounce);
    z-index: 15;
}

.placed-crate:hover .quick-fill-btn {
    opacity: 1;
}

.quick-fill-btn:hover {
    transform: scale(1.2);
    background: var(--honey-glow);
}

/* ============================================
   Workspace / Control Dashboard
   ============================================ */

#workspace {
    position: relative;
    padding: 0.8rem;
    background: linear-gradient(180deg, var(--cream-dark) 0%, #E8DCC8 100%);
    border-radius: 25px 25px 0 0;
    border: 3px solid var(--wood);
    border-bottom: none;
    box-shadow:
        0 -10px 30px rgba(0, 0, 0, 0.1),
        inset 0 5px 0 rgba(255, 255, 255, 0.5);
    z-index: 60;
    flex-shrink: 0;
}

/* Decorative Hazard Stripe */
#workspace::before {
    content: '';
    position: absolute;
    top: -18px;
    left: -4px;
    right: -4px;
    height: 18px;
    background: repeating-linear-gradient(
        -45deg,
        var(--honey) 0px,
        var(--honey) 15px,
        var(--charcoal) 15px,
        var(--charcoal) 30px
    );
    border-radius: 15px 15px 0 0;
    border: 3px solid var(--charcoal);
    border-bottom: none;
}

/* Decorative Gears */
.workspace-deco {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.gear {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        var(--slate) 0deg 30deg,
        transparent 30deg 45deg,
        var(--slate) 45deg 75deg,
        transparent 75deg 90deg,
        var(--slate) 90deg 120deg,
        transparent 120deg 135deg,
        var(--slate) 135deg 165deg,
        transparent 165deg 180deg,
        var(--slate) 180deg 210deg,
        transparent 210deg 225deg,
        var(--slate) 225deg 255deg,
        transparent 255deg 270deg,
        var(--slate) 270deg 300deg,
        transparent 300deg 315deg,
        var(--slate) 315deg 345deg,
        transparent 345deg 360deg
    );
    opacity: 0.15;
}

.gear::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: var(--slate);
    border-radius: 50%;
}

.gear-1 {
    top: -20px;
    right: 80px;
    animation: spin-gear 10s linear infinite;
}

.gear-2 {
    top: -10px;
    right: 30px;
    width: 45px;
    height: 45px;
    animation: spin-gear 8s linear infinite reverse;
}

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

.control-panel {
    display: flex;
    justify-content: center;
    gap: 2rem;
    position: relative;
    z-index: 1;
}

.control-pod {
    position: relative;
    background: var(--paper-white);
    border-radius: 20px;
    padding: 0.6rem;
    width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    border: 3px solid transparent;
    box-shadow:
        4px 4px 0 rgba(0, 0, 0, 0.1),
        var(--shadow-soft);
    transition: all 0.3s var(--bounce);
    cursor: pointer;
}

.control-pod:hover {
    transform: translateY(-5px);
    box-shadow:
        8px 8px 0 rgba(0, 0, 0, 0.1),
        var(--shadow-medium);
}

.control-pod:active {
    transform: scale(0.98);
}

#supply-crates {
    border-color: var(--wood);
}

#supply-crates .pod-glow {
    background: radial-gradient(circle, rgba(192, 130, 74, 0.3) 0%, transparent 70%);
}

#supply-apples {
    border-color: var(--candy-pink);
}

#supply-apples .pod-glow {
    background: radial-gradient(circle, rgba(232, 93, 117, 0.3) 0%, transparent 70%);
}

.pod-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 25px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.control-pod:hover .pod-glow {
    opacity: 1;
}

.pod-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pod-icon {
    font-size: 1.3rem;
}

.pod-header h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--charcoal);
    margin: 0;
}

.pod-bay {
    width: 100%;
    height: 60px;
    background: linear-gradient(180deg, #F0F0F0 0%, #E0E0E0 100%);
    border-radius: 12px;
    box-shadow: var(--shadow-inset);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.pod-inner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pod-bay img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s var(--bounce);
}

.control-pod:hover .pod-bay img {
    transform: scale(1.15) rotate(5deg);
}

.tap-hint {
    display: none;
}

.pod-count {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
}

.count-label {
    color: var(--slate);
}

.count-value {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--charcoal);
    background: var(--cream);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
}

.help-hint {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--slate);
    opacity: 0.8;
}

/* ============================================
   Feedback Modal
   ============================================ */

#feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.feedback-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 62, 80, 0.7);
    backdrop-filter: blur(8px);
    animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.feedback-modal {
    position: relative;
    background: var(--paper-white);
    width: 90%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    border-radius: 40px;
    text-align: center;
    border: 6px solid var(--honey);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 0 12px rgba(255, 255, 255, 0.2),
        inset 0 0 30px rgba(255, 255, 255, 0.5);
    animation: modal-pop 0.5s var(--bounce);
}

@keyframes modal-pop {
    0% { opacity: 0; transform: scale(0.7) translateY(50px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-deco {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.star {
    position: absolute;
    font-size: 2rem;
    animation: star-float 2s ease-in-out infinite;
}

.star-1 {
    top: -10px;
    left: 20%;
    animation-delay: 0s;
}

.star-2 {
    top: 20%;
    right: 10%;
    font-size: 1.5rem;
    animation-delay: 0.5s;
}

.star-3 {
    bottom: 20%;
    left: 10%;
    animation-delay: 1s;
}

@keyframes star-float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(10deg); }
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: bounce-in 0.6s var(--bounce) 0.2s backwards;
}

@keyframes bounce-in {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

#feedback-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 0.5rem 0;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
}

#feedback-msg {
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: var(--slate);
    margin: 0 0 1.5rem 0;
    line-height: 1.6;
    white-space: pre-line;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 1.8rem;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s var(--smooth);
}

.primary-btn {
    background: linear-gradient(135deg, var(--forest) 0%, var(--forest-dark) 100%);
    color: white;
    box-shadow:
        0 5px 0 #2E5040,
        var(--shadow-soft);
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 0 #2E5040,
        var(--shadow-medium);
}

.primary-btn:active {
    transform: translateY(2px);
    box-shadow:
        0 3px 0 #2E5040;
}

.secondary-btn {
    background: linear-gradient(135deg, var(--candy-pink) 0%, var(--candy-pink-dark) 100%);
    color: white;
    box-shadow:
        0 5px 0 #A33D4D,
        var(--shadow-soft);
}

.secondary-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 0 #A33D4D,
        var(--shadow-medium);
}

.secondary-btn:active {
    transform: translateY(2px);
    box-shadow:
        0 3px 0 #A33D4D;
}

.btn-arrow {
    font-size: 1.3rem;
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
    display: none !important;
}

.shake-screen {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 900px) {
    #game-container {
        padding: 0.5rem;
        max-height: none;
        height: auto;
        min-height: 100vh;
    }

    #stage {
        flex-direction: column;
        gap: 0.5rem;
        flex: 1;
    }

    #order-panel {
        flex-direction: row;
        width: 100%;
        justify-content: center;
        align-items: center;
        gap: 0.8rem;
        padding: 0;
    }

    #bear-character {
        flex-shrink: 0;
    }

    #bear-avatar {
        width: 60px;
        height: 60px;
    }

    .bear-glow {
        width: 70px;
        height: 70px;
    }

    .bear-name-tag {
        display: none;
    }

    #order-ticket {
        flex: 1;
        max-width: 280px;
        transform: none;
    }

    .ticket-header {
        padding: 0.3rem;
        font-size: 0.75rem;
    }

    .ticket-body {
        padding: 0.4rem;
    }

    .order-num.highlight {
        font-size: 1.3rem;
        padding: 0.1rem 0.4rem;
    }

    .order-unit, .order-times, .order-equals {
        font-size: 0.9rem;
    }

    .order-result {
        font-size: 1.3rem;
    }

    #ship-btn {
        padding: 0.5rem;
        font-size: 0.95rem;
    }

    #conveyor-zone {
        flex: 1;
        min-height: 200px;
    }

    .zone-hint {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        bottom: 75px;
    }

    #conveyor-belt {
        height: 60px;
        bottom: 20px;
    }

    .belt-track {
        height: 35px;
    }

    .belt-rollers {
        bottom: 32px;
    }

    .roller {
        width: 18px;
        height: 18px;
    }

    #active-crates {
        padding-bottom: 70px;
        gap: 10px;
        min-height: 150px;
    }

    .placed-crate {
        width: 100px;
        height: 95px;
        margin-bottom: 15px;
    }

    .crate-contents {
        height: 75px;
        bottom: 15px;
        grid-template-columns: repeat(3, 1fr);
    }

    .packed-apple {
        width: 28px;
        height: 28px;
    }

    .crate-stepper {
        padding: 2px 4px;
        gap: 3px;
    }

    .stepper-btn {
        width: 22px;
        height: 22px;
        font-size: 0.95rem;
    }

    .stepper-count {
        font-size: 0.9rem;
        min-width: 18px;
    }

    .frame-corner {
        width: 25px;
        height: 25px;
        border-width: 4px;
    }

    .frame-tl, .frame-tr, .frame-bl, .frame-br {
        top: 8px;
        left: 8px;
    }
    .frame-tr, .frame-br { left: auto; right: 8px; }
    .frame-bl, .frame-br { top: auto; bottom: 8px; }

    #workspace {
        padding: 0.6rem;
    }

    #workspace::before {
        height: 14px;
        top: -14px;
    }

    .control-panel {
        gap: 0.8rem;
    }

    .control-pod {
        width: 130px;
        padding: 0.5rem;
    }

    .pod-header h3 {
        font-size: 0.9rem;
    }

    .pod-icon {
        font-size: 1rem;
    }

    .pod-bay {
        height: 50px;
    }

    .pod-bay img {
        width: 35px;
        height: 35px;
    }

    .pod-count {
        font-size: 0.7rem;
    }
}

@media (max-width: 600px) {
    .audio-btn {
        width: 40px;
        height: 40px;
        border-width: 2px;
    }

    .audio-icon {
        font-size: 1.1rem;
    }

    #top-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
        padding: 0.3rem 0.5rem;
    }

    .title-badge {
        padding: 0.3rem 0.8rem;
        border-width: 3px;
        box-shadow: 3px 3px 0 var(--bear-dark);
    }

    .badge-icon {
        font-size: 1.2rem;
    }

    .game-title {
        font-size: 1.1rem;
    }

    .difficulty-wrapper {
        padding: 0.3rem 0.6rem;
        border-width: 2px;
    }

    .diff-label {
        font-size: 0.75rem;
    }

    .game-select {
        font-size: 0.8rem;
        padding: 0.3rem 0.5rem;
    }

    #score-display {
        padding: 0.4rem 0.8rem;
        border-width: 2px;
    }

    .score-icon {
        font-size: 1rem;
    }

    .score-value {
        font-size: 1.2rem;
    }

    .score-label {
        font-size: 0.65rem;
    }

    #order-panel {
        gap: 0.5rem;
    }

    #bear-avatar {
        width: 50px;
        height: 50px;
        border-width: 3px;
    }

    .bear-glow {
        width: 60px;
        height: 60px;
    }

    #order-ticket {
        max-width: 220px;
        border-width: 3px;
        box-shadow: 4px 4px 0 var(--honey-dark);
    }

    .order-num.highlight {
        font-size: 1.1rem;
        border-width: 2px;
    }

    .order-unit, .order-times, .order-equals {
        font-size: 0.8rem;
    }

    .order-result {
        font-size: 1.1rem;
    }

    #ship-btn {
        padding: 0.4rem;
        font-size: 0.85rem;
        gap: 0.3rem;
    }

    .btn-icon {
        font-size: 1rem;
    }

    .control-pod {
        width: 110px;
        padding: 0.4rem;
        border-width: 2px;
    }

    .pod-header {
        gap: 0.2rem;
    }

    .pod-header h3 {
        font-size: 0.8rem;
    }

    .pod-icon {
        font-size: 0.9rem;
    }

    .pod-bay {
        height: 45px;
        border-radius: 10px;
    }

    .pod-bay img {
        width: 30px;
        height: 30px;
    }

    .placed-crate {
        width: 85px;
        height: 80px;
        margin-bottom: 12px;
    }

    .packed-apple {
        width: 24px;
        height: 24px;
    }

    .crate-contents {
        grid-template-columns: repeat(3, 1fr);
        height: 60px;
        bottom: 12px;
    }

    .crate-stepper {
        bottom: -6px;
        padding: 2px 3px;
        gap: 2px;
    }

    .stepper-btn {
        width: 18px;
        height: 18px;
        font-size: 0.8rem;
    }

    .stepper-count {
        font-size: 0.8rem;
        min-width: 16px;
    }

    .quick-fill-btn {
        width: 18px;
        height: 18px;
        font-size: 0.55rem;
    }

    /* Hide decorative elements on small screens */
    .deco-pipes,
    .workspace-deco {
        display: none;
    }
}

@media (max-width: 400px) {
    .title-badge {
        order: 1;
        width: 100%;
        justify-content: center;
    }

    .difficulty-wrapper {
        order: 2;
    }

    #score-display {
        order: 3;
    }

    #order-ticket {
        max-width: 180px;
    }

    .ticket-header {
        font-size: 0.7rem;
    }

    .order-num.highlight {
        font-size: 1rem;
    }

    .control-pod {
        width: 100px;
    }
}
